r1346 - in topia/trunk: . topia-ui topia-ui/src/main/java/org/codelutin/topia/generator topia-ui/src/test topia-ui/src/test/java topia-ui/src/test/java/org topia-ui/src/test/java/org/codelutin topia-ui/src/test/java/org/codelutin/test topia-ui/src/test/java/org/codelutin/test/web topia-ui/src/test/java/org/codelutin/test/web/base topia-ui/src/test/java/org/codelutin/test/web/components topia-ui/src/test/java/org/codelutin/test/web/pages topia-ui/src/test/java/org/codelutin/test/web/pages/con
Author: chatellier Date: 2009-02-09 15:56:49 +0000 (Mon, 09 Feb 2009) New Revision: 1346 Added: topia/trunk/topia-ui/src/test/java/org/ topia/trunk/topia-ui/src/test/java/org/codelutin/ topia/trunk/topia-ui/src/test/java/org/codelutin/test/ topia/trunk/topia-ui/src/test/java/org/codelutin/test/web/ topia/trunk/topia-ui/src/test/java/org/codelutin/test/web/base/ topia/trunk/topia-ui/src/test/java/org/codelutin/test/web/base/BasePage.java topia/trunk/topia-ui/src/test/java/org/codelutin/test/web/base/SessionBean.java topia/trunk/topia-ui/src/test/java/org/codelutin/test/web/components/ topia/trunk/topia-ui/src/test/java/org/codelutin/test/web/components/ContextLink.java topia/trunk/topia-ui/src/test/java/org/codelutin/test/web/components/Layout.java topia/trunk/topia-ui/src/test/java/org/codelutin/test/web/pages/ topia/trunk/topia-ui/src/test/java/org/codelutin/test/web/pages/LoginForm.java topia/trunk/topia-ui/src/test/java/org/codelutin/test/web/pages/contactManagement/ topia/trunk/topia-ui/src/test/java/org/codelutin/test/web/pages/contactManagement/ContactForm.java topia/trunk/topia-ui/src/test/java/org/codelutin/test/web/pages/contactManagement/ContactList.java topia/trunk/topia-ui/src/test/java/org/codelutin/test/web/pages/contactManagement/ContactView.java topia/trunk/topia-ui/src/test/java/org/codelutin/test/web/pages/contactManagement/SocietyForm.java topia/trunk/topia-ui/src/test/java/org/codelutin/test/web/pages/contactManagement/SocietyView.java topia/trunk/topia-ui/src/test/xmi/ topia/trunk/topia-ui/src/test/xmi/contact.properties topia/trunk/topia-ui/src/test/xmi/contact.zargo Modified: topia/trunk/pom.xml topia/trunk/topia-ui/pom.xml topia/trunk/topia-ui/src/main/java/org/codelutin/topia/generator/TapestryWebGenerator.java Log: Ajout de tests dans topiaUI, generation d'un model de case d'utilisation sous tapestry Modified: topia/trunk/pom.xml =================================================================== --- topia/trunk/pom.xml 2009-02-05 18:05:17 UTC (rev 1345) +++ topia/trunk/pom.xml 2009-02-09 15:56:49 UTC (rev 1346) @@ -70,7 +70,7 @@ <dependency> <groupId>org.apache.tapestry</groupId> <artifactId>tapestry-core</artifactId> - <version>5.0.7</version> + <version>5.0.18</version> <scope>compile</scope> </dependency> Modified: topia/trunk/topia-ui/pom.xml =================================================================== --- topia/trunk/topia-ui/pom.xml 2009-02-05 18:05:17 UTC (rev 1345) +++ topia/trunk/topia-ui/pom.xml 2009-02-09 15:56:49 UTC (rev 1346) @@ -20,6 +20,13 @@ <dependencies> <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>topia-persistence</artifactId> + <version>${project.version}</version> + <scope>test</scope> + </dependency> + + <dependency> <groupId>org.codelutin</groupId> <artifactId>lutinutil</artifactId> </dependency> @@ -32,7 +39,7 @@ <dependency> <groupId>org.apache.tapestry</groupId> <artifactId>tapestry-core</artifactId> - <!--version>5.0.7</version> + <!--version>5.0.18</version> <scope>compile</scope--> </dependency> @@ -55,11 +62,85 @@ <plugins> + <!-- Add du répertoire de compilation des tests --> <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>build-helper-maven-plugin</artifactId> + <version>1.2</version> + <executions> + <execution> + <id>add-test-source</id> + <phase>process-test-sources</phase> + <goals> + <goal>add-test-source</goal> + </goals> + <configuration> + <sources> + <source>target/generated-test-sources/java</source> + </sources> + </configuration> + </execution> + </executions> + </plugin> + + <plugin> <groupId>org.codelutin</groupId> <artifactId>maven-processor-plugin</artifactId> </plugin> + <plugin> + <groupId>org.codelutin</groupId> + <artifactId>maven-generator-plugin</artifactId> + <version>${generator.version}</version> + <executions> + <execution> + <id>generate-objectmodel</id> + <phase>generate-test-sources</phase> + <configuration> + <srcDirZuml>src/test/xmi</srcDirZuml> + <srcXmiDest>target/generated-test-sources/xmi/</srcXmiDest> + <srcGenDest>target/generated-test-sources/models/</srcGenDest> + <includes>**/*.objectmodel</includes> + <templates>org.codelutin.topia.generator.TopiaMetaGenerator</templates> + <destDirGen>target/generated-test-sources/java</destDirGen> + <defaultPackage>org.codelutin.test</defaultPackage> + </configuration> + <goals> + <goal>zargo2xmi</goal> + <goal>xmi2objectmodel</goal> + <goal>generate</goal> + </goals> + </execution> + + <execution> + <id>generate-statemodel</id> + <phase>generate-test-sources</phase> + <configuration> + <srcDirZuml>src/test/xmi</srcDirZuml> + <srcXmiDest>target/generated-test-sources/xmi/</srcXmiDest> + <srcGenDest>target/generated-test-sources/models/</srcGenDest> + <includes>**/*.statemodel</includes> + <templates>org.codelutin.topia.generator.TapestryWebGenerator</templates> + <destDirGen>target/generated-test-sources/java</destDirGen> + <extraClassPathDirectory>target/classes</extraClassPathDirectory> + </configuration> + <goals> + <goal>zargo2xmi</goal> + <goal>xmi2statemodel</goal> + <goal>generate</goal> + </goals> + </execution> + </executions> + <dependencies> + <dependency> + <groupId>org.codelutin.topia</groupId> + <artifactId>topia-persistence</artifactId> + <version>${project.version}</version> + <scope>compile</scope> + </dependency> + </dependencies> + </plugin> + </plugins> </build> Modified: topia/trunk/topia-ui/src/main/java/org/codelutin/topia/generator/TapestryWebGenerator.java =================================================================== --- topia/trunk/topia-ui/src/main/java/org/codelutin/topia/generator/TapestryWebGenerator.java 2009-02-05 18:05:17 UTC (rev 1345) +++ topia/trunk/topia-ui/src/main/java/org/codelutin/topia/generator/TapestryWebGenerator.java 2009-02-09 15:56:49 UTC (rev 1346) @@ -28,6 +28,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.tapestry5.Link; import org.codelutin.generator.MonitorWriter; import org.codelutin.generator.StateModelGenerator; import org.codelutin.generator.GeneratorUtil; @@ -211,7 +212,7 @@ /*{// Automatically generated by LutinGenerator package <%=getPackageFromState(chart)%>; -import org.apache.tapestry.annotations.InjectPage; +import org.apache.tapestry5.annotations.InjectPage; import <%=getPackageFromComponents(chart)%>.UseCasePage; /* @@ -446,13 +447,13 @@ private void generateUseCasePageClass(MonitorWriter output, StateModel model, String componentPackageName) throws IOException { /*{package <%=componentPackageName%>; -import org.apache.tapestry.Link; -import org.apache.tapestry.annotations.ApplicationState; -import org.apache.tapestry.ioc.annotations.Inject; -import org.apache.tapestry.annotations.Service; -import org.apache.tapestry.internal.services.LinkFactory; -import org.apache.tapestry.internal.services.LinkFactoryListener; -import org.apache.tapestry.services.Request; +import org.apache.tapestry5.Link; +import org.apache.tapestry5.annotations.ApplicationState; +import org.apache.tapestry5.ioc.annotations.Inject; +import org.apache.tapestry5.annotations.Service; +import org.apache.tapestry5.internal.services.LinkFactory; +import org.apache.tapestry5.internal.services.LinkFactoryListener; +import org.apache.tapestry5.services.Request; public abstract class UseCasePage}*/ @@ -537,21 +538,23 @@ return nextPage; } - /* (non-Javadoc) - * @see org.apache.tapestry.internal.services.LinkFactoryListener#createdActionLink(org.apache.tapestry.Link) - *) - public void createdActionLink(Link _link) { - addUCParameter(_link); - } + /* + * @see org.apache.tapestry5.internal.services.LinkFactoryListener#createdComponentEventLink(org.apache.tapestry5.Link) + *) + @Override + public void createdComponentEventLink(Link _link) { + addUCParameter(_link); + } - /* (non-Javadoc) - * @see org.apache.tapestry.internal.services.LinkFactoryListener#createdPageLink(org.apache.tapestry.Link) - *) - public void createdPageLink(Link _link) { - // PageLink englobe ausssi les redirects envoyés au client apres une - // action - addUCParameter(_link); - } + /* + * @see org.apache.tapestry5.internal.services.LinkFactoryListener#createdPageRenderLink(org.apache.tapestry5.Link) + *) + @Override + public void createdPageRenderLink(Link _link) { + // PageLink englobe ausssi les redirects envoyés au client apres une + // action + addUCParameter(_link); + } protected void addUCParameter(Link _link) { if(_link.getParameterValue(UC_PARAMETER_NAME) == null) { Added: topia/trunk/topia-ui/src/test/java/org/codelutin/test/web/base/BasePage.java =================================================================== --- topia/trunk/topia-ui/src/test/java/org/codelutin/test/web/base/BasePage.java (rev 0) +++ topia/trunk/topia-ui/src/test/java/org/codelutin/test/web/base/BasePage.java 2009-02-09 15:56:49 UTC (rev 1346) @@ -0,0 +1,33 @@ +/* *##% + * Copyright (C) 2007 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. + *##%*/ + +package org.codelutin.test.web.base; + + +/** + * BasePage.java + * + * @author chatellier + * @version $Revision$ + * + * Last update : $Date$ + * By : $Author$ + */ +public class BasePage { + +} Added: topia/trunk/topia-ui/src/test/java/org/codelutin/test/web/base/SessionBean.java =================================================================== --- topia/trunk/topia-ui/src/test/java/org/codelutin/test/web/base/SessionBean.java (rev 0) +++ topia/trunk/topia-ui/src/test/java/org/codelutin/test/web/base/SessionBean.java 2009-02-09 15:56:49 UTC (rev 1346) @@ -0,0 +1,58 @@ +/* *##% + * Copyright (C) 2006 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. + *##%*/ + +package org.codelutin.test.web.base; + +import java.io.Serializable; + +/** + * SessionBean.java + * + * @author chatellier + * @version $Revision: 1.1 $ + * + * Last update : $Date: 2007/05/14 07:56:43 $ + * By : $Author: E023931M $ + */ +public class SessionBean implements Serializable { + + /** + * serialVersionUID + */ + private static final long serialVersionUID = 4167552239802992200L; + + private boolean logged; + + public SessionBean() { + logged = false; + } + + /** + * @return the logged + */ + public boolean isLogged() { + return logged; + } + + /** + * @param logged the logged to set + */ + public void setLogged(boolean logged) { + this.logged = logged; + } +} Added: topia/trunk/topia-ui/src/test/java/org/codelutin/test/web/components/ContextLink.java =================================================================== --- topia/trunk/topia-ui/src/test/java/org/codelutin/test/web/components/ContextLink.java (rev 0) +++ topia/trunk/topia-ui/src/test/java/org/codelutin/test/web/components/ContextLink.java 2009-02-09 15:56:49 UTC (rev 1346) @@ -0,0 +1,52 @@ +/* *##% + * Copyright (C) 2006 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. + *##%*/ + +package org.codelutin.test.web.components; + +import org.apache.tapestry5.MarkupWriter; +import org.apache.tapestry5.annotations.Parameter; +import org.apache.tapestry5.internal.services.ContextResource; +import org.apache.tapestry5.ioc.annotations.Inject; + +/** + * ContextLink.java + * + * Juste pour ajouter le context + * + * @author chatellier + * @version $Revision$ + * + * Last update : $Date$ By : $Author$ + */ +public class ContextLink { + + /** The logical name of the page to link to. */ + @Parameter(required = true, defaultPrefix = "literal") + private String _page; + + @Inject + private ContextResource contextResource; + + void beginRender(MarkupWriter writer) { + writer.element("a", "href", contextResource.toString() + "/" + _page); + } + + void afterRender(MarkupWriter writer) { + writer.end(); // <a> + } +} Added: topia/trunk/topia-ui/src/test/java/org/codelutin/test/web/components/Layout.java =================================================================== --- topia/trunk/topia-ui/src/test/java/org/codelutin/test/web/components/Layout.java (rev 0) +++ topia/trunk/topia-ui/src/test/java/org/codelutin/test/web/components/Layout.java 2009-02-09 15:56:49 UTC (rev 1346) @@ -0,0 +1,143 @@ +/* *##% + * Copyright (C) 2006 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. + *##%*/ + +package org.codelutin.test.web.components; + +import java.util.Locale; + +import org.apache.tapestry5.Asset; +import org.apache.tapestry5.annotations.Parameter; +import org.apache.tapestry5.annotations.Path; +import org.apache.tapestry5.annotations.Service; +import org.apache.tapestry5.ioc.annotations.Inject; +import org.apache.tapestry5.services.PersistentLocale; + + +/** + * AbstractPage.java + * + * @author chatellier + * @version $Revision: 1.1 $ + * + * Last update : $Date: 2007/05/14 07:56:43 $ By : $Author: E023931M $ + */ +public class Layout { + + /** + * page title + */ + @Parameter("defaulttitle") + private String title; + + @Inject + @Path("context:css/general.css") + private Asset _stylesheetGeneral; + + @Inject + @Path("context:css/layout.css") + private Asset _stylesheetLayout; + + /** + * @return the title + */ + public String getTitle() { + return title; + } + + /** + * Set default title + */ + void getDefaultTitle() { + title = ""; + } + + /** + * @return the _stylesheetGeneral + */ + public Asset getStylesheetGeneral() { + return _stylesheetGeneral; + } + + + /** + * @return the _stylesheetLayout + */ + public Asset getStylesheetLayout() { + return _stylesheetLayout; + } + + /*@Inject + @Service("ThreadLocale") + private ThreadLocale threadLocaleService;*/ + + /** + * Change locale + * @param locale locale + * @return + */ + /*Object onActionFormSwitchLocaleFr(@InjectService("ThreadLocale") + ThreadLocale threadLocale) { + threadLocale.setLocale(new Locale("fr")); + return null; + } + + Object onActionFormSwitchLocaleEn(@InjectService("ThreadLocale") + ThreadLocale threadLocale) { + threadLocale.setLocale(new Locale("en")); + return null; + }*/ + + @Inject + @Service("PersistentLocale") + private PersistentLocale persistentLocale; + + Object onActionFormSwitchLocaleFr() { + persistentLocale.set(new Locale("fr")); + return null; + } + + Object onActionFormSwitchLocaleEn() { + persistentLocale.set(new Locale("en")); + return null; + } + + /*@ApplicationState + SessionBean sessionBean; + + @InjectPage + private LoginForm loginForm; + + @BeforeRenderBody + Object testConnected() { + if(sessionBean == null) sessionBean = new SessionBean(); + if(!sessionBean.isLogged()) { + sessionBean.setLogged(true); + return loginForm; + } + return true; + } + + /*@AfterRenderBody + boolean testConnected2() { + /*if(!sessionBean.isLogged()) { + sessionBean.setLogged(true); + return loginForm; + }* + return false; + }*/ +} Added: topia/trunk/topia-ui/src/test/java/org/codelutin/test/web/pages/LoginForm.java =================================================================== --- topia/trunk/topia-ui/src/test/java/org/codelutin/test/web/pages/LoginForm.java (rev 0) +++ topia/trunk/topia-ui/src/test/java/org/codelutin/test/web/pages/LoginForm.java 2009-02-09 15:56:49 UTC (rev 1346) @@ -0,0 +1,88 @@ +/* *##% + * Copyright (C) 2006 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. + *##%*/ + +package org.codelutin.test.web.pages; + +import org.apache.tapestry5.annotations.Component; +import org.apache.tapestry5.annotations.Persist; +import org.codelutin.test.web.components.Layout; + +/** + * ProjectForm.java + * + * @author chatellier + * @version $Revision: 1.1 $ + * + * Last update : $Date: 2007/05/14 07:56:43 $ + * By : $Author: E023931M $ + * + * Based on authentication tutorial : + * http://new2java.blogspot.com/2007/05/tsa503pageslogin-step-01.html + */ +public class LoginForm { + + /** layout */ + @SuppressWarnings("unused") + @Component + private Layout layout; + + @Persist + private String user; + private String password; + + /** + * Form validation + */ + Object onSuccess() { + + /*if(user.equals("demo") && password.equals("demo")) { + String sessionBeanAttr = "aso:" + SessionBean.class.getName(); + ((SessionBean)_request.getSession(true).getAttribute(sessionBeanAttr)).setLogged(true); + }*/ + + return null; + } + + /** + * @return the password + */ + public String getPassword() { + return password; + } + + /** + * @param password the password to set + */ + public void setPassword(String password) { + this.password = password; + } + + /** + * @return the user + */ + public String getUser() { + return user; + } + + /** + * @param user the user to set + */ + public void setUser(String user) { + this.user = user; + } +} Added: topia/trunk/topia-ui/src/test/java/org/codelutin/test/web/pages/contactManagement/ContactForm.java =================================================================== --- topia/trunk/topia-ui/src/test/java/org/codelutin/test/web/pages/contactManagement/ContactForm.java (rev 0) +++ topia/trunk/topia-ui/src/test/java/org/codelutin/test/web/pages/contactManagement/ContactForm.java 2009-02-09 15:56:49 UTC (rev 1346) @@ -0,0 +1,267 @@ +/* *##% + * Copyright (C) 2007 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. + *##%*/ + +package org.codelutin.test.web.pages.contactManagement; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.tapestry5.Link; +import org.apache.tapestry5.OptionGroupModel; +import org.apache.tapestry5.OptionModel; +import org.apache.tapestry5.SelectModel; +import org.apache.tapestry5.SelectModelVisitor; +import org.apache.tapestry5.ValueEncoder; +import org.apache.tapestry5.annotations.Persist; +import org.apache.tapestry5.internal.OptionModelImpl; +import org.codelutin.test.TapestryTestDAOHelper; +import org.codelutin.test.entities.Contact; +import org.codelutin.test.entities.ContactDAO; +import org.codelutin.test.entities.ContactImpl; +import org.codelutin.test.entities.Society; +import org.codelutin.test.entities.SocietyDAO; +import org.codelutin.topia.TopiaContext; +import org.codelutin.topia.TopiaContextFactory; +import org.codelutin.topia.TopiaException; +import org.codelutin.topia.TopiaNotFoundException; + + +/** + * ContactForm.java + * + * @author chatellier + * @version $Revision$ + * + * Last update : $Date$ + * By : $Author$ + */ +public class ContactForm extends AbstractContactForm { + + private SocietyDAO societyDao; + private ContactDAO contactDao; + + @Persist + private Society society; + @Persist + private Contact contact; + + @Persist + private boolean use_for_new; + + public ContactForm() { + societyDao = new SocietyDAO(); + contactDao = new ContactDAO(); + contact = new ContactImpl(); + + use_for_new = true; + } + + /** + * @return the contact + */ + public Contact getContact() { + return contact; + } + + + /** + * @param contact the contact to set + */ + public void setContact(Contact contact) { + this.contact = contact; + use_for_new = false; + } + + + /** + * @return the society + */ + public Society getSociety() { + return society; + } + + + /** + * @param society the society to set + */ + public void setSociety(Society society) { + this.society = society; + } + + + public Object onSubmit() { + // store contact + // chech if update !!! + + try { + TopiaContext context = TopiaContextFactory.getContext(); + // FIXME get proper DAO + contact.setSociety(society); + if(use_for_new) { + contactDao.create(contact); + } + else { + contactDao.update(contact); + } + context.commitTransaction(); + } catch (TopiaException e) { + // TODO log + } + + return super.onActionFromContactStore(); + } + + /** + * + */ + public void setEmptyContact() { + + contact = new ContactImpl(); + use_for_new = true; + + } + + /* (non-Javadoc) + * @see org.codelutin.test.web.pages.contactManagement.AbstractContactForm#onActionFromAddSociety() + */ + @Override + public Object onActionFromAddSociety() { + + getSocietyForm().setEmptySociety(); + + return super.onActionFromAddSociety(); + } + + /* (non-Javadoc) + * @see org.codelutin.test.web.pages.contactManagement.AbstractContactForm#onActionFromContactCancel() + */ + @Override + public Object onActionFromContactCancel() { + return super.onActionFromContactCancel(); + } + + /* + * Ce qui suit sert au composant t:select de la page + */ + + /** + * Return all projects + * @return + */ + public List<Society> getSocieties() { + + List<Society> lp = null; + + try { + TopiaContext context = TopiaContextFactory.getContext(); + context.beginTransaction(); + lp = societyDao.findAll(); + context.commitTransaction(); + } catch (TopiaException e) { + // TODO log + } + + return lp; + } + + public SocietySelectModel getSocietySelectModel() { + return new SocietySelectModel(getSocieties()); + } + + public SocietyValueEncoder getSocietyValueEncoder() { + return new SocietyValueEncoder(getSocieties()); + } + + public class SocietyValueEncoder implements ValueEncoder<Society> { + + private List<Society> societies; + + public SocietyValueEncoder(List<Society> societies) { + this.societies = societies; + } + + public String toClient(Society society) { + return society.getName(); + } + + public Society toValue(String string) { + for (Society society : societies) { + + if (society.getName().equals(string)) { + return society; + } + } + return null; + } + + } + + public class SocietySelectModel implements SelectModel { + + private List<Society> societies; + + public SocietySelectModel(List<Society> societies) { + this.societies = societies; + } + + public List<OptionGroupModel> getOptionGroups() { + return null; + } + + public List<OptionModel> getOptions() { + List<OptionModel> optionModelList = new ArrayList<OptionModel>(); + for (Society society2 : societies) { + /*if(society2.getId().equals(society.getId())) { + optionModelList.add(new OptionModelImpl(society2.getName(), + false, society2,"selected","selected")); + } + else {*/ + optionModelList.add(new OptionModelImpl(society2.getName(), + society2)); + /*}*/ + } + return optionModelList; + } + + /* (non-Javadoc) + * @see org.apache.tapestry.SelectModel#visit(org.apache.tapestry.SelectModelVisitor) + */ + public void visit(SelectModelVisitor visitor) { + List<OptionGroupModel> groups = getOptionGroups(); + if (groups != null) { + for (OptionGroupModel groupModel : groups) { + visitor.beginOptionGroup(groupModel); + + visitOptions(groupModel.getOptions(), visitor); + + visitor.endOptionGroup(groupModel); + } + } + visitOptions(getOptions(), visitor); + } + + private void visitOptions(List<OptionModel> options, + SelectModelVisitor vistor) { + if (options != null) { + for (OptionModel optionModel : options) + vistor.option(optionModel); + } + } + + } +} Added: topia/trunk/topia-ui/src/test/java/org/codelutin/test/web/pages/contactManagement/ContactList.java =================================================================== --- topia/trunk/topia-ui/src/test/java/org/codelutin/test/web/pages/contactManagement/ContactList.java (rev 0) +++ topia/trunk/topia-ui/src/test/java/org/codelutin/test/web/pages/contactManagement/ContactList.java 2009-02-09 15:56:49 UTC (rev 1346) @@ -0,0 +1,116 @@ +/* *##% + * Copyright (C) 2007 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. + *##%*/ + +package org.codelutin.test.web.pages.contactManagement; + +import java.util.List; + +import org.codelutin.test.entities.Contact; +import org.codelutin.test.entities.ContactDAO; +import org.codelutin.topia.TopiaContext; +import org.codelutin.topia.TopiaContextFactory; +import org.codelutin.topia.TopiaException; + +/** + * ContactList.java + * + * @author chatellier + * @version $Revision$ + * + * Last update : $Date$ + * By : $Author$ + */ +public class ContactList extends AbstractContactList { + + /** + * Variable for loop + */ + private Contact contact; + + private ContactDAO dao; + + /** + * Constructeur + */ + public ContactList() { + super(); + dao = new ContactDAO(); + } + + /** + * @return the contact + */ + public Contact getContact() { + return contact; + } + + /** + * @param contact the contact to set + */ + public void setContact(Contact contact) { + this.contact = contact; + } + + /** + * Return all projects + * @return + */ + public List<Contact> getContacts() { + List<Contact> lc = null; + try { + TopiaContext context = TopiaContextFactory.getContext(); + context.beginTransaction(); + lc = dao.findAll(); + context.commitTransaction(); + } catch (TopiaException e) { + // TODO log + } + + return lc; + } + + /* (non-Javadoc) + * @see org.codelutin.test.web.pages.contactManagement.AbstractContactList#onActionFromAddContact() + */ + @Override + public Object onActionFromAddContact() { + + getContactForm().setEmptyContact(); + + return super.onActionFromAddContact(); + } + + public Object onActionFromViewer(String id) { + + Contact c = null; + + try { + TopiaContext context = TopiaContextFactory.getContext(); + context.beginTransaction(); + c = dao.findByTopiaId(id); + c.getSociety().getName(); // lazy exception + context.commitTransaction(); + } catch (TopiaException e) { + // TODO log + } + + getContactView().setContact(c); + + return super.onActionFromView(); + } +} Added: topia/trunk/topia-ui/src/test/java/org/codelutin/test/web/pages/contactManagement/ContactView.java =================================================================== --- topia/trunk/topia-ui/src/test/java/org/codelutin/test/web/pages/contactManagement/ContactView.java (rev 0) +++ topia/trunk/topia-ui/src/test/java/org/codelutin/test/web/pages/contactManagement/ContactView.java 2009-02-09 15:56:49 UTC (rev 1346) @@ -0,0 +1,98 @@ +/* *##% + * Copyright (C) 2007 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. + *##%*/ + +package org.codelutin.test.web.pages.contactManagement; + +import org.apache.tapestry5.annotations.Persist; +import org.codelutin.test.entities.Contact; +import org.codelutin.test.entities.ContactDAO; +import org.codelutin.topia.TopiaContext; +import org.codelutin.topia.TopiaContextFactory; +import org.codelutin.topia.TopiaException; + +/** + * ContactView.java + * + * @author chatellier + * @version $Revision$ + * + * Last update : $Date$ + * By : $Author$ + */ +public class ContactView extends AbstractContactView { + + @Persist + private Contact contact; + + private ContactDAO contactDAO; + + public ContactView() { + contactDAO = new ContactDAO(); + } + + /** + * @return the contact + */ + public Contact getContact() { + return contact; + } + + /** + * @param contact the contact to set + */ + public void setContact(Contact contact) { + this.contact = contact; + } + + /* (non-Javadoc) + * @see org.codelutin.test.web.pages.contactManagement.AbstractViewContact#onActionFromEdit() + */ + @Override + public Object onActionFromEdit() { + + getContactForm().setContact(contact); + + return super.onActionFromEdit(); + } + + /* (non-Javadoc) + * @see org.codelutin.test.web.pages.contactManagement.AbstractViewContact#onActionFromViewSociety() + */ + public Object onActionFromViewTheSociety() { + getSocietyView().setSociety(contact.getSociety()); + return super.onActionFromViewSociety(); + } + + /* (non-Javadoc) + * @see org.codelutin.test.web.pages.contactManagement.AbstractContactView#onActionFromDelete() + */ + @Override + public Object onActionFromDelete() { + + try { + TopiaContext context = TopiaContextFactory.getContext(); + context.beginTransaction(); + contactDAO.delete(contact); + context.commitTransaction(); + } catch (TopiaException e) { + // TODO log + } + + return super.onActionFromDelete(); + } +} Added: topia/trunk/topia-ui/src/test/java/org/codelutin/test/web/pages/contactManagement/SocietyForm.java =================================================================== --- topia/trunk/topia-ui/src/test/java/org/codelutin/test/web/pages/contactManagement/SocietyForm.java (rev 0) +++ topia/trunk/topia-ui/src/test/java/org/codelutin/test/web/pages/contactManagement/SocietyForm.java 2009-02-09 15:56:49 UTC (rev 1346) @@ -0,0 +1,102 @@ +/* *##% + * Copyright (C) 2007 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. + *##%*/ + +package org.codelutin.test.web.pages.contactManagement; + +import org.apache.tapestry5.annotations.Persist; +import org.codelutin.test.entities.Society; +import org.codelutin.test.entities.SocietyDAO; +import org.codelutin.test.entities.SocietyImpl; +import org.codelutin.topia.TopiaContext; +import org.codelutin.topia.TopiaContextFactory; +import org.codelutin.topia.TopiaException; + +/** + * SocietyForm.java + * + * @author chatellier + * @version $Revision$ + * + * Last update : $Date$ + * By : $Author$ + */ +public class SocietyForm extends AbstractSocietyForm { + + @Persist + private Society society; + + private SocietyDAO societyDAO; + + @Persist + private boolean use_for_new = true; + + public SocietyForm() { + super(); + society = new SocietyImpl(); + societyDAO = new SocietyDAO(); + } + + /** + * @return the society + */ + public Society getSociety() { + return society; + } + + /** + * @param society the society to set + */ + public void setSociety(Society society) { + this.society = society; + use_for_new = false; + } + + /** + * + */ + public void setEmptySociety() { + society = new SocietyImpl(); + use_for_new = true; + } + + /* (non-Javadoc) + * @see org.codelutin.test.web.pages.contactManagement.AbstractSocietyForm#onActionFromCancel() + */ + @Override + public Object onActionFromCancel() { + // TODO Auto-generated method stub + return super.onActionFromCancel(); + } + + public Object onSubmit() { + + try { + TopiaContext context = TopiaContextFactory.getContext(); + context.beginTransaction(); + if(use_for_new) + societyDAO.create(society); + else + societyDAO.update(society); + context.commitTransaction(); + } catch (TopiaException e) { + // TODO log + } + + return super.onActionFromSocietyStore(); + } +} Added: topia/trunk/topia-ui/src/test/java/org/codelutin/test/web/pages/contactManagement/SocietyView.java =================================================================== --- topia/trunk/topia-ui/src/test/java/org/codelutin/test/web/pages/contactManagement/SocietyView.java (rev 0) +++ topia/trunk/topia-ui/src/test/java/org/codelutin/test/web/pages/contactManagement/SocietyView.java 2009-02-09 15:56:49 UTC (rev 1346) @@ -0,0 +1,73 @@ +/* *##% + * Copyright (C) 2007 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. + *##%*/ + +package org.codelutin.test.web.pages.contactManagement; + +import org.apache.tapestry5.annotations.Persist; +import org.codelutin.test.entities.Society; + +/** + * SocietyList.java + * + * @author chatellier + * @version $Revision$ + * + * Last update : $Date$ + * By : $Author$ + */ +public class SocietyView extends AbstractSocietyView { + + @Persist + private Society society; + + public SocietyView() { + } + + /** + * @return the society + */ + public Society getSociety() { + return society; + } + + /** + * @param society the society to set + */ + public void setSociety(Society society) { + this.society = society; + } + + /* (non-Javadoc) + * @see org.codelutin.test.web.pages.contactManagement.AbstractSocietyView#onActionFromEdit() + */ + @Override + public Object onActionFromEdit() { + + getSocietyForm().setSociety(society); + + return super.onActionFromEdit(); + } + + /* (non-Javadoc) + * @see org.codelutin.test.web.pages.contactManagement.AbstractSocietyView#onActionFromOk() + */ + @Override + public Object onActionFromOk() { + return super.onActionFromOk(); + } +} Added: topia/trunk/topia-ui/src/test/xmi/contact.properties =================================================================== --- topia/trunk/topia-ui/src/test/xmi/contact.properties (rev 0) +++ topia/trunk/topia-ui/src/test/xmi/contact.properties 2009-02-09 15:56:49 UTC (rev 1346) @@ -0,0 +1 @@ +model.tagvalue.usecaseengineextendedclass=BasePage \ No newline at end of file Added: topia/trunk/topia-ui/src/test/xmi/contact.zargo =================================================================== (Binary files differ) Property changes on: topia/trunk/topia-ui/src/test/xmi/contact.zargo ___________________________________________________________________ Name: svn:mime-type + application/octet-stream
participants (1)
-
chatellier@users.labs.libre-entreprise.org