r46 - in trunk: cantharella.data/src/main/java/nc/ird/cantharella/data/model cantharella.data/src/main/resources/commons cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/molecule cantharella.web/src/main/java/nc/ird/cantharella/web/pages/renderers cantharella.web/src/main/resources/commons
Author: echatellier Date: 2013-01-07 17:23:51 +0100 (Mon, 07 Jan 2013) New Revision: 46 Url: http://forge.codelutin.com/projects/cantharella/repository/revisions/46 Log: refs #1646: list et creation de molecules Added: trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/MoleculeProvenance.java trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/renderers/ProduitRenderer.java Modified: trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Molecule.java trunk/cantharella.data/src/main/resources/commons/data_en.properties trunk/cantharella.data/src/main/resources/commons/data_fr.properties 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.java trunk/cantharella.web/src/main/resources/commons/web_en.properties trunk/cantharella.web/src/main/resources/commons/web_fr.properties Modified: 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 2013-01-07 10:50:58 UTC (rev 45) +++ trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Molecule.java 2013-01-07 16:23:51 UTC (rev 46) @@ -1,7 +1,31 @@ +/* + * #%L + * Cantharella :: Data + * $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.data.model; +import java.math.BigDecimal; import java.util.List; +import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.FetchType; import javax.persistence.GeneratedValue; @@ -9,8 +33,11 @@ import javax.persistence.Lob; import javax.persistence.ManyToOne; import javax.persistence.OneToMany; +import javax.validation.constraints.Max; +import javax.validation.constraints.Min; import javax.validation.constraints.NotNull; +import nc.ird.cantharella.data.config.DataContext; import nc.ird.cantharella.data.model.search.UtilisateurSearchFilter; import nc.ird.cantharella.data.model.utils.AbstractModel; @@ -68,21 +95,21 @@ private String formuleBrute; /** Masse molaire */ - @NotEmpty - private Double masseMolaire; + @Min(value = 0) + @Max(value = DataContext.DECIMAL_MAX) + @Column(precision = DataContext.DECIMAL_PRECISION, scale = DataContext.DECIMAL_SCALE) + private BigDecimal masseMolaire; /** Est-ce une nouvelle molécule ? */ - @NotEmpty - private Boolean nouvMolecul; + private boolean nouvMolecul; - @ManyToOne(fetch = FetchType.EAGER, optional = false) + @ManyToOne(fetch = FetchType.EAGER) @IndexedEmbedded private Campagne campagne; /** Identifiee par. */ - @Length(max = LENGTH_MEDIUM_TEXT) - @NotNull - private String identifieePar; + @ManyToOne(fetch = FetchType.EAGER) + private Personne identifieePar; /** Publication d'origine */ @Lob @@ -101,9 +128,9 @@ private Personne createur; /** Produit utilisé obtenir le résultat **/ - @OneToMany(fetch = FetchType.LAZY) + @OneToMany(mappedBy = "molecule", fetch = FetchType.LAZY, orphanRemoval = true) @Cascade({ CascadeType.SAVE_UPDATE }) - private List<Produit> produits; + private List<MoleculeProvenance> provenances; /** * @return the idMolecule @@ -192,28 +219,28 @@ /** * @return the masseMolaire */ - public Double getMasseMolaire() { + public BigDecimal getMasseMolaire() { return masseMolaire; } /** * @param masseMolaire the masseMolaire to set */ - public void setMasseMolaire(Double masseMolaire) { + public void setMasseMolaire(BigDecimal masseMolaire) { this.masseMolaire = masseMolaire; } /** * @return the nouvMolecul */ - public Boolean getNouvMolecul() { + public boolean isNouvMolecul() { return nouvMolecul; } /** * @param nouvMolecul the nouvMolecul to set */ - public void setNouvMolecul(Boolean nouvMolecul) { + public void setNouvMolecul(boolean nouvMolecul) { this.nouvMolecul = nouvMolecul; } @@ -232,6 +259,20 @@ } /** + * @return the identifieePar + */ + public Personne getIdentifieePar() { + return identifieePar; + } + + /** + * @param identifieePar the identifieePar to set + */ + public void setIdentifieePar(Personne identifieePar) { + this.identifieePar = identifieePar; + } + + /** * @return the publiOrigine */ public String getPubliOrigine() { @@ -274,16 +315,16 @@ } /** - * @return the produits + * @return the provenances */ - public List<Produit> getProduits() { - return produits; + public List<MoleculeProvenance> getProvenances() { + return provenances; } /** - * @param produits the produits to set + * @param provenance the provenances to set */ - public void setProduits(List<Produit> produits) { - this.produits = produits; + public void setProvenances(List<MoleculeProvenance> provenances) { + this.provenances = provenances; } } Added: trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/MoleculeProvenance.java =================================================================== --- trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/MoleculeProvenance.java (rev 0) +++ trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/MoleculeProvenance.java 2013-01-07 16:23:51 UTC (rev 46) @@ -0,0 +1,119 @@ +/* + * #%L + * Cantharella :: Data + * $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.data.model; + +import java.math.BigDecimal; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.FetchType; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.ManyToOne; +import javax.validation.constraints.Max; +import javax.validation.constraints.Min; +import javax.validation.constraints.NotNull; + +import nc.ird.cantharella.data.config.DataContext; +import nc.ird.cantharella.data.model.utils.AbstractModel; + +@Entity +public class MoleculeProvenance extends AbstractModel { + + /** Id */ + @Id + @GeneratedValue + private Integer id; + + /** Concentration/masse **/ + @Min(value = 0) + @Max(value = 100) + @Column(precision = DataContext.DECIMAL_PRECISION, scale = DataContext.DECIMAL_SCALE) + private BigDecimal pourcentage; + + /** Molecule dont fait partie la provenance */ + @NotNull + @ManyToOne(fetch = FetchType.EAGER, optional = false) + private Molecule molecule; + + /** Produit sur lequel porte la provenance **/ + @NotNull + @ManyToOne(fetch = FetchType.EAGER, optional = false) + private Produit produit; + + /** + * @return the id + */ + public Integer getId() { + return id; + } + + /** + * @param id the id to set + */ + public void setId(Integer id) { + this.id = id; + } + + /** + * @return the pourcentage + */ + public BigDecimal getPourcentage() { + return pourcentage; + } + + /** + * @param pourcentage the pourcentage to set + */ + public void setPourcentage(BigDecimal pourcentage) { + this.pourcentage = pourcentage; + } + + /** + * @return the molecule + */ + public Molecule getMolecule() { + return molecule; + } + + /** + * @param molecule the molecule to set + */ + public void setMolecule(Molecule molecule) { + this.molecule = molecule; + } + + /** + * @return the produit + */ + public Produit getProduit() { + return produit; + } + + /** + * @param produit the produit to set + */ + public void setProduit(Produit produit) { + this.produit = produit; + } +} Property changes on: trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/MoleculeProvenance.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Modified: trunk/cantharella.data/src/main/resources/commons/data_en.properties =================================================================== --- trunk/cantharella.data/src/main/resources/commons/data_en.properties 2013-01-07 10:50:58 UTC (rev 45) +++ trunk/cantharella.data/src/main/resources/commons/data_en.properties 2013-01-07 16:23:51 UTC (rev 46) @@ -195,6 +195,12 @@ Molecule.complement=Compl�ment Molecule.createur=Cr�ateur de la fiche Molecule.produits=Provenance +Molecule.produits.produit.ref=R�f. Produit +Molecule.produits.presence=% +Molecule.produits.lot.ref=R�f. Lot +Molecule.produits.genre=Genre +Molecule.produits.espece=Esp�ce +Molecule.produits.campagne=Campagne TestBio.ref=Test ref. Modified: trunk/cantharella.data/src/main/resources/commons/data_fr.properties =================================================================== --- trunk/cantharella.data/src/main/resources/commons/data_fr.properties 2013-01-07 10:50:58 UTC (rev 45) +++ trunk/cantharella.data/src/main/resources/commons/data_fr.properties 2013-01-07 16:23:51 UTC (rev 46) @@ -195,8 +195,13 @@ Molecule.complement=Complément Molecule.createur=Créateur de la fiche Molecule.produits=Provenance +Molecule.produits.produit.ref=Réf. Produit +Molecule.produits.presence=% +Molecule.produits.lot.ref=Réf. Lot +Molecule.produits.genre=Genre +Molecule.produits.espece=Espèce +Molecule.produits.campagne=Campagne - TestBio.ref=Réf. test TestBio.manipulateur=Manipulateur TestBio.organismeTesteur=Organisme testeur Modified: 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 2013-01-07 10:50:58 UTC (rev 45) +++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/molecule/ListMoleculesPage.java 2013-01-07 16:23:51 UTC (rev 46) @@ -25,17 +25,13 @@ 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.service.services.MoleculeService; 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; @@ -53,10 +49,20 @@ import org.apache.wicket.markup.repeater.Item; import org.apache.wicket.model.IModel; import org.apache.wicket.model.Model; +import org.apache.wicket.spring.injection.annot.SpringBean; +/** + * Liste des molécules. + * + * @author Eric Chatellier + */ @AuthRoles( { AuthRole.ADMIN, AuthRole.USER }) public class ListMoleculesPage extends TemplatePage { + /** Service : molecule */ + @SpringBean + private MoleculeService moleculeService; + public ListMoleculesPage() { super(ListMoleculesPage.class); @@ -76,7 +82,7 @@ add(moleculesRefresh); // Liste des molecules - final List<Molecule> molecules = new ArrayList<Molecule>(); + final List<Molecule> molecules = moleculeService.listMolecules(); LoadableDetachableSortableListDataProvider<Molecule> moleculesDataProvider = new LoadableDetachableSortableListDataProvider<Molecule>( molecules, getSession().getLocale()); Modified: 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 2013-01-07 10:50:58 UTC (rev 45) +++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/molecule/ManageMoleculePage.html 2013-01-07 16:23:51 UTC (rev 46) @@ -58,27 +58,34 @@ <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> + <fieldset> + <legend><wicket:message key="Molecule.nouvMolecul" /></legend> + + <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 wicket:id="Molecule.nouvMolecul.Refresh"> + <div class="property"> + <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> + <select 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> + </fieldset> + <div class="property"> <label for="Molecule.complement"><wicket:message key="Molecule.complement" /></label> <textarea id="Molecule.complement" wicket:id="Molecule.complement"></textarea> @@ -88,7 +95,84 @@ <label for="Molecule.createur"><wicket:message key="Molecule.createur" /></label> <input type="text" id="Molecule.createur" wicket:id="Molecule.createur" disabled="disabled"/> </div> - + + <fieldset> + <legend><wicket:message key="Molecule.produits" /></legend> + <table class="large" cellspacing="0" wicket:id="Molecule.produits.Table"> + <thead> + <tr> + <th class="required"> + <label for="Molecule.produits.List.produit.ref"><wicket:message key="Molecule.produits.produit.ref" /></label> + </th> + <th class="required"> + <label for="Molecule.produits.List.presence"><wicket:message key="Molecule.produits.presence" /></label> + </th> + <th> + <label for="Molecule.produits.List.lot.ref"><wicket:message key="Molecule.produits.lot.ref" /></label> + </th> + <th> + <label for="Molecule.produits.List.genre"><wicket:message key="Molecule.produits.genre" /></label> + </th> + <th> + <label for="Molecule.produits.List.espece"><wicket:message key="Molecule.produits.espece" /></label> + </th> + <th> + <label for="Molecule.produits.List.campagne"><wicket:message key="Molecule.produits.campagne" /></label> + </th> + <th><wicket:message key="Actions" /></th> + </tr> + </thead> + <tbody> + <tr wicket:id="Molecule.produits.List"> + <td> + <span wicket:id="Molecule.produits.List.produit.ref" /> + </td> + <td> + <span wicket:id="Molecule.produits.List.presence" /> + </td> + <td> + <span wicket:id="Molecule.produits.List.lot.ref" /> + </td> + <td> + <span wicket:id="Molecule.produits.List.genre" /> + </td> + <td> + <span wicket:id="Molecule.produits.List.espece" /> + </td> + <td> + <span wicket:id="Molecule.produits.List.campagne" /> + </td> + <td> + <input wicket:id="Molecule.produits.List.Delete" type="submit" wicket:message="value:Delete" /> + </td> + </tr> + <tr> + <td> + <select class="tiny" id="Molecule.produits.produit.ref" wicket:id="Molecule.produits.produit.ref" /> + </td> + <td> + <input type="text" class="tiny" id="Molecule.produits.presence" wicket:id="Molecule.produits.presence" /> + </td> + <td> + todo lot + </td> + <td> + todo genre + </td> + <td> + todo espece + </td> + <td> + todo campagne + </td> + <td> + <input wicket:id="Molecule.produits.Add" type="submit" wicket:message="value:Add" /> + </td> + </tr> + </tbody> + </table> + </fieldset> + <div class="actions"> <input type="submit" wicket:message="value:Submit" wicket:id="Create" /> <input type="submit" wicket:message="value:Submit" wicket:id="Update" /> Modified: 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 2013-01-07 10:50:58 UTC (rev 45) +++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/molecule/ManageMoleculePage.java 2013-01-07 16:23:51 UTC (rev 46) @@ -22,6 +22,7 @@ */ package nc.ird.cantharella.web.pages.domain.molecule; +import java.math.BigDecimal; import java.util.List; import nc.ird.cantharella.data.exceptions.DataConstraintException; @@ -29,11 +30,19 @@ 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.model.MoleculeProvenance; +import nc.ird.cantharella.data.model.Personne; +import nc.ird.cantharella.data.model.Produit; +import nc.ird.cantharella.data.model.Utilisateur; 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.service.services.PersonneService; +import nc.ird.cantharella.service.services.ProduitService; import nc.ird.cantharella.web.pages.TemplatePage; import nc.ird.cantharella.web.pages.domain.campagne.ManageCampagnePage; +import nc.ird.cantharella.web.pages.renderers.PersonneRenderer; +import nc.ird.cantharella.web.pages.renderers.ProduitRenderer; import nc.ird.cantharella.web.utils.CallerPage; import nc.ird.cantharella.web.utils.behaviors.JSConfirmationBehavior; import nc.ird.cantharella.web.utils.forms.SubmittableButton; @@ -42,10 +51,12 @@ 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.MarkupContainer; import org.apache.wicket.ajax.AjaxRequestTarget; +import org.apache.wicket.ajax.markup.html.form.AjaxFallbackButton; import org.apache.wicket.ajax.markup.html.form.AjaxSubmitLink; +import org.apache.wicket.markup.html.WebMarkupContainer; import org.apache.wicket.markup.html.form.Button; import org.apache.wicket.markup.html.form.CheckBox; import org.apache.wicket.markup.html.form.DropDownChoice; @@ -53,15 +64,17 @@ 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.markup.html.list.ListItem; +import org.apache.wicket.markup.html.list.ListView; 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 + * Gestion des molecules. + * + * @author Eric Chatellier */ @AuthRoles({ AuthRole.USER, AuthRole.ADMIN }) public final class ManageMoleculePage extends TemplatePage { @@ -78,16 +91,30 @@ /** Logger */ private static final Log LOG = LogTools.getLog(); + /** Personnes */ + private final List<Personne> personnes; + /** Campagnes */ private final List<Campagne> campagnes; + /** Service : personne */ + @SpringBean + private PersonneService personneService; + /** Service : campagne */ @SpringBean private CampagneService campagneService; + /** Service : produit */ + @SpringBean + private ProduitService produitService; + /** Modèle : molecule */ private final IModel<Molecule> moleculeModel; + /** Modèle to add new provenance. */ + private Model<MoleculeProvenance> newProvenanceModel; + /** Service : molecule */ @SpringBean private MoleculeService moleculeService; @@ -98,6 +125,9 @@ /** Page appelante */ private final CallerPage callerPage; + + /** Bouton d'ajout d'une provenance **/ + Button addProvenanceButton; /** * Constructeur (mode création) @@ -122,6 +152,8 @@ final CallerPage currentPage = new CallerPage(this); + newProvenanceModel = new Model<MoleculeProvenance>(new MoleculeProvenance()); + // Initialisation du modèle try { moleculeModel = new Model<Molecule>(idMolecule == null ? new Molecule() : moleculeService.loadMolecule(idMolecule)); @@ -136,62 +168,53 @@ } // Initialisation des listes + personnes = personneService.listPersonnes(); 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"); + initProvenanceFields(formView); + 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")) { + + // div qui englobe les champs visible ssi nouvMolecul est coché + final MarkupContainer nouvMoleculRefresh = new WebMarkupContainer("Molecule.nouvMolecul.Refresh"); + nouvMoleculRefresh.setOutputMarkupId(true); + nouvMoleculRefresh.setVisible(moleculeModel.getObject().isNouvMolecul()); + formView.add(nouvMoleculRefresh); + + // predéclaration des champs activé par la chec + formView.add(new CheckBox("Molecule.nouvMolecul", new PropertyModel<Boolean>(moleculeModel, "nouvMolecul")) { @Override - public boolean isVisible() { - return BooleanUtils.isTrue(moleculeModel.getObject().getNouvMolecul()); + protected void onSelectionChanged(Boolean newSelection) { + nouvMoleculRefresh.setVisible(newSelection); } + @Override + protected boolean wantOnSelectionChangedNotifications() { + return true; + } }); + DropDownChoice<Personne> pers = new DropDownChoice<Personne>("Molecule.identifieePar", + new PropertyModel<Personne>(moleculeModel, "identifieePar"), personnes, new PersonneRenderer()); + //pers.setNullValid(false); + //pers.setModelObject(extractionModel.getObject().getManipulateur()); + nouvMoleculRefresh.add(pers); + 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); + new PropertyModel<Campagne>(moleculeModel, "campagne"), campagnes); + //campagnesInput.setNullValid(false); + nouvMoleculRefresh.add(campagnesInput); // Action : création d'une nouvelle campagne // ajaxSubmitLink permet de sauvegarder l'état du formulaire - formView.add(new AjaxSubmitLink("NewCampagne") { + nouvMoleculRefresh.add(new AjaxSubmitLink("NewCampagne") { @Override - protected void onSubmit(AjaxRequestTarget arg0, Form<?> arg1) { + protected void onSubmit(AjaxRequestTarget request, Form<?> form) { setResponsePage(new ManageCampagnePage(currentPage, false)); } @@ -200,21 +223,12 @@ 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"))); - + nouvMoleculRefresh.add(new TextArea<String>("Molecule.publiOrigine", new PropertyModel<String>(moleculeModel, "publiOrigine"))); + 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)); @@ -291,6 +305,62 @@ } /** + * Init provenance table. + * + * @param formView + */ + private void initProvenanceFields(final Form<Void> formView) { + // Déclaration tableau des provenances + final MarkupContainer provenanceTable = new WebMarkupContainer("Molecule.produits.Table"); + provenanceTable.setOutputMarkupId(true); + + // Contenu tableaux provenance + provenanceTable.add(new ListView<MoleculeProvenance>("Molecule.produits.List", + new PropertyModel<List<MoleculeProvenance>>(moleculeModel, "provenances")) { + @Override + protected void populateItem(ListItem<MoleculeProvenance> item) { + // TODO echatellier it's NOT produit (new object with %) + } + }); + + // champs d'input + Utilisateur utilisateur = getSession().getUtilisateur(); + List<Produit> utilisateurProduits = produitService.listProduits(utilisateur); + final DropDownChoice<Produit> produitChoice = new DropDownChoice<Produit>( + "Molecule.produits.produit.ref", new PropertyModel<Produit>(newProvenanceModel, "produit"), + utilisateurProduits, new ProduitRenderer()) { + + }; + produitChoice.setNullValid(false); + provenanceTable.add(produitChoice); + + final TextField<BigDecimal> presenceInput = new TextField<BigDecimal>("Molecule.produits.presence", + new PropertyModel<BigDecimal>(newProvenanceModel, "pourcentage")) { + + }; + presenceInput.setOutputMarkupId(true); + presenceInput.setOutputMarkupPlaceholderTag(true); + provenanceTable.add(presenceInput); + + // Bouton AJAX pour ajouter un résultat de test + addProvenanceButton = new AjaxFallbackButton("Molecule.produits.Add", formView) { + @Override + protected void onSubmit(AjaxRequestTarget target, Form<?> form) { + + } + + @Override + protected void onError(AjaxRequestTarget target, Form<?> form) { + + } + + }; + provenanceTable.add(addProvenanceButton); + + formView.add(provenanceTable); + } + + /** * Redirection vers une autre page. Cas où le formulaire est validé */ private void redirect() { Modified: 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 2013-01-07 10:50:58 UTC (rev 45) +++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/molecule/ReadMoleculePage.java 2013-01-07 16:23:51 UTC (rev 46) @@ -27,6 +27,11 @@ import nc.ird.cantharella.web.utils.security.AuthRole; import nc.ird.cantharella.web.utils.security.AuthRoles; +/** + * Lecture d'une molécule. + * + * @author Eric Chatellier + */ @AuthRoles( { AuthRole.ADMIN, AuthRole.USER }) public class ReadMoleculePage extends TemplatePage { Added: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/renderers/ProduitRenderer.java =================================================================== --- trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/renderers/ProduitRenderer.java (rev 0) +++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/renderers/ProduitRenderer.java 2013-01-07 16:23:51 UTC (rev 46) @@ -0,0 +1,40 @@ +/* + * #%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.renderers; + +import nc.ird.cantharella.data.model.Produit; + +import org.apache.wicket.markup.html.form.ChoiceRenderer; + +/** + * Renderer to display Produit with product ref. + * @author Eric Chatellier + */ +public class ProduitRenderer extends ChoiceRenderer<Produit> { + + /** {@inheritDoc} */ + @Override + public Object getDisplayValue(final Produit produit) { + return produit.getRef(); + } +} Property changes on: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/renderers/ProduitRenderer.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-07 10:50:58 UTC (rev 45) +++ trunk/cantharella.web/src/main/resources/commons/web_en.properties 2013-01-07 16:23:51 UTC (rev 46) @@ -192,6 +192,12 @@ ManagePurificationPage.Delete.DataConstraintException=There are data linked to this purification ManageMoleculePage=Molecule management +ManageMoleculePage.Create.DataConstraintException=Can't save molecule +ManageMoleculePage.Create.OK=Molecule added +ManageMoleculePage.Update.DataConstraintException=Cant' update molecule +ManageMoleculePage.Update.OK=Molecule updated +ManageMoleculePage.Delete.DataConstraintException=Can't delete molecule +ManageMoleculePage.Delete.OK=Molecule deleted ManageTestBioPage=Bioassay management ManageTestBioPage.Create.OK=Bioassay added Modified: trunk/cantharella.web/src/main/resources/commons/web_fr.properties =================================================================== --- trunk/cantharella.web/src/main/resources/commons/web_fr.properties 2013-01-07 10:50:58 UTC (rev 45) +++ trunk/cantharella.web/src/main/resources/commons/web_fr.properties 2013-01-07 16:23:51 UTC (rev 46) @@ -191,6 +191,12 @@ ManagePurificationPage.Delete.DataConstraintException=Il existe des données liées à cette purification ManageMoleculePage=Gestion d'une molécule +ManageMoleculePage.Create.DataConstraintException=Impossible de sauver la molécule +ManageMoleculePage.Create.OK=Molecule ajoutée +ManageMoleculePage.Update.DataConstraintException=Impossible de modifier la molécule +ManageMoleculePage.Update.OK=Molecule mise à jour +ManageMoleculePage.Delete.DataConstraintException=Impossible de supprimer la molécule +ManageMoleculePage.Delete.OK=Molecule supprimée ManageTestBioPage=Gestion d'un test biologique ManageTestBioPage.Create.OK=Test biologique ajouté
participants (1)
-
echatellier@users.forge.codelutin.com