r44 - in trunk: cantharella.data/src/main/java/nc/ird/cantharella/data/model cantharella.data/src/main/java/nc/ird/cantharella/data/model/utils cantharella.data/src/main/resources/commons cantharella.data/src/test/java/nc/ird/cantharella/data cantharella.service/src/main/java/nc/ird/cantharella/service/services cantharella.service/src/main/java/nc/ird/cantharella/service/services/impl cantharella.service/src/main/java/nc/ird/cantharella/service/utils/normalizers cantharella.web/src/mai
Author: echatellier Date: 2013-01-03 18:10:01 +0100 (Thu, 03 Jan 2013) New Revision: 44 Url: http://forge.codelutin.com/projects/cantharella/repository/revisions/44 Log: refs #1648, #1949 : Add molecule entity, list and edit page Added: trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Molecule.java trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/services/MoleculeService.java trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/services/impl/MoleculeServiceImpl.java trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/utils/normalizers/MoleculeNormalizer.java trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/molecule/ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/molecule/ListMoleculesPage.html trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/molecule/ListMoleculesPage.java trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/molecule/ManageMoleculePage.html trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/molecule/ManageMoleculePage.java trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/molecule/ReadMoleculePage.html trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/molecule/ReadMoleculePage.java Modified: trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/utils/AbstractModel.java trunk/cantharella.data/src/main/resources/commons/data_en.properties trunk/cantharella.data/src/main/resources/commons/data_fr.properties trunk/cantharella.data/src/test/java/nc/ird/cantharella/data/SchemaExporter.java trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/config/WebApplicationImpl.java trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/TemplatePage.html trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/TemplatePage.java trunk/cantharella.web/src/main/resources/commons/web_en.properties trunk/cantharella.web/src/main/resources/commons/web_fr.properties Added: trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Molecule.java =================================================================== --- trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Molecule.java (rev 0) +++ trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Molecule.java 2013-01-03 17:10:01 UTC (rev 44) @@ -0,0 +1,289 @@ +package nc.ird.cantharella.data.model; + +import java.util.List; + +import javax.persistence.Entity; +import javax.persistence.FetchType; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.Lob; +import javax.persistence.ManyToOne; +import javax.persistence.OneToMany; +import javax.validation.constraints.NotNull; + +import nc.ird.cantharella.data.model.search.UtilisateurSearchFilter; +import nc.ird.cantharella.data.model.utils.AbstractModel; + +import org.hibernate.annotations.Cascade; +import org.hibernate.annotations.CascadeType; +import org.hibernate.annotations.Type; +import org.hibernate.search.annotations.Analyze; +import org.hibernate.search.annotations.Field; +import org.hibernate.search.annotations.FullTextFilterDef; +import org.hibernate.search.annotations.FullTextFilterDefs; +import org.hibernate.search.annotations.Index; +import org.hibernate.search.annotations.Indexed; +import org.hibernate.search.annotations.IndexedEmbedded; +import org.hibernate.search.annotations.Store; +import org.hibernate.validator.constraints.Length; +import org.hibernate.validator.constraints.NotEmpty; + +@Entity +@Indexed +@FullTextFilterDefs( { + @FullTextFilterDef(name = "utilisateur-Molecule", impl = UtilisateurSearchFilter.class) +}) +public class Molecule extends AbstractModel { + + /** ID */ + @Id + @GeneratedValue + private Integer idMolecule; + + /** Nom commun */ + @Length(max = LENGTH_LONG_TEXT) + @NotNull + @Field(index=Index.YES, analyze=Analyze.YES, store=Store.YES) + private String nomCommun; + + /** Famille chimique */ + @Length(max = LENGTH_MEDIUM_TEXT) + @NotNull + @Field(index=Index.YES, analyze=Analyze.YES, store=Store.YES) + private String familleChimique; + + /** Famille developpée */ + @Lob + @Type(type="org.hibernate.type.StringClobType") // see HHH-6105 + private String formuleDevMol; + + /** Nom IUPAC */ + @Length(max = LENGTH_BIG_TEXT) + @NotNull + private String nomIupca; + + /** Formule brute */ + @Length(max = LENGTH_MEDIUM_TEXT) + @NotEmpty + private String formuleBrute; + + /** Masse molaire */ + @NotEmpty + private Double masseMolaire; + + /** Est-ce une nouvelle molécule ? */ + @NotEmpty + private Boolean nouvMolecul; + + @ManyToOne(fetch = FetchType.EAGER, optional = false) + @IndexedEmbedded + private Campagne campagne; + + /** Identifiee par. */ + @Length(max = LENGTH_MEDIUM_TEXT) + @NotNull + private String identifieePar; + + /** Publication d'origine */ + @Lob + @Type(type="org.hibernate.type.StringClobType") // see HHH-6105 + private String publiOrigine; + + /** Complement */ + @Lob + @Type(type="org.hibernate.type.StringClobType") // see HHH-6105 + private String complement; + + /** Créateur */ + @NotNull + @ManyToOne(fetch = FetchType.LAZY, optional = false) + @IndexedEmbedded + private Personne createur; + + /** Produit utilisé obtenir le résultat **/ + @OneToMany(fetch = FetchType.LAZY) + @Cascade({ CascadeType.SAVE_UPDATE }) + private List<Produit> produits; + + /** + * @return the idMolecule + */ + public Integer getIdMolecule() { + return idMolecule; + } + + /** + * @param idMolecule the idMolecule to set + */ + public void setIdMolecule(Integer idMolecule) { + this.idMolecule = idMolecule; + } + + /** + * @return the nomCommun + */ + public String getNomCommun() { + return nomCommun; + } + + /** + * @param nomCommun the nomCommun to set + */ + public void setNomCommun(String nomCommun) { + this.nomCommun = nomCommun; + } + + /** + * @return the familleChimique + */ + public String getFamilleChimique() { + return familleChimique; + } + + /** + * @param familleChimique the familleChimique to set + */ + public void setFamilleChimique(String familleChimique) { + this.familleChimique = familleChimique; + } + + /** + * @return the formuleDevMol + */ + public String getFormuleDevMol() { + return formuleDevMol; + } + + /** + * @param formuleDevMol the formuleDevMol to set + */ + public void setFormuleDevMol(String formuleDevMol) { + this.formuleDevMol = formuleDevMol; + } + + /** + * @return the nomIupca + */ + public String getNomIupca() { + return nomIupca; + } + + /** + * @param nomIupca the nomIupca to set + */ + public void setNomIupca(String nomIupca) { + this.nomIupca = nomIupca; + } + + /** + * @return the formuleBrute + */ + public String getFormuleBrute() { + return formuleBrute; + } + + /** + * @param formuleBrute the formuleBrute to set + */ + public void setFormuleBrute(String formuleBrute) { + this.formuleBrute = formuleBrute; + } + + /** + * @return the masseMolaire + */ + public Double getMasseMolaire() { + return masseMolaire; + } + + /** + * @param masseMolaire the masseMolaire to set + */ + public void setMasseMolaire(Double masseMolaire) { + this.masseMolaire = masseMolaire; + } + + /** + * @return the nouvMolecul + */ + public Boolean getNouvMolecul() { + return nouvMolecul; + } + + /** + * @param nouvMolecul the nouvMolecul to set + */ + public void setNouvMolecul(Boolean nouvMolecul) { + this.nouvMolecul = nouvMolecul; + } + + /** + * @return the campagne + */ + public Campagne getCampagne() { + return campagne; + } + + /** + * @param campagne the campagne to set + */ + public void setCampagne(Campagne campagne) { + this.campagne = campagne; + } + + /** + * @return the publiOrigine + */ + public String getPubliOrigine() { + return publiOrigine; + } + + /** + * @param publiOrigine the publiOrigine to set + */ + public void setPubliOrigine(String publiOrigine) { + this.publiOrigine = publiOrigine; + } + + /** + * @return the complement + */ + public String getComplement() { + return complement; + } + + /** + * @param complement the complement to set + */ + public void setComplement(String complement) { + this.complement = complement; + } + + /** + * @return the createur + */ + public Personne getCreateur() { + return createur; + } + + /** + * @param createur the createur to set + */ + public void setCreateur(Personne createur) { + this.createur = createur; + } + + /** + * @return the produits + */ + public List<Produit> getProduits() { + return produits; + } + + /** + * @param produits the produits to set + */ + public void setProduits(List<Produit> produits) { + this.produits = produits; + } +} Property changes on: trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Molecule.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Modified: trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/utils/AbstractModel.java =================================================================== --- trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/utils/AbstractModel.java 2013-01-02 11:06:26 UTC (rev 43) +++ trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/utils/AbstractModel.java 2013-01-03 17:10:01 UTC (rev 44) @@ -52,6 +52,9 @@ /** ID fields cache (for each model class name) */ private static final Map<String, Field> ID_FIELDS = Collections.synchronizedMap(new TreeMap<String, Field>()); + /** Length: big text */ + protected static final int LENGTH_BIG_TEXT = 255; + /** Length: long text */ protected static final int LENGTH_LONG_TEXT = 100; Modified: trunk/cantharella.data/src/main/resources/commons/data_en.properties =================================================================== --- trunk/cantharella.data/src/main/resources/commons/data_en.properties 2013-01-02 11:06:26 UTC (rev 43) +++ trunk/cantharella.data/src/main/resources/commons/data_en.properties 2013-01-03 17:10:01 UTC (rev 44) @@ -180,6 +180,23 @@ ParamMethoPuri=Parameter ParamMethoPuriEffect.valeur=Value + +Molecule.idMolecule=Mol�cule N� +Molecule.nomCommun=Nom commun +Molecule.familleChimique=Famille Chimique +Molecule.formuleDevMol=Formule d�velopp�e +Molecule.nomIupca=Nom IUPAC +Molecule.formuleBrute=Formule brute +Molecule.masseMolaire=Masse molaire (g/mol) +Molecule.nouvMolecul=Est-ce une nouvelle mol�cule ? +Molecule.campagne=Dans le cadre de la campagne +Molecule.identifieePar=Identifi�e par +Molecule.publiOrigine=Publication d'origine +Molecule.complement=Compl�ment +Molecule.createur=Cr�ateur de la fiche +Molecule.produits=Provenance + + TestBio.ref=Test ref. TestBio.manipulateur=Operator TestBio.organismeTesteur=Test organization Modified: trunk/cantharella.data/src/main/resources/commons/data_fr.properties =================================================================== --- trunk/cantharella.data/src/main/resources/commons/data_fr.properties 2013-01-02 11:06:26 UTC (rev 43) +++ trunk/cantharella.data/src/main/resources/commons/data_fr.properties 2013-01-03 17:10:01 UTC (rev 44) @@ -180,6 +180,23 @@ ParamMethoPuri=Paramètre ParamMethoPuriEffect.valeur=Valeur + +Molecule.idMolecule=Molécule N° +Molecule.nomCommun=Nom commun +Molecule.familleChimique=Famille Chimique +Molecule.formuleDevMol=Formule développée +Molecule.nomIupca=Nom IUPAC +Molecule.formuleBrute=Formule brute +Molecule.masseMolaire=Masse molaire (g/mol) +Molecule.nouvMolecul=Est-ce une nouvelle molécule ? +Molecule.campagne=Dans le cadre de la campagne +Molecule.identifieePar=Identifiée par +Molecule.publiOrigine=Publication d'origine +Molecule.complement=Complément +Molecule.createur=Créateur de la fiche +Molecule.produits=Provenance + + TestBio.ref=Réf. test TestBio.manipulateur=Manipulateur TestBio.organismeTesteur=Organisme testeur Modified: trunk/cantharella.data/src/test/java/nc/ird/cantharella/data/SchemaExporter.java =================================================================== --- trunk/cantharella.data/src/test/java/nc/ird/cantharella/data/SchemaExporter.java 2013-01-02 11:06:26 UTC (rev 43) +++ trunk/cantharella.data/src/test/java/nc/ird/cantharella/data/SchemaExporter.java 2013-01-03 17:10:01 UTC (rev 44) @@ -3,34 +3,27 @@ import java.io.IOException; import java.util.Properties; -import javax.sql.DataSource; - import org.hibernate.cfg.Configuration; import org.hibernate.cfg.Environment; import org.hibernate.dialect.PostgreSQL82Dialect; import org.hibernate.tool.hbm2ddl.SchemaExport; import org.junit.Test; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.orm.hibernate4.LocalSessionFactoryBean; -public class SchemaExporter extends AbstractDataTest { +public class SchemaExporter { - @Autowired - protected DataSource datasource; - @Test public void exportSchema() throws IOException { LocalSessionFactoryBean sessionFactoryBean = new LocalSessionFactoryBean(); - //sessionFactoryBean.setDataSource(datasource); sessionFactoryBean.setPackagesToScan(new String[] { "nc.ird.cantharella.data.model" }); Properties hibernateProperties = new Properties(); // Hibernate: basic hibernateProperties.setProperty(Environment.DIALECT, PostgreSQL82Dialect.class.getName()); + hibernateProperties.setProperty(Environment.SHOW_SQL, "false"); sessionFactoryBean.setHibernateProperties(hibernateProperties); sessionFactoryBean.afterPropertiesSet(); Configuration configuration = sessionFactoryBean.getConfiguration(); SchemaExport schemaExport = new SchemaExport(configuration); - schemaExport.create(true, false); - + schemaExport.create(true, false); } } Added: trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/services/MoleculeService.java =================================================================== --- trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/services/MoleculeService.java (rev 0) +++ trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/services/MoleculeService.java 2013-01-03 17:10:01 UTC (rev 44) @@ -0,0 +1,85 @@ +/* + * #%L + * Cantharella :: Service + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2013 IRD (Institut de Recherche pour le Developpement) and by respective authors (see below) + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 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 Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ +package nc.ird.cantharella.service.services; + +import java.util.List; + +import nc.ird.cantharella.data.exceptions.DataConstraintException; +import nc.ird.cantharella.data.exceptions.DataNotFoundException; +import nc.ird.cantharella.data.model.Molecule; +import nc.ird.cantharella.service.utils.normalizers.MoleculeNormalizer; +import nc.ird.cantharella.service.utils.normalizers.utils.Normalize; + +import org.springframework.transaction.annotation.Transactional; + +/** + * Service : molecules. + * + * @author Eric Chatellier + */ +public interface MoleculeService { + + /** + * Compte le nombre de molecules + * @return Nombre de Molecules + */ + long countMolecules(); + + /** + * Créée une molecule + * @param molecule Molecule + * @throws DataConstraintException Si la molecule existe déjà + */ + void createMolecule(@Normalize(MoleculeNormalizer.class) Molecule molecule) throws DataConstraintException; + + /** + * Supprime une molecule + * @param molecule Molecule + * @throws DataConstraintException Si la molecule a des données liées + */ + void deleteMolecule(Molecule molecule) throws DataConstraintException; + + /** + * Liste les molecules + * @return Molecules + */ + @Transactional(readOnly = true) + List<Molecule> listMolecules(); + + /** + * Charge une molecule + * @param numero numero + * @return Le lot correspondant + * @throws DataNotFoundException Si le lot n'existe pas + */ + Molecule loadMolecule(Integer numero) throws DataNotFoundException; + + /** + * Met à jour une molecule + * @param molecule Molecule + * @throws DataConstraintException Si la molecule existe déjà + */ + void updateMolecule(@Normalize(MoleculeNormalizer.class) Molecule molecule) throws DataConstraintException; + + +} Property changes on: trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/services/MoleculeService.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/services/impl/MoleculeServiceImpl.java =================================================================== --- trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/services/impl/MoleculeServiceImpl.java (rev 0) +++ trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/services/impl/MoleculeServiceImpl.java 2013-01-03 17:10:01 UTC (rev 44) @@ -0,0 +1,103 @@ +/* + * #%L + * Cantharella :: Service + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2013 IRD (Institut de Recherche pour le Developpement) and by respective authors (see below) + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 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 Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ +package nc.ird.cantharella.service.services.impl; + +import java.util.List; + +import nc.ird.cantharella.data.dao.GenericDao; +import nc.ird.cantharella.data.exceptions.DataConstraintException; +import nc.ird.cantharella.data.exceptions.DataNotFoundException; +import nc.ird.cantharella.data.exceptions.UnexpectedException; +import nc.ird.cantharella.data.model.Molecule; +import nc.ird.cantharella.service.services.MoleculeService; +import nc.ird.module.utils.AssertTools; +import nc.ird.module.utils.LogTools; + +import org.apache.commons.logging.Log; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +/** + * Implémentation du service molecule. + * + * @author Eric Chatellier + */ +@Service +public final class MoleculeServiceImpl implements MoleculeService { + + /** Logger */ + private static final Log LOG = LogTools.getLog(); + + /** DAO */ + @Autowired + private GenericDao dao; + + @Override + public long countMolecules() { + return dao.count(Molecule.class); + } + + @Override + public void createMolecule(Molecule molecule) + throws DataConstraintException { + LOG.info("createMolecule " + molecule.getFormuleBrute()); + dao.create(molecule); + } + + @Override + public void deleteMolecule(Molecule molecule) + throws DataConstraintException { + AssertTools.assertNotNull(molecule); + LOG.info("deleteMolecule " + molecule.getIdMolecule()); + try { + dao.delete(molecule); + } catch (DataNotFoundException e) { + LOG.error(e.getMessage(), e); + throw new UnexpectedException(e); + } + + } + + @Override + public List<Molecule> listMolecules() { + return dao.readList(Molecule.class, "idMolecule"); + } + + @Override + public Molecule loadMolecule(Integer numero) throws DataNotFoundException { + return dao.read(Molecule.class, numero); + } + + @Override + public void updateMolecule(Molecule molecule) + throws DataConstraintException { + LOG.info("updateMolecule: " + molecule.getIdMolecule()); + try { + dao.update(molecule); + } catch (DataNotFoundException e) { + LOG.error(e.getMessage(), e); + throw new UnexpectedException(e); + } + + } +} Property changes on: trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/services/impl/MoleculeServiceImpl.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/utils/normalizers/MoleculeNormalizer.java =================================================================== --- trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/utils/normalizers/MoleculeNormalizer.java (rev 0) +++ trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/utils/normalizers/MoleculeNormalizer.java 2013-01-03 17:10:01 UTC (rev 44) @@ -0,0 +1,41 @@ +/* + * #%L + * Cantharella :: Service + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2013 IRD (Institut de Recherche pour le Developpement) and by respective authors (see below) + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 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 Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ +package nc.ird.cantharella.service.utils.normalizers; + +import nc.ird.cantharella.data.model.Molecule; +import nc.ird.cantharella.service.utils.normalizers.utils.Normalizer; +import nc.ird.module.utils.AssertTools; + +/** + * Molecule normalizer + * @author Eric Chatellier + */ +public final class MoleculeNormalizer extends Normalizer<Molecule> { + + /** {@inheritDoc} */ + @Override + protected Molecule normalize(Molecule molecule) { + AssertTools.assertNotNull(molecule); + return molecule; + } +} Property changes on: trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/utils/normalizers/MoleculeNormalizer.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Modified: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/config/WebApplicationImpl.java =================================================================== --- trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/config/WebApplicationImpl.java 2013-01-02 11:06:26 UTC (rev 43) +++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/config/WebApplicationImpl.java 2013-01-03 17:10:01 UTC (rev 44) @@ -40,6 +40,9 @@ import nc.ird.cantharella.web.pages.domain.lot.ListLotsPage; import nc.ird.cantharella.web.pages.domain.lot.ManageLotPage; import nc.ird.cantharella.web.pages.domain.lot.ReadLotPage; +import nc.ird.cantharella.web.pages.domain.molecule.ListMoleculesPage; +import nc.ird.cantharella.web.pages.domain.molecule.ManageMoleculePage; +import nc.ird.cantharella.web.pages.domain.molecule.ReadMoleculePage; import nc.ird.cantharella.web.pages.domain.personne.ListPersonnesPage; import nc.ird.cantharella.web.pages.domain.personne.ManagePersonnePage; import nc.ird.cantharella.web.pages.domain.personne.ReadPersonnePage; @@ -381,7 +384,14 @@ getRootRequestMapperAsCompound().add(new MountedMapper("/station/edit", ManageStationPage.class)); mountPage("/station/edit", ManageStationPage.class); getRootRequestMapperAsCompound().add(new MountedMapper("/station/view", ReadStationPage.class)); - mountPage("/station/view", ReadStationPage.class); + mountPage("/station/view", ReadStationPage.class); + + getRootRequestMapperAsCompound().add(new MountedMapper("/molecule/list", ListMoleculesPage.class)); + mountPage("/molecule/list", ListMoleculesPage.class); + getRootRequestMapperAsCompound().add(new MountedMapper("/molecule/edit", ManageMoleculePage.class)); + mountPage("/molecule/edit", ManageMoleculePage.class); + getRootRequestMapperAsCompound().add(new MountedMapper("/molecule/view", ReadMoleculePage.class)); + mountPage("/molecule/view", ReadMoleculePage.class); getRootRequestMapperAsCompound().add(new MountedMapper("/testBio/list", ListTestsBioPage.class)); mountPage("/testBio/list", ListTestsBioPage.class); Modified: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/TemplatePage.html =================================================================== --- trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/TemplatePage.html 2013-01-02 11:06:26 UTC (rev 43) +++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/TemplatePage.html 2013-01-03 17:10:01 UTC (rev 44) @@ -4,7 +4,7 @@ $Id:$ $HeadURL:$ %% - Copyright (C) 2009 - 2012 IRD (Institut de Recherche pour le Developpement) and by respective authors (see below) + Copyright (C) 2009 - 2013 IRD (Institut de Recherche pour le Developpement) and by respective authors (see below) %% This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by @@ -136,7 +136,7 @@ </li> <li class="sm2 chi"><span><wicket:message key="TemplatePage.Chemistry"/></span><img src="images/chimie.jpg" /> <ul> - <li><wicket:message key="ListMoleculesPage" /></li> + <li><a wicket:id="ListMoleculesPage"><wicket:message key="ListMoleculesPage" /></a></li> </ul> </li> <li class="sm1 bio"><span><wicket:message key="TemplatePage.Biology"/></span><img src="images/biologie.jpg" /> Modified: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/TemplatePage.java =================================================================== --- trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/TemplatePage.java 2013-01-02 11:06:26 UTC (rev 43) +++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/TemplatePage.java 2013-01-03 17:10:01 UTC (rev 44) @@ -4,7 +4,7 @@ * $Id:$ * $HeadURL:$ * %% - * Copyright (C) 2009 - 2012 IRD (Institut de Recherche pour le Developpement) and by respective authors (see below) + * Copyright (C) 2009 - 2013 IRD (Institut de Recherche pour le Developpement) and by respective authors (see below) * %% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by @@ -32,6 +32,7 @@ import nc.ird.cantharella.web.pages.domain.config.ListConfigurationPage; import nc.ird.cantharella.web.pages.domain.extraction.ListExtractionsPage; import nc.ird.cantharella.web.pages.domain.lot.ListLotsPage; +import nc.ird.cantharella.web.pages.domain.molecule.ListMoleculesPage; import nc.ird.cantharella.web.pages.domain.personne.ListPersonnesPage; import nc.ird.cantharella.web.pages.domain.purification.ListPurificationsPage; import nc.ird.cantharella.web.pages.domain.search.SearchPage; @@ -244,6 +245,7 @@ ListExtractionsPage.class)); userMenu.add(new BookmarkablePageLink<Void>(ListPurificationsPage.class.getSimpleName(), ListPurificationsPage.class)); + userMenu.add(new BookmarkablePageLink<Void>(ListMoleculesPage.class.getSimpleName(), ListMoleculesPage.class)); userMenu.add(new BookmarkablePageLink<Void>(ListTestsBioPage.class.getSimpleName(), ListTestsBioPage.class)); // userMenu.add(new BookmarkablePageLink<Void>(SandboxPage.class.getSimpleName(), SandboxPage.class)); Added: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/molecule/ListMoleculesPage.html =================================================================== --- trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/molecule/ListMoleculesPage.html (rev 0) +++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/molecule/ListMoleculesPage.html 2013-01-03 17:10:01 UTC (rev 44) @@ -0,0 +1,37 @@ +<!-- + #%L + Cantharella :: Web + $Id:$ + $HeadURL:$ + %% + Copyright (C) 2009 - 2013 IRD (Institut de Recherche pour le Developpement) and by respective authors (see below) + %% + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 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 Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + #L% + --> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" + xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd"> +<body> +<wicket:extend> +<p><a wicket:id="ListMoleculesPage.NewMolecule" class="add"><wicket:message key="ListMoleculesPage.NewMolecule" /></a> +</p> + +<div wicket:id="ListMoleculesPage.Molecules.Refresh"> +<table cellspacing="0" wicket:id="ListMoleculesPage.Molecules"/> +</div> + +</wicket:extend> +</body> +</html> \ No newline at end of file Added: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/molecule/ListMoleculesPage.java =================================================================== --- trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/molecule/ListMoleculesPage.java (rev 0) +++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/molecule/ListMoleculesPage.java 2013-01-03 17:10:01 UTC (rev 44) @@ -0,0 +1,127 @@ +/* + * #%L + * Cantharella :: Web + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2013 IRD (Institut de Recherche pour le Developpement) and by respective authors (see below) + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 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 Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ +package nc.ird.cantharella.web.pages.domain.molecule; + +import java.util.ArrayList; +import java.util.List; + +import nc.ird.cantharella.data.model.Lot; +import nc.ird.cantharella.data.model.Molecule; +import nc.ird.cantharella.web.config.WebContext; +import nc.ird.cantharella.web.pages.TemplatePage; +import nc.ird.cantharella.web.pages.columns.TaxonomyPropertyColumn; +import nc.ird.cantharella.web.pages.domain.lot.ListLotsPage; +import nc.ird.cantharella.web.pages.domain.lot.ReadLotPage; +import nc.ird.cantharella.web.pages.domain.specimen.ReadSpecimenPage; +import nc.ird.cantharella.web.pages.domain.station.ReadStationPage; +import nc.ird.cantharella.web.utils.CallerPage; +import nc.ird.cantharella.web.utils.columns.EnumPropertyColumn; +import nc.ird.cantharella.web.utils.columns.LinkPropertyColumn; +import nc.ird.cantharella.web.utils.columns.LinkableImagePropertyColumn; +import nc.ird.cantharella.web.utils.models.LoadableDetachableSortableListDataProvider; +import nc.ird.cantharella.web.utils.security.AuthRole; +import nc.ird.cantharella.web.utils.security.AuthRoles; + +import org.apache.wicket.MarkupContainer; +import org.apache.wicket.extensions.ajax.markup.html.repeater.data.table.AjaxFallbackDefaultDataTable; +import org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator; +import org.apache.wicket.extensions.markup.html.repeater.data.table.DataTable; +import org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn; +import org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn; +import org.apache.wicket.markup.html.WebMarkupContainer; +import org.apache.wicket.markup.html.link.Link; +import org.apache.wicket.markup.repeater.Item; +import org.apache.wicket.model.IModel; +import org.apache.wicket.model.Model; + +@AuthRoles( { AuthRole.ADMIN, AuthRole.USER }) +public class ListMoleculesPage extends TemplatePage { + + public ListMoleculesPage() { + super(ListMoleculesPage.class); + + final CallerPage currentPage = new CallerPage(ListLotsPage.class); + + add(new Link<Void>(getResource() + ".NewMolecule") { + @Override + public void onClick() { + setResponsePage(new ManageMoleculePage(currentPage)); + } + }); + + // On englobe le "DataView" dans un composant neutre que l'on pourra + // rafraichir quand la liste évoluera + final MarkupContainer moleculesRefresh = new WebMarkupContainer(getResource() + ".Molecules.Refresh"); + moleculesRefresh.setOutputMarkupId(true); + add(moleculesRefresh); + + // Liste des molecules + final List<Molecule> molecules = new ArrayList<Molecule>(); + + LoadableDetachableSortableListDataProvider<Molecule> moleculesDataProvider = new LoadableDetachableSortableListDataProvider<Molecule>( + molecules, getSession().getLocale()); + + List<IColumn<Molecule>> columns = new ArrayList<IColumn<Molecule>>(); + + columns.add(new LinkableImagePropertyColumn<Molecule>("images/read.png", getString("Read"), getString("Read")) { + @Override + public void onClick(Item<ICellPopulator<Molecule>> item, String componentId, IModel<Molecule> model) { + setResponsePage(new ReadMoleculePage(model.getObject().getIdMolecule(), currentPage)); + } + }); + columns.add(new LinkPropertyColumn<Molecule>(new Model<String>(getString("Molecule.idMolecule")), "idMolecule", "idMolecule", + getString("Read")) { + @Override + public void onClick(Item<ICellPopulator<Molecule>> item, String componentId, IModel<Molecule> model) { + setResponsePage(new ReadLotPage(model.getObject().getIdMolecule(), currentPage)); + } + }); + + columns.add(new PropertyColumn<Molecule>(new Model<String>(getString("Molecule.nomCommun")), "nomCommun", + "nomCommun")); + columns.add(new PropertyColumn<Molecule>(new Model<String>(getString("Molecule.familleChimique")), "familleChimique", + "familleChimique")); + columns.add(new PropertyColumn<Molecule>(new Model<String>(getString("Molecule.formuleDevMol")), "formuleDevMol", + "formuleDevMol")); + columns.add(new PropertyColumn<Molecule>(new Model<String>(getString("Molecule.nomIupca")), "nomIupca", + "nomIupca")); + columns.add(new PropertyColumn<Molecule>(new Model<String>(getString("Molecule.formuleBrute")), "formuleBrute", + "formuleBrute")); + columns.add(new PropertyColumn<Molecule>(new Model<String>(getString("Molecule.masseMolaire")), "masseMolaire", + "masseMolaire")); + columns.add(new PropertyColumn<Molecule>(new Model<String>(getString("Molecule.nouvMolecul")), "nouvMolecul", + "nouvMolecul")); + columns.add(new PropertyColumn<Molecule>(new Model<String>(getString("Molecule.campagne")), "campagne", + "campagne")); + columns.add(new PropertyColumn<Molecule>(new Model<String>(getString("Molecule.identifieePar")), "identifieePar", + "identifieePar")); + columns.add(new PropertyColumn<Molecule>(new Model<String>(getString("Molecule.publiOrigine")), "publiOrigine", + "publiOrigine")); + columns.add(new PropertyColumn<Molecule>(new Model<String>(getString("Molecule.complement")), "complement", + "complement")); + + final DataTable<Molecule> moleculesDataTable = new AjaxFallbackDefaultDataTable<Molecule>("ListMoleculesPage.Molecules", columns, + moleculesDataProvider, WebContext.ROWS_PER_PAGE); + moleculesRefresh.add(moleculesDataTable); + } +} Property changes on: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/molecule/ListMoleculesPage.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/molecule/ManageMoleculePage.html =================================================================== --- trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/molecule/ManageMoleculePage.html (rev 0) +++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/molecule/ManageMoleculePage.html 2013-01-03 17:10:01 UTC (rev 44) @@ -0,0 +1,102 @@ +<!-- + #%L + Cantharella :: Web + $Id:$ + $HeadURL:$ + %% + Copyright (C) 2009 - 2013 IRD (Institut de Recherche pour le Developpement) and by respective authors (see below) + %% + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 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 Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + #L% + --> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" + xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd"> +<body> +<wicket:extend> + + <form wicket:id="Form"> + + <div class="property"> + <label for="Molecule.nomCommun"><wicket:message key="Molecule.nomCommun" /></label> + <input type="text" id="Molecule.nomCommun" wicket:id="Molecule.nomCommun" /> + </div> + + <div class="property"> + <label for="Molecule.familleChimique"><wicket:message key="Molecule.familleChimique" /></label> + <input type="text" id="Molecule.familleChimique" wicket:id="Molecule.familleChimique" /> + </div> + + <div class="property"> + <label for="Molecule.formuleDevMol"><wicket:message key="Molecule.formuleDevMol" /></label> + <input type="text" id="Molecule.formuleDevMol" wicket:id="Molecule.formuleDevMol" /> + </div> + + <div class="property"> + <label for="Molecule.nomIupca"><wicket:message key="Molecule.nomIupca" /></label> + <input type="text" id="Molecule.nomIupca" wicket:id="Molecule.nomIupca" /> + </div> + + <div class="property required"> + <label for="Molecule.formuleBrute"><wicket:message key="Molecule.formuleBrute" /></label> + <input type="text" id="Molecule.formuleBrute" wicket:id="Molecule.formuleBrute" /> + </div> + + <div class="property"> + <label for="Molecule.masseMolaire"><wicket:message key="Molecule.masseMolaire" /></label> + <input type="text" id="Molecule.masseMolaire" wicket:id="Molecule.masseMolaire" /> + </div> + + <div class="property"> + <label for="Molecule.nouvMolecul"><wicket:message key="Molecule.nouvMolecul" /></label> + <input type="checkbox" id="Molecule.nouvMolecul" wicket:id="Molecule.nouvMolecul" /> + </div> + + <div class="property required"> + <label for="Molecule.campagne"><wicket:message key="Molecule.campagne" /></label> + <select id="Molecule.campagne" wicket:id="Molecule.campagne" /> + <a wicket:id="NewCampagne" class="add"><wicket:message key="ListCampagnesPage.NewCampagne" /></a> + </div> + + <div class="property"> + <label for="Molecule.identifieePar"><wicket:message key="Molecule.identifieePar" /></label> + <input type="text" id="Molecule.identifieePar" wicket:id="Molecule.identifieePar" /> + </div> + + <div class="property"> + <label for="Molecule.publiOrigine"><wicket:message key="Molecule.publiOrigine" /></label> + <textarea id="Molecule.publiOrigine" wicket:id="Molecule.publiOrigine"></textarea> + </div> + + <div class="property"> + <label for="Molecule.complement"><wicket:message key="Molecule.complement" /></label> + <textarea id="Molecule.complement" wicket:id="Molecule.complement"></textarea> + </div> + + <div class="property required"> + <label for="Molecule.createur"><wicket:message key="Molecule.createur" /></label> + <input type="text" id="Molecule.createur" wicket:id="Molecule.createur" disabled="disabled"/> + </div> + + <div class="actions"> + <input type="submit" wicket:message="value:Submit" wicket:id="Create" /> + <input type="submit" wicket:message="value:Submit" wicket:id="Update" /> + <input type="submit" wicket:message="value:Delete" wicket:id="Delete" class="warning" /> + <a wicket:id="Cancel"><wicket:message key="Cancel" /></a> + </div> + </form> + +</wicket:extend> +</body> +</html> \ No newline at end of file Added: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/molecule/ManageMoleculePage.java =================================================================== --- trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/molecule/ManageMoleculePage.java (rev 0) +++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/molecule/ManageMoleculePage.java 2013-01-03 17:10:01 UTC (rev 44) @@ -0,0 +1,311 @@ +/* + * #%L + * Cantharella :: Web + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2013 IRD (Institut de Recherche pour le Developpement) and by respective authors (see below) + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 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 Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ +package nc.ird.cantharella.web.pages.domain.molecule; + +import java.util.List; + +import nc.ird.cantharella.data.exceptions.DataConstraintException; +import nc.ird.cantharella.data.exceptions.DataNotFoundException; +import nc.ird.cantharella.data.exceptions.UnexpectedException; +import nc.ird.cantharella.data.model.Campagne; +import nc.ird.cantharella.data.model.Molecule; +import nc.ird.cantharella.data.validation.utils.ModelValidator; +import nc.ird.cantharella.service.services.CampagneService; +import nc.ird.cantharella.service.services.MoleculeService; +import nc.ird.cantharella.web.pages.TemplatePage; +import nc.ird.cantharella.web.pages.domain.campagne.ManageCampagnePage; +import nc.ird.cantharella.web.utils.CallerPage; +import nc.ird.cantharella.web.utils.behaviors.JSConfirmationBehavior; +import nc.ird.cantharella.web.utils.forms.SubmittableButton; +import nc.ird.cantharella.web.utils.forms.SubmittableButtonEvents; +import nc.ird.cantharella.web.utils.security.AuthRole; +import nc.ird.cantharella.web.utils.security.AuthRoles; +import nc.ird.module.utils.LogTools; + +import org.apache.commons.lang3.BooleanUtils; +import org.apache.commons.logging.Log; +import org.apache.wicket.ajax.AjaxRequestTarget; +import org.apache.wicket.ajax.markup.html.form.AjaxSubmitLink; +import org.apache.wicket.markup.html.form.Button; +import org.apache.wicket.markup.html.form.CheckBox; +import org.apache.wicket.markup.html.form.DropDownChoice; +import org.apache.wicket.markup.html.form.Form; +import org.apache.wicket.markup.html.form.TextArea; +import org.apache.wicket.markup.html.form.TextField; +import org.apache.wicket.markup.html.link.Link; +import org.apache.wicket.model.IModel; +import org.apache.wicket.model.Model; +import org.apache.wicket.model.PropertyModel; +import org.apache.wicket.spring.injection.annot.SpringBean; + +/** + * Gestion des lots + * @author Mickael Tricot + * @author Adrien Cheype + */ +@AuthRoles({ AuthRole.USER, AuthRole.ADMIN }) +public final class ManageMoleculePage extends TemplatePage { + + /** Action : create */ + private static final String ACTION_CREATE = "Create"; + + /** Action : delete */ + public static final String ACTION_DELETE = "Delete"; + + /** Action : update */ + private static final String ACTION_UPDATE = "Update"; + + /** Logger */ + private static final Log LOG = LogTools.getLog(); + + /** Campagnes */ + private final List<Campagne> campagnes; + + /** Service : campagne */ + @SpringBean + private CampagneService campagneService; + + /** Modèle : molecule */ + private final IModel<Molecule> moleculeModel; + + /** Service : molecule */ + @SpringBean + private MoleculeService moleculeService; + + /** Model validateur */ + @SpringBean(name = "webModelValidator") + private ModelValidator validator; + + /** Page appelante */ + private final CallerPage callerPage; + + /** + * Constructeur (mode création) + * @param callerPage Page appelante + * @param multipleEntry Saisie multiple + */ + public ManageMoleculePage(CallerPage callerPage) { + this(null, callerPage); + } + + /** + * Constructeur. Si idMolecule est null, on créée une nouvelle Molecule. Si idMolecule est renseigné, on édite la molecule + * correspondante. + * @param idMolecule ID molecule + * @param lot Lot + * @param callerPage Page appelante + * @param multipleEntry Saisie multiple + */ + private ManageMoleculePage(Integer idMolecule, final CallerPage callerPage) { + super(ManageMoleculePage.class); + this.callerPage = callerPage; + + final CallerPage currentPage = new CallerPage(this); + + // Initialisation du modèle + try { + moleculeModel = new Model<Molecule>(idMolecule == null ? new Molecule() : moleculeService.loadMolecule(idMolecule)); + } catch (DataNotFoundException e) { + LOG.error(e.getMessage(), e); + throw new UnexpectedException(e); + } + + boolean createMode = idMolecule == null; + if (createMode) { + moleculeModel.getObject().setCreateur(getSession().getUtilisateur()); + } + + // Initialisation des listes + campagnes = campagneService.listCampagnes(getSession().getUtilisateur()); + + /*if (lot != null) { + // qd saisie multiple avec préremplissage, hack nécessaire afin d'avoir dans le model le même objet que + // celui de la liste de choix (sinon comme les objets viennent de sessions hibernate différentes, on n'a pas + // l'égalité entre les objets) + lotModel.getObject().setCampagne( + CollectionTools.findWithValue(campagnes, "idCampagne", AccessType.GETTER, lotModel.getObject() + .getCampagne().getIdCampagne())); + // normalement pas nul car un bean campagne (le modèle donné en l'occurence) bien formé comporte une + // campagne de renseigné + if (lotModel.getObject().getCampagne() != null) { + List<Station> stations = lotModel.getObject().getCampagne().getStations(); + lotModel.getObject().setStation( + CollectionTools.findWithValue(stations, "idStation", AccessType.GETTER, lotModel.getObject() + .getStation().getIdStation())); + } + if (lotModel.getObject().getPartie() != null) { + lotModel.getObject().setPartie( + CollectionTools.findWithValue(parties, "idPartie", AccessType.GETTER, lotModel.getObject() + .getPartie().getIdPartie())); + } + } else if (idLot != null) { + + }*/ + + final Form<Void> formView = new Form<Void>("Form"); + formView.add(new TextField<String>("Molecule.nomCommun", new PropertyModel<String>(moleculeModel, "nomCommun"))); + formView.add(new TextField<String>("Molecule.familleChimique", new PropertyModel<String>(moleculeModel, "familleChimique"))); + formView.add(new TextField<String>("Molecule.formuleDevMol", new PropertyModel<String>(moleculeModel, "formuleDevMol"))); + formView.add(new TextField<String>("Molecule.nomIupca", new PropertyModel<String>(moleculeModel, "nomIupca"))); + formView.add(new TextField<String>("Molecule.formuleBrute", new PropertyModel<String>(moleculeModel, "formuleBrute"))); + formView.add(new TextField<String>("Molecule.masseMolaire", new PropertyModel<String>(moleculeModel, "masseMolaire"))); + formView.add(new CheckBox("Molecule.nouvMolecul", new PropertyModel<Boolean>(moleculeModel, "nouvMolecul"))); + formView.add(new TextField<String>("Molecule.identifieePar", new PropertyModel<String>(moleculeModel, "identifieePar")) { + @Override + public boolean isVisible() { + return BooleanUtils.isTrue(moleculeModel.getObject().getNouvMolecul()); + } + }); + + DropDownChoice<Campagne> campagnesInput = new DropDownChoice<Campagne>("Molecule.campagne", + new PropertyModel<Campagne>(moleculeModel, "campagne"), campagnes) { + @Override + public boolean isVisible() { + return BooleanUtils.isTrue(moleculeModel.getObject().getNouvMolecul()); + } + }; + campagnesInput.setNullValid(false); + formView.add(campagnesInput); + + // Action : création d'une nouvelle campagne + // ajaxSubmitLink permet de sauvegarder l'état du formulaire + formView.add(new AjaxSubmitLink("NewCampagne") { + @Override + protected void onSubmit(AjaxRequestTarget arg0, Form<?> arg1) { + setResponsePage(new ManageCampagnePage(currentPage, false)); + } + + // si erreur, le formulaire est également enregistré puis la redirection effectuée + @Override + protected void onError(AjaxRequestTarget target, Form<?> form) { + setResponsePage(new ManageCampagnePage(currentPage, false)); + } + @Override + public boolean isVisible() { + return BooleanUtils.isTrue(moleculeModel.getObject().getNouvMolecul()); + } + }); + + formView.add(new TextArea<String>("Molecule.publiOrigine", new PropertyModel<String>(moleculeModel, "publiOrigine")) { + @Override + public boolean isVisible() { + return BooleanUtils.isTrue(moleculeModel.getObject().getNouvMolecul()); + } + }); + formView.add(new TextArea<String>("Molecule.complement", new PropertyModel<String>(moleculeModel, "complement"))); + + + // Créateur en lecture seule + formView.add(new TextField<String>("Molecule.createur", new PropertyModel<String>(moleculeModel, "createur")) + .setEnabled(false)); + + // Action : création du lot + Button createButton = new SubmittableButton(ACTION_CREATE, new SubmittableButtonEvents() { + @Override + public void onProcess() throws DataConstraintException { + moleculeService.createMolecule(moleculeModel.getObject()); + } + + @Override + public void onSuccess() { + successNextPage(ACTION_CREATE); + redirect(); + } + + @Override + public void onValidate() { + validateModel(); + } + }); + createButton.setVisibilityAllowed(createMode); + formView.add(createButton); + + // Action : mise à jour du lot + Button updateButton = new SubmittableButton(ACTION_UPDATE, new SubmittableButtonEvents() { + @Override + public void onProcess() throws DataConstraintException { + moleculeService.updateMolecule(moleculeModel.getObject()); + } + + @Override + public void onSuccess() { + successNextPage(ACTION_UPDATE); + callerPage.responsePage((TemplatePage) getPage()); + } + + @Override + public void onValidate() { + validateModel(); + } + }); + updateButton.setVisibilityAllowed(!createMode); + formView.add(updateButton); + + // Action : suppression du lot + Button deleteButton = new SubmittableButton(ACTION_DELETE, new SubmittableButtonEvents() { + @Override + public void onProcess() throws DataConstraintException { + moleculeService.deleteMolecule(moleculeModel.getObject()); + } + + @Override + public void onSuccess() { + successNextPage(ACTION_DELETE); + callerPage.responsePage((TemplatePage) getPage()); + } + }); + deleteButton.setVisibilityAllowed(!createMode); + deleteButton.add(new JSConfirmationBehavior(getString("Confirm"))); + deleteButton.setDefaultFormProcessing(false); + formView.add(deleteButton); + + formView.add(new Link<Void>("Cancel") { + // Cas où le formulaire est annulé + @Override + public void onClick() { + callerPage.responsePage((TemplatePage) this.getPage()); + } + }); + + add(formView); + } + + /** + * Redirection vers une autre page. Cas où le formulaire est validé + */ + private void redirect() { + if (callerPage != null) { + callerPage.responsePage(this); + } + } + + /** + * Validate model + */ + private void validateModel() { + if (moleculeModel.getObject().getCreateur() == null) { + moleculeModel.getObject().setCreateur(getSession().getUtilisateur()); + } + addValidationErrors(validator.validate(moleculeModel.getObject(), getSession().getLocale())); + } +} Property changes on: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/molecule/ManageMoleculePage.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/molecule/ReadMoleculePage.html =================================================================== --- trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/molecule/ReadMoleculePage.html (rev 0) +++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/molecule/ReadMoleculePage.html 2013-01-03 17:10:01 UTC (rev 44) @@ -0,0 +1,152 @@ +<!-- + #%L + Cantharella :: Web + $Id:$ + $HeadURL:$ + %% + Copyright (C) 2009 - 2013 IRD (Institut de Recherche pour le Developpement) and by respective authors (see below) + %% + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 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 Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + #L% + --> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" + xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd"> +<body> +<wicket:extend> + <div id="sheet"> + <div class="property"> + <span class="label"><wicket:message key="Molecule.idMolecule" /></span> + <span class="value" wicket:id="Molecule.idMolecule"></span> + </div> + + <div class="property"> + <span class="label"><wicket:message key="Molecule.nomCommun" /></span> + <span class="value" wicket:id="Molecule.nomCommun"></span> + </div> + + <div class="property"> + <span class="label"><wicket:message key="Molecule.familleChimique" /></span> + <span class="value" wicket:id="Molecule.familleChimique"></span> + </div> + + <div class="property"> + <span class="label"><wicket:message key="Molecule.formuleDevMol" /></span> + <span class="value" wicket:id="Molecule.formuleDevMol"></span> + </div> + + <div class="property"> + <span class="label"><wicket:message key="Molecule.nomIupca" /></span> + <span class="value" wicket:id="Molecule.nomIupca"></span> + </div> + + <div class="property"> + <span class="label"><wicket:message key="Molecule.formuleBrute" /></span> + <span class="value" wicket:id="Molecule.formuleBrute" ></span> + </div> + + <div class="property"> + <span class="label"><wicket:message key="Molecule.masseMolaire" /></span> + <span class="value" wicket:id="Molecule.masseMolaire" ></span> + </div> + + <div class="property"> + <span class="label"><wicket:message key="Molecule.nouvMolecul" /></span> + <span class="value" wicket:id="Molecule.nouvMolecul" ></span> + </div> + + <div class="property"> + <span class="label"><wicket:message key="Molecule.campagne" /></span> + <span class="value" wicket:id="Molecule.campagne" ></span> + </div> + + <div class="property"> + <span class="label"><wicket:message key="Molecule.identifieePar" /></span> + <span class="value" wicket:id="Molecule.identifieePar" ></span> + </div> + + <div class="property"> + <span class="label"><wicket:message key="Molecule.publiOrigine" /></span> + <span class="value" wicket:id="Molecule.publiOrigine" ></span> + </div> + + <div class="property"> + <span class="label"><wicket:message key="Molecule.complement" /></span> + <span class="value" wicket:id="Molecule.complement"></span> + </div> + + <div class="property"> + <span class="label"><wicket:message key="Molecule.createur" /></span> + <span class="value" wicket:id="Molecule.createur"></span> + </div> + + <fieldset> + <legend><wicket:message key="Molecule.produits" /></legend> + <!-- <table cellspacing="0" wicket:id="Molecule.produits.Table"> + <thead> + <tr> + <th> + <wicket:message key="Extrait.typeExtrait" /> + </th> + <th> + <wicket:message key="Extrait.ref" /> + </th> + <th> + <wicket:message key="Extrait.masseObtenue" /> + </th> + <th> + <wicket:message key="Extrait.rendement" /> + </th> + </tr> + </thead> + <tbody> + <tr wicket:id="Molecule.produits.List"> + <td> + <span wicket:id="Extraction.extraits.List.typeExtrait" /><wicket:container wicket:id="Molecule.produits.List.typeExtrait.info"/> + </td> + <td> + <span wicket:id="Extraction.extraits.List.ref" /> + </td> + <td> + <span wicket:id="Extraction.extraits.List.masseObtenue" /> + </td> + <td> + <span wicket:id="Extraction.extraits.List.rendement" /> + </td> + </tr> + </tbody> + </table> --> + <div class="property" wicket:id="Molecule.produits.noTable"> + <span class="label"> </span> + <span class="value"><wicket:message key="List.none" /></span> + </div> + </fieldset> + + <form wicket:id="Form"> + <div class="actions"> + <a class="edit" wicket:id="ReadMoleculePage.Lot.Update" wicket:message="title:Update"> + <wicket:message key="Update" /> + </a> + + <input type="submit" wicket:message="value:Delete" wicket:id="Delete" class="warning" /> + + <a wicket:id="ReadMoleculePage.Molecule.Back" wicket:message="title:Back"> + <wicket:message key="Back" /> + </a> + </div> + </form> + </div> +</wicket:extend> +</body> +</html> \ No newline at end of file Added: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/molecule/ReadMoleculePage.java =================================================================== --- trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/molecule/ReadMoleculePage.java (rev 0) +++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/molecule/ReadMoleculePage.java 2013-01-03 17:10:01 UTC (rev 44) @@ -0,0 +1,37 @@ +/* + * #%L + * Cantharella :: Web + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2013 IRD (Institut de Recherche pour le Developpement) and by respective authors (see below) + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 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 Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ +package nc.ird.cantharella.web.pages.domain.molecule; + +import nc.ird.cantharella.web.pages.TemplatePage; +import nc.ird.cantharella.web.utils.CallerPage; +import nc.ird.cantharella.web.utils.security.AuthRole; +import nc.ird.cantharella.web.utils.security.AuthRoles; + +@AuthRoles( { AuthRole.ADMIN, AuthRole.USER }) +public class ReadMoleculePage extends TemplatePage { + + public ReadMoleculePage(Integer idMolecule, final CallerPage callerPage) { + super(ReadMoleculePage.class); + } + +} Property changes on: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/molecule/ReadMoleculePage.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Modified: trunk/cantharella.web/src/main/resources/commons/web_en.properties =================================================================== --- trunk/cantharella.web/src/main/resources/commons/web_en.properties 2013-01-02 11:06:26 UTC (rev 43) +++ trunk/cantharella.web/src/main/resources/commons/web_en.properties 2013-01-03 17:10:01 UTC (rev 44) @@ -191,6 +191,8 @@ ManagePurificationPage.Delete.OK=Purification deleted ManagePurificationPage.Delete.DataConstraintException=There are data linked to this purification +ManageMoleculePage=Molecule management + ManageTestBioPage=Bioassay management ManageTestBioPage.Create.OK=Bioassay added ManageTestBioPage.Create.DataConstraintException=Unidentified error during the creation @@ -270,6 +272,7 @@ ReadStationPage=Viewing a location ReadExtractionPage=Viewing an extraction ReadPurificationPage=Viewing a purification +ReadMoleculePage=Viewing a molecule ReadTestBioPage=Viewing a bioassay SearchPage=Search Modified: trunk/cantharella.web/src/main/resources/commons/web_fr.properties =================================================================== --- trunk/cantharella.web/src/main/resources/commons/web_fr.properties 2013-01-02 11:06:26 UTC (rev 43) +++ trunk/cantharella.web/src/main/resources/commons/web_fr.properties 2013-01-03 17:10:01 UTC (rev 44) @@ -190,6 +190,8 @@ ManagePurificationPage.Delete.OK=Purification supprimée ManagePurificationPage.Delete.DataConstraintException=Il existe des données liées à cette purification +ManageMoleculePage=Gestion d'une molécule + ManageTestBioPage=Gestion d'un test biologique ManageTestBioPage.Create.OK=Test biologique ajouté ManageTestBioPage.Create.DataConstraintException=Erreur non identifiée lors de la création @@ -269,6 +271,7 @@ ReadStationPage=Consultation d'une station ReadExtractionPage=Consultation d'une extraction ReadPurificationPage=Consultation d'une purification +ReadMoleculePage=Consultation d'une molécule ReadTestBioPage=Consultation d'un test biologique SearchPage=Recherche
participants (1)
-
echatellier@users.forge.codelutin.com