Cantharella-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
February 2013
- 3 participants
- 101 discussions
Author: acheype
Date: 2013-02-14 02:47:03 +0100 (Thu, 14 Feb 2013)
New Revision: 106
Url: http://forge.codelutin.com/projects/cantharella/repository/revisions/106
Log:
just typing errors fixed
Modified:
trunk/src/site/rst/configuration.rst
Modified: trunk/src/site/rst/configuration.rst
===================================================================
--- trunk/src/site/rst/configuration.rst 2013-02-13 15:53:11 UTC (rev 105)
+++ trunk/src/site/rst/configuration.rst 2013-02-14 01:47:03 UTC (rev 106)
@@ -21,7 +21,7 @@
.. * #L%
.. -
-Configuraiton
+Configuration
=============
All configuration variables can be put in file **cantharella.conf**. This file can be in:
@@ -33,7 +33,7 @@
- JVM variables
Configuration files and variables are read in this order, last file found
-overwrite variable from previous file.
+overwrite variables from previous file.
Classpath
---------
1
0
r105 - in trunk: cantharella.data/src/main/java/nc/ird/cantharella/data/dao/impl cantharella.service/src/main/java/nc/ird/cantharella/service/services/impl cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/document
by echatellier@users.forge.codelutin.com 13 Feb '13
by echatellier@users.forge.codelutin.com 13 Feb '13
13 Feb '13
Author: echatellier
Date: 2013-02-13 16:53:11 +0100 (Wed, 13 Feb 2013)
New Revision: 105
Url: http://forge.codelutin.com/projects/cantharella/repository/revisions/105
Log:
fixes #1650: Extraction interface - modification
fixes #1651: Purification interface - modification
Modified:
trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/dao/impl/ProduitDao.java
trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/services/impl/ProduitServiceImpl.java
trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/document/ManageDocumentPage.java
Modified: trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/dao/impl/ProduitDao.java
===================================================================
--- trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/dao/impl/ProduitDao.java 2013-02-13 15:03:01 UTC (rev 104)
+++ trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/dao/impl/ProduitDao.java 2013-02-13 15:53:11 UTC (rev 105)
@@ -22,7 +22,12 @@
*/
package nc.ird.cantharella.data.dao.impl;
+import java.util.Collections;
+
import nc.ird.cantharella.data.dao.AbstractModelDao;
+import nc.ird.cantharella.data.model.Molecule;
+import nc.ird.cantharella.data.model.MoleculeProvenance;
+import nc.ird.cantharella.data.model.Produit;
import nc.ird.cantharella.data.model.Purification;
import nc.ird.cantharella.data.model.ResultatTestBio;
@@ -60,4 +65,14 @@
Restrictions.eq("prod.ref", refProduit)).setProjection(Projections.rowCount());
}
+ /**
+ * Rend le criteria qui rend le nombre de molécule qui référencent un produit
+ * @param produit Le produit
+ * @return Le criteria
+ **/
+ public static DetachedCriteria getCriteriaCountMoleculeFromProduit(String refProduit) {
+ return DetachedCriteria.forClass(MoleculeProvenance.class).createAlias("produit", "prod").add(
+ Restrictions.eq("prod.ref", refProduit)).setProjection(Projections.rowCount());
+ }
+
}
Modified: trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/services/impl/ProduitServiceImpl.java
===================================================================
--- trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/services/impl/ProduitServiceImpl.java 2013-02-13 15:03:01 UTC (rev 104)
+++ trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/services/impl/ProduitServiceImpl.java 2013-02-13 15:53:11 UTC (rev 105)
@@ -121,6 +121,7 @@
@Override
public boolean isProduitReferenced(Produit produit) {
return dao.count(ProduitDao.getCriteriaCountPurifFromProduit(produit.getRef())) > 0
- && dao.count(ProduitDao.getCriteriaCountTestBioFromProduit(produit.getRef())) > 0;
+ || dao.count(ProduitDao.getCriteriaCountTestBioFromProduit(produit.getRef())) > 0
+ || dao.count(ProduitDao.getCriteriaCountMoleculeFromProduit(produit.getRef())) > 0;
}
}
Modified: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/document/ManageDocumentPage.java
===================================================================
--- trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/document/ManageDocumentPage.java 2013-02-13 15:03:01 UTC (rev 104)
+++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/document/ManageDocumentPage.java 2013-02-13 15:53:11 UTC (rev 105)
@@ -22,8 +22,6 @@
*/
package nc.ird.cantharella.web.pages.domain.document;
-import java.io.IOException;
-import java.sql.Blob;
import java.util.Date;
import java.util.List;
@@ -45,7 +43,6 @@
import nc.ird.cantharella.web.utils.forms.SubmittableButton;
import nc.ird.cantharella.web.utils.forms.SubmittableButtonEvents;
import nc.ird.cantharella.web.utils.renderers.MapChoiceRenderer;
-import net.sf.ehcache.hibernate.HibernateUtil;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.markup.html.form.AjaxSubmitLink;
@@ -65,10 +62,8 @@
import org.apache.wicket.model.PropertyModel;
import org.apache.wicket.spring.injection.annot.SpringBean;
import org.apache.wicket.util.lang.Bytes;
-import org.hibernate.engine.jdbc.internal.LobCreatorBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.springframework.jdbc.support.lob.LobCreator;
/**
* Document management page (creation/edition).
1
0
13 Feb '13
Author: echatellier
Date: 2013-02-13 16:03:01 +0100 (Wed, 13 Feb 2013)
New Revision: 104
Url: http://forge.codelutin.com/projects/cantharella/repository/revisions/104
Log:
refs #1653: Add a linked document
refs #1654: Consult linked document metadata
refs #1656: Manage documents at info level
refs #1657: Display documents at info level
refs #1658: Display documents at lists level
Added:
trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Document.java
trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/utils/DocumentAttachable.java
trunk/cantharella.data/src/test/resources/log4j.xml
trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/utils/normalizers/DocumentNormalizer.java
trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/document/
trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/document/ManageDocumentPage.html
trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/document/ManageDocumentPage.java
trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/document/ReadDocumentPage.html
trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/document/ReadDocumentPage.java
trunk/cantharella.web/src/main/webapp/images/attachment.png
Removed:
trunk/cantharella.data/src/test/resources/log4j.xml
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/MoleculeProvenance.java
trunk/cantharella.data/src/main/resources/data_en.properties
trunk/cantharella.data/src/main/resources/data_fr.properties
trunk/cantharella.data/src/main/resources/sql/dev_update.sql
trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/services/DocumentService.java
trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/services/impl/DocumentServiceImpl.java
trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/services/impl/MoleculeServiceImpl.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/domain/lot/ManageLotPage.java
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
trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/columns/LinkableImagePropertyColumn.java
trunk/cantharella.web/src/main/resources/web_en.properties
trunk/cantharella.web/src/main/resources/web_fr.properties
Added: trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Document.java
===================================================================
--- trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Document.java (rev 0)
+++ trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Document.java 2013-02-13 15:03:01 UTC (rev 104)
@@ -0,0 +1,219 @@
+/*
+ * #%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.io.InputStream;
+import java.util.Date;
+
+import javax.persistence.Basic;
+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.validation.constraints.NotNull;
+
+import nc.ird.cantharella.data.model.utils.AbstractModel;
+import nc.ird.cantharella.data.validation.CountryCode;
+
+import org.hibernate.annotations.Type;
+import org.hibernate.validator.constraints.Length;
+import org.hibernate.validator.constraints.NotEmpty;
+
+/**
+ * Document entity.
+ *
+ * @author Eric Chatellier
+ */
+@Entity
+public class Document extends AbstractModel {
+
+ /** Id du document. */
+ @Id
+ @GeneratedValue
+ private Integer idDocument;
+
+ /** Titre. */
+ @Length(max = LENGTH_LONG_TEXT)
+ @NotEmpty
+ private String titre;
+
+ /** Createur. */
+ @NotNull
+ @ManyToOne(fetch = FetchType.LAZY, optional = false)
+ private Personne createur;
+
+ /** Date de creation. */
+ @NotNull
+ private Date dateCreation;
+
+ /** Editeur. */
+ @Length(max = LENGTH_LONG_TEXT)
+ @NotEmpty
+ private String editeur;
+
+ /** Description. */
+ @Lob
+ @Type(type="org.hibernate.type.StringClobType") // see HHH-6105
+ private String description;
+
+ /** Langue. */
+ @Length(min = 2, max = 2)
+ @CountryCode
+ private String langue;
+
+ /** Contrainte légale. */
+ @Length(max = LENGTH_LONG_TEXT)
+ private String contrainteLegale;
+
+ /** Ajouté par. */
+ @NotNull
+ @ManyToOne(fetch = FetchType.LAZY, optional = false)
+ private Personne ajoutePar;
+
+ /** Type document. */
+ @NotNull
+ @ManyToOne(fetch = FetchType.LAZY, optional = false)
+ private TypeDocument typeDocument;
+
+ /** File name. */
+ @NotEmpty
+ @Length(max = LENGTH_MEDIUM_TEXT)
+ private String fileName;
+
+ /* File data.
+ @Lob
+ @Basic(fetch=FetchType.LAZY, optional=true)
+ private byte[] fileContent;*/
+
+ /** File mime type. */
+ @NotEmpty
+ @Length(max = LENGTH_MEDIUM_TEXT)
+ private String fileMimetype;
+
+ public Integer getIdDocument() {
+ return idDocument;
+ }
+
+ public void setIdDocument(Integer idDocument) {
+ this.idDocument = idDocument;
+ }
+
+ public String getTitre() {
+ return titre;
+ }
+
+ public void setTitre(String titre) {
+ this.titre = titre;
+ }
+
+ public Personne getCreateur() {
+ return createur;
+ }
+
+ public void setCreateur(Personne createur) {
+ this.createur = createur;
+ }
+
+ public Date getDateCreation() {
+ return dateCreation;
+ }
+
+ public void setDateCreation(Date dateCreation) {
+ this.dateCreation = dateCreation;
+ }
+
+ public String getEditeur() {
+ return editeur;
+ }
+
+ public void setEditeur(String editeur) {
+ this.editeur = editeur;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public String getLangue() {
+ return langue;
+ }
+
+ public void setLangue(String langue) {
+ this.langue = langue;
+ }
+
+ public String getContrainteLegale() {
+ return contrainteLegale;
+ }
+
+ public void setContrainteLegale(String contrainteLegale) {
+ this.contrainteLegale = contrainteLegale;
+ }
+
+ public Personne getAjoutePar() {
+ return ajoutePar;
+ }
+
+ public void setAjoutePar(Personne ajoutePar) {
+ this.ajoutePar = ajoutePar;
+ }
+
+ public TypeDocument getTypeDocument() {
+ return typeDocument;
+ }
+
+ public void setTypeDocument(TypeDocument typeDocument) {
+ this.typeDocument = typeDocument;
+ }
+
+ public String getFileName() {
+ return fileName;
+ }
+
+ public void setFileName(String fileName) {
+ this.fileName = fileName;
+ }
+
+ /*public byte[] getFileContent() {
+ return fileContent;
+ }
+
+ public void setFileContent(byte[] fileContent) {
+ this.fileContent = fileContent;
+ }*/
+
+ public String getFileMimetype() {
+ return fileMimetype;
+ }
+
+ public void setFileMimetype(String fileMimetype) {
+ this.fileMimetype = fileMimetype;
+ }
+}
Property changes on: trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Document.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
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-02-13 11:57:28 UTC (rev 103)
+++ trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Molecule.java 2013-02-13 15:03:01 UTC (rev 104)
@@ -30,6 +30,7 @@
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
+import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
@@ -41,6 +42,7 @@
import nc.ird.cantharella.data.config.DataContext;
import nc.ird.cantharella.data.model.search.UtilisateurSearchFilter;
import nc.ird.cantharella.data.model.utils.AbstractModel;
+import nc.ird.cantharella.data.model.utils.DocumentAttachable;
import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;
@@ -66,7 +68,7 @@
@FullTextFilterDefs( {
@FullTextFilterDef(name = "utilisateur-Molecule", impl = UtilisateurSearchFilter.class)
})
-public class Molecule extends AbstractModel {
+public class Molecule extends AbstractModel implements DocumentAttachable {
/** ID */
@Id
@@ -134,11 +136,17 @@
@IndexedEmbedded
private Personne createur;
- /** Produit utilisé obtenir le résultat **/
+ /** Produit utilisé obtenir le résultat */
@OneToMany(mappedBy = "molecule", fetch = FetchType.LAZY, orphanRemoval = true)
@Cascade({ CascadeType.SAVE_UPDATE })
private List<MoleculeProvenance> provenances;
+ /** Liste des documents attachés. */
+ @OneToMany(fetch = FetchType.LAZY, orphanRemoval = true)
+ @JoinColumn(name="molecule")
+ @Cascade({ CascadeType.SAVE_UPDATE })
+ private List<Document> documents;
+
/**
* Id molecule getter.
*
@@ -390,4 +398,30 @@
public void setProvenances(List<MoleculeProvenance> provenances) {
this.provenances = provenances;
}
+
+ /** {@inheritDoc} */
+ public List<Document> getDocuments() {
+ return documents;
+ }
+
+ /**
+ * Documents setter.
+ *
+ * @param documents the documents to set
+ */
+ public void setDocuments(List<Document> documents) {
+ this.documents = documents;
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public void addDocument(Document document) {
+ documents.add(document);
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public void removeDocument(Document document) {
+ documents.remove(document);
+ }
}
Modified: 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 2013-02-13 11:57:28 UTC (rev 103)
+++ trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/MoleculeProvenance.java 2013-02-13 15:03:01 UTC (rev 104)
@@ -38,7 +38,7 @@
import nc.ird.cantharella.data.model.utils.AbstractModel;
/**
- * MoleculeProvenance association entity between {@link Molecule} and {@Produit}.
+ * MoleculeProvenance association entity between {@link Molecule} and {@link Produit}.
*
* @author Eric Chatellier
*/
Added: trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/utils/DocumentAttachable.java
===================================================================
--- trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/utils/DocumentAttachable.java (rev 0)
+++ trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/utils/DocumentAttachable.java 2013-02-13 15:03:01 UTC (rev 104)
@@ -0,0 +1,53 @@
+/*
+ * #%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.utils;
+
+import java.util.List;
+
+import nc.ird.cantharella.data.model.Document;
+
+/**
+ * Interface to mark entity on which documents can be attached.
+ *
+ * @author Eric Chatellier
+ */
+public interface DocumentAttachable {
+
+ /**
+ * Get document attached to entity.
+ * @return document list
+ */
+ List<Document> getDocuments();
+
+ /**
+ * Attach new document.
+ * @param document new document to attach
+ */
+ void addDocument(Document document);
+
+ /**
+ * Remove an attached document.
+ * @param document document to remove
+ */
+ void removeDocument(Document document);
+}
Property changes on: trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/utils/DocumentAttachable.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Modified: trunk/cantharella.data/src/main/resources/data_en.properties
===================================================================
--- trunk/cantharella.data/src/main/resources/data_en.properties 2013-02-13 11:57:28 UTC (rev 103)
+++ trunk/cantharella.data/src/main/resources/data_en.properties 2013-02-13 15:03:01 UTC (rev 104)
@@ -244,6 +244,22 @@
ErreurTestBio.nom=Name
ErreurTestBio.description=Description
+TypeDocument.nom=Nom
+TypeDocument.domaine=Domaine
+TypeDocument.description=Description
+
+Document.titre=Titre
+Document.createur=Créateur
+Document.dateCreation=Date de création
+Document.editeur=Éditeur
+Document.description=Description
+Document.langue=Langue
+Document.contrainteLegale=Contrainte légale
+Document.ajoutePar=Ajouté par
+Document.typeDocument=Type
+Document.fileName=Nom
+Document.fileMimetype=Format
+
#Internationalisation des enums#
TypeDroit.ADMINISTRATEUR=Administrator
TypeDroit.UTILISATEUR=User
Modified: trunk/cantharella.data/src/main/resources/data_fr.properties
===================================================================
--- trunk/cantharella.data/src/main/resources/data_fr.properties 2013-02-13 11:57:28 UTC (rev 103)
+++ trunk/cantharella.data/src/main/resources/data_fr.properties 2013-02-13 15:03:01 UTC (rev 104)
@@ -243,6 +243,23 @@
ErreurTestBio.nom=Nom
ErreurTestBio.description=Description
+TypeDocument.nom=Nom
+TypeDocument.domaine=Domaine
+TypeDocument.description=Description
+
+Document.titre=Titre
+Document.createur=Créateur
+Document.dateCreation=Date de création
+Document.editeur=Éditeur
+Document.description=Description
+Document.langue=Langue
+Document.contrainteLegale=Contrainte légale
+Document.ajoutePar=Ajouté par
+Document.typeDocument=Type
+Document.fileName=Nom
+Document.fileMimetype=Format
+
+
#Internationalisation des enums#
TypeDroit.ADMINISTRATEUR=Administrateur
TypeDroit.UTILISATEUR=Utilisateur
Modified: trunk/cantharella.data/src/main/resources/sql/dev_update.sql
===================================================================
--- trunk/cantharella.data/src/main/resources/sql/dev_update.sql 2013-02-13 11:57:28 UTC (rev 103)
+++ trunk/cantharella.data/src/main/resources/sql/dev_update.sql 2013-02-13 15:03:01 UTC (rev 104)
@@ -83,5 +83,43 @@
references Produit;
create sequence molecule_sequence;
-
+
+-- Document (12/02/2013)
+ create table Document (
+ idDocument int4 not null,
+ contrainteLegale varchar(100),
+ dateCreation timestamp not null,
+ description text,
+ editeur varchar(100) not null,
+ fileContent oid,
+ fileMimetype varchar(60) not null,
+ fileName varchar(60) not null,
+ langue varchar(2),
+ titre varchar(100) not null,
+ ajoutePar_idPersonne int4 not null,
+ createur_idPersonne int4 not null,
+ typeDocument_idTypeDocument int4 not null,
+ molecule int4,
+ primary key (idDocument)
+ );
+
+ alter table Document
+ add constraint FK3737353B2F46DB31
+ foreign key (ajoutePar_idPersonne)
+ references Personne;
+
+ alter table Document
+ add constraint FK3737353B822055B9
+ foreign key (createur_idPersonne)
+ references Personne;
+
+ alter table Document
+ add constraint FK3737353BBECBA92F
+ foreign key (typeDocument_idTypeDocument)
+ references TypeDocument;
+
+ alter table Document
+ add constraint FK3737353B20FEEDAC
+ foreign key (molecule)
+ references Molecule;
COMMIT;
\ No newline at end of file
Deleted: trunk/cantharella.data/src/test/resources/log4j.xml
===================================================================
(Binary files differ)
Copied: trunk/cantharella.data/src/test/resources/log4j.xml (from rev 58, trunk/cantharella.data/src/test/resources/log4j.xml)
===================================================================
(Binary files differ)
Modified: trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/services/DocumentService.java
===================================================================
--- trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/services/DocumentService.java 2013-02-13 11:57:28 UTC (rev 103)
+++ trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/services/DocumentService.java 2013-02-13 15:03:01 UTC (rev 104)
@@ -26,7 +26,10 @@
import nc.ird.cantharella.data.exceptions.DataConstraintException;
import nc.ird.cantharella.data.exceptions.DataNotFoundException;
+import nc.ird.cantharella.data.model.Document;
import nc.ird.cantharella.data.model.TypeDocument;
+import nc.ird.cantharella.data.model.Utilisateur;
+import nc.ird.cantharella.service.utils.normalizers.DocumentNormalizer;
import nc.ird.cantharella.service.utils.normalizers.TypeDocumentNormalizer;
import nc.ird.cantharella.service.utils.normalizers.UniqueFieldNormalizer;
import nc.ird.cantharella.service.utils.normalizers.utils.Normalize;
@@ -85,4 +88,21 @@
*/
void deleteTypeDocument(TypeDocument typeDocument) throws DataConstraintException;
+ /**
+ * Load a document.
+ *
+ * @param idDocument id
+ * @return the corresponding document
+ * @throws DataNotFoundException if not found
+ */
+ Document loadDocument(Integer idDocument) throws DataNotFoundException;
+
+ /**
+ * Check if a user can update or delete a document.
+ * @param document document
+ * @param utilisateur Utilisateur
+ * @return TRUE si il a le droit
+ */
+ boolean updateOrdeleteDocumentEnabled(Document document, Utilisateur utilisateur);
+
}
Modified: trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/services/impl/DocumentServiceImpl.java
===================================================================
--- trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/services/impl/DocumentServiceImpl.java 2013-02-13 11:57:28 UTC (rev 103)
+++ trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/services/impl/DocumentServiceImpl.java 2013-02-13 15:03:01 UTC (rev 104)
@@ -28,7 +28,9 @@
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.Document;
import nc.ird.cantharella.data.model.TypeDocument;
+import nc.ird.cantharella.data.model.Utilisateur;
import nc.ird.cantharella.service.services.DocumentService;
import nc.ird.module.utils.AssertTools;
@@ -100,4 +102,17 @@
throw new UnexpectedException(e);
}
}
+
+ /** {@inheritDoc} */
+ @Override
+ public Document loadDocument(Integer idDocument) throws DataNotFoundException {
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public boolean updateOrdeleteDocumentEnabled(Document document, Utilisateur utilisateur) {
+ return false;
+ }
}
Modified: 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 2013-02-13 11:57:28 UTC (rev 103)
+++ trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/services/impl/MoleculeServiceImpl.java 2013-02-13 15:03:01 UTC (rev 104)
@@ -38,7 +38,6 @@
import nc.ird.cantharella.data.model.Produit;
import nc.ird.cantharella.data.model.Utilisateur;
import nc.ird.cantharella.data.model.Utilisateur.TypeDroit;
-import nc.ird.cantharella.data.model.utils.AbstractModel;
import nc.ird.cantharella.service.model.MoleculeProvenanceBean;
import nc.ird.cantharella.service.services.LotService;
import nc.ird.cantharella.service.services.MoleculeService;
Added: trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/utils/normalizers/DocumentNormalizer.java
===================================================================
--- trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/utils/normalizers/DocumentNormalizer.java (rev 0)
+++ trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/utils/normalizers/DocumentNormalizer.java 2013-02-13 15:03:01 UTC (rev 104)
@@ -0,0 +1,43 @@
+/*
+ * #%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.Document;
+import nc.ird.cantharella.service.utils.normalizers.utils.Normalizer;
+import nc.ird.module.utils.AssertTools;
+
+/**
+ * Document normalizer
+ * @author Eric Chatellier
+ */
+public final class DocumentNormalizer extends Normalizer<Document> {
+
+ /** {@inheritDoc} */
+ @Override
+ protected Document normalize(Document document) {
+ AssertTools.assertNotNull(document);
+ // Unique field
+ document.setTitre(Normalizer.normalize(ConfigNameNormalizer.class, document.getTitre()));
+ return document;
+ }
+}
Property changes on: trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/utils/normalizers/DocumentNormalizer.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-02-13 11:57:28 UTC (rev 103)
+++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/config/WebApplicationImpl.java 2013-02-13 15:03:01 UTC (rev 104)
@@ -22,81 +22,83 @@
*/
package nc.ird.cantharella.web.config;
-import java.math.BigDecimal;
-
-import nc.ird.cantharella.data.config.DataContext;
-import nc.ird.cantharella.data.exceptions.DataConstraintException;
-import nc.ird.cantharella.data.exceptions.UnexpectedException;
-import nc.ird.cantharella.service.services.PersonneService;
-import nc.ird.cantharella.web.pages.ContactPage;
-import nc.ird.cantharella.web.pages.HomePage;
-import nc.ird.cantharella.web.pages.domain.campagne.ListCampagnesPage;
-import nc.ird.cantharella.web.pages.domain.campagne.ManageCampagnePage;
-import nc.ird.cantharella.web.pages.domain.campagne.ReadCampagnePage;
-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.extraction.ManageExtractionPage;
-import nc.ird.cantharella.web.pages.domain.extraction.ReadExtractionPage;
-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 java.math.BigDecimal;
+
+import nc.ird.cantharella.data.config.DataContext;
+import nc.ird.cantharella.data.exceptions.DataConstraintException;
+import nc.ird.cantharella.data.exceptions.UnexpectedException;
+import nc.ird.cantharella.service.services.PersonneService;
+import nc.ird.cantharella.web.pages.ContactPage;
+import nc.ird.cantharella.web.pages.HomePage;
+import nc.ird.cantharella.web.pages.domain.campagne.ListCampagnesPage;
+import nc.ird.cantharella.web.pages.domain.campagne.ManageCampagnePage;
+import nc.ird.cantharella.web.pages.domain.campagne.ReadCampagnePage;
+import nc.ird.cantharella.web.pages.domain.config.ListConfigurationPage;
+import nc.ird.cantharella.web.pages.domain.document.ManageDocumentPage;
+import nc.ird.cantharella.web.pages.domain.document.ReadDocumentPage;
+import nc.ird.cantharella.web.pages.domain.extraction.ListExtractionsPage;
+import nc.ird.cantharella.web.pages.domain.extraction.ManageExtractionPage;
+import nc.ird.cantharella.web.pages.domain.extraction.ReadExtractionPage;
+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;
-import nc.ird.cantharella.web.pages.domain.purification.ListPurificationsPage;
-import nc.ird.cantharella.web.pages.domain.purification.ManagePurificationPage;
-import nc.ird.cantharella.web.pages.domain.purification.ReadPurificationPage;
+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;
+import nc.ird.cantharella.web.pages.domain.purification.ListPurificationsPage;
+import nc.ird.cantharella.web.pages.domain.purification.ManagePurificationPage;
+import nc.ird.cantharella.web.pages.domain.purification.ReadPurificationPage;
import nc.ird.cantharella.web.pages.domain.search.SearchPage;
-import nc.ird.cantharella.web.pages.domain.specimen.ListSpecimensPage;
-import nc.ird.cantharella.web.pages.domain.specimen.ManageSpecimenPage;
-import nc.ird.cantharella.web.pages.domain.specimen.ReadSpecimenPage;
-import nc.ird.cantharella.web.pages.domain.station.ListStationsPage;
-import nc.ird.cantharella.web.pages.domain.station.ManageStationPage;
-import nc.ird.cantharella.web.pages.domain.station.ReadStationPage;
-import nc.ird.cantharella.web.pages.domain.testBio.ListTestsBioPage;
-import nc.ird.cantharella.web.pages.domain.testBio.ManageTestBioPage;
-import nc.ird.cantharella.web.pages.domain.testBio.ReadTestBioPage;
-import nc.ird.cantharella.web.pages.domain.utilisateur.ManageUtilisateurPage;
-import nc.ird.cantharella.web.pages.domain.utilisateur.RegisterPage;
-import nc.ird.cantharella.web.pages.domain.utilisateur.ResetPasswordPage;
-import nc.ird.cantharella.web.pages.domain.utilisateur.UpdateUtilisateurPage;
-import nc.ird.cantharella.web.pages.errors.AccessDeniedPage;
-import nc.ird.cantharella.web.pages.errors.InternalErrorPage;
-import nc.ird.cantharella.web.pages.errors.PageExpiredErrorPage;
-import nc.ird.cantharella.web.utils.converters.BigDecimalConverterImpl;
-import nc.ird.cantharella.web.utils.converters.DoubleConverterImpl;
-import nc.ird.cantharella.web.utils.security.AuthSession;
-import nc.ird.cantharella.web.utils.security.AuthStrategy;
-import nc.ird.module.utils.AssertTools;
-
+import nc.ird.cantharella.web.pages.domain.specimen.ListSpecimensPage;
+import nc.ird.cantharella.web.pages.domain.specimen.ManageSpecimenPage;
+import nc.ird.cantharella.web.pages.domain.specimen.ReadSpecimenPage;
+import nc.ird.cantharella.web.pages.domain.station.ListStationsPage;
+import nc.ird.cantharella.web.pages.domain.station.ManageStationPage;
+import nc.ird.cantharella.web.pages.domain.station.ReadStationPage;
+import nc.ird.cantharella.web.pages.domain.testBio.ListTestsBioPage;
+import nc.ird.cantharella.web.pages.domain.testBio.ManageTestBioPage;
+import nc.ird.cantharella.web.pages.domain.testBio.ReadTestBioPage;
+import nc.ird.cantharella.web.pages.domain.utilisateur.ManageUtilisateurPage;
+import nc.ird.cantharella.web.pages.domain.utilisateur.RegisterPage;
+import nc.ird.cantharella.web.pages.domain.utilisateur.ResetPasswordPage;
+import nc.ird.cantharella.web.pages.domain.utilisateur.UpdateUtilisateurPage;
+import nc.ird.cantharella.web.pages.errors.AccessDeniedPage;
+import nc.ird.cantharella.web.pages.errors.InternalErrorPage;
+import nc.ird.cantharella.web.pages.errors.PageExpiredErrorPage;
+import nc.ird.cantharella.web.utils.converters.BigDecimalConverterImpl;
+import nc.ird.cantharella.web.utils.converters.DoubleConverterImpl;
+import nc.ird.cantharella.web.utils.security.AuthSession;
+import nc.ird.cantharella.web.utils.security.AuthStrategy;
+import nc.ird.module.utils.AssertTools;
+
+import org.apache.wicket.ConverterLocator;
+import org.apache.wicket.IConverterLocator;
+import org.apache.wicket.RuntimeConfigurationType;
+import org.apache.wicket.Session;
+import org.apache.wicket.authentication.IAuthenticationStrategy;
+import org.apache.wicket.authentication.strategy.DefaultAuthenticationStrategy;
+import org.apache.wicket.injection.Injector;
+import org.apache.wicket.javascript.DefaultJavaScriptCompressor;
+import org.apache.wicket.protocol.http.WebApplication;
+import org.apache.wicket.request.Request;
+import org.apache.wicket.request.Response;
+import org.apache.wicket.request.mapper.MountedMapper;
+import org.apache.wicket.request.mapper.PackageMapper;
+import org.apache.wicket.request.mapper.mount.MountMapper;
+import org.apache.wicket.resource.NoOpTextCompressor;
+import org.apache.wicket.resource.loader.IStringResourceLoader;
+import org.apache.wicket.settings.IExceptionSettings;
+import org.apache.wicket.settings.IRequestCycleSettings.RenderStrategy;
+import org.apache.wicket.spring.injection.annot.SpringBean;
+import org.apache.wicket.spring.injection.annot.SpringComponentInjector;
+import org.apache.wicket.util.cookies.CookieUtils;
+import org.apache.wicket.util.lang.PackageName;
+import org.apache.wicket.util.time.Duration;
import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.apache.wicket.ConverterLocator;
-import org.apache.wicket.IConverterLocator;
-import org.apache.wicket.RuntimeConfigurationType;
-import org.apache.wicket.Session;
-import org.apache.wicket.authentication.IAuthenticationStrategy;
-import org.apache.wicket.authentication.strategy.DefaultAuthenticationStrategy;
-import org.apache.wicket.injection.Injector;
-import org.apache.wicket.javascript.DefaultJavaScriptCompressor;
-import org.apache.wicket.protocol.http.WebApplication;
-import org.apache.wicket.request.Request;
-import org.apache.wicket.request.Response;
-import org.apache.wicket.request.mapper.MountedMapper;
-import org.apache.wicket.request.mapper.PackageMapper;
-import org.apache.wicket.request.mapper.mount.MountMapper;
-import org.apache.wicket.resource.NoOpTextCompressor;
-import org.apache.wicket.resource.loader.IStringResourceLoader;
-import org.apache.wicket.settings.IExceptionSettings;
-import org.apache.wicket.settings.IRequestCycleSettings.RenderStrategy;
-import org.apache.wicket.spring.injection.annot.SpringBean;
-import org.apache.wicket.spring.injection.annot.SpringComponentInjector;
-import org.apache.wicket.util.cookies.CookieUtils;
-import org.apache.wicket.util.lang.PackageName;
-import org.apache.wicket.util.time.Duration;
+import org.slf4j.LoggerFactory;
/**
* Web application
@@ -385,7 +387,7 @@
mountPage("/station/edit", ManageStationPage.class);
getRootRequestMapperAsCompound().add(new MountedMapper("/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));
@@ -398,7 +400,12 @@
getRootRequestMapperAsCompound().add(new MountedMapper("/testBio/edit", ManageTestBioPage.class));
mountPage("/testBio/edit", ManageTestBioPage.class);
getRootRequestMapperAsCompound().add(new MountedMapper("/testBio/view", ReadTestBioPage.class));
- mountPage("/testBio/view", ReadTestBioPage.class);
+ mountPage("/testBio/view", ReadTestBioPage.class);
+
+ getRootRequestMapperAsCompound().add(new MountedMapper("/document/edit", ManageDocumentPage.class));
+ mountPage("/document/edit", ManageDocumentPage.class);
+ getRootRequestMapperAsCompound().add(new MountedMapper("/document/view", ReadDocumentPage.class));
+ mountPage("/document/view", ReadDocumentPage.class);
getRootRequestMapperAsCompound().add(new MountedMapper("/utilisateur/edit", ManageUtilisateurPage.class));
mountPage("/utilisateur/edit", ManageUtilisateurPage.class);
Added: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/document/ManageDocumentPage.html
===================================================================
--- trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/document/ManageDocumentPage.html (rev 0)
+++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/document/ManageDocumentPage.html 2013-02-13 15:03:01 UTC (rev 104)
@@ -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="ManageDocumentPage.Form">
+
+ <div class="property required">
+ <label for="Document.titre"><wicket:message key="Document.titre" /></label>
+ <input type="text" id="Document.titre" wicket:id="Document.titre" />
+ </div>
+
+ <div class="property required">
+ <label for="Document.createur"><wicket:message key="Document.createur" /></label>
+ <select id="Document.createur" wicket:id="Document.createur" />
+ <a wicket:id="NewPersonne" class="add"><wicket:message key="ListPersonnesPage.NewPersonne" /></a>
+ </div>
+
+ <div class="property required">
+ <label for="Document.dateCreation"><wicket:message key="Document.dateCreation" /></label>
+ <input type="text" id="Document.dateCreation" wicket:id="Document.dateCreation" />
+ </div>
+
+ <div class="property required">
+ <label for="Document.editeur"><wicket:message key="Document.editeur" /></label>
+ <input type="text" id="Document.editeur" wicket:id="Document.editeur" />
+ </div>
+
+ <div class="property">
+ <label for="Document.description"><wicket:message key="Document.description" /></label>
+ <textarea id="Document.description" wicket:id="Document.description"></textarea>
+ </div>
+
+ <div class="property">
+ <label for="Document.langue"><wicket:message key="Document.langue" /></label>
+ <select id="Document.langue" wicket:id="Document.langue" />
+ </div>
+
+ <div class="property">
+ <label for="Document.contrainteLegale"><wicket:message key="Document.contrainteLegale" /></label>
+ <input type="text" id="Document.contrainteLegale" wicket:id="Document.contrainteLegale" />
+ </div>
+
+ <div class="property required">
+ <label for="Document.ajoutePar"><wicket:message key="Document.ajoutePar" /></label>
+ <input type="text" id="Document.ajoutePar" wicket:id="Document.ajoutePar" />
+ </div>
+
+ <div class="property required">
+ <label for="TypeDocument.nom"><wicket:message key="TypeDocument.nom" /></label>
+ <select id="TypeDocument.nom" wicket:id="TypeDocument.nom" />
+ </div>
+
+ <div class="property">
+ <label for="TypeDocument.domaine"><wicket:message key="TypeDocument.domaine" /></label>
+ <span id="TypeDocument.domain" wicket:id="TypeDocument.domaine" />
+ </div>
+
+ <div class="property">
+ <label for="TypeDocument.description"><wicket:message key="TypeDocument.description" /></label>
+ <span id="TypeDocument.description" wicket:id="TypeDocument.description" />
+ </div>
+
+ <div class="property required">
+ <label for="Document.fileName"><wicket:message key="Document.fileName" /></label>
+ <input type="file" id="Document.fileName" wicket:id="Document.fileName" />
+ </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/document/ManageDocumentPage.java
===================================================================
--- trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/document/ManageDocumentPage.java (rev 0)
+++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/document/ManageDocumentPage.java 2013-02-13 15:03:01 UTC (rev 104)
@@ -0,0 +1,361 @@
+/*
+ * #%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.document;
+
+import java.io.IOException;
+import java.sql.Blob;
+import java.util.Date;
+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.Document;
+import nc.ird.cantharella.data.model.Personne;
+import nc.ird.cantharella.data.model.TypeDocument;
+import nc.ird.cantharella.data.model.utils.DocumentAttachable;
+import nc.ird.cantharella.data.validation.utils.ModelValidator;
+import nc.ird.cantharella.service.services.DocumentService;
+import nc.ird.cantharella.service.services.PersonneService;
+import nc.ird.cantharella.web.config.WebContext;
+import nc.ird.cantharella.web.pages.TemplatePage;
+import nc.ird.cantharella.web.pages.domain.personne.ManagePersonnePage;
+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.renderers.MapChoiceRenderer;
+import net.sf.ehcache.hibernate.HibernateUtil;
+
+import org.apache.wicket.ajax.AjaxRequestTarget;
+import org.apache.wicket.ajax.markup.html.form.AjaxSubmitLink;
+import org.apache.wicket.extensions.markup.html.form.DateTextField;
+import org.apache.wicket.extensions.yui.calendar.DatePicker;
+import org.apache.wicket.markup.html.basic.Label;
+import org.apache.wicket.markup.html.form.Button;
+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.form.upload.FileUpload;
+import org.apache.wicket.markup.html.form.upload.FileUploadField;
+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;
+import org.apache.wicket.util.lang.Bytes;
+import org.hibernate.engine.jdbc.internal.LobCreatorBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.jdbc.support.lob.LobCreator;
+
+/**
+ * Document management page (creation/edition).
+ *
+ * @author Eric Chatellier
+ */
+public class ManageDocumentPage 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 Logger LOG = LoggerFactory.getLogger(ManageDocumentPage.class);
+
+ /** Model : document. */
+ private final IModel<Document> documentModel;
+
+ /** Service : document */
+ @SpringBean
+ private DocumentService documentService;
+
+ /** Service : personnes */
+ @SpringBean
+ private PersonneService personneService;
+
+ /** Model validateur */
+ @SpringBean(name = "webModelValidator")
+ private ModelValidator validator;
+
+ /** Entity where document is attached. */
+ private DocumentAttachable documentAttachable;
+
+ /** Caller page. */
+ private final CallerPage callerPage;
+
+ /** Multiple entry. */
+ private boolean multipleEntry;
+
+ /**
+ * Constructeur (mode création)
+ * @param callerPage Page appelante
+ * @param documentAttachable entity where document is attached to
+ * @param multipleEntry Saisie multiple
+ */
+ public ManageDocumentPage(CallerPage callerPage, DocumentAttachable documentAttachable, boolean multipleEntry) {
+ this(null, null, documentAttachable, callerPage, multipleEntry);
+ }
+
+ /**
+ * Constructeur (mode édition)
+ * @param idDocument ID document
+ * @param callerPage Page appelante
+ */
+ public ManageDocumentPage(Integer idDocument, CallerPage callerPage) {
+ this(idDocument, null, null, callerPage, false);
+ }
+
+ /**
+ * Constructeur (mode saisie du lot suivante)
+ * @param document document
+ * @param callerPage Page appelante
+ */
+ public ManageDocumentPage(Document document, CallerPage callerPage) {
+ this(null, document, null, callerPage, true);
+ }
+
+ /**
+ * Constructeur. Si idDocument et document sont null, on créée un nouveau Document.
+ * Si idDocument est renseigné, on édite le document
+ * correspondant. Si document est renseigné, on créée un nouveau document à
+ * partir des informations qu'il contient.
+ * @param idDocument ID document
+ * @param document document
+ * @param documentAttachable entity where document is attached to
+ * @param callerPage Page appelante
+ * @param multipleEntry Saisie multiple
+ */
+ private ManageDocumentPage(Integer idDocument, Document document, final DocumentAttachable documentAttachable,
+ final CallerPage callerPage, boolean multipleEntry) {
+ super(ManageDocumentPage.class);
+ assert idDocument == null || document == null;
+ this.callerPage = callerPage;
+ this.multipleEntry = multipleEntry;
+ this.documentAttachable = documentAttachable;
+
+ final CallerPage currentPage = new CallerPage(this);
+
+ // Initialisation du modèle
+ try {
+ documentModel = new Model<Document>(idDocument == null && document == null ? new Document() : document != null ? document
+ : documentService.loadDocument(idDocument));
+ } catch (DataNotFoundException e) {
+ LOG.error(e.getMessage(), e);
+ throw new UnexpectedException(e);
+ }
+
+ boolean createMode = idDocument == null;
+ if (createMode) {
+ documentModel.getObject().setCreateur(getSession().getUtilisateur());
+ documentModel.getObject().setAjoutePar(getSession().getUtilisateur());
+ }
+
+ // Initialisation des listes (pour le dropDownChoice)
+ List<Personne> personnes = personneService.listPersonnes();
+ List<TypeDocument> typeDocuments = documentService.listTypeDocuments();
+
+ // champ fichier
+ final FileUploadField fileUploadField = new FileUploadField("Document.fileName");
+
+ // initialisation du formulaire wicket
+ final Form<Void> formView = new Form<Void>("ManageDocumentPage.Form") {
+ @Override
+ protected void onSubmit() {
+ super.onSubmit();
+
+
+ }
+ };
+ formView.setMultiPart(true);
+ formView.setMaxSize(Bytes.megabytes(1));
+
+ formView.add(new TextField<String>("Document.titre", new PropertyModel<String>(documentModel, "titre")));
+
+ final DropDownChoice<Personne> createurInput = new DropDownChoice<Personne>("Document.createur",
+ new PropertyModel<Personne>(documentModel, "createur"), personnes);
+ createurInput.setOutputMarkupId(true);
+ createurInput.setNullValid(false);
+ formView.add(createurInput);
+
+ // Action : création d'une nouvelle personne
+ // ajaxSubmitLink permet de sauvegarder l'état du formulaire
+ formView.add(new AjaxSubmitLink("NewPersonne") {
+ @Override
+ protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
+ setResponsePage(new ManagePersonnePage(currentPage, false));
+ }
+
+ // si erreur, le formulaire est également enregistré puis la redirection effectuée
+ @Override
+ protected void onError(AjaxRequestTarget target, Form<?> form) {
+ setResponsePage(new ManagePersonnePage(currentPage, false));
+ }
+ });
+
+ formView.add(new DateTextField("Document.dateCreation", new PropertyModel<Date>(documentModel, "dateCreation"))
+ .add(new DatePicker()));
+ formView.add(new TextField<String>("Document.editeur", new PropertyModel<String>(documentModel, "editeur")));
+
+ formView.add(new TextArea<String>("Document.description", new PropertyModel<String>(documentModel, "description")));
+
+ formView.add(new DropDownChoice<String>("Document.langue",
+ new PropertyModel<String>(documentModel, "langue"), WebContext.COUNTRY_CODES.get(getSession()
+ .getLocale()), new MapChoiceRenderer<String, String>(WebContext.COUNTRIES.get(getSession()
+ .getLocale()))));
+ formView.add(new TextField<String>("Document.contrainteLegale", new PropertyModel<String>(documentModel, "contrainteLegale")));
+
+ // AjoutePar en lecture seule
+ formView.add(new TextField<String>("Document.ajoutePar", new PropertyModel<String>(documentModel, "ajoutePar"))
+ .setEnabled(false));
+
+ // Type de document
+ final DropDownChoice<TypeDocument> typeDocumentInput = new DropDownChoice<TypeDocument>("TypeDocument.nom",
+ new PropertyModel<TypeDocument>(documentModel, "typeDocument"), typeDocuments);
+ typeDocumentInput.setOutputMarkupId(true);
+ typeDocumentInput.setNullValid(false);
+ formView.add(typeDocumentInput);
+
+ final Label typeDocumentDomainLabel = new Label("TypeDocument.domaine", new PropertyModel<String>(documentModel, "typeDocument.domaine"));
+ typeDocumentDomainLabel.setOutputMarkupId(true);
+ formView.add(typeDocumentDomainLabel);
+
+ final Label typeDocumentDescriptionLabel = new Label("TypeDocument.description", new PropertyModel<String>(documentModel, "typeDocument.description"));
+ typeDocumentDescriptionLabel.setOutputMarkupId(true);
+ formView.add(typeDocumentDescriptionLabel);
+
+ // Fichier
+ formView.add(fileUploadField);
+
+ // Action : création du document
+ Button createButton = new SubmittableButton(ACTION_CREATE, new SubmittableButtonEvents() {
+ @Override
+ public void onProcess() throws DataConstraintException {
+ documentAttachable.addDocument(documentModel.getObject());
+ }
+
+ @Override
+ public void onSuccess() {
+ successNextPage(ACTION_CREATE);
+ redirect();
+ }
+
+ @Override
+ public void onValidate() {
+ final FileUpload uploadedFile = fileUploadField.getFileUpload();
+ if (uploadedFile != null) {
+ //documentModel.getObject().setFileContent(uploadedFile.getBytes());
+ documentModel.getObject().setFileName(uploadedFile.getClientFileName());
+ documentModel.getObject().setFileMimetype(uploadedFile.getContentType());
+
+ }
+ validateModel();
+ }
+ });
+ createButton.setVisibilityAllowed(createMode);
+ formView.add(createButton);
+
+ // Action : mise à jour du document
+ Button updateButton = new SubmittableButton(ACTION_UPDATE, new SubmittableButtonEvents() {
+ @Override
+ public void onProcess() throws DataConstraintException {
+ // nothing, will be updated by cascade
+ }
+
+ @Override
+ public void onSuccess() {
+ successNextPage(ACTION_UPDATE);
+ callerPage.responsePage((TemplatePage) getPage());
+ }
+
+ @Override
+ public void onValidate() {
+ validateModel();
+ }
+ });
+ updateButton.setVisibilityAllowed(!createMode
+ && documentService.updateOrdeleteDocumentEnabled(documentModel.getObject(), getSession().getUtilisateur()));
+ formView.add(updateButton);
+
+ // Action : suppression du document
+ Button deleteButton = new SubmittableButton(ACTION_DELETE, new SubmittableButtonEvents() {
+ @Override
+ public void onProcess() throws DataConstraintException {
+ documentAttachable.removeDocument(documentModel.getObject());
+ }
+
+ @Override
+ public void onSuccess() {
+ successNextPage(ACTION_DELETE);
+ callerPage.responsePage((TemplatePage) getPage());
+ }
+ });
+ deleteButton.setVisibilityAllowed(!createMode
+ && documentService.updateOrdeleteDocumentEnabled(documentModel.getObject(), getSession().getUtilisateur()));
+ 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 (multipleEntry) {
+ // Redirection vers l'écran de saisie d'un nouveau document, en fournissant déjà quelques données
+ Document nextDocument = new Document();
+ setResponsePage(new ManageDocumentPage(nextDocument, callerPage));
+ } else if (callerPage != null) {
+ // On passe l'id du document associé à cette page, en paramètre de la prochaine page, pour lui permettre de
+ // l'exploiter si besoin
+ //callerPage.addPageParameter(Document.class.getSimpleName(), documentModel.getObject().getIdDocument());
+ callerPage.responsePage(this);
+ }
+ }
+
+ /**
+ * Validate model
+ */
+ private void validateModel() {
+ if (documentModel.getObject().getCreateur() == null) {
+ documentModel.getObject().setCreateur(getSession().getUtilisateur());
+ }
+ addValidationErrors(validator.validate(documentModel.getObject(), getSession().getLocale()));
+ }
+}
Property changes on: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/document/ManageDocumentPage.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/document/ReadDocumentPage.html
===================================================================
--- trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/document/ReadDocumentPage.html (rev 0)
+++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/document/ReadDocumentPage.html 2013-02-13 15:03:01 UTC (rev 104)
@@ -0,0 +1,110 @@
+<!--
+ #%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="Document.titre" /></span>
+ <span class="value" wicket:id="Document.titre"></span>
+ </div>
+
+ <div class="property">
+ <span class="label"><wicket:message key="Document.createur" /></span>
+ <span class="value" wicket:id="Document.createur"></span>
+ </div>
+
+ <div class="property">
+ <span class="label"><wicket:message key="Document.editeur" /></span>
+ <span class="value" wicket:id="Document.editeur"></span>
+ </div>
+
+ <div class="property">
+ <span class="label"><wicket:message key="Document.dateCreation" /></span>
+ <span class="value" wicket:id="Document.dateCreation"></span>
+ </div>
+
+ <div class="property">
+ <span class="label"><wicket:message key="Document.description" /></span>
+ <span class="value" wicket:id="Document.description"></span>
+ </div>
+
+ <div class="property">
+ <span class="label"><wicket:message key="Document.langue" /></span>
+ <span class="value" wicket:id="Document.langue" ></span>
+ </div>
+
+ <div class="property">
+ <span class="label"><wicket:message key="Document.contrainteLegale" /></span>
+ <span class="value" wicket:id="Document.contrainteLegale" ></span>
+ </div>
+
+ <div class="property">
+ <span class="label"><wicket:message key="Document.ajoutePar" /></span>
+ <span class="value" wicket:id="Document.ajoutePar" ></span>
+ </div>
+
+ <div class="property">
+ <span class="label"><wicket:message key="TypeDocument.nom" /></span>
+ <span class="value" wicket:id="TypeDocument.nom" ></span>
+ </div>
+
+ <div class="property">
+ <span class="label"><wicket:message key="TypeDocument.domaine" /></span>
+ <span class="value" wicket:id="TypeDocument.domaine" ></span>
+ </div>
+
+ <div class="property">
+ <span class="label"><wicket:message key="TypeDocument.description" /></span>
+ <span class="value" wicket:id="TypeDocument.description" ></span>
+ </div>
+
+ <div class="property">
+ <span class="label"><wicket:message key="Document.fileName" /></span>
+ <span class="value" wicket:id="Document.fileName"></span>
+ </div>
+
+ <div class="property">
+ <span class="label"><wicket:message key="Document.fileMimetype" /></span>
+ <span class="value" wicket:id="Document.fileMimetype"></span>
+ </div>
+
+ <form wicket:id="Form">
+ <div class="actions">
+ <a class="edit" wicket:id="ReadDocumentPage.Document.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="ReadDocumentPage.Document.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/document/ReadDocumentPage.java
===================================================================
--- trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/document/ReadDocumentPage.java (rev 0)
+++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/document/ReadDocumentPage.java 2013-02-13 15:03:01 UTC (rev 104)
@@ -0,0 +1,149 @@
+/*
+ * #%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.document;
+
+import nc.ird.cantharella.data.exceptions.DataConstraintException;
+import nc.ird.cantharella.data.model.Document;
+import nc.ird.cantharella.data.model.utils.DocumentAttachable;
+import nc.ird.cantharella.web.pages.TemplatePage;
+import nc.ird.cantharella.web.pages.domain.lot.ManageLotPage;
+import nc.ird.cantharella.web.utils.CallerPage;
+import nc.ird.cantharella.web.utils.behaviors.JSConfirmationBehavior;
+import nc.ird.cantharella.web.utils.behaviors.ReplaceEmptyLabelBehavior;
+import nc.ird.cantharella.web.utils.forms.SubmittableButton;
+import nc.ird.cantharella.web.utils.forms.SubmittableButtonEvents;
+
+import org.apache.wicket.markup.html.basic.Label;
+import org.apache.wicket.markup.html.form.Button;
+import org.apache.wicket.markup.html.form.Form;
+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;
+
+/**
+ * Document read page.
+ *
+ * @author Eric Chatellier
+ */
+public class ReadDocumentPage extends TemplatePage {
+
+ /** Action : delete */
+ public static final String ACTION_DELETE = "Delete";
+
+ /** Model : document */
+ private final IModel<Document> documentModel;
+
+ /** Caller page. */
+ private final CallerPage callerPage;
+
+ /**
+ * Constructeur
+ * @param idDocument ID document
+ * @param callerPage Page appelante
+ */
+ public ReadDocumentPage(final Document document, final DocumentAttachable documentAttachable, final CallerPage callerPage) {
+ super(ReadDocumentPage.class);
+ this.callerPage = callerPage;
+ final CallerPage currentPage = new CallerPage(this);
+
+ // Initialisation du modèle
+ documentModel = new Model<Document>(document);
+
+ add(new Label("Document.titre", new PropertyModel<String>(documentModel, "titre"))
+ .add(new ReplaceEmptyLabelBehavior()));
+ add(new Label("Document.createur", new PropertyModel<String>(documentModel, "createur"))
+ .add(new ReplaceEmptyLabelBehavior()));
+ add(new Label("Document.dateCreation", new PropertyModel<String>(documentModel, "dateCreation"))
+ .add(new ReplaceEmptyLabelBehavior()));
+ add(new Label("Document.editeur", new PropertyModel<String>(documentModel, "editeur"))
+ .add(new ReplaceEmptyLabelBehavior()));
+ add(new Label("Document.description", new PropertyModel<String>(documentModel, "description"))
+ .add(new ReplaceEmptyLabelBehavior()));
+ add(new Label("Document.langue", new PropertyModel<String>(documentModel, "langue"))
+ .add(new ReplaceEmptyLabelBehavior()));
+ add(new Label("Document.contrainteLegale", new PropertyModel<String>(documentModel, "contrainteLegale"))
+ .add(new ReplaceEmptyLabelBehavior()));
+ add(new Label("Document.ajoutePar", new PropertyModel<String>(documentModel, "ajoutePar"))
+ .add(new ReplaceEmptyLabelBehavior()));
+ add(new Label("TypeDocument.nom", new PropertyModel<String>(documentModel, "typeDocument.nom"))
+ .add(new ReplaceEmptyLabelBehavior()));
+ add(new Label("TypeDocument.domaine", new PropertyModel<String>(documentModel, "typeDocument.domaine"))
+ .add(new ReplaceEmptyLabelBehavior()));
+ add(new Label("TypeDocument.description", new PropertyModel<String>(documentModel, "typeDocument.description"))
+ .add(new ReplaceEmptyLabelBehavior()));
+ add(new Label("Document.fileName", new PropertyModel<String>(documentModel, "fileName"))
+ .add(new ReplaceEmptyLabelBehavior()));
+ add(new Label("Document.fileMimetype", new PropertyModel<String>(documentModel, "fileMimetype"))
+ .add(new ReplaceEmptyLabelBehavior()));
+
+ // Formulaire des actions
+ final Form<Void> formView = new Form<Void>("Form");
+
+ // Action : mise à jour (redirection vers le formulaire)
+ Link<Document> updateLink = new Link<Document>(getResource() + ".Document.Update", new Model<Document>(documentModel.getObject())) {
+ @Override
+ public void onClick() {
+ setResponsePage(new ManageDocumentPage(getModelObject().getIdDocument(), currentPage));
+ }
+ };
+ //FIXME updateLink.setVisibilityAllowed(documentService.updateOrdeleteDocumentEnabled(documentModel.getObject(), getSession()
+ // .getUtilisateur()));
+ formView.add(updateLink);
+
+ // Action : suppression
+ Button deleteButton = new SubmittableButton(ACTION_DELETE, ManageLotPage.class, new SubmittableButtonEvents() {
+ @Override
+ public void onProcess() throws DataConstraintException {
+ documentAttachable.removeDocument(documentModel.getObject());
+ }
+
+ @Override
+ public void onSuccess() {
+ successNextPage(ManageLotPage.class, ACTION_DELETE);
+ redirect();
+ }
+ });
+ // FIXME deleteButton.setVisibilityAllowed(documentService.updateOrdeleteDocumentEnabled(documentModel.getObject(), getSession()
+ // .getUtilisateur()));
+ deleteButton.add(new JSConfirmationBehavior(getString("Confirm")));
+ deleteButton.setDefaultFormProcessing(false);
+ formView.add(deleteButton);
+
+ // Action : retour
+ formView.add(new Link<Void>(getResource() + ".Document.Back") {
+ @Override
+ public void onClick() {
+ callerPage.responsePage((TemplatePage) getPage());
+ }
+ });
+ add(formView);
+ }
+
+ /**
+ * Redirection vers une autre page
+ */
+ private void redirect() {
+ callerPage.responsePage(this);
+ }
+}
Property changes on: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/document/ReadDocumentPage.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Modified: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/lot/ManageLotPage.java
===================================================================
--- trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/lot/ManageLotPage.java 2013-02-13 11:57:28 UTC (rev 103)
+++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/lot/ManageLotPage.java 2013-02-13 15:03:01 UTC (rev 104)
@@ -220,7 +220,7 @@
// ajaxSubmitLink permet de sauvegarder l'état du formulaire
formView.add(new AjaxSubmitLink("NewCampagne") {
@Override
- protected void onSubmit(AjaxRequestTarget arg0, Form<?> arg1) {
+ protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
setResponsePage(new ManageCampagnePage(currentPage, false));
}
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-02-13 11:57:28 UTC (rev 103)
+++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/molecule/ListMoleculesPage.java 2013-02-13 15:03:01 UTC (rev 104)
@@ -24,6 +24,7 @@
import java.util.ArrayList;
import java.util.List;
+
import nc.ird.cantharella.data.model.Lot;
import nc.ird.cantharella.data.model.Utilisateur;
import nc.ird.cantharella.service.model.MoleculeProvenanceBean;
@@ -41,6 +42,8 @@
import nc.ird.cantharella.web.utils.models.SimpleSortableListDataProvider;
import nc.ird.cantharella.web.utils.security.AuthRole;
import nc.ird.cantharella.web.utils.security.AuthRoles;
+
+import org.apache.commons.collections.CollectionUtils;
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;
@@ -141,6 +144,19 @@
new Model<String>(getString("Molecule.masseMolaire")),
"molecule.masseMolaire", "molecule.masseMolaire", DecimalDisplFormat.SMALL, getLocale()));
+ columns.add(new LinkableImagePropertyColumn<MoleculeProvenanceBean>(
+ "images/attachment.png", getString("Read"), getString("Read")) {
+ @Override
+ public void onClick(Item<ICellPopulator<MoleculeProvenanceBean>> item, String componentId, IModel<MoleculeProvenanceBean> model) {
+ setResponsePage(new ReadMoleculePage(model.getObject().getIdMolecule(), currentPage));
+ }
+
+ @Override
+ protected boolean isVisibleAllowed(IModel<MoleculeProvenanceBean> model) {
+ return CollectionUtils.isNotEmpty(model.getObject().getMolecule().getDocuments());
+ }
+ });
+
columns.add(new BooleanPropertyColumn<MoleculeProvenanceBean>(
new Model<String>(getString("Molecule.nouvMolecul")),
"molecule.nouvMolecul", "molecule.nouvMolecul", this));
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-02-13 11:57:28 UTC (rev 103)
+++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/molecule/ManageMoleculePage.html 2013-02-13 15:03:01 UTC (rev 104)
@@ -178,6 +178,14 @@
</table>
</fieldset>
+ <fieldset>
+ <legend><wicket:message key="ListDocumentsPage.AttachedDocuments" /></legend>
+ <div wicket:id="ListDocumentsPage.AttachedDocuments.Refresh">
+ <table cellspacing="0" wicket:id="ListDocumentsPage.AttachedDocuments"/>
+ </div>
+ <a wicket:id="NewDocument" class="add"><wicket:message key="ListDocumentsPage.NewDocument" /></a>
+ </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-02-13 11:57:28 UTC (rev 103)
+++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/molecule/ManageMoleculePage.java 2013-02-13 15:03:01 UTC (rev 104)
@@ -30,19 +30,23 @@
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.Document;
import nc.ird.cantharella.data.model.Extrait;
import nc.ird.cantharella.data.model.Fraction;
import nc.ird.cantharella.data.model.Molecule;
import nc.ird.cantharella.data.model.MoleculeProvenance;
import nc.ird.cantharella.data.model.Produit;
import nc.ird.cantharella.data.model.Utilisateur;
+import nc.ird.cantharella.data.model.utils.DocumentAttachable;
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.config.WebContext;
import nc.ird.cantharella.web.pages.TemplatePage;
import nc.ird.cantharella.web.pages.domain.campagne.ManageCampagnePage;
+import nc.ird.cantharella.web.pages.domain.document.ManageDocumentPage;
import nc.ird.cantharella.web.pages.domain.extraction.ReadExtractionPage;
import nc.ird.cantharella.web.pages.domain.purification.ReadPurificationPage;
import nc.ird.cantharella.web.pages.renderers.ProduitRenderer;
@@ -56,6 +60,7 @@
import nc.ird.cantharella.web.utils.forms.SubmittableButtonEvents;
import nc.ird.cantharella.web.utils.models.DisplayDecimalPropertyModel;
import nc.ird.cantharella.web.utils.models.DisplayDecimalPropertyModel.DecimalDisplFormat;
+import nc.ird.cantharella.web.utils.models.SimpleSortableListDataProvider;
import nc.ird.cantharella.web.utils.panels.PropertyLabelLinkProduitPanel;
import nc.ird.cantharella.web.utils.security.AuthRole;
import nc.ird.cantharella.web.utils.security.AuthRoles;
@@ -67,6 +72,12 @@
import org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior;
import org.apache.wicket.ajax.markup.html.form.AjaxFallbackButton;
import org.apache.wicket.ajax.markup.html.form.AjaxSubmitLink;
+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.AbstractColumn;
+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.basic.Label;
import org.apache.wicket.markup.html.form.Button;
@@ -79,6 +90,7 @@
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.markup.repeater.Item;
import org.apache.wicket.model.AbstractPropertyModel;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.LoadableDetachableModel;
@@ -146,7 +158,6 @@
/**
* Constructeur (mode création).
* @param callerPage Page appelante
- * @param multipleEntry Saisie multiple
*/
public ManageMoleculePage(CallerPage callerPage) {
this(null, callerPage);
@@ -156,9 +167,7 @@
* 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
*/
public ManageMoleculePage(Integer idMolecule, final CallerPage callerPage) {
super(ManageMoleculePage.class);
@@ -187,6 +196,7 @@
final Form<Void> formView = new Form<Void>("Form");
initProvenanceFields(formView, currentPage);
+ initAttachedDocumentsTable(formView, moleculeModel.getObject(), currentPage);
// page can be accessed by anyone for editing provenance
// but molecule fields can be edited only by administrators or
@@ -268,6 +278,21 @@
formView.add(new TextField<String>("Molecule.createur", new PropertyModel<String>(moleculeModel, "createur"))
.setEnabled(false));
+ // Action : création d'un nouveau document
+ // ajaxSubmitLink permet de sauvegarder l'état du formulaire
+ formView.add(new AjaxSubmitLink("NewDocument") {
+ @Override
+ protected void onSubmit(AjaxRequestTarget request, Form<?> form) {
+ setResponsePage(new ManageDocumentPage(currentPage, moleculeModel.getObject(), false));
+ }
+
+ // si erreur, le formulaire est également enregistré puis la redirection effectuée
+ @Override
+ protected void onError(AjaxRequestTarget target, Form<?> form) {
+ setResponsePage(new ManageDocumentPage(currentPage, moleculeModel.getObject(), false));
+ }
+ }.setVisibilityAllowed(editEnabled));
+
// Action : création du lot
Button createButton = new SubmittableButton(ACTION_CREATE, new SubmittableButtonEvents() {
@Override
@@ -575,6 +600,68 @@
}
/**
+ * Init attached document table for current entity.
+ *
+ * @param formView form to add table to
+ * @param documentAttachable entity to get documents
+ * @param currentPage current page
+ */
+ private void initAttachedDocumentsTable(final Form<Void> formView, final DocumentAttachable documentAttachable, CallerPage currentPage) {
+
+ List<Document> documents = documentAttachable.getDocuments();
+
+ // On englobe le "DataView" dans un composant neutre que l'on pourra
+ // rafraichir quand la liste évoluera
+ final MarkupContainer attachedDocumentRefresh = new WebMarkupContainer("ListDocumentsPage.AttachedDocuments.Refresh");
+ attachedDocumentRefresh.setOutputMarkupId(true);
+ formView.add(attachedDocumentRefresh);
+
+ SimpleSortableListDataProvider<Document> attachedDocumentsDataProvider =
+ new SimpleSortableListDataProvider<Document>(
+ documents, getSession().getLocale());
+
+ List<IColumn<Document>> columns = new ArrayList<IColumn<Document>>();
+
+ columns.add(new PropertyColumn<Document>(
+ new Model<String>(getString("Document.titre")), "titre", "titre"));
+
+ columns.add(new PropertyColumn<Document>(
+ new Model<String>(getString("Document.typeDocument")), "typeDocument.nom", "typeDocument.nom"));
+
+ columns.add(new PropertyColumn<Document>(
+ new Model<String>(getString("Document.createur")), "createur", "createur"));
+
+ columns.add(new PropertyColumn<Document>(
+ new Model<String>(getString("Document.fileName")), "fileName", "fileName"));
+
+ columns.add(new AbstractColumn<Document>(new Model<String>(), "idMolecule") {
+ @Override
+ public void populateItem(Item<ICellPopulator<Document>> cellItem, String componentId, final IModel<Document> rowModel) {
+ cellItem.add(new AjaxFallbackButton(componentId, new Model<String>(getString("Delete")), formView) {
+ @Override
+ protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
+ documentAttachable.removeDocument(rowModel.getObject());
+
+ if (target != null) {
+ target.add(attachedDocumentRefresh);
+ refreshFeedbackPage(target);
+ }
+ }
+
+ @Override
+ protected void onError(AjaxRequestTarget target, Form<?> form) {
+ // never called
+ }
+ });
+ }
+ });
+
+ final DataTable<Document> attachedDocumentTable = new AjaxFallbackDefaultDataTable<Document>("ListDocumentsPage.AttachedDocuments", columns,
+ attachedDocumentsDataProvider, WebContext.ROWS_PER_PAGE);
+ attachedDocumentRefresh.add(attachedDocumentTable);
+ }
+
+ /**
* 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.html
===================================================================
--- trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/molecule/ReadMoleculePage.html 2013-02-13 11:57:28 UTC (rev 103)
+++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/molecule/ReadMoleculePage.html 2013-02-13 15:03:01 UTC (rev 104)
@@ -152,6 +152,11 @@
</div>
</fieldset>
+ <fieldset>
+ <legend><wicket:message key="ListDocumentsPage.AttachedDocuments" /></legend>
+ <table cellspacing="0" wicket:id="ListDocumentsPage.AttachedDocuments"/>
+ </fieldset>
+
<form wicket:id="Form">
<div class="actions">
<a class="edit" wicket:id="ReadMoleculePage.Molecule.Update" wicket:message="title:Update">
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-02-13 11:57:28 UTC (rev 103)
+++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/molecule/ReadMoleculePage.java 2013-02-13 15:03:01 UTC (rev 104)
@@ -27,14 +27,18 @@
import nc.ird.cantharella.data.exceptions.DataConstraintException;
import nc.ird.cantharella.data.model.Campagne;
+import nc.ird.cantharella.data.model.Document;
import nc.ird.cantharella.data.model.Extrait;
import nc.ird.cantharella.data.model.Fraction;
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.utils.DocumentAttachable;
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.domain.document.ReadDocumentPage;
import nc.ird.cantharella.web.pages.domain.extraction.ReadExtractionPage;
import nc.ird.cantharella.web.pages.domain.lot.ManageLotPage;
import nc.ird.cantharella.web.pages.domain.personne.ReadPersonnePage;
@@ -43,12 +47,14 @@
import nc.ird.cantharella.web.utils.behaviors.JSConfirmationBehavior;
import nc.ird.cantharella.web.utils.behaviors.MoleculeViewBehavior;
import nc.ird.cantharella.web.utils.behaviors.ReplaceEmptyLabelBehavior;
+import nc.ird.cantharella.web.utils.columns.LinkPropertyColumn;
import nc.ird.cantharella.web.utils.forms.SubmittableButton;
import nc.ird.cantharella.web.utils.forms.SubmittableButtonEvents;
import nc.ird.cantharella.web.utils.models.DisplayBooleanPropertyModel;
import nc.ird.cantharella.web.utils.models.DisplayDecimalPropertyModel;
import nc.ird.cantharella.web.utils.models.DisplayDecimalPropertyModel.DecimalDisplFormat;
import nc.ird.cantharella.web.utils.models.GenericLoadableDetachableModel;
+import nc.ird.cantharella.web.utils.models.SimpleSortableListDataProvider;
import nc.ird.cantharella.web.utils.panels.PropertyLabelLinkPanel;
import nc.ird.cantharella.web.utils.panels.PropertyLabelLinkProduitPanel;
import nc.ird.cantharella.web.utils.security.AuthRole;
@@ -57,6 +63,11 @@
import org.apache.wicket.AttributeModifier;
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.basic.Label;
import org.apache.wicket.markup.html.form.Button;
@@ -64,6 +75,7 @@
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.markup.repeater.Item;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.LoadableDetachableModel;
import org.apache.wicket.model.Model;
@@ -106,6 +118,7 @@
moleculeModel = new GenericLoadableDetachableModel<Molecule>(Molecule.class, idMolecule);
initProvenanceFields(currentPage);
+ initAttachedDocumentsTable(moleculeModel.getObject(), currentPage);
add(new Label("Molecule.idMolecule", new PropertyModel<String>(moleculeModel, "idMolecule")));
add(new Label("Molecule.nomCommun", new PropertyModel<String>(moleculeModel, "nomCommun")).add(new ReplaceEmptyLabelBehavior()));
@@ -271,4 +284,43 @@
};
add(noTableProvenances);
}
+
+ /**
+ * Init attached document table for current entity.
+ *
+ * @param formView form to add table to
+ * @param documentAttachable entity to get documents
+ * @param currentPage current page
+ */
+ private void initAttachedDocumentsTable(final DocumentAttachable documentAttachable, final CallerPage currentPage) {
+
+ List<Document> documents = documentAttachable.getDocuments();
+
+ SimpleSortableListDataProvider<Document> attachedDocumentsDataProvider =
+ new SimpleSortableListDataProvider<Document>(
+ documents, getSession().getLocale());
+
+ List<IColumn<Document>> columns = new ArrayList<IColumn<Document>>();
+
+ columns.add(new LinkPropertyColumn<Document>(
+ new Model<String>(getString("Document.titre")), "titre", "titre") {
+ @Override
+ public void onClick(Item<ICellPopulator<Document>> item, String componentId, IModel<Document> model) {
+ setResponsePage(new ReadDocumentPage(model.getObject(), documentAttachable, currentPage));
+ }
+ });
+
+ columns.add(new PropertyColumn<Document>(
+ new Model<String>(getString("Document.typeDocument")), "typeDocument.nom", "typeDocument.nom"));
+
+ columns.add(new PropertyColumn<Document>(
+ new Model<String>(getString("Document.createur")), "createur", "createur"));
+
+ columns.add(new PropertyColumn<Document>(
+ new Model<String>(getString("Document.fileName")), "fileName", "fileName"));
+
+ final DataTable<Document> attachedDocumentTable = new AjaxFallbackDefaultDataTable<Document>("ListDocumentsPage.AttachedDocuments", columns,
+ attachedDocumentsDataProvider, WebContext.ROWS_PER_PAGE);
+ add(attachedDocumentTable);
+ }
}
Modified: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/columns/LinkableImagePropertyColumn.java
===================================================================
--- trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/columns/LinkableImagePropertyColumn.java 2013-02-13 11:57:28 UTC (rev 103)
+++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/columns/LinkableImagePropertyColumn.java 2013-02-13 15:03:01 UTC (rev 104)
@@ -64,10 +64,21 @@
/** {@inheritDoc} */
@Override
public void populateItem(Item<ICellPopulator<T>> item, String componentId, IModel<T> model) {
- item.add(new LinkableImagePanel(item, componentId, model));
+ LinkableImagePanel panel = new LinkableImagePanel(item, componentId, model);
+ panel.setVisibilityAllowed(isVisibleAllowed(model));
+ item.add(panel);
}
/**
+ * Overridable method to mask panel.
+ * @param model model
+ * @return true if panel is visible
+ */
+ protected boolean isVisibleAllowed(IModel<T> model) {
+ return true;
+ }
+
+ /**
* Override this method to react to link clicks. Your own/internal row id will most likely be inside the model.
* @param item Item
* @param componentId Component id
Modified: trunk/cantharella.web/src/main/resources/web_en.properties
===================================================================
--- trunk/cantharella.web/src/main/resources/web_en.properties 2013-02-13 11:57:28 UTC (rev 103)
+++ trunk/cantharella.web/src/main/resources/web_en.properties 2013-02-13 15:03:01 UTC (rev 104)
@@ -131,6 +131,9 @@
ListTestsBioPage2=Bioassays
ListTestsBioPage.NewTestBio=New bioassay
+ListDocumentsPage.NewDocument=New document
+ListDocumentsPage.AttachedDocuments=Attached documents
+
ManageCampagnePage=Campaign management
ManageCampagnePage.Create.OK=Campaign added
ManageCampagnePage.Create.DataConstraintException=The name already exists
@@ -207,6 +210,12 @@
ManageTestBioPage.Delete.OK=Bioassay deleted
ManageTestBioPage.Delete.DataConstraintException=There are data linked to this biassay
+ManageDocumentPage=Document management
+ManageDocumentPage.Create.OK=Document added
+ManageDocumentPage.Update.OK=Document updated
+ManageDocumentPage.Delete.OK=Document deleted
+ManageDocumentPage.Form.uploadTooLarge=La taille du document ne peut pas dépasser ${maxSize}
+
UpdateUtilisateurPage=Account management
UpdateUtilisateurPage.Password=Password
UpdateUtilisateurPage.Profile=Profile
@@ -280,6 +289,7 @@
ReadPurificationPage=Viewing a purification
ReadMoleculePage=Viewing a molecule
ReadTestBioPage=Viewing a bioassay
+ReadDocumentPage=Viewing a document
SearchPage=Search
SearchPage.Search=Search
Modified: trunk/cantharella.web/src/main/resources/web_fr.properties
===================================================================
--- trunk/cantharella.web/src/main/resources/web_fr.properties 2013-02-13 11:57:28 UTC (rev 103)
+++ trunk/cantharella.web/src/main/resources/web_fr.properties 2013-02-13 15:03:01 UTC (rev 104)
@@ -130,6 +130,9 @@
ListTestsBioPage2=Tests biologiques
ListTestsBioPage.NewTestBio=Nouveau test biologique
+ListDocumentsPage.NewDocument=Nouveau document
+ListDocumentsPage.AttachedDocuments=Document(s) attaché(s)
+
ManageCampagnePage=Gestion d'une campagne
ManageCampagnePage.Create.OK=Campagne ajoutée
ManageCampagnePage.Create.DataConstraintException=Le nom existe déjà
@@ -206,6 +209,12 @@
ManageTestBioPage.Delete.OK=Test biologique supprimé
ManageTestBioPage.Delete.DataConstraintException=Il existe des données liées à ce test biologique
+ManageDocumentPage=Gestion d'un document
+ManageDocumentPage.Create.OK=Document ajouté
+ManageDocumentPage.Update.OK=Document mis à jour
+ManageDocumentPage.Delete.OK=Document supprimé
+ManageDocumentPage.Form.uploadTooLarge=La taille du document ne peut pas dépasser ${maxSize}
+
UpdateUtilisateurPage=Gestion du compte
UpdateUtilisateurPage.Password=Mot de passe
UpdateUtilisateurPage.Profile=Profil
@@ -279,6 +288,7 @@
ReadPurificationPage=Consultation d'une purification
ReadMoleculePage=Consultation d'une molécule
ReadTestBioPage=Consultation d'un test biologique
+ReadDocumentPage=Consultation d'un document
SearchPage=Recherche
SearchPage.Search=Rechercher
Added: trunk/cantharella.web/src/main/webapp/images/attachment.png
===================================================================
(Binary files differ)
Property changes on: trunk/cantharella.web/src/main/webapp/images/attachment.png
___________________________________________________________________
Added: svn:mime-type
+ image/png
1
0
Author: bpoussin
Date: 2013-02-13 12:57:28 +0100 (Wed, 13 Feb 2013)
New Revision: 103
Url: http://forge.codelutin.com/projects/cantharella/repository/revisions/103
Log:
site files are in english, menu must be in english too
Modified:
trunk/src/site/site.xml
Modified: trunk/src/site/site.xml
===================================================================
--- trunk/src/site/site.xml 2013-02-13 11:49:36 UTC (rev 102)
+++ trunk/src/site/site.xml 2013-02-13 11:57:28 UTC (rev 103)
@@ -48,8 +48,8 @@
<item name="Code Lutin" href="http://www.codelutin.com"/>
</links>
- <menu name="Utilisateur">
- <item name="Accueil" href="index.html"/>
+ <menu name="User">
+ <item name="About" href="index.html"/>
<item name="Configuration" href="configuration.html"/>
</menu>
<menu ref="reports"/>
1
0
Author: bpoussin
Date: 2013-02-13 12:49:36 +0100 (Wed, 13 Feb 2013)
New Revision: 102
Url: http://forge.codelutin.com/projects/cantharella/repository/revisions/102
Log:
xml file is not binary :(
Modified:
trunk/src/site/site.xml
Property changes on: trunk/src/site/site.xml
___________________________________________________________________
Deleted: svn:mime-type
- application/xml
1
0
13 Feb '13
Author: bpoussin
Date: 2013-02-13 12:48:45 +0100 (Wed, 13 Feb 2013)
New Revision: 101
Url: http://forge.codelutin.com/projects/cantharella/repository/revisions/101
Log:
rename site file description, because there is only on language
Added:
trunk/src/site/resources/images/jrst-logo.png
trunk/src/site/site.xml
Removed:
trunk/src/site/site_en.xml
Modified:
trunk/src/site/rst/configuration.rst
Added: trunk/src/site/resources/images/jrst-logo.png
===================================================================
(Binary files differ)
Property changes on: trunk/src/site/resources/images/jrst-logo.png
___________________________________________________________________
Added: svn:mime-type
+ image/png
Modified: trunk/src/site/rst/configuration.rst
===================================================================
--- trunk/src/site/rst/configuration.rst 2013-02-13 11:21:32 UTC (rev 100)
+++ trunk/src/site/rst/configuration.rst 2013-02-13 11:48:45 UTC (rev 101)
@@ -24,7 +24,7 @@
Configuraiton
=============
-All configuration can be put in file **cantharella.conf**. This file can be in:
+All configuration variables can be put in file **cantharella.conf**. This file can be in:
- classpath
- system configuration directory
Copied: trunk/src/site/site.xml (from rev 95, trunk/src/site/site_en.xml)
===================================================================
(Binary files differ)
Deleted: trunk/src/site/site_en.xml
===================================================================
(Binary files differ)
1
0
Author: bpoussin
Date: 2013-02-13 12:21:32 +0100 (Wed, 13 Feb 2013)
New Revision: 100
Url: http://forge.codelutin.com/projects/cantharella/repository/revisions/100
Log:
move images site in site directory
Added:
trunk/src/site/resources/
Removed:
trunk/src/resources/
1
0
Author: bpoussin
Date: 2013-02-13 12:13:37 +0100 (Wed, 13 Feb 2013)
New Revision: 99
Url: http://forge.codelutin.com/projects/cantharella/repository/revisions/99
Log:
update documentation to specify exact configuration directory for
each OS
Modified:
trunk/src/site/rst/configuration.rst
Modified: trunk/src/site/rst/configuration.rst
===================================================================
--- trunk/src/site/rst/configuration.rst 2013-02-13 10:45:15 UTC (rev 98)
+++ trunk/src/site/rst/configuration.rst 2013-02-13 11:13:37 UTC (rev 99)
@@ -27,17 +27,54 @@
All configuration can be put in file **cantharella.conf**. This file can be in:
- classpath
-- /etc directory
+- system configuration directory
- user configuration directory
- current directory
+- JVM variables
-Configuration variable
-======================
+Configuration files and variables are read in this order, last file found
+overwrite variable from previous file.
-When you put some variable in cantharella.conf file to change default value.
+Classpath
+---------
-All variables with default values::
+This file contains default value and is found in cantharella jar file
+System configuration directory
+------------------------------
+
+- Unix : /etc/cantharella.conf
+- Windows : C:\\Windows\\System32\\cantharella.conf
+- Mac OS : /etc/cantharella.conf
+
+User configuration directory
+----------------------------
+
+- Unix : ${user.home}/.config/cantharella.conf
+- Windows : ${user.home}\\Application Data\\cantharella.conf
+- Mac OS x : ${user.home}/Library/Application Support/cantharella.conf
+
+Current directory
+-----------------
+
+Directory used to launch application
+
+JVM variables
+-------------
+
+You can add parameter to JVM command line to set variable.
+
+example::
+
+ java -Ddb.user=$USER -Dmail.host=localhost ...
+
+Configuration variables
+=======================
+
+You can put some variable in cantharella.conf file to change default value.
+
+List of all variables with default values::
+
#
# DATA
#
1
0
r98 - in trunk: cantharella.service/src/main/java/nc/ird/cantharella/service/model cantharella.service/src/main/java/nc/ird/cantharella/service/services cantharella.service/src/main/java/nc/ird/cantharella/service/services/impl cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/molecule cantharella.web/src/main/java/nc/ird/cantharella/web/utils/models
by bpoussin@users.forge.codelutin.com 13 Feb '13
by bpoussin@users.forge.codelutin.com 13 Feb '13
13 Feb '13
Author: bpoussin
Date: 2013-02-13 11:45:15 +0100 (Wed, 13 Feb 2013)
New Revision: 98
Url: http://forge.codelutin.com/projects/cantharella/repository/revisions/98
Log:
refactoring page and service for molecule liste.
Added:
trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/model/MoleculeProvenanceBean.java
trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/models/SimpleSortableListDataProvider.java
Modified:
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.web/src/main/java/nc/ird/cantharella/web/pages/domain/molecule/ListMoleculesPage.java
Added: trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/model/MoleculeProvenanceBean.java
===================================================================
--- trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/model/MoleculeProvenanceBean.java (rev 0)
+++ trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/model/MoleculeProvenanceBean.java 2013-02-13 10:45:15 UTC (rev 98)
@@ -0,0 +1,71 @@
+package nc.ird.cantharella.service.model;
+
+import java.io.Serializable;
+import nc.ird.cantharella.data.model.Extrait;
+import nc.ird.cantharella.data.model.Fraction;
+import nc.ird.cantharella.data.model.Lot;
+import nc.ird.cantharella.data.model.Molecule;
+import nc.ird.cantharella.data.model.MoleculeProvenance;
+import nc.ird.cantharella.data.model.Produit;
+import nc.ird.cantharella.service.services.MoleculeService;
+
+/**
+ * Simple bean object used as result for {@link MoleculeService#listMoleculeProvenances}
+ *
+ * @author poussin
+ * @version $Revision$
+ *
+ * Last update: $Date$
+ * by : $Author$
+ */
+public class MoleculeProvenanceBean implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * Molecule
+ */
+ protected Molecule molecule;
+
+ /**
+ * Provenance, this field can be null if provenance is not readable by user
+ */
+ protected MoleculeProvenance provenance;
+
+ public MoleculeProvenanceBean(Molecule molecule) {
+ this.molecule = molecule;
+ }
+
+ public MoleculeProvenanceBean(MoleculeProvenance provenance) {
+ this(provenance.getMolecule());
+ this.provenance = provenance;
+ }
+
+
+ public Integer getIdMolecule() {
+ return molecule.getIdMolecule();
+ }
+
+ public Molecule getMolecule() {
+ return molecule;
+ }
+
+ public MoleculeProvenance getMoleculeProvenance() {
+ return provenance;
+ }
+
+ public Lot getLot() {
+ Lot result = null;
+ if (provenance != null) {
+ Produit produit = provenance.getProduit();
+ if (produit instanceof Fraction) {
+ Fraction fraction = (Fraction)produit;
+ result = fraction.getPurification().getLotSource();
+ } else {
+ Extrait extrait = (Extrait)produit;
+ result = extrait.getExtraction().getLot();
+ }
+ }
+ return result;
+ }
+
+}
Modified: 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 2013-02-12 17:52:35 UTC (rev 97)
+++ trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/services/MoleculeService.java 2013-02-13 10:45:15 UTC (rev 98)
@@ -30,6 +30,7 @@
import nc.ird.cantharella.data.model.MoleculeProvenance;
import nc.ird.cantharella.data.model.Utilisateur;
import nc.ird.cantharella.data.model.utils.AbstractModel;
+import nc.ird.cantharella.service.model.MoleculeProvenanceBean;
import nc.ird.cantharella.service.utils.normalizers.MoleculeNormalizer;
import nc.ird.cantharella.service.utils.normalizers.utils.Normalize;
@@ -80,7 +81,7 @@
* @return Molecules
*/
@Transactional(readOnly = true)
- List<AbstractModel> listMoleculeProvenances(Utilisateur utilisateur);
+ List<MoleculeProvenanceBean> listMoleculeProvenances(Utilisateur utilisateur);
/**
* Charge une molecule
Modified: 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 2013-02-12 17:52:35 UTC (rev 97)
+++ trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/services/impl/MoleculeServiceImpl.java 2013-02-13 10:45:15 UTC (rev 98)
@@ -39,6 +39,7 @@
import nc.ird.cantharella.data.model.Utilisateur;
import nc.ird.cantharella.data.model.Utilisateur.TypeDroit;
import nc.ird.cantharella.data.model.utils.AbstractModel;
+import nc.ird.cantharella.service.model.MoleculeProvenanceBean;
import nc.ird.cantharella.service.services.LotService;
import nc.ird.cantharella.service.services.MoleculeService;
import nc.ird.module.utils.AssertTools;
@@ -103,8 +104,8 @@
/** {@inheritDoc} */
@Override
- public List<AbstractModel> listMoleculeProvenances(Utilisateur utilisateur) {
- List<AbstractModel> result = new ArrayList<AbstractModel>();
+ public List<MoleculeProvenanceBean> listMoleculeProvenances(Utilisateur utilisateur) {
+ List<MoleculeProvenanceBean> result = new ArrayList<MoleculeProvenanceBean>();
List<Molecule> molecules = listMolecules();
for (Molecule molecule : molecules) {
@@ -113,13 +114,13 @@
List<MoleculeProvenance> moleculeProvenances = molecule.getProvenances();
for (MoleculeProvenance moleculeProvenance : moleculeProvenances) {
if (isMoleculeProvenanceAccessibleByUser(moleculeProvenance, utilisateur)) {
- result.add(moleculeProvenance);
+ result.add(new MoleculeProvenanceBean(moleculeProvenance));
isOneProductVisible = true;
}
}
if (!isOneProductVisible) {
- result.add(molecule);
+ result.add(new MoleculeProvenanceBean(molecule));
}
}
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-02-12 17:52:35 UTC (rev 97)
+++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/molecule/ListMoleculesPage.java 2013-02-13 10:45:15 UTC (rev 98)
@@ -24,14 +24,9 @@
import java.util.ArrayList;
import java.util.List;
-
-import nc.ird.cantharella.data.model.Extrait;
-import nc.ird.cantharella.data.model.Fraction;
-import nc.ird.cantharella.data.model.Molecule;
-import nc.ird.cantharella.data.model.MoleculeProvenance;
-import nc.ird.cantharella.data.model.Produit;
+import nc.ird.cantharella.data.model.Lot;
import nc.ird.cantharella.data.model.Utilisateur;
-import nc.ird.cantharella.data.model.utils.AbstractModel;
+import nc.ird.cantharella.service.model.MoleculeProvenanceBean;
import nc.ird.cantharella.service.services.MoleculeService;
import nc.ird.cantharella.web.config.WebContext;
import nc.ird.cantharella.web.pages.TemplatePage;
@@ -42,13 +37,10 @@
import nc.ird.cantharella.web.utils.columns.DecimalPropertyColumn;
import nc.ird.cantharella.web.utils.columns.LinkPropertyColumn;
import nc.ird.cantharella.web.utils.columns.LinkableImagePropertyColumn;
-import nc.ird.cantharella.web.utils.models.DisplayBooleanPropertyModel;
-import nc.ird.cantharella.web.utils.models.DisplayDecimalPropertyModel;
import nc.ird.cantharella.web.utils.models.DisplayDecimalPropertyModel.DecimalDisplFormat;
-import nc.ird.cantharella.web.utils.models.LoadableDetachableSortableListDataProvider;
+import nc.ird.cantharella.web.utils.models.SimpleSortableListDataProvider;
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;
@@ -100,260 +92,102 @@
// Liste des molecules
Utilisateur utilisateur = getSession().getUtilisateur();
- final List<AbstractModel> moleculeProvenances = moleculeService.listMoleculeProvenances(utilisateur);
+ final List<MoleculeProvenanceBean> moleculeProvenances = moleculeService.listMoleculeProvenances(utilisateur);
- LoadableDetachableSortableListDataProvider<AbstractModel> moleculesDataProvider =
- new LoadableDetachableSortableListDataProvider<AbstractModel>(
+ SimpleSortableListDataProvider<MoleculeProvenanceBean> moleculesDataProvider =
+ new SimpleSortableListDataProvider<MoleculeProvenanceBean>(
moleculeProvenances, getSession().getLocale());
- List<IColumn<AbstractModel>> columns = new ArrayList<IColumn<AbstractModel>>();
+ List<IColumn<MoleculeProvenanceBean>> columns = new ArrayList<IColumn<MoleculeProvenanceBean>>();
- columns.add(new LinkableImagePropertyColumn<AbstractModel>("images/read.png", getString("Read"), getString("Read")) {
+ columns.add(new LinkableImagePropertyColumn<MoleculeProvenanceBean>(
+ "images/read.png", getString("Read"), getString("Read")) {
@Override
- public void onClick(Item<ICellPopulator<AbstractModel>> item, String componentId, IModel<AbstractModel> model) {
- int idMolecule;
- if (model.getObject() instanceof Molecule) {
- idMolecule = ((Molecule)model.getObject()).getIdMolecule();
- } else {
- idMolecule = ((MoleculeProvenance)model.getObject()).getMolecule().getIdMolecule();
- }
- setResponsePage(new ReadMoleculePage(idMolecule, currentPage));
+ public void onClick(Item<ICellPopulator<MoleculeProvenanceBean>> item, String componentId, IModel<MoleculeProvenanceBean> model) {
+ setResponsePage(new ReadMoleculePage(model.getObject().getIdMolecule(), currentPage));
}
});
- columns.add(new LinkPropertyColumn<AbstractModel>(new Model<String>(getString("Molecule.idMolecule")), "idMolecule",
- getString("Read")) {
- @Override
- protected IModel<AbstractModel> createLabelModel(final IModel<AbstractModel> rowModel) {
- PropertyModel<AbstractModel> propertyModel;
- if (rowModel.getObject() instanceof Molecule) {
- propertyModel = new PropertyModel<AbstractModel>(rowModel, "idMolecule");
- } else {
- propertyModel = new PropertyModel<AbstractModel>(rowModel, "molecule.idMolecule");
- }
- return propertyModel;
- }
+ columns.add(new LinkPropertyColumn<MoleculeProvenanceBean>(
+ new Model<String>(getString("Molecule.idMolecule")),
+ "idMolecule", "idMolecule") {
@Override
- public void onClick(Item<ICellPopulator<AbstractModel>> item, String componentId, IModel<AbstractModel> model) {
- int idMolecule;
- if (model.getObject() instanceof Molecule) {
- idMolecule = ((Molecule)model.getObject()).getIdMolecule();
- } else {
- idMolecule = ((MoleculeProvenance)model.getObject()).getMolecule().getIdMolecule();
- }
- setResponsePage(new ReadMoleculePage(idMolecule, currentPage));
+ public void onClick(Item<ICellPopulator<MoleculeProvenanceBean>> item, String componentId, IModel<MoleculeProvenanceBean> model) {
+ setResponsePage(new ReadMoleculePage(model.getObject().getIdMolecule(), currentPage));
}
});
- columns.add(new AbstractColumn<AbstractModel>(new Model<String>(getString("Molecule.formuleDevMol"))) {
- public void populateItem(Item<ICellPopulator<AbstractModel>> cellItem, String componentId, IModel<AbstractModel> rowModel) {
- if (rowModel.getObject() instanceof Molecule) {
- cellItem.add(new Label(componentId, "-")
- .add(new MoleculeViewBehavior(new PropertyModel<String>(rowModel, "formuleDevMol"))));
- } else {
- cellItem.add(new Label(componentId, "-")
- .add(new MoleculeViewBehavior(new PropertyModel<String>(rowModel, "molecule.formuleDevMol"))));
- }
- }
- });
- columns.add(new PropertyColumn<AbstractModel>(new Model<String>(getString("Molecule.nomCommun")), "nomCommun",
- "nomCommun") {
- @Override
- public void populateItem(Item<ICellPopulator<AbstractModel>> cellItem, String componentId, IModel<AbstractModel> rowModel) {
- String nomCommun;
- if (rowModel.getObject() instanceof Molecule) {
- nomCommun = ((Molecule)rowModel.getObject()).getNomCommun();
- } else {
- nomCommun = ((MoleculeProvenance)rowModel.getObject()).getMolecule().getNomCommun();
- }
- cellItem.add(new Label(componentId, nomCommun));
+ columns.add(new AbstractColumn<MoleculeProvenanceBean>(
+ new Model<String>(getString("Molecule.formuleDevMol"))) {
+ public void populateItem(Item<ICellPopulator<MoleculeProvenanceBean>> cellItem, String componentId, IModel<MoleculeProvenanceBean> rowModel) {
+ cellItem.add(new Label(componentId, "-")
+ .add(new MoleculeViewBehavior(new PropertyModel<String>(rowModel, "molecule.formuleDevMol"))));
}
});
- columns.add(new PropertyColumn<AbstractModel>(new Model<String>(getString("Molecule.familleChimique")), "familleChimique",
- "familleChimique") {
- @Override
- public void populateItem(Item<ICellPopulator<AbstractModel>> cellItem, String componentId, IModel<AbstractModel> rowModel) {
- String familleChimique;
- if (rowModel.getObject() instanceof Molecule) {
- familleChimique = ((Molecule)rowModel.getObject()).getFamilleChimique();
- } else {
- familleChimique = ((MoleculeProvenance)rowModel.getObject()).getMolecule().getFamilleChimique();
- }
- cellItem.add(new Label(componentId, familleChimique));
- }
- });
- columns.add(new PropertyColumn<AbstractModel>(new Model<String>(getString("Molecule.formuleBrute")), "formuleBrute",
- "formuleBrute") {
- @Override
- public void populateItem(Item<ICellPopulator<AbstractModel>> cellItem, String componentId, IModel<AbstractModel> rowModel) {
- String formuleBrute;
- if (rowModel.getObject() instanceof Molecule) {
- formuleBrute = ((Molecule)rowModel.getObject()).getFormuleBrute();
- } else {
- formuleBrute = ((MoleculeProvenance)rowModel.getObject()).getMolecule().getFormuleBrute();
- }
- cellItem.add(new Label(componentId, formuleBrute));
- }
- });
- columns.add(new DecimalPropertyColumn<AbstractModel>(new Model<String>(getString("Molecule.masseMolaire")), "masseMolaire",
- "masseMolaire", DecimalDisplFormat.SMALL, getLocale()) {
- @Override
- public void populateItem(Item<ICellPopulator<AbstractModel>> cellItem, String componentId, IModel<AbstractModel> rowModel) {
- if (rowModel.getObject() instanceof Molecule) {
- cellItem.add(new Label(componentId, new DisplayDecimalPropertyModel(rowModel.getObject(), "masseMolaire",
- DecimalDisplFormat.SMALL, getLocale())));
- } else {
- cellItem.add(new Label(componentId, new DisplayDecimalPropertyModel(rowModel.getObject(), "molecule.masseMolaire",
- DecimalDisplFormat.SMALL, getLocale())));
- }
- }
- });
- columns.add(new BooleanPropertyColumn<AbstractModel>(new Model<String>(getString("Molecule.nouvMolecul")), "nouvMolecul",
- "nouvMolecul", this) {
- @Override
- public void populateItem(Item<ICellPopulator<AbstractModel>> cellItem, String componentId, IModel<AbstractModel> rowModel) {
- if (rowModel.getObject() instanceof Molecule) {
- cellItem.add(new Label(componentId, new DisplayBooleanPropertyModel(rowModel.getObject(), "nouvMolecul",
- ListMoleculesPage.this)));
- } else {
- cellItem.add(new Label(componentId, new DisplayBooleanPropertyModel(rowModel.getObject(), "molecule.nouvMolecul",
- ListMoleculesPage.this)));
- }
- }
- });
- columns.add(new PropertyColumn<AbstractModel>(new Model<String>(getString("Molecule.provenance.embranchement")), "embranchement",
- "embranchement") {
- @Override
- public void populateItem(Item<ICellPopulator<AbstractModel>> cellItem, String componentId, IModel<AbstractModel> rowModel) {
- if (rowModel.getObject() instanceof Molecule) {
- cellItem.add(new Label(componentId, "-"));
- } else {
- MoleculeProvenance provenance = (MoleculeProvenance)rowModel.getObject();
- Produit produit = provenance.getProduit();
- if (produit instanceof Fraction) {
- Fraction fraction = (Fraction)produit;
- cellItem.add(new Label(componentId, fraction.getPurification().getLotSource().getSpecimenRef().getEmbranchement()));
- } else {
- Extrait extrait = (Extrait)produit;
- cellItem.add(new Label(componentId, extrait.getExtraction().getLot().getSpecimenRef().getEmbranchement()));
- }
- }
- }
- });
- columns.add(new PropertyColumn<AbstractModel>(new Model<String>(getString("Molecule.provenance.genre")), "genre",
- "genre") {
- @Override
- public void populateItem(Item<ICellPopulator<AbstractModel>> cellItem, String componentId, IModel<AbstractModel> rowModel) {
- if (rowModel.getObject() instanceof Molecule) {
- cellItem.add(new Label(componentId, "-"));
- } else {
- MoleculeProvenance provenance = (MoleculeProvenance)rowModel.getObject();
- Produit produit = provenance.getProduit();
- if (produit instanceof Fraction) {
- Fraction fraction = (Fraction)produit;
- cellItem.add(new Label(componentId, fraction.getPurification().getLotSource().getSpecimenRef().getGenre()));
- } else {
- Extrait extrait = (Extrait)produit;
- cellItem.add(new Label(componentId, extrait.getExtraction().getLot().getSpecimenRef().getGenre()));
- }
- }
- }
- });
- columns.add(new PropertyColumn<AbstractModel>(new Model<String>(getString("Molecule.provenance.espece")), "espece",
- "espece") {
- @Override
- public void populateItem(Item<ICellPopulator<AbstractModel>> cellItem, String componentId, IModel<AbstractModel> rowModel) {
- if (rowModel.getObject() instanceof Molecule) {
- cellItem.add(new Label(componentId, "-"));
- } else {
- MoleculeProvenance provenance = (MoleculeProvenance)rowModel.getObject();
- Produit produit = provenance.getProduit();
- if (produit instanceof Fraction) {
- Fraction fraction = (Fraction)produit;
- cellItem.add(new Label(componentId, fraction.getPurification().getLotSource().getSpecimenRef().getEspece()));
- } else {
- Extrait extrait = (Extrait)produit;
- cellItem.add(new Label(componentId, extrait.getExtraction().getLot().getSpecimenRef().getEspece()));
- }
- }
- }
- });
- columns.add(new LinkPropertyColumn<AbstractModel>(new Model<String>(getString("Molecule.provenance.lot.ref")), "lot.ref",
- getString("Read")) {
- @Override
- public void populateItem(Item<ICellPopulator<AbstractModel>> cellItem, String componentId, IModel<AbstractModel> rowModel) {
- if (rowModel.getObject() instanceof Molecule) {
- cellItem.add(new Label(componentId, "-"));
- } else {
- super.populateItem(cellItem, componentId, rowModel);
- }
- }
- @Override
- protected IModel<AbstractModel> createLabelModel(final IModel<AbstractModel> rowModel) {
- IModel<AbstractModel> propertyModel = null;
- if (rowModel.getObject() instanceof MoleculeProvenance) {
- MoleculeProvenance provenance = (MoleculeProvenance)rowModel.getObject();
- Produit produit = provenance.getProduit();
- if (produit instanceof Fraction) {
- propertyModel = new PropertyModel<AbstractModel>(rowModel, "produit.purification.lotSource.ref");
- } else {
- propertyModel = new PropertyModel<AbstractModel>(rowModel, "produit.extraction.lot.ref");
- }
- }
- return propertyModel;
- }
+ columns.add(new PropertyColumn<MoleculeProvenanceBean>(
+ new Model<String>(getString("Molecule.nomCommun")),
+ "molecule.nomCommun", "molecule.nomCommun"));
+
+ columns.add(new PropertyColumn<MoleculeProvenanceBean>(
+ new Model<String>(getString("Molecule.familleChimique")),
+ "molecule.familleChimique", "molecule.familleChimique"));
+
+ columns.add(new PropertyColumn<MoleculeProvenanceBean>(
+ new Model<String>(getString("Molecule.formuleBrute")),
+ "molecule.formuleBrute", "molecule.formuleBrute"));
+
+ columns.add(new DecimalPropertyColumn<MoleculeProvenanceBean>(
+ new Model<String>(getString("Molecule.masseMolaire")),
+ "molecule.masseMolaire", "molecule.masseMolaire", DecimalDisplFormat.SMALL, getLocale()));
+
+ columns.add(new BooleanPropertyColumn<MoleculeProvenanceBean>(
+ new Model<String>(getString("Molecule.nouvMolecul")),
+ "molecule.nouvMolecul", "molecule.nouvMolecul", this));
+
+ columns.add(new PropertyColumn<MoleculeProvenanceBean>(
+ new Model<String>(getString("Molecule.provenance.embranchement")),
+ "lot.specimenRef.embranchement", "lot.specimenRef.embranchement"));
+
+ columns.add(new PropertyColumn<MoleculeProvenanceBean>(
+ new Model<String>(getString("Molecule.provenance.genre")),
+ "lot.specimenRef.genre", "lot.specimenRef.genre"));
+
+ columns.add(new PropertyColumn<MoleculeProvenanceBean>(
+ new Model<String>(getString("Molecule.provenance.espece")),
+ "lot.specimenRef.espece", "lot.specimenRef.espece"));
+
+ columns.add(new LinkPropertyColumn<MoleculeProvenanceBean>(
+ new Model<String>(getString("Molecule.provenance.lot.ref")),
+ "lot.ref", "lot.ref") {
@Override
- public void onClick(Item<ICellPopulator<AbstractModel>> item, String componentId, IModel<AbstractModel> model) {
- int idLot;
- if (model.getObject() instanceof MoleculeProvenance) {
- MoleculeProvenance provenance = (MoleculeProvenance)model.getObject();
- Produit produit = provenance.getProduit();
- if (produit instanceof Fraction) {
- Fraction fraction = (Fraction)produit;
- idLot = fraction.getPurification().getLotSource().getIdLot();
- } else {
- Extrait extrait = (Extrait)produit;
- idLot = extrait.getExtraction().getLot().getIdLot();
- }
-
+ public void onClick(Item<ICellPopulator<MoleculeProvenanceBean>> item,
+ String componentId, IModel<MoleculeProvenanceBean> model) {
+ Lot lot = model.getObject().getLot();
+ if (lot != null) {
+ int idLot = lot.getIdLot();
setResponsePage(new ReadLotPage(idLot, currentPage));
}
}
});
- columns.add(new PropertyColumn<AbstractModel>(new Model<String>(getString("Molecule.provenance.programme")), "programme",
- "programme") {
+
+ columns.add(new PropertyColumn<MoleculeProvenanceBean>(
+ new Model<String>(getString("Molecule.provenance.programme")),
+ "lot.campagne.programme", "lot.campagne.programme"));
+
+ columns.add(new LinkableImagePropertyColumn<MoleculeProvenanceBean>(
+ "images/edit.png", getString("Update"), getString("Update")) {
@Override
- public void populateItem(Item<ICellPopulator<AbstractModel>> cellItem, String componentId, IModel<AbstractModel> rowModel) {
- if (rowModel.getObject() instanceof Molecule) {
- cellItem.add(new Label(componentId, "-"));
- } else {
- MoleculeProvenance provenance = (MoleculeProvenance)rowModel.getObject();
- Produit produit = provenance.getProduit();
- if (produit instanceof Fraction) {
- Fraction fraction = (Fraction)produit;
- cellItem.add(new Label(componentId, fraction.getPurification().getLotSource().getCampagne().getProgramme()));
- } else {
- Extrait extrait = (Extrait)produit;
- cellItem.add(new Label(componentId, extrait.getExtraction().getLot().getCampagne().getProgramme()));
- }
- }
- }
- });
- columns.add(new LinkableImagePropertyColumn<AbstractModel>("images/edit.png", getString("Update"), getString("Update")) {
- @Override
- public void onClick(Item<ICellPopulator<AbstractModel>> item, String componentId, IModel<AbstractModel> model) {
- int idMolecule;
- if (model.getObject() instanceof Molecule) {
- idMolecule = ((Molecule)model.getObject()).getIdMolecule();
- } else {
- idMolecule = ((MoleculeProvenance)model.getObject()).getMolecule().getIdMolecule();
- }
+ public void onClick(Item<ICellPopulator<MoleculeProvenanceBean>> item,
+ String componentId, IModel<MoleculeProvenanceBean> model) {
+ int idMolecule = model.getObject().getIdMolecule();
setResponsePage(new ManageMoleculePage(idMolecule, currentPage));
}
});
- final DataTable<AbstractModel> moleculesDataTable = new AjaxFallbackDefaultDataTable<AbstractModel>("ListMoleculesPage.Molecules", columns,
+ final DataTable<MoleculeProvenanceBean> moleculesDataTable =
+ new AjaxFallbackDefaultDataTable<MoleculeProvenanceBean>(
+ "ListMoleculesPage.Molecules", columns,
moleculesDataProvider, WebContext.ROWS_PER_PAGE);
moleculesRefresh.add(moleculesDataTable);
}
Copied: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/models/SimpleSortableListDataProvider.java (from rev 95, trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/models/LoadableDetachableSortableListDataProvider.java)
===================================================================
--- trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/models/SimpleSortableListDataProvider.java (rev 0)
+++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/models/SimpleSortableListDataProvider.java 2013-02-13 10:45:15 UTC (rev 98)
@@ -0,0 +1,163 @@
+/*
+ * #%L
+ * Cantharella :: Web
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2009 - 2012 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.utils.models;
+
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+import nc.ird.cantharella.data.config.DataContext;
+import nc.ird.cantharella.data.exceptions.UnexpectedException;
+import nc.ird.cantharella.web.config.WebContext;
+import nc.ird.module.utils.AssertTools;
+import nc.ird.module.utils.BeanTools;
+import nc.ird.module.utils.BeanTools.AccessType;
+import nc.ird.module.utils.GenericsTools;
+import org.apache.commons.collections.comparators.NullComparator;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.wicket.extensions.markup.html.repeater.util.SortableDataProvider;
+import org.apache.wicket.model.IModel;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Same as {@link LoadableDetachableSortableListDataProvider} but use directly object
+ * in list (without reload from data base)
+ *
+ *
+ * @author Mickael Tricot
+ * @author Adrien Cheype
+ * @param <M> Model object type
+ */
+public class SimpleSortableListDataProvider<M> extends SortableDataProvider<M> {
+
+ private static final long serialVersionUID = 1L;
+
+ /** Logger */
+ private static final Logger LOG = LoggerFactory.getLogger(SimpleSortableListDataProvider.class);
+
+ /** Comparator */
+ private Comparator<Object> comparator;
+
+ /** Data list */
+ private List<M> list;
+
+ /** Locale */
+ private Locale locale;
+
+ /** To recognize a special sort by codePays */
+ final static String CODE_PAYS_PROPERTY = "codePays";
+
+ /** Current filter to select results */
+ // private FilterMapHomeMade filter;
+ /**
+ * Constructor
+ * @param list List
+ * @param locale Locale
+ */
+ @SuppressWarnings("unchecked")
+ public SimpleSortableListDataProvider(List<M> list, Locale locale) {
+ AssertTools.assertNotNull(list);
+ AssertTools.assertIn(locale, DataContext.LOCALES);
+ this.list = list;
+ this.locale = locale;
+ comparator = new NullComparator(true);
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public Iterator<M> iterator(int first, int count) {
+
+ if (getSort() != null && !StringUtils.isEmpty(getSort().getProperty())) {
+ Collections.sort(list, new Comparator<M>() {
+ @Override
+ public int compare(M o1, M o2) {
+ try {
+ Comparable<? extends Object> c1;
+ Object c2;
+ c1 = GenericsTools.cast(BeanTools.getValueFromPath(o1, AccessType.GETTER, getSort()
+ .getProperty()));
+
+ c2 = GenericsTools.cast(BeanTools.getValueFromPath(o2, AccessType.GETTER, getSort()
+ .getProperty()));
+
+ // Exceptions
+ // Countries are sorted by country name, not by country code
+ if (getSort().getProperty().endsWith(CODE_PAYS_PROPERTY)) {
+ if (c1 != null) {
+ c1 = WebContext.COUNTRIES.get(locale).get(c1);
+ }
+ if (c2 != null) {
+ c2 = WebContext.COUNTRIES.get(locale).get(c2);
+ }
+ }
+
+ return (getSort().isAscending() ? 1 : -1) * comparator.compare(c1, c2);
+ } catch (Exception e) {
+ LOG.error(e.getMessage(), e);
+ throw new UnexpectedException(e);
+ }
+ }
+ });
+ }
+
+ return list.subList(first, Math.min(first + count, size())).iterator();
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public IModel<M> model(final M object) {
+ // return new Model<M>(object);
+ return new IModel<M>(){
+ public M getObject() {
+ return object;
+ }
+ public void setObject(M t) {}
+ public void detach() {}
+ };
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public int size() {
+ return list.size();
+ }
+
+ /**
+ * list getter
+ * @return list
+ */
+ public List<M> getList() {
+ return list;
+ }
+
+ /**
+ * list setter
+ * @param list list
+ */
+ public void setList(List<M> list) {
+ this.list = list;
+ }
+
+}
\ No newline at end of file
1
0
Author: echatellier
Date: 2013-02-12 18:52:35 +0100 (Tue, 12 Feb 2013)
New Revision: 97
Url: http://forge.codelutin.com/projects/cantharella/repository/revisions/97
Log:
Exclude commons-vfs2
Modified:
trunk/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2013-02-12 16:18:24 UTC (rev 96)
+++ trunk/pom.xml 2013-02-12 17:52:35 UTC (rev 97)
@@ -448,6 +448,12 @@
<groupId>org.nuiton</groupId>
<artifactId>nuiton-utils</artifactId>
<version>2.6.6</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-vfs2</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
1
0