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
January 2013
- 2 participants
- 25 discussions
r45 - in trunk/cantharella.web/src/main/java/nc/ird/cantharella/web: pages/columns pages/domain/search utils/columns utils/links
by echatellier@users.forge.codelutin.com 07 Jan '13
by echatellier@users.forge.codelutin.com 07 Jan '13
07 Jan '13
Author: echatellier
Date: 2013-01-07 11:50:58 +0100 (Mon, 07 Jan 2013)
New Revision: 45
Url: http://forge.codelutin.com/projects/cantharella/repository/revisions/45
Log:
refs #1643: Fix csv export format
Modified:
trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/columns/TaxonomyPropertyColumn.java
trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/search/SearchPage.java
trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/columns/BooleanPropertyColumn.java
trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/columns/CsvWriter.java
trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/columns/DecimalPropertyColumn.java
trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/columns/EnumPropertyColumn.java
trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/columns/ExportablePropertyColumn.java
trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/columns/ExportableTextFilteredPropertyColumn.java
trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/columns/LinkPropertyColumn.java
trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/columns/MapValuePropertyColumn.java
trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/columns/ShortDatePropertyColumn.java
trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/links/CsvExportLink.java
Modified: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/columns/TaxonomyPropertyColumn.java
===================================================================
--- trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/columns/TaxonomyPropertyColumn.java 2013-01-03 17:10:01 UTC (rev 44)
+++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/columns/TaxonomyPropertyColumn.java 2013-01-07 10:50:58 UTC (rev 45)
@@ -70,7 +70,7 @@
@Override
public String getHeaderName() {
- return getPropertyExpression();
+ return getDisplayModel().getObject().toString();
}
@Override
Modified: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/search/SearchPage.java
===================================================================
--- trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/search/SearchPage.java 2013-01-03 17:10:01 UTC (rev 44)
+++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/search/SearchPage.java 2013-01-07 10:50:58 UTC (rev 45)
@@ -4,7 +4,7 @@
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2009 - 2012 IRD (Institut de Recherche pour le Developpement) and by respective authors (see below)
+ * Copyright (C) 2009 - 2013 IRD (Institut de Recherche pour le Developpement) and by respective authors (see below)
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@@ -190,7 +190,7 @@
final DataTable<Specimen> specimensDataTable = new DefaultDataTable<Specimen>(getResource() + ".Specimens.Results",
specimensColumns, specimensDataProvider, Integer.MAX_VALUE);
add(specimensDataTable);
- add(new CsvExportLink("SearchPage.Specimens.ExportCSV", specimensDataTable));
+ add(new CsvExportLink("SearchPage.Specimens.ExportCSV", specimensDataTable, "specimens.csv"));
}
protected void addLotsTable(final CallerPage currentPage, SearchResult searchResult) {
@@ -271,7 +271,7 @@
final DataTable<Lot> lotsDataTable = new DefaultDataTable<Lot>(getResource() + ".Lots.Results", lotsColumns,
lotsDataProvider, Integer.MAX_VALUE);
add(lotsDataTable);
- add(new CsvExportLink("SearchPage.Lots.ExportCSV", lotsDataTable));
+ add(new CsvExportLink("SearchPage.Lots.ExportCSV", lotsDataTable, "lots.csv"));
}
protected void addExtractionsTable(final CallerPage currentPage, SearchResult searchResult) {
@@ -365,7 +365,7 @@
final DataTable<Extraction> extractionsDataTable = new DefaultDataTable<Extraction>(
getResource() + ".Extractions.Results", extractionsColumns, extractionsDataProvider, Integer.MAX_VALUE);
add(extractionsDataTable);
- add(new CsvExportLink("SearchPage.Extractions.ExportCSV", extractionsDataTable));
+ add(new CsvExportLink("SearchPage.Extractions.ExportCSV", extractionsDataTable, "extractions.csv"));
}
protected void addPurificationsTable(final CallerPage currentPage, SearchResult searchResult) {
@@ -430,7 +430,7 @@
final DataTable<Purification> purificationsDataTable = new DefaultDataTable<Purification>(
getResource() + ".Purifications.Results", columns, purificationsDataProvider, Integer.MAX_VALUE);
add(purificationsDataTable);
- add(new CsvExportLink("SearchPage.Purifications.ExportCSV", purificationsDataTable));
+ add(new CsvExportLink("SearchPage.Purifications.ExportCSV", purificationsDataTable, "purifications.csv"));
}
protected void addTestBiosTable(final CallerPage currentPage, SearchResult searchResult) {
@@ -513,7 +513,7 @@
getResource() + ".ResultatTestBios.Results", columns, resTestBiosDataProvider, Integer.MAX_VALUE);
add(resTestBiosDataTable);
- add(new CsvExportLink("SearchPage.ResultatTestBios.ExportCSV", resTestBiosDataTable));
+ add(new CsvExportLink("SearchPage.ResultatTestBios.ExportCSV", resTestBiosDataTable, "testbios.csv"));
}
@@ -559,6 +559,6 @@
getResource() + ".Stations.Results", columns, stationsDataProvider, WebContext.ROWS_PER_PAGE);
add(stationsDataTable);
- add(new CsvExportLink("SearchPage.Stations.ExportCSV", stationsDataTable));
+ add(new CsvExportLink("SearchPage.Stations.ExportCSV", stationsDataTable, "stations.csv"));
}
}
Modified: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/columns/BooleanPropertyColumn.java
===================================================================
--- trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/columns/BooleanPropertyColumn.java 2013-01-03 17:10:01 UTC (rev 44)
+++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/columns/BooleanPropertyColumn.java 2013-01-07 10:50:58 UTC (rev 45)
@@ -68,7 +68,7 @@
@Override
public String getHeaderName() {
- return propertyExpression;
+ return getDisplayModel().getObject().toString();
}
@Override
Modified: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/columns/CsvWriter.java
===================================================================
--- trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/columns/CsvWriter.java 2013-01-03 17:10:01 UTC (rev 44)
+++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/columns/CsvWriter.java 2013-01-07 10:50:58 UTC (rev 45)
@@ -33,14 +33,16 @@
public class CsvWriter {
private final PrintWriter out;
private boolean first = true;
+ private char separator;
- public CsvWriter(OutputStream os) {
+ public CsvWriter(OutputStream os, char separator) {
out = new PrintWriter(os);
+ this.separator = separator;
}
public CsvWriter write(Object value) {
if (!first) {
- out.append(";");
+ out.append(separator);
}
out.append("\"");
if (value != null) {
Modified: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/columns/DecimalPropertyColumn.java
===================================================================
--- trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/columns/DecimalPropertyColumn.java 2013-01-03 17:10:01 UTC (rev 44)
+++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/columns/DecimalPropertyColumn.java 2013-01-07 10:50:58 UTC (rev 45)
@@ -75,7 +75,7 @@
@Override
public String getHeaderName() {
- return propertyExpression;
+ return getDisplayModel().getObject().toString();
}
@Override
Modified: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/columns/EnumPropertyColumn.java
===================================================================
--- trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/columns/EnumPropertyColumn.java 2013-01-03 17:10:01 UTC (rev 44)
+++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/columns/EnumPropertyColumn.java 2013-01-07 10:50:58 UTC (rev 45)
@@ -68,7 +68,7 @@
@Override
public String getHeaderName() {
- return propertyExpression;
+ return getDisplayModel().getObject().toString();
}
@Override
Modified: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/columns/ExportablePropertyColumn.java
===================================================================
--- trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/columns/ExportablePropertyColumn.java 2013-01-03 17:10:01 UTC (rev 44)
+++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/columns/ExportablePropertyColumn.java 2013-01-07 10:50:58 UTC (rev 45)
@@ -42,7 +42,7 @@
@Override
public String getHeaderName() {
- return getPropertyExpression();
+ return getDisplayModel().getObject().toString();
}
@Override
Modified: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/columns/ExportableTextFilteredPropertyColumn.java
===================================================================
--- trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/columns/ExportableTextFilteredPropertyColumn.java 2013-01-03 17:10:01 UTC (rev 44)
+++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/columns/ExportableTextFilteredPropertyColumn.java 2013-01-07 10:50:58 UTC (rev 45)
@@ -43,7 +43,7 @@
@Override
public String getHeaderName() {
- return getPropertyExpression();
+ return getDisplayModel().getObject().toString();
}
@Override
Modified: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/columns/LinkPropertyColumn.java
===================================================================
--- trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/columns/LinkPropertyColumn.java 2013-01-03 17:10:01 UTC (rev 44)
+++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/columns/LinkPropertyColumn.java 2013-01-07 10:50:58 UTC (rev 45)
@@ -174,7 +174,7 @@
@Override
public String getHeaderName() {
- return getPropertyExpression();
+ return getDisplayModel().getObject().toString();
}
@Override
Modified: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/columns/MapValuePropertyColumn.java
===================================================================
--- trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/columns/MapValuePropertyColumn.java 2013-01-03 17:10:01 UTC (rev 44)
+++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/columns/MapValuePropertyColumn.java 2013-01-07 10:50:58 UTC (rev 45)
@@ -70,7 +70,7 @@
@Override
public String getHeaderName() {
- return propertyExpression;
+ return getDisplayModel().getObject().toString();
}
@Override
Modified: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/columns/ShortDatePropertyColumn.java
===================================================================
--- trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/columns/ShortDatePropertyColumn.java 2013-01-03 17:10:01 UTC (rev 44)
+++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/columns/ShortDatePropertyColumn.java 2013-01-07 10:50:58 UTC (rev 45)
@@ -69,7 +69,7 @@
@Override
public String getHeaderName() {
- return propertyExpression;
+ return getDisplayModel().getObject().toString();
}
@Override
Modified: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/links/CsvExportLink.java
===================================================================
--- trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/links/CsvExportLink.java 2013-01-03 17:10:01 UTC (rev 44)
+++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/links/CsvExportLink.java 2013-01-07 10:50:58 UTC (rev 45)
@@ -1,9 +1,35 @@
+/*
+ * #%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.utils.links;
import java.io.OutputStream;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
import java.util.ArrayList;
+import java.util.Date;
import java.util.Iterator;
import java.util.List;
+import java.util.Locale;
import nc.ird.cantharella.web.utils.columns.CsvWriter;
import nc.ird.cantharella.web.utils.columns.ExportableColumn;
@@ -14,21 +40,43 @@
import org.apache.wicket.request.http.WebResponse;
public class CsvExportLink<T> extends Link<Void> {
+
+ /** Date format for download filename. */
+ private static final DateFormat FILENAME_DF = new SimpleDateFormat("yyyy_MM_dd-HH_mm-");
+
private final DataTable<T> table;
- public CsvExportLink(String id, DataTable<T> table) {
+ private final String filename;
+
+ public CsvExportLink(String id, DataTable<T> table, String filename) {
super(id);
this.table = table;
+ this.filename = filename;
}
@Override
public void onClick() {
WebResponse response = (WebResponse) getResponse();
- response.setAttachmentHeader("export.csv");
response.setContentType("text/csv");
+
+ // configuration du nom de fichier
+ String headerFilename = FILENAME_DF.format(new Date());
+ headerFilename += this.filename;
+ response.setAttachmentHeader(headerFilename);
+
OutputStream out = getResponse().getOutputStream();
- CsvWriter writer = new CsvWriter(out);
+
+ // cofiguration du separateur suivant la locale
+ // fr : ;
+ // en : ,
+ CsvWriter writer;
+ if (Locale.FRENCH.equals(getSession().getLocale())) {
+ writer = new CsvWriter(out, ';');
+ } else {
+ writer = new CsvWriter(out, ',');
+ }
List<ExportableColumn<T>> exportable = getExportableColumns();
+
// write header
for (ExportableColumn<T> column : exportable) {
writer.write(column.getHeaderName());
1
0
03 Jan '13
Author: echatellier
Date: 2013-01-03 18:10:01 +0100 (Thu, 03 Jan 2013)
New Revision: 44
Url: http://forge.codelutin.com/projects/cantharella/repository/revisions/44
Log:
refs #1648, #1949 : Add molecule entity, list and edit page
Added:
trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Molecule.java
trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/services/MoleculeService.java
trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/services/impl/MoleculeServiceImpl.java
trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/utils/normalizers/MoleculeNormalizer.java
trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/molecule/
trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/molecule/ListMoleculesPage.html
trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/molecule/ListMoleculesPage.java
trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/molecule/ManageMoleculePage.html
trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/molecule/ManageMoleculePage.java
trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/molecule/ReadMoleculePage.html
trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/molecule/ReadMoleculePage.java
Modified:
trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/utils/AbstractModel.java
trunk/cantharella.data/src/main/resources/commons/data_en.properties
trunk/cantharella.data/src/main/resources/commons/data_fr.properties
trunk/cantharella.data/src/test/java/nc/ird/cantharella/data/SchemaExporter.java
trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/config/WebApplicationImpl.java
trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/TemplatePage.html
trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/TemplatePage.java
trunk/cantharella.web/src/main/resources/commons/web_en.properties
trunk/cantharella.web/src/main/resources/commons/web_fr.properties
Added: trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Molecule.java
===================================================================
--- trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Molecule.java (rev 0)
+++ trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Molecule.java 2013-01-03 17:10:01 UTC (rev 44)
@@ -0,0 +1,289 @@
+package nc.ird.cantharella.data.model;
+
+import java.util.List;
+
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.Lob;
+import javax.persistence.ManyToOne;
+import javax.persistence.OneToMany;
+import javax.validation.constraints.NotNull;
+
+import nc.ird.cantharella.data.model.search.UtilisateurSearchFilter;
+import nc.ird.cantharella.data.model.utils.AbstractModel;
+
+import org.hibernate.annotations.Cascade;
+import org.hibernate.annotations.CascadeType;
+import org.hibernate.annotations.Type;
+import org.hibernate.search.annotations.Analyze;
+import org.hibernate.search.annotations.Field;
+import org.hibernate.search.annotations.FullTextFilterDef;
+import org.hibernate.search.annotations.FullTextFilterDefs;
+import org.hibernate.search.annotations.Index;
+import org.hibernate.search.annotations.Indexed;
+import org.hibernate.search.annotations.IndexedEmbedded;
+import org.hibernate.search.annotations.Store;
+import org.hibernate.validator.constraints.Length;
+import org.hibernate.validator.constraints.NotEmpty;
+
+@Entity
+@Indexed
+@FullTextFilterDefs( {
+ @FullTextFilterDef(name = "utilisateur-Molecule", impl = UtilisateurSearchFilter.class)
+})
+public class Molecule extends AbstractModel {
+
+ /** ID */
+ @Id
+ @GeneratedValue
+ private Integer idMolecule;
+
+ /** Nom commun */
+ @Length(max = LENGTH_LONG_TEXT)
+ @NotNull
+ @Field(index=Index.YES, analyze=Analyze.YES, store=Store.YES)
+ private String nomCommun;
+
+ /** Famille chimique */
+ @Length(max = LENGTH_MEDIUM_TEXT)
+ @NotNull
+ @Field(index=Index.YES, analyze=Analyze.YES, store=Store.YES)
+ private String familleChimique;
+
+ /** Famille developpée */
+ @Lob
+ @Type(type="org.hibernate.type.StringClobType") // see HHH-6105
+ private String formuleDevMol;
+
+ /** Nom IUPAC */
+ @Length(max = LENGTH_BIG_TEXT)
+ @NotNull
+ private String nomIupca;
+
+ /** Formule brute */
+ @Length(max = LENGTH_MEDIUM_TEXT)
+ @NotEmpty
+ private String formuleBrute;
+
+ /** Masse molaire */
+ @NotEmpty
+ private Double masseMolaire;
+
+ /** Est-ce une nouvelle molécule ? */
+ @NotEmpty
+ private Boolean nouvMolecul;
+
+ @ManyToOne(fetch = FetchType.EAGER, optional = false)
+ @IndexedEmbedded
+ private Campagne campagne;
+
+ /** Identifiee par. */
+ @Length(max = LENGTH_MEDIUM_TEXT)
+ @NotNull
+ private String identifieePar;
+
+ /** Publication d'origine */
+ @Lob
+ @Type(type="org.hibernate.type.StringClobType") // see HHH-6105
+ private String publiOrigine;
+
+ /** Complement */
+ @Lob
+ @Type(type="org.hibernate.type.StringClobType") // see HHH-6105
+ private String complement;
+
+ /** Créateur */
+ @NotNull
+ @ManyToOne(fetch = FetchType.LAZY, optional = false)
+ @IndexedEmbedded
+ private Personne createur;
+
+ /** Produit utilisé obtenir le résultat **/
+ @OneToMany(fetch = FetchType.LAZY)
+ @Cascade({ CascadeType.SAVE_UPDATE })
+ private List<Produit> produits;
+
+ /**
+ * @return the idMolecule
+ */
+ public Integer getIdMolecule() {
+ return idMolecule;
+ }
+
+ /**
+ * @param idMolecule the idMolecule to set
+ */
+ public void setIdMolecule(Integer idMolecule) {
+ this.idMolecule = idMolecule;
+ }
+
+ /**
+ * @return the nomCommun
+ */
+ public String getNomCommun() {
+ return nomCommun;
+ }
+
+ /**
+ * @param nomCommun the nomCommun to set
+ */
+ public void setNomCommun(String nomCommun) {
+ this.nomCommun = nomCommun;
+ }
+
+ /**
+ * @return the familleChimique
+ */
+ public String getFamilleChimique() {
+ return familleChimique;
+ }
+
+ /**
+ * @param familleChimique the familleChimique to set
+ */
+ public void setFamilleChimique(String familleChimique) {
+ this.familleChimique = familleChimique;
+ }
+
+ /**
+ * @return the formuleDevMol
+ */
+ public String getFormuleDevMol() {
+ return formuleDevMol;
+ }
+
+ /**
+ * @param formuleDevMol the formuleDevMol to set
+ */
+ public void setFormuleDevMol(String formuleDevMol) {
+ this.formuleDevMol = formuleDevMol;
+ }
+
+ /**
+ * @return the nomIupca
+ */
+ public String getNomIupca() {
+ return nomIupca;
+ }
+
+ /**
+ * @param nomIupca the nomIupca to set
+ */
+ public void setNomIupca(String nomIupca) {
+ this.nomIupca = nomIupca;
+ }
+
+ /**
+ * @return the formuleBrute
+ */
+ public String getFormuleBrute() {
+ return formuleBrute;
+ }
+
+ /**
+ * @param formuleBrute the formuleBrute to set
+ */
+ public void setFormuleBrute(String formuleBrute) {
+ this.formuleBrute = formuleBrute;
+ }
+
+ /**
+ * @return the masseMolaire
+ */
+ public Double getMasseMolaire() {
+ return masseMolaire;
+ }
+
+ /**
+ * @param masseMolaire the masseMolaire to set
+ */
+ public void setMasseMolaire(Double masseMolaire) {
+ this.masseMolaire = masseMolaire;
+ }
+
+ /**
+ * @return the nouvMolecul
+ */
+ public Boolean getNouvMolecul() {
+ return nouvMolecul;
+ }
+
+ /**
+ * @param nouvMolecul the nouvMolecul to set
+ */
+ public void setNouvMolecul(Boolean nouvMolecul) {
+ this.nouvMolecul = nouvMolecul;
+ }
+
+ /**
+ * @return the campagne
+ */
+ public Campagne getCampagne() {
+ return campagne;
+ }
+
+ /**
+ * @param campagne the campagne to set
+ */
+ public void setCampagne(Campagne campagne) {
+ this.campagne = campagne;
+ }
+
+ /**
+ * @return the publiOrigine
+ */
+ public String getPubliOrigine() {
+ return publiOrigine;
+ }
+
+ /**
+ * @param publiOrigine the publiOrigine to set
+ */
+ public void setPubliOrigine(String publiOrigine) {
+ this.publiOrigine = publiOrigine;
+ }
+
+ /**
+ * @return the complement
+ */
+ public String getComplement() {
+ return complement;
+ }
+
+ /**
+ * @param complement the complement to set
+ */
+ public void setComplement(String complement) {
+ this.complement = complement;
+ }
+
+ /**
+ * @return the createur
+ */
+ public Personne getCreateur() {
+ return createur;
+ }
+
+ /**
+ * @param createur the createur to set
+ */
+ public void setCreateur(Personne createur) {
+ this.createur = createur;
+ }
+
+ /**
+ * @return the produits
+ */
+ public List<Produit> getProduits() {
+ return produits;
+ }
+
+ /**
+ * @param produits the produits to set
+ */
+ public void setProduits(List<Produit> produits) {
+ this.produits = produits;
+ }
+}
Property changes on: trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Molecule.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Modified: trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/utils/AbstractModel.java
===================================================================
--- trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/utils/AbstractModel.java 2013-01-02 11:06:26 UTC (rev 43)
+++ trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/utils/AbstractModel.java 2013-01-03 17:10:01 UTC (rev 44)
@@ -52,6 +52,9 @@
/** ID fields cache (for each model class name) */
private static final Map<String, Field> ID_FIELDS = Collections.synchronizedMap(new TreeMap<String, Field>());
+ /** Length: big text */
+ protected static final int LENGTH_BIG_TEXT = 255;
+
/** Length: long text */
protected static final int LENGTH_LONG_TEXT = 100;
Modified: trunk/cantharella.data/src/main/resources/commons/data_en.properties
===================================================================
--- trunk/cantharella.data/src/main/resources/commons/data_en.properties 2013-01-02 11:06:26 UTC (rev 43)
+++ trunk/cantharella.data/src/main/resources/commons/data_en.properties 2013-01-03 17:10:01 UTC (rev 44)
@@ -180,6 +180,23 @@
ParamMethoPuri=Parameter
ParamMethoPuriEffect.valeur=Value
+
+Molecule.idMolecule=Mol�cule N�
+Molecule.nomCommun=Nom commun
+Molecule.familleChimique=Famille Chimique
+Molecule.formuleDevMol=Formule d�velopp�e
+Molecule.nomIupca=Nom IUPAC
+Molecule.formuleBrute=Formule brute
+Molecule.masseMolaire=Masse molaire (g/mol)
+Molecule.nouvMolecul=Est-ce une nouvelle mol�cule ?
+Molecule.campagne=Dans le cadre de la campagne
+Molecule.identifieePar=Identifi�e par
+Molecule.publiOrigine=Publication d'origine
+Molecule.complement=Compl�ment
+Molecule.createur=Cr�ateur de la fiche
+Molecule.produits=Provenance
+
+
TestBio.ref=Test ref.
TestBio.manipulateur=Operator
TestBio.organismeTesteur=Test organization
Modified: trunk/cantharella.data/src/main/resources/commons/data_fr.properties
===================================================================
--- trunk/cantharella.data/src/main/resources/commons/data_fr.properties 2013-01-02 11:06:26 UTC (rev 43)
+++ trunk/cantharella.data/src/main/resources/commons/data_fr.properties 2013-01-03 17:10:01 UTC (rev 44)
@@ -180,6 +180,23 @@
ParamMethoPuri=Paramètre
ParamMethoPuriEffect.valeur=Valeur
+
+Molecule.idMolecule=Molécule N°
+Molecule.nomCommun=Nom commun
+Molecule.familleChimique=Famille Chimique
+Molecule.formuleDevMol=Formule développée
+Molecule.nomIupca=Nom IUPAC
+Molecule.formuleBrute=Formule brute
+Molecule.masseMolaire=Masse molaire (g/mol)
+Molecule.nouvMolecul=Est-ce une nouvelle molécule ?
+Molecule.campagne=Dans le cadre de la campagne
+Molecule.identifieePar=Identifiée par
+Molecule.publiOrigine=Publication d'origine
+Molecule.complement=Complément
+Molecule.createur=Créateur de la fiche
+Molecule.produits=Provenance
+
+
TestBio.ref=Réf. test
TestBio.manipulateur=Manipulateur
TestBio.organismeTesteur=Organisme testeur
Modified: trunk/cantharella.data/src/test/java/nc/ird/cantharella/data/SchemaExporter.java
===================================================================
--- trunk/cantharella.data/src/test/java/nc/ird/cantharella/data/SchemaExporter.java 2013-01-02 11:06:26 UTC (rev 43)
+++ trunk/cantharella.data/src/test/java/nc/ird/cantharella/data/SchemaExporter.java 2013-01-03 17:10:01 UTC (rev 44)
@@ -3,34 +3,27 @@
import java.io.IOException;
import java.util.Properties;
-import javax.sql.DataSource;
-
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
import org.hibernate.dialect.PostgreSQL82Dialect;
import org.hibernate.tool.hbm2ddl.SchemaExport;
import org.junit.Test;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.hibernate4.LocalSessionFactoryBean;
-public class SchemaExporter extends AbstractDataTest {
+public class SchemaExporter {
- @Autowired
- protected DataSource datasource;
-
@Test
public void exportSchema() throws IOException {
LocalSessionFactoryBean sessionFactoryBean = new LocalSessionFactoryBean();
- //sessionFactoryBean.setDataSource(datasource);
sessionFactoryBean.setPackagesToScan(new String[] { "nc.ird.cantharella.data.model" });
Properties hibernateProperties = new Properties();
// Hibernate: basic
hibernateProperties.setProperty(Environment.DIALECT, PostgreSQL82Dialect.class.getName());
+ hibernateProperties.setProperty(Environment.SHOW_SQL, "false");
sessionFactoryBean.setHibernateProperties(hibernateProperties);
sessionFactoryBean.afterPropertiesSet();
Configuration configuration = sessionFactoryBean.getConfiguration();
SchemaExport schemaExport = new SchemaExport(configuration);
- schemaExport.create(true, false);
-
+ schemaExport.create(true, false);
}
}
Added: trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/services/MoleculeService.java
===================================================================
--- trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/services/MoleculeService.java (rev 0)
+++ trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/services/MoleculeService.java 2013-01-03 17:10:01 UTC (rev 44)
@@ -0,0 +1,85 @@
+/*
+ * #%L
+ * Cantharella :: Service
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2009 - 2013 IRD (Institut de Recherche pour le Developpement) and by respective authors (see below)
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+package nc.ird.cantharella.service.services;
+
+import java.util.List;
+
+import nc.ird.cantharella.data.exceptions.DataConstraintException;
+import nc.ird.cantharella.data.exceptions.DataNotFoundException;
+import nc.ird.cantharella.data.model.Molecule;
+import nc.ird.cantharella.service.utils.normalizers.MoleculeNormalizer;
+import nc.ird.cantharella.service.utils.normalizers.utils.Normalize;
+
+import org.springframework.transaction.annotation.Transactional;
+
+/**
+ * Service : molecules.
+ *
+ * @author Eric Chatellier
+ */
+public interface MoleculeService {
+
+ /**
+ * Compte le nombre de molecules
+ * @return Nombre de Molecules
+ */
+ long countMolecules();
+
+ /**
+ * Créée une molecule
+ * @param molecule Molecule
+ * @throws DataConstraintException Si la molecule existe déjà
+ */
+ void createMolecule((a)Normalize(MoleculeNormalizer.class) Molecule molecule) throws DataConstraintException;
+
+ /**
+ * Supprime une molecule
+ * @param molecule Molecule
+ * @throws DataConstraintException Si la molecule a des données liées
+ */
+ void deleteMolecule(Molecule molecule) throws DataConstraintException;
+
+ /**
+ * Liste les molecules
+ * @return Molecules
+ */
+ @Transactional(readOnly = true)
+ List<Molecule> listMolecules();
+
+ /**
+ * Charge une molecule
+ * @param numero numero
+ * @return Le lot correspondant
+ * @throws DataNotFoundException Si le lot n'existe pas
+ */
+ Molecule loadMolecule(Integer numero) throws DataNotFoundException;
+
+ /**
+ * Met à jour une molecule
+ * @param molecule Molecule
+ * @throws DataConstraintException Si la molecule existe déjà
+ */
+ void updateMolecule((a)Normalize(MoleculeNormalizer.class) Molecule molecule) throws DataConstraintException;
+
+
+}
Property changes on: trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/services/MoleculeService.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/services/impl/MoleculeServiceImpl.java
===================================================================
--- trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/services/impl/MoleculeServiceImpl.java (rev 0)
+++ trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/services/impl/MoleculeServiceImpl.java 2013-01-03 17:10:01 UTC (rev 44)
@@ -0,0 +1,103 @@
+/*
+ * #%L
+ * Cantharella :: Service
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2009 - 2013 IRD (Institut de Recherche pour le Developpement) and by respective authors (see below)
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+package nc.ird.cantharella.service.services.impl;
+
+import java.util.List;
+
+import nc.ird.cantharella.data.dao.GenericDao;
+import nc.ird.cantharella.data.exceptions.DataConstraintException;
+import nc.ird.cantharella.data.exceptions.DataNotFoundException;
+import nc.ird.cantharella.data.exceptions.UnexpectedException;
+import nc.ird.cantharella.data.model.Molecule;
+import nc.ird.cantharella.service.services.MoleculeService;
+import nc.ird.module.utils.AssertTools;
+import nc.ird.module.utils.LogTools;
+
+import org.apache.commons.logging.Log;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+/**
+ * Implémentation du service molecule.
+ *
+ * @author Eric Chatellier
+ */
+@Service
+public final class MoleculeServiceImpl implements MoleculeService {
+
+ /** Logger */
+ private static final Log LOG = LogTools.getLog();
+
+ /** DAO */
+ @Autowired
+ private GenericDao dao;
+
+ @Override
+ public long countMolecules() {
+ return dao.count(Molecule.class);
+ }
+
+ @Override
+ public void createMolecule(Molecule molecule)
+ throws DataConstraintException {
+ LOG.info("createMolecule " + molecule.getFormuleBrute());
+ dao.create(molecule);
+ }
+
+ @Override
+ public void deleteMolecule(Molecule molecule)
+ throws DataConstraintException {
+ AssertTools.assertNotNull(molecule);
+ LOG.info("deleteMolecule " + molecule.getIdMolecule());
+ try {
+ dao.delete(molecule);
+ } catch (DataNotFoundException e) {
+ LOG.error(e.getMessage(), e);
+ throw new UnexpectedException(e);
+ }
+
+ }
+
+ @Override
+ public List<Molecule> listMolecules() {
+ return dao.readList(Molecule.class, "idMolecule");
+ }
+
+ @Override
+ public Molecule loadMolecule(Integer numero) throws DataNotFoundException {
+ return dao.read(Molecule.class, numero);
+ }
+
+ @Override
+ public void updateMolecule(Molecule molecule)
+ throws DataConstraintException {
+ LOG.info("updateMolecule: " + molecule.getIdMolecule());
+ try {
+ dao.update(molecule);
+ } catch (DataNotFoundException e) {
+ LOG.error(e.getMessage(), e);
+ throw new UnexpectedException(e);
+ }
+
+ }
+}
Property changes on: trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/services/impl/MoleculeServiceImpl.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/utils/normalizers/MoleculeNormalizer.java
===================================================================
--- trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/utils/normalizers/MoleculeNormalizer.java (rev 0)
+++ trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/utils/normalizers/MoleculeNormalizer.java 2013-01-03 17:10:01 UTC (rev 44)
@@ -0,0 +1,41 @@
+/*
+ * #%L
+ * Cantharella :: Service
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2009 - 2013 IRD (Institut de Recherche pour le Developpement) and by respective authors (see below)
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+package nc.ird.cantharella.service.utils.normalizers;
+
+import nc.ird.cantharella.data.model.Molecule;
+import nc.ird.cantharella.service.utils.normalizers.utils.Normalizer;
+import nc.ird.module.utils.AssertTools;
+
+/**
+ * Molecule normalizer
+ * @author Eric Chatellier
+ */
+public final class MoleculeNormalizer extends Normalizer<Molecule> {
+
+ /** {@inheritDoc} */
+ @Override
+ protected Molecule normalize(Molecule molecule) {
+ AssertTools.assertNotNull(molecule);
+ return molecule;
+ }
+}
Property changes on: trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/utils/normalizers/MoleculeNormalizer.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Modified: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/config/WebApplicationImpl.java
===================================================================
--- trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/config/WebApplicationImpl.java 2013-01-02 11:06:26 UTC (rev 43)
+++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/config/WebApplicationImpl.java 2013-01-03 17:10:01 UTC (rev 44)
@@ -40,6 +40,9 @@
import nc.ird.cantharella.web.pages.domain.lot.ListLotsPage;
import nc.ird.cantharella.web.pages.domain.lot.ManageLotPage;
import nc.ird.cantharella.web.pages.domain.lot.ReadLotPage;
+import nc.ird.cantharella.web.pages.domain.molecule.ListMoleculesPage;
+import nc.ird.cantharella.web.pages.domain.molecule.ManageMoleculePage;
+import nc.ird.cantharella.web.pages.domain.molecule.ReadMoleculePage;
import nc.ird.cantharella.web.pages.domain.personne.ListPersonnesPage;
import nc.ird.cantharella.web.pages.domain.personne.ManagePersonnePage;
import nc.ird.cantharella.web.pages.domain.personne.ReadPersonnePage;
@@ -381,7 +384,14 @@
getRootRequestMapperAsCompound().add(new MountedMapper("/station/edit", ManageStationPage.class));
mountPage("/station/edit", ManageStationPage.class);
getRootRequestMapperAsCompound().add(new MountedMapper("/station/view", ReadStationPage.class));
- mountPage("/station/view", ReadStationPage.class);
+ mountPage("/station/view", ReadStationPage.class);
+
+ getRootRequestMapperAsCompound().add(new MountedMapper("/molecule/list", ListMoleculesPage.class));
+ mountPage("/molecule/list", ListMoleculesPage.class);
+ getRootRequestMapperAsCompound().add(new MountedMapper("/molecule/edit", ManageMoleculePage.class));
+ mountPage("/molecule/edit", ManageMoleculePage.class);
+ getRootRequestMapperAsCompound().add(new MountedMapper("/molecule/view", ReadMoleculePage.class));
+ mountPage("/molecule/view", ReadMoleculePage.class);
getRootRequestMapperAsCompound().add(new MountedMapper("/testBio/list", ListTestsBioPage.class));
mountPage("/testBio/list", ListTestsBioPage.class);
Modified: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/TemplatePage.html
===================================================================
--- trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/TemplatePage.html 2013-01-02 11:06:26 UTC (rev 43)
+++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/TemplatePage.html 2013-01-03 17:10:01 UTC (rev 44)
@@ -4,7 +4,7 @@
$Id:$
$HeadURL:$
%%
- Copyright (C) 2009 - 2012 IRD (Institut de Recherche pour le Developpement) and by respective authors (see below)
+ Copyright (C) 2009 - 2013 IRD (Institut de Recherche pour le Developpement) and by respective authors (see below)
%%
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
@@ -136,7 +136,7 @@
</li>
<li class="sm2 chi"><span><wicket:message key="TemplatePage.Chemistry"/></span><img src="images/chimie.jpg" />
<ul>
- <li><wicket:message key="ListMoleculesPage" /></li>
+ <li><a wicket:id="ListMoleculesPage"><wicket:message key="ListMoleculesPage" /></a></li>
</ul>
</li>
<li class="sm1 bio"><span><wicket:message key="TemplatePage.Biology"/></span><img src="images/biologie.jpg" />
Modified: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/TemplatePage.java
===================================================================
--- trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/TemplatePage.java 2013-01-02 11:06:26 UTC (rev 43)
+++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/TemplatePage.java 2013-01-03 17:10:01 UTC (rev 44)
@@ -4,7 +4,7 @@
* $Id:$
* $HeadURL:$
* %%
- * Copyright (C) 2009 - 2012 IRD (Institut de Recherche pour le Developpement) and by respective authors (see below)
+ * Copyright (C) 2009 - 2013 IRD (Institut de Recherche pour le Developpement) and by respective authors (see below)
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@@ -32,6 +32,7 @@
import nc.ird.cantharella.web.pages.domain.config.ListConfigurationPage;
import nc.ird.cantharella.web.pages.domain.extraction.ListExtractionsPage;
import nc.ird.cantharella.web.pages.domain.lot.ListLotsPage;
+import nc.ird.cantharella.web.pages.domain.molecule.ListMoleculesPage;
import nc.ird.cantharella.web.pages.domain.personne.ListPersonnesPage;
import nc.ird.cantharella.web.pages.domain.purification.ListPurificationsPage;
import nc.ird.cantharella.web.pages.domain.search.SearchPage;
@@ -244,6 +245,7 @@
ListExtractionsPage.class));
userMenu.add(new BookmarkablePageLink<Void>(ListPurificationsPage.class.getSimpleName(),
ListPurificationsPage.class));
+ userMenu.add(new BookmarkablePageLink<Void>(ListMoleculesPage.class.getSimpleName(), ListMoleculesPage.class));
userMenu.add(new BookmarkablePageLink<Void>(ListTestsBioPage.class.getSimpleName(), ListTestsBioPage.class));
// userMenu.add(new BookmarkablePageLink<Void>(SandboxPage.class.getSimpleName(), SandboxPage.class));
Added: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/molecule/ListMoleculesPage.html
===================================================================
--- trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/molecule/ListMoleculesPage.html (rev 0)
+++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/molecule/ListMoleculesPage.html 2013-01-03 17:10:01 UTC (rev 44)
@@ -0,0 +1,37 @@
+<!--
+ #%L
+ Cantharella :: Web
+ $Id:$
+ $HeadURL:$
+ %%
+ Copyright (C) 2009 - 2013 IRD (Institut de Recherche pour le Developpement) and by respective authors (see below)
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+ #L%
+ -->
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd">
+<body>
+<wicket:extend>
+<p><a wicket:id="ListMoleculesPage.NewMolecule" class="add"><wicket:message key="ListMoleculesPage.NewMolecule" /></a>
+</p>
+
+<div wicket:id="ListMoleculesPage.Molecules.Refresh">
+<table cellspacing="0" wicket:id="ListMoleculesPage.Molecules"/>
+</div>
+
+</wicket:extend>
+</body>
+</html>
\ No newline at end of file
Added: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/molecule/ListMoleculesPage.java
===================================================================
--- trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/molecule/ListMoleculesPage.java (rev 0)
+++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/molecule/ListMoleculesPage.java 2013-01-03 17:10:01 UTC (rev 44)
@@ -0,0 +1,127 @@
+/*
+ * #%L
+ * Cantharella :: Web
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2009 - 2013 IRD (Institut de Recherche pour le Developpement) and by respective authors (see below)
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+package nc.ird.cantharella.web.pages.domain.molecule;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import nc.ird.cantharella.data.model.Lot;
+import nc.ird.cantharella.data.model.Molecule;
+import nc.ird.cantharella.web.config.WebContext;
+import nc.ird.cantharella.web.pages.TemplatePage;
+import nc.ird.cantharella.web.pages.columns.TaxonomyPropertyColumn;
+import nc.ird.cantharella.web.pages.domain.lot.ListLotsPage;
+import nc.ird.cantharella.web.pages.domain.lot.ReadLotPage;
+import nc.ird.cantharella.web.pages.domain.specimen.ReadSpecimenPage;
+import nc.ird.cantharella.web.pages.domain.station.ReadStationPage;
+import nc.ird.cantharella.web.utils.CallerPage;
+import nc.ird.cantharella.web.utils.columns.EnumPropertyColumn;
+import nc.ird.cantharella.web.utils.columns.LinkPropertyColumn;
+import nc.ird.cantharella.web.utils.columns.LinkableImagePropertyColumn;
+import nc.ird.cantharella.web.utils.models.LoadableDetachableSortableListDataProvider;
+import nc.ird.cantharella.web.utils.security.AuthRole;
+import nc.ird.cantharella.web.utils.security.AuthRoles;
+
+import org.apache.wicket.MarkupContainer;
+import org.apache.wicket.extensions.ajax.markup.html.repeater.data.table.AjaxFallbackDefaultDataTable;
+import org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator;
+import org.apache.wicket.extensions.markup.html.repeater.data.table.DataTable;
+import org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn;
+import org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn;
+import org.apache.wicket.markup.html.WebMarkupContainer;
+import org.apache.wicket.markup.html.link.Link;
+import org.apache.wicket.markup.repeater.Item;
+import org.apache.wicket.model.IModel;
+import org.apache.wicket.model.Model;
+
+@AuthRoles( { AuthRole.ADMIN, AuthRole.USER })
+public class ListMoleculesPage extends TemplatePage {
+
+ public ListMoleculesPage() {
+ super(ListMoleculesPage.class);
+
+ final CallerPage currentPage = new CallerPage(ListLotsPage.class);
+
+ add(new Link<Void>(getResource() + ".NewMolecule") {
+ @Override
+ public void onClick() {
+ setResponsePage(new ManageMoleculePage(currentPage));
+ }
+ });
+
+ // On englobe le "DataView" dans un composant neutre que l'on pourra
+ // rafraichir quand la liste évoluera
+ final MarkupContainer moleculesRefresh = new WebMarkupContainer(getResource() + ".Molecules.Refresh");
+ moleculesRefresh.setOutputMarkupId(true);
+ add(moleculesRefresh);
+
+ // Liste des molecules
+ final List<Molecule> molecules = new ArrayList<Molecule>();
+
+ LoadableDetachableSortableListDataProvider<Molecule> moleculesDataProvider = new LoadableDetachableSortableListDataProvider<Molecule>(
+ molecules, getSession().getLocale());
+
+ List<IColumn<Molecule>> columns = new ArrayList<IColumn<Molecule>>();
+
+ columns.add(new LinkableImagePropertyColumn<Molecule>("images/read.png", getString("Read"), getString("Read")) {
+ @Override
+ public void onClick(Item<ICellPopulator<Molecule>> item, String componentId, IModel<Molecule> model) {
+ setResponsePage(new ReadMoleculePage(model.getObject().getIdMolecule(), currentPage));
+ }
+ });
+ columns.add(new LinkPropertyColumn<Molecule>(new Model<String>(getString("Molecule.idMolecule")), "idMolecule", "idMolecule",
+ getString("Read")) {
+ @Override
+ public void onClick(Item<ICellPopulator<Molecule>> item, String componentId, IModel<Molecule> model) {
+ setResponsePage(new ReadLotPage(model.getObject().getIdMolecule(), currentPage));
+ }
+ });
+
+ columns.add(new PropertyColumn<Molecule>(new Model<String>(getString("Molecule.nomCommun")), "nomCommun",
+ "nomCommun"));
+ columns.add(new PropertyColumn<Molecule>(new Model<String>(getString("Molecule.familleChimique")), "familleChimique",
+ "familleChimique"));
+ columns.add(new PropertyColumn<Molecule>(new Model<String>(getString("Molecule.formuleDevMol")), "formuleDevMol",
+ "formuleDevMol"));
+ columns.add(new PropertyColumn<Molecule>(new Model<String>(getString("Molecule.nomIupca")), "nomIupca",
+ "nomIupca"));
+ columns.add(new PropertyColumn<Molecule>(new Model<String>(getString("Molecule.formuleBrute")), "formuleBrute",
+ "formuleBrute"));
+ columns.add(new PropertyColumn<Molecule>(new Model<String>(getString("Molecule.masseMolaire")), "masseMolaire",
+ "masseMolaire"));
+ columns.add(new PropertyColumn<Molecule>(new Model<String>(getString("Molecule.nouvMolecul")), "nouvMolecul",
+ "nouvMolecul"));
+ columns.add(new PropertyColumn<Molecule>(new Model<String>(getString("Molecule.campagne")), "campagne",
+ "campagne"));
+ columns.add(new PropertyColumn<Molecule>(new Model<String>(getString("Molecule.identifieePar")), "identifieePar",
+ "identifieePar"));
+ columns.add(new PropertyColumn<Molecule>(new Model<String>(getString("Molecule.publiOrigine")), "publiOrigine",
+ "publiOrigine"));
+ columns.add(new PropertyColumn<Molecule>(new Model<String>(getString("Molecule.complement")), "complement",
+ "complement"));
+
+ final DataTable<Molecule> moleculesDataTable = new AjaxFallbackDefaultDataTable<Molecule>("ListMoleculesPage.Molecules", columns,
+ moleculesDataProvider, WebContext.ROWS_PER_PAGE);
+ moleculesRefresh.add(moleculesDataTable);
+ }
+}
Property changes on: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/molecule/ListMoleculesPage.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/molecule/ManageMoleculePage.html
===================================================================
--- trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/molecule/ManageMoleculePage.html (rev 0)
+++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/molecule/ManageMoleculePage.html 2013-01-03 17:10:01 UTC (rev 44)
@@ -0,0 +1,102 @@
+<!--
+ #%L
+ Cantharella :: Web
+ $Id:$
+ $HeadURL:$
+ %%
+ Copyright (C) 2009 - 2013 IRD (Institut de Recherche pour le Developpement) and by respective authors (see below)
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+ #L%
+ -->
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd">
+<body>
+<wicket:extend>
+
+ <form wicket:id="Form">
+
+ <div class="property">
+ <label for="Molecule.nomCommun"><wicket:message key="Molecule.nomCommun" /></label>
+ <input type="text" id="Molecule.nomCommun" wicket:id="Molecule.nomCommun" />
+ </div>
+
+ <div class="property">
+ <label for="Molecule.familleChimique"><wicket:message key="Molecule.familleChimique" /></label>
+ <input type="text" id="Molecule.familleChimique" wicket:id="Molecule.familleChimique" />
+ </div>
+
+ <div class="property">
+ <label for="Molecule.formuleDevMol"><wicket:message key="Molecule.formuleDevMol" /></label>
+ <input type="text" id="Molecule.formuleDevMol" wicket:id="Molecule.formuleDevMol" />
+ </div>
+
+ <div class="property">
+ <label for="Molecule.nomIupca"><wicket:message key="Molecule.nomIupca" /></label>
+ <input type="text" id="Molecule.nomIupca" wicket:id="Molecule.nomIupca" />
+ </div>
+
+ <div class="property required">
+ <label for="Molecule.formuleBrute"><wicket:message key="Molecule.formuleBrute" /></label>
+ <input type="text" id="Molecule.formuleBrute" wicket:id="Molecule.formuleBrute" />
+ </div>
+
+ <div class="property">
+ <label for="Molecule.masseMolaire"><wicket:message key="Molecule.masseMolaire" /></label>
+ <input type="text" id="Molecule.masseMolaire" wicket:id="Molecule.masseMolaire" />
+ </div>
+
+ <div class="property">
+ <label for="Molecule.nouvMolecul"><wicket:message key="Molecule.nouvMolecul" /></label>
+ <input type="checkbox" id="Molecule.nouvMolecul" wicket:id="Molecule.nouvMolecul" />
+ </div>
+
+ <div class="property required">
+ <label for="Molecule.campagne"><wicket:message key="Molecule.campagne" /></label>
+ <select id="Molecule.campagne" wicket:id="Molecule.campagne" />
+ <a wicket:id="NewCampagne" class="add"><wicket:message key="ListCampagnesPage.NewCampagne" /></a>
+ </div>
+
+ <div class="property">
+ <label for="Molecule.identifieePar"><wicket:message key="Molecule.identifieePar" /></label>
+ <input type="text" id="Molecule.identifieePar" wicket:id="Molecule.identifieePar" />
+ </div>
+
+ <div class="property">
+ <label for="Molecule.publiOrigine"><wicket:message key="Molecule.publiOrigine" /></label>
+ <textarea id="Molecule.publiOrigine" wicket:id="Molecule.publiOrigine"></textarea>
+ </div>
+
+ <div class="property">
+ <label for="Molecule.complement"><wicket:message key="Molecule.complement" /></label>
+ <textarea id="Molecule.complement" wicket:id="Molecule.complement"></textarea>
+ </div>
+
+ <div class="property required">
+ <label for="Molecule.createur"><wicket:message key="Molecule.createur" /></label>
+ <input type="text" id="Molecule.createur" wicket:id="Molecule.createur" disabled="disabled"/>
+ </div>
+
+ <div class="actions">
+ <input type="submit" wicket:message="value:Submit" wicket:id="Create" />
+ <input type="submit" wicket:message="value:Submit" wicket:id="Update" />
+ <input type="submit" wicket:message="value:Delete" wicket:id="Delete" class="warning" />
+ <a wicket:id="Cancel"><wicket:message key="Cancel" /></a>
+ </div>
+ </form>
+
+</wicket:extend>
+</body>
+</html>
\ No newline at end of file
Added: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/molecule/ManageMoleculePage.java
===================================================================
--- trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/molecule/ManageMoleculePage.java (rev 0)
+++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/molecule/ManageMoleculePage.java 2013-01-03 17:10:01 UTC (rev 44)
@@ -0,0 +1,311 @@
+/*
+ * #%L
+ * Cantharella :: Web
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2009 - 2013 IRD (Institut de Recherche pour le Developpement) and by respective authors (see below)
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+package nc.ird.cantharella.web.pages.domain.molecule;
+
+import java.util.List;
+
+import nc.ird.cantharella.data.exceptions.DataConstraintException;
+import nc.ird.cantharella.data.exceptions.DataNotFoundException;
+import nc.ird.cantharella.data.exceptions.UnexpectedException;
+import nc.ird.cantharella.data.model.Campagne;
+import nc.ird.cantharella.data.model.Molecule;
+import nc.ird.cantharella.data.validation.utils.ModelValidator;
+import nc.ird.cantharella.service.services.CampagneService;
+import nc.ird.cantharella.service.services.MoleculeService;
+import nc.ird.cantharella.web.pages.TemplatePage;
+import nc.ird.cantharella.web.pages.domain.campagne.ManageCampagnePage;
+import nc.ird.cantharella.web.utils.CallerPage;
+import nc.ird.cantharella.web.utils.behaviors.JSConfirmationBehavior;
+import nc.ird.cantharella.web.utils.forms.SubmittableButton;
+import nc.ird.cantharella.web.utils.forms.SubmittableButtonEvents;
+import nc.ird.cantharella.web.utils.security.AuthRole;
+import nc.ird.cantharella.web.utils.security.AuthRoles;
+import nc.ird.module.utils.LogTools;
+
+import org.apache.commons.lang3.BooleanUtils;
+import org.apache.commons.logging.Log;
+import org.apache.wicket.ajax.AjaxRequestTarget;
+import org.apache.wicket.ajax.markup.html.form.AjaxSubmitLink;
+import org.apache.wicket.markup.html.form.Button;
+import org.apache.wicket.markup.html.form.CheckBox;
+import org.apache.wicket.markup.html.form.DropDownChoice;
+import org.apache.wicket.markup.html.form.Form;
+import org.apache.wicket.markup.html.form.TextArea;
+import org.apache.wicket.markup.html.form.TextField;
+import org.apache.wicket.markup.html.link.Link;
+import org.apache.wicket.model.IModel;
+import org.apache.wicket.model.Model;
+import org.apache.wicket.model.PropertyModel;
+import org.apache.wicket.spring.injection.annot.SpringBean;
+
+/**
+ * Gestion des lots
+ * @author Mickael Tricot
+ * @author Adrien Cheype
+ */
+@AuthRoles({ AuthRole.USER, AuthRole.ADMIN })
+public final class ManageMoleculePage extends TemplatePage {
+
+ /** Action : create */
+ private static final String ACTION_CREATE = "Create";
+
+ /** Action : delete */
+ public static final String ACTION_DELETE = "Delete";
+
+ /** Action : update */
+ private static final String ACTION_UPDATE = "Update";
+
+ /** Logger */
+ private static final Log LOG = LogTools.getLog();
+
+ /** Campagnes */
+ private final List<Campagne> campagnes;
+
+ /** Service : campagne */
+ @SpringBean
+ private CampagneService campagneService;
+
+ /** Modèle : molecule */
+ private final IModel<Molecule> moleculeModel;
+
+ /** Service : molecule */
+ @SpringBean
+ private MoleculeService moleculeService;
+
+ /** Model validateur */
+ @SpringBean(name = "webModelValidator")
+ private ModelValidator validator;
+
+ /** Page appelante */
+ private final CallerPage callerPage;
+
+ /**
+ * Constructeur (mode création)
+ * @param callerPage Page appelante
+ * @param multipleEntry Saisie multiple
+ */
+ public ManageMoleculePage(CallerPage callerPage) {
+ this(null, callerPage);
+ }
+
+ /**
+ * Constructeur. Si idMolecule est null, on créée une nouvelle Molecule. Si idMolecule est renseigné, on édite la molecule
+ * correspondante.
+ * @param idMolecule ID molecule
+ * @param lot Lot
+ * @param callerPage Page appelante
+ * @param multipleEntry Saisie multiple
+ */
+ private ManageMoleculePage(Integer idMolecule, final CallerPage callerPage) {
+ super(ManageMoleculePage.class);
+ this.callerPage = callerPage;
+
+ final CallerPage currentPage = new CallerPage(this);
+
+ // Initialisation du modèle
+ try {
+ moleculeModel = new Model<Molecule>(idMolecule == null ? new Molecule() : moleculeService.loadMolecule(idMolecule));
+ } catch (DataNotFoundException e) {
+ LOG.error(e.getMessage(), e);
+ throw new UnexpectedException(e);
+ }
+
+ boolean createMode = idMolecule == null;
+ if (createMode) {
+ moleculeModel.getObject().setCreateur(getSession().getUtilisateur());
+ }
+
+ // Initialisation des listes
+ campagnes = campagneService.listCampagnes(getSession().getUtilisateur());
+
+ /*if (lot != null) {
+ // qd saisie multiple avec préremplissage, hack nécessaire afin d'avoir dans le model le même objet que
+ // celui de la liste de choix (sinon comme les objets viennent de sessions hibernate différentes, on n'a pas
+ // l'égalité entre les objets)
+ lotModel.getObject().setCampagne(
+ CollectionTools.findWithValue(campagnes, "idCampagne", AccessType.GETTER, lotModel.getObject()
+ .getCampagne().getIdCampagne()));
+ // normalement pas nul car un bean campagne (le modèle donné en l'occurence) bien formé comporte une
+ // campagne de renseigné
+ if (lotModel.getObject().getCampagne() != null) {
+ List<Station> stations = lotModel.getObject().getCampagne().getStations();
+ lotModel.getObject().setStation(
+ CollectionTools.findWithValue(stations, "idStation", AccessType.GETTER, lotModel.getObject()
+ .getStation().getIdStation()));
+ }
+ if (lotModel.getObject().getPartie() != null) {
+ lotModel.getObject().setPartie(
+ CollectionTools.findWithValue(parties, "idPartie", AccessType.GETTER, lotModel.getObject()
+ .getPartie().getIdPartie()));
+ }
+ } else if (idLot != null) {
+
+ }*/
+
+ final Form<Void> formView = new Form<Void>("Form");
+ formView.add(new TextField<String>("Molecule.nomCommun", new PropertyModel<String>(moleculeModel, "nomCommun")));
+ formView.add(new TextField<String>("Molecule.familleChimique", new PropertyModel<String>(moleculeModel, "familleChimique")));
+ formView.add(new TextField<String>("Molecule.formuleDevMol", new PropertyModel<String>(moleculeModel, "formuleDevMol")));
+ formView.add(new TextField<String>("Molecule.nomIupca", new PropertyModel<String>(moleculeModel, "nomIupca")));
+ formView.add(new TextField<String>("Molecule.formuleBrute", new PropertyModel<String>(moleculeModel, "formuleBrute")));
+ formView.add(new TextField<String>("Molecule.masseMolaire", new PropertyModel<String>(moleculeModel, "masseMolaire")));
+ formView.add(new CheckBox("Molecule.nouvMolecul", new PropertyModel<Boolean>(moleculeModel, "nouvMolecul")));
+ formView.add(new TextField<String>("Molecule.identifieePar", new PropertyModel<String>(moleculeModel, "identifieePar")) {
+ @Override
+ public boolean isVisible() {
+ return BooleanUtils.isTrue(moleculeModel.getObject().getNouvMolecul());
+ }
+ });
+
+ DropDownChoice<Campagne> campagnesInput = new DropDownChoice<Campagne>("Molecule.campagne",
+ new PropertyModel<Campagne>(moleculeModel, "campagne"), campagnes) {
+ @Override
+ public boolean isVisible() {
+ return BooleanUtils.isTrue(moleculeModel.getObject().getNouvMolecul());
+ }
+ };
+ campagnesInput.setNullValid(false);
+ formView.add(campagnesInput);
+
+ // Action : création d'une nouvelle campagne
+ // ajaxSubmitLink permet de sauvegarder l'état du formulaire
+ formView.add(new AjaxSubmitLink("NewCampagne") {
+ @Override
+ protected void onSubmit(AjaxRequestTarget arg0, Form<?> arg1) {
+ setResponsePage(new ManageCampagnePage(currentPage, false));
+ }
+
+ // si erreur, le formulaire est également enregistré puis la redirection effectuée
+ @Override
+ protected void onError(AjaxRequestTarget target, Form<?> form) {
+ setResponsePage(new ManageCampagnePage(currentPage, false));
+ }
+ @Override
+ public boolean isVisible() {
+ return BooleanUtils.isTrue(moleculeModel.getObject().getNouvMolecul());
+ }
+ });
+
+ formView.add(new TextArea<String>("Molecule.publiOrigine", new PropertyModel<String>(moleculeModel, "publiOrigine")) {
+ @Override
+ public boolean isVisible() {
+ return BooleanUtils.isTrue(moleculeModel.getObject().getNouvMolecul());
+ }
+ });
+ formView.add(new TextArea<String>("Molecule.complement", new PropertyModel<String>(moleculeModel, "complement")));
+
+
+ // Créateur en lecture seule
+ formView.add(new TextField<String>("Molecule.createur", new PropertyModel<String>(moleculeModel, "createur"))
+ .setEnabled(false));
+
+ // Action : création du lot
+ Button createButton = new SubmittableButton(ACTION_CREATE, new SubmittableButtonEvents() {
+ @Override
+ public void onProcess() throws DataConstraintException {
+ moleculeService.createMolecule(moleculeModel.getObject());
+ }
+
+ @Override
+ public void onSuccess() {
+ successNextPage(ACTION_CREATE);
+ redirect();
+ }
+
+ @Override
+ public void onValidate() {
+ validateModel();
+ }
+ });
+ createButton.setVisibilityAllowed(createMode);
+ formView.add(createButton);
+
+ // Action : mise à jour du lot
+ Button updateButton = new SubmittableButton(ACTION_UPDATE, new SubmittableButtonEvents() {
+ @Override
+ public void onProcess() throws DataConstraintException {
+ moleculeService.updateMolecule(moleculeModel.getObject());
+ }
+
+ @Override
+ public void onSuccess() {
+ successNextPage(ACTION_UPDATE);
+ callerPage.responsePage((TemplatePage) getPage());
+ }
+
+ @Override
+ public void onValidate() {
+ validateModel();
+ }
+ });
+ updateButton.setVisibilityAllowed(!createMode);
+ formView.add(updateButton);
+
+ // Action : suppression du lot
+ Button deleteButton = new SubmittableButton(ACTION_DELETE, new SubmittableButtonEvents() {
+ @Override
+ public void onProcess() throws DataConstraintException {
+ moleculeService.deleteMolecule(moleculeModel.getObject());
+ }
+
+ @Override
+ public void onSuccess() {
+ successNextPage(ACTION_DELETE);
+ callerPage.responsePage((TemplatePage) getPage());
+ }
+ });
+ deleteButton.setVisibilityAllowed(!createMode);
+ deleteButton.add(new JSConfirmationBehavior(getString("Confirm")));
+ deleteButton.setDefaultFormProcessing(false);
+ formView.add(deleteButton);
+
+ formView.add(new Link<Void>("Cancel") {
+ // Cas où le formulaire est annulé
+ @Override
+ public void onClick() {
+ callerPage.responsePage((TemplatePage) this.getPage());
+ }
+ });
+
+ add(formView);
+ }
+
+ /**
+ * Redirection vers une autre page. Cas où le formulaire est validé
+ */
+ private void redirect() {
+ if (callerPage != null) {
+ callerPage.responsePage(this);
+ }
+ }
+
+ /**
+ * Validate model
+ */
+ private void validateModel() {
+ if (moleculeModel.getObject().getCreateur() == null) {
+ moleculeModel.getObject().setCreateur(getSession().getUtilisateur());
+ }
+ addValidationErrors(validator.validate(moleculeModel.getObject(), getSession().getLocale()));
+ }
+}
Property changes on: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/molecule/ManageMoleculePage.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/molecule/ReadMoleculePage.html
===================================================================
--- trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/molecule/ReadMoleculePage.html (rev 0)
+++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/molecule/ReadMoleculePage.html 2013-01-03 17:10:01 UTC (rev 44)
@@ -0,0 +1,152 @@
+<!--
+ #%L
+ Cantharella :: Web
+ $Id:$
+ $HeadURL:$
+ %%
+ Copyright (C) 2009 - 2013 IRD (Institut de Recherche pour le Developpement) and by respective authors (see below)
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+ #L%
+ -->
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd">
+<body>
+<wicket:extend>
+ <div id="sheet">
+ <div class="property">
+ <span class="label"><wicket:message key="Molecule.idMolecule" /></span>
+ <span class="value" wicket:id="Molecule.idMolecule"></span>
+ </div>
+
+ <div class="property">
+ <span class="label"><wicket:message key="Molecule.nomCommun" /></span>
+ <span class="value" wicket:id="Molecule.nomCommun"></span>
+ </div>
+
+ <div class="property">
+ <span class="label"><wicket:message key="Molecule.familleChimique" /></span>
+ <span class="value" wicket:id="Molecule.familleChimique"></span>
+ </div>
+
+ <div class="property">
+ <span class="label"><wicket:message key="Molecule.formuleDevMol" /></span>
+ <span class="value" wicket:id="Molecule.formuleDevMol"></span>
+ </div>
+
+ <div class="property">
+ <span class="label"><wicket:message key="Molecule.nomIupca" /></span>
+ <span class="value" wicket:id="Molecule.nomIupca"></span>
+ </div>
+
+ <div class="property">
+ <span class="label"><wicket:message key="Molecule.formuleBrute" /></span>
+ <span class="value" wicket:id="Molecule.formuleBrute" ></span>
+ </div>
+
+ <div class="property">
+ <span class="label"><wicket:message key="Molecule.masseMolaire" /></span>
+ <span class="value" wicket:id="Molecule.masseMolaire" ></span>
+ </div>
+
+ <div class="property">
+ <span class="label"><wicket:message key="Molecule.nouvMolecul" /></span>
+ <span class="value" wicket:id="Molecule.nouvMolecul" ></span>
+ </div>
+
+ <div class="property">
+ <span class="label"><wicket:message key="Molecule.campagne" /></span>
+ <span class="value" wicket:id="Molecule.campagne" ></span>
+ </div>
+
+ <div class="property">
+ <span class="label"><wicket:message key="Molecule.identifieePar" /></span>
+ <span class="value" wicket:id="Molecule.identifieePar" ></span>
+ </div>
+
+ <div class="property">
+ <span class="label"><wicket:message key="Molecule.publiOrigine" /></span>
+ <span class="value" wicket:id="Molecule.publiOrigine" ></span>
+ </div>
+
+ <div class="property">
+ <span class="label"><wicket:message key="Molecule.complement" /></span>
+ <span class="value" wicket:id="Molecule.complement"></span>
+ </div>
+
+ <div class="property">
+ <span class="label"><wicket:message key="Molecule.createur" /></span>
+ <span class="value" wicket:id="Molecule.createur"></span>
+ </div>
+
+ <fieldset>
+ <legend><wicket:message key="Molecule.produits" /></legend>
+ <!-- <table cellspacing="0" wicket:id="Molecule.produits.Table">
+ <thead>
+ <tr>
+ <th>
+ <wicket:message key="Extrait.typeExtrait" />
+ </th>
+ <th>
+ <wicket:message key="Extrait.ref" />
+ </th>
+ <th>
+ <wicket:message key="Extrait.masseObtenue" />
+ </th>
+ <th>
+ <wicket:message key="Extrait.rendement" />
+ </th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr wicket:id="Molecule.produits.List">
+ <td>
+ <span wicket:id="Extraction.extraits.List.typeExtrait" /><wicket:container wicket:id="Molecule.produits.List.typeExtrait.info"/>
+ </td>
+ <td>
+ <span wicket:id="Extraction.extraits.List.ref" />
+ </td>
+ <td>
+ <span wicket:id="Extraction.extraits.List.masseObtenue" />
+ </td>
+ <td>
+ <span wicket:id="Extraction.extraits.List.rendement" />
+ </td>
+ </tr>
+ </tbody>
+ </table> -->
+ <div class="property" wicket:id="Molecule.produits.noTable">
+ <span class="label"> </span>
+ <span class="value"><wicket:message key="List.none" /></span>
+ </div>
+ </fieldset>
+
+ <form wicket:id="Form">
+ <div class="actions">
+ <a class="edit" wicket:id="ReadMoleculePage.Lot.Update" wicket:message="title:Update">
+ <wicket:message key="Update" />
+ </a>
+
+ <input type="submit" wicket:message="value:Delete" wicket:id="Delete" class="warning" />
+
+ <a wicket:id="ReadMoleculePage.Molecule.Back" wicket:message="title:Back">
+ <wicket:message key="Back" />
+ </a>
+ </div>
+ </form>
+ </div>
+</wicket:extend>
+</body>
+</html>
\ No newline at end of file
Added: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/molecule/ReadMoleculePage.java
===================================================================
--- trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/molecule/ReadMoleculePage.java (rev 0)
+++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/molecule/ReadMoleculePage.java 2013-01-03 17:10:01 UTC (rev 44)
@@ -0,0 +1,37 @@
+/*
+ * #%L
+ * Cantharella :: Web
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2009 - 2013 IRD (Institut de Recherche pour le Developpement) and by respective authors (see below)
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+package nc.ird.cantharella.web.pages.domain.molecule;
+
+import nc.ird.cantharella.web.pages.TemplatePage;
+import nc.ird.cantharella.web.utils.CallerPage;
+import nc.ird.cantharella.web.utils.security.AuthRole;
+import nc.ird.cantharella.web.utils.security.AuthRoles;
+
+@AuthRoles( { AuthRole.ADMIN, AuthRole.USER })
+public class ReadMoleculePage extends TemplatePage {
+
+ public ReadMoleculePage(Integer idMolecule, final CallerPage callerPage) {
+ super(ReadMoleculePage.class);
+ }
+
+}
Property changes on: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/molecule/ReadMoleculePage.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Modified: trunk/cantharella.web/src/main/resources/commons/web_en.properties
===================================================================
--- trunk/cantharella.web/src/main/resources/commons/web_en.properties 2013-01-02 11:06:26 UTC (rev 43)
+++ trunk/cantharella.web/src/main/resources/commons/web_en.properties 2013-01-03 17:10:01 UTC (rev 44)
@@ -191,6 +191,8 @@
ManagePurificationPage.Delete.OK=Purification deleted
ManagePurificationPage.Delete.DataConstraintException=There are data linked to this purification
+ManageMoleculePage=Molecule management
+
ManageTestBioPage=Bioassay management
ManageTestBioPage.Create.OK=Bioassay added
ManageTestBioPage.Create.DataConstraintException=Unidentified error during the creation
@@ -270,6 +272,7 @@
ReadStationPage=Viewing a location
ReadExtractionPage=Viewing an extraction
ReadPurificationPage=Viewing a purification
+ReadMoleculePage=Viewing a molecule
ReadTestBioPage=Viewing a bioassay
SearchPage=Search
Modified: trunk/cantharella.web/src/main/resources/commons/web_fr.properties
===================================================================
--- trunk/cantharella.web/src/main/resources/commons/web_fr.properties 2013-01-02 11:06:26 UTC (rev 43)
+++ trunk/cantharella.web/src/main/resources/commons/web_fr.properties 2013-01-03 17:10:01 UTC (rev 44)
@@ -190,6 +190,8 @@
ManagePurificationPage.Delete.OK=Purification supprimée
ManagePurificationPage.Delete.DataConstraintException=Il existe des données liées à cette purification
+ManageMoleculePage=Gestion d'une molécule
+
ManageTestBioPage=Gestion d'un test biologique
ManageTestBioPage.Create.OK=Test biologique ajouté
ManageTestBioPage.Create.DataConstraintException=Erreur non identifiée lors de la création
@@ -269,6 +271,7 @@
ReadStationPage=Consultation d'une station
ReadExtractionPage=Consultation d'une extraction
ReadPurificationPage=Consultation d'une purification
+ReadMoleculePage=Consultation d'une molécule
ReadTestBioPage=Consultation d'un test biologique
SearchPage=Recherche
1
0
r43 - trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/columns
by echatellier@users.forge.codelutin.com 02 Jan '13
by echatellier@users.forge.codelutin.com 02 Jan '13
02 Jan '13
Author: echatellier
Date: 2013-01-02 12:06:26 +0100 (Wed, 02 Jan 2013)
New Revision: 43
Url: http://forge.codelutin.com/projects/cantharella/repository/revisions/43
Log:
Use ; separator
Modified:
trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/columns/CsvWriter.java
Modified: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/columns/CsvWriter.java
===================================================================
--- trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/columns/CsvWriter.java 2013-01-02 11:05:13 UTC (rev 42)
+++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/columns/CsvWriter.java 2013-01-02 11:06:26 UTC (rev 43)
@@ -4,7 +4,7 @@
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2009 - 2012 IRD (Institut de Recherche pour le Developpement) and by respective authors (see below)
+ * Copyright (C) 2009 - 2013 IRD (Institut de Recherche pour le Developpement) and by respective authors (see below)
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@@ -33,32 +33,37 @@
public class CsvWriter {
private final PrintWriter out;
private boolean first = true;
+
public CsvWriter(OutputStream os) {
- out = new PrintWriter(os);
+ out = new PrintWriter(os);
}
+
public CsvWriter write(Object value) {
- if (!first) {
- out.append(",");
- }
- out.append("\"");
- if (value != null) {
- out.append(value.toString().replace("\"", "\"\"")
- .replace("\n", " "));
- }
- out.append("\"");
- first = false;
- return this;
- }
+ if (!first) {
+ out.append(";");
+ }
+ out.append("\"");
+ if (value != null) {
+ out.append(value.toString().replace("\"", "\"\"")
+ .replace("\n", " "));
+ }
+ out.append("\"");
+ first = false;
+ return this;
+ }
+
public CsvWriter endLine() {
- out.append("\r\n");
- first = true;
- return this;
+ out.append("\r\n");
+ first = true;
+ return this;
}
+
public CsvWriter flush() {
- out.flush();
- return this;
+ out.flush();
+ return this;
}
+
public void close() {
- out.close();
+ out.close();
}
}
1
0
r42 - trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/links
by echatellier@users.forge.codelutin.com 02 Jan '13
by echatellier@users.forge.codelutin.com 02 Jan '13
02 Jan '13
Author: echatellier
Date: 2013-01-02 12:05:13 +0100 (Wed, 02 Jan 2013)
New Revision: 42
Url: http://forge.codelutin.com/projects/cantharella/repository/revisions/42
Log:
Fix compil error
Modified:
trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/links/CsvExportLink.java
Modified: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/links/CsvExportLink.java
===================================================================
--- trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/links/CsvExportLink.java 2013-01-02 10:58:27 UTC (rev 41)
+++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/links/CsvExportLink.java 2013-01-02 11:05:13 UTC (rev 42)
@@ -12,7 +12,6 @@
import org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn;
import org.apache.wicket.markup.html.link.Link;
import org.apache.wicket.request.http.WebResponse;
-import org.aspectj.bridge.AbortException;
public class CsvExportLink<T> extends Link<Void> {
private final DataTable<T> table;
@@ -45,7 +44,6 @@
writer.endLine();
}
writer.close();
- throw new AbortException();
}
private List<ExportableColumn<T>> getExportableColumns() {
1
0
r41 - in trunk: cantharella.data/src/main/java/nc/ird/cantharella/data/model cantharella.data/src/main/java/nc/ird/cantharella/data/model/search cantharella.service/src/main/java/nc/ird/cantharella/service/services cantharella.service/src/main/java/nc/ird/cantharella/service/services/impl cantharella.service/src/test/java/nc/ird/cantharella/service/services cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/search
by echatellier@users.forge.codelutin.com 02 Jan '13
by echatellier@users.forge.codelutin.com 02 Jan '13
02 Jan '13
Author: echatellier
Date: 2013-01-02 11:58:27 +0100 (Wed, 02 Jan 2013)
New Revision: 41
Url: http://forge.codelutin.com/projects/cantharella/repository/revisions/41
Log:
Add createur based security filter
Added:
trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/search/UtilisateurSearchFilter.java
Modified:
trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Extraction.java
trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Lot.java
trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Personne.java
trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Purification.java
trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/ResultatTestBio.java
trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Specimen.java
trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Station.java
trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/TestBio.java
trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Utilisateur.java
trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/services/SearchService.java
trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/services/impl/SearchServiceImpl.java
trunk/cantharella.service/src/test/java/nc/ird/cantharella/service/services/SearchServiceTest.java
trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/search/SearchPage.html
Modified: trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Extraction.java
===================================================================
--- trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Extraction.java 2012-12-29 14:39:13 UTC (rev 40)
+++ trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Extraction.java 2013-01-02 10:58:27 UTC (rev 41)
@@ -4,7 +4,7 @@
* $Id:$
* $HeadURL:$
* %%
- * Copyright (C) 2009 - 2012 IRD (Institut de Recherche pour le Developpement) and by respective authors (see below)
+ * Copyright (C) 2009 - 2013 IRD (Institut de Recherche pour le Developpement) and by respective authors (see below)
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@@ -44,6 +44,7 @@
import nc.ird.cantharella.data.config.DataContext;
import nc.ird.cantharella.data.model.comparators.ExtraitsOfExtractionComp;
+import nc.ird.cantharella.data.model.search.UtilisateurSearchFilter;
import nc.ird.cantharella.data.model.utils.AbstractModel;
import org.apache.commons.beanutils.BeanComparator;
@@ -54,6 +55,8 @@
import org.hibernate.search.annotations.Analyze;
import org.hibernate.search.annotations.ContainedIn;
import org.hibernate.search.annotations.Field;
+import org.hibernate.search.annotations.FullTextFilterDef;
+import org.hibernate.search.annotations.FullTextFilterDefs;
import org.hibernate.search.annotations.Index;
import org.hibernate.search.annotations.Indexed;
import org.hibernate.search.annotations.IndexedEmbedded;
@@ -67,6 +70,9 @@
*/
@Entity
@Indexed
+@FullTextFilterDefs( {
+ @FullTextFilterDef(name = "utilisateur-Extraction", impl = UtilisateurSearchFilter.class)
+})
public class Extraction extends AbstractModel implements Comparable<Extraction> {
/** Id de l'extraction */
@@ -116,6 +122,7 @@
/** Créateur */
@NotNull
@ManyToOne(fetch = FetchType.LAZY, optional = false)
+ @IndexedEmbedded
private Personne createur;
/** Extraits produits par l'extraction */
Modified: trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Lot.java
===================================================================
--- trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Lot.java 2012-12-29 14:39:13 UTC (rev 40)
+++ trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Lot.java 2013-01-02 10:58:27 UTC (rev 41)
@@ -4,7 +4,7 @@
* $Id:$
* $HeadURL:$
* %%
- * Copyright (C) 2009 - 2012 IRD (Institut de Recherche pour le Developpement) and by respective authors (see below)
+ * Copyright (C) 2009 - 2013 IRD (Institut de Recherche pour le Developpement) and by respective authors (see below)
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@@ -45,13 +45,15 @@
import javax.validation.constraints.Past;
import nc.ird.cantharella.data.config.DataContext;
+import nc.ird.cantharella.data.model.search.UtilisateurSearchFilter;
import nc.ird.cantharella.data.model.utils.AbstractModel;
import org.apache.commons.beanutils.BeanComparator;
import org.hibernate.annotations.Type;
import org.hibernate.search.annotations.Analyze;
-import org.hibernate.search.annotations.DocumentId;
import org.hibernate.search.annotations.Field;
+import org.hibernate.search.annotations.FullTextFilterDef;
+import org.hibernate.search.annotations.FullTextFilterDefs;
import org.hibernate.search.annotations.Index;
import org.hibernate.search.annotations.Indexed;
import org.hibernate.search.annotations.IndexedEmbedded;
@@ -68,6 +70,9 @@
@Table
@Indexed
@Embeddable
+@FullTextFilterDefs( {
+ @FullTextFilterDef(name = "utilisateur-Lot", impl = UtilisateurSearchFilter.class)
+})
public class Lot extends AbstractModel implements Comparable<Lot> {
/** ID */
@@ -96,6 +101,7 @@
/** createur */
@NotNull
@ManyToOne(fetch = FetchType.LAZY, optional = false)
+ @IndexedEmbedded
private Personne createur;
/** Date */
Modified: trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Personne.java
===================================================================
--- trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Personne.java 2012-12-29 14:39:13 UTC (rev 40)
+++ trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Personne.java 2013-01-02 10:58:27 UTC (rev 41)
@@ -4,7 +4,7 @@
* $Id:$
* $HeadURL:$
* %%
- * Copyright (C) 2009 - 2012 IRD (Institut de Recherche pour le Developpement) and by respective authors (see below)
+ * Copyright (C) 2009 - 2013 IRD (Institut de Recherche pour le Developpement) and by respective authors (see below)
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@@ -272,7 +272,7 @@
* @param campagnesDroits campagnesDroits
*/
public void setCampagnesDroits(Map<Campagne, CampagnePersonneDroits> campagnesDroits) {
- this.campagnesDroits = campagnesDroits;
+ this.campagnesDroits = campagnesDroits;
}
/**
Modified: trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Purification.java
===================================================================
--- trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Purification.java 2012-12-29 14:39:13 UTC (rev 40)
+++ trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Purification.java 2013-01-02 10:58:27 UTC (rev 41)
@@ -4,7 +4,7 @@
* $Id:$
* $HeadURL:$
* %%
- * Copyright (C) 2009 - 2012 IRD (Institut de Recherche pour le Developpement) and by respective authors (see below)
+ * Copyright (C) 2009 - 2013 IRD (Institut de Recherche pour le Developpement) and by respective authors (see below)
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@@ -45,6 +45,7 @@
import nc.ird.cantharella.data.config.DataContext;
import nc.ird.cantharella.data.model.comparators.FractionsOfPurificationComp;
+import nc.ird.cantharella.data.model.search.UtilisateurSearchFilter;
import nc.ird.cantharella.data.model.utils.AbstractModel;
import nc.ird.module.utils.AssertTools;
@@ -55,6 +56,8 @@
import org.hibernate.annotations.Type;
import org.hibernate.search.annotations.Analyze;
import org.hibernate.search.annotations.Field;
+import org.hibernate.search.annotations.FullTextFilterDef;
+import org.hibernate.search.annotations.FullTextFilterDefs;
import org.hibernate.search.annotations.Index;
import org.hibernate.search.annotations.Indexed;
import org.hibernate.search.annotations.IndexedEmbedded;
@@ -68,6 +71,9 @@
*/
@Entity
@Indexed
+@FullTextFilterDefs( {
+ @FullTextFilterDef(name = "utilisateur-Purification", impl = UtilisateurSearchFilter.class)
+})
public class Purification extends AbstractModel implements Comparable<Purification> {
/** Logger */
@@ -133,6 +139,7 @@
/** Créateur */
@NotNull
@ManyToOne(fetch = FetchType.LAZY, optional = false)
+ @IndexedEmbedded
private Personne createur;
/** Fractions produites par la purification */
Modified: trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/ResultatTestBio.java
===================================================================
--- trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/ResultatTestBio.java 2012-12-29 14:39:13 UTC (rev 40)
+++ trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/ResultatTestBio.java 2013-01-02 10:58:27 UTC (rev 41)
@@ -4,7 +4,7 @@
* $Id:$
* $HeadURL:$
* %%
- * Copyright (C) 2009 - 2012 IRD (Institut de Recherche pour le Developpement) and by respective authors (see below)
+ * Copyright (C) 2009 - 2013 IRD (Institut de Recherche pour le Developpement) and by respective authors (see below)
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@@ -37,6 +37,8 @@
import javax.validation.constraints.NotNull;
import nc.ird.cantharella.data.config.DataContext;
+import nc.ird.cantharella.data.model.search.ProduitBridge;
+import nc.ird.cantharella.data.model.search.UtilisateurSearchFilter;
import nc.ird.cantharella.data.model.utils.AbstractModel;
import nc.ird.cantharella.data.validation.CollectionUniqueField;
import nc.ird.module.utils.AssertTools;
@@ -44,6 +46,9 @@
import org.apache.commons.beanutils.BeanComparator;
import org.apache.commons.collections.comparators.ComparatorChain;
import org.hibernate.annotations.Index;
+import org.hibernate.search.annotations.FieldBridge;
+import org.hibernate.search.annotations.FullTextFilterDef;
+import org.hibernate.search.annotations.FullTextFilterDefs;
import org.hibernate.search.annotations.Indexed;
import org.hibernate.search.annotations.IndexedEmbedded;
import org.hibernate.validator.constraints.Length;
@@ -52,11 +57,17 @@
/**
* Modèle : Résultat issue d'un test biologique
*
+ * Custom indexing of polymorphic produit is based on example at:
+ * http://blog.pfa-labs.com/2009/03/building-custom-entity-bridge-with.html
+ *
* @author Adrien Cheype
*/
@Entity
@CollectionUniqueField(fieldName = "repere", pathToCollection = "testBio.resultats")
@Indexed
+@FullTextFilterDefs( {
+ @FullTextFilterDef(name = "utilisateur-ResultatTestBio", impl = UtilisateurSearchFilter.class)
+})
public class ResultatTestBio extends AbstractModel implements Cloneable,
Comparable<ResultatTestBio> {
Modified: trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Specimen.java
===================================================================
--- trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Specimen.java 2012-12-29 14:39:13 UTC (rev 40)
+++ trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Specimen.java 2013-01-02 10:58:27 UTC (rev 41)
@@ -4,7 +4,7 @@
* $Id:$
* $HeadURL:$
* %%
- * Copyright (C) 2009 - 2012 IRD (Institut de Recherche pour le Developpement) and by respective authors (see below)
+ * Copyright (C) 2009 - 2013 IRD (Institut de Recherche pour le Developpement) and by respective authors (see below)
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@@ -39,6 +39,7 @@
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
+import nc.ird.cantharella.data.model.search.UtilisateurSearchFilter;
import nc.ird.cantharella.data.model.utils.AbstractModel;
import org.apache.commons.beanutils.BeanComparator;
@@ -46,6 +47,8 @@
import org.hibernate.search.annotations.Analyze;
import org.hibernate.search.annotations.DocumentId;
import org.hibernate.search.annotations.Field;
+import org.hibernate.search.annotations.FullTextFilterDef;
+import org.hibernate.search.annotations.FullTextFilterDefs;
import org.hibernate.search.annotations.Index;
import org.hibernate.search.annotations.Indexed;
import org.hibernate.search.annotations.IndexedEmbedded;
@@ -62,6 +65,9 @@
@Table
@Indexed
@Embeddable
+@FullTextFilterDefs( {
+ @FullTextFilterDef(name = "utilisateur-Specimen", impl = UtilisateurSearchFilter.class)
+})
public class Specimen extends AbstractModel implements Comparable<Specimen> {
/**
@@ -159,6 +165,7 @@
/** Créateur */
@NotNull
@ManyToOne(fetch = FetchType.LAZY, optional = false)
+ @IndexedEmbedded
private Personne createur;
/** {@inheritDoc} */
Modified: trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Station.java
===================================================================
--- trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Station.java 2012-12-29 14:39:13 UTC (rev 40)
+++ trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Station.java 2013-01-02 10:58:27 UTC (rev 41)
@@ -4,7 +4,7 @@
* $Id:$
* $HeadURL:$
* %%
- * Copyright (C) 2009 - 2012 IRD (Institut de Recherche pour le Developpement) and by respective authors (see below)
+ * Copyright (C) 2009 - 2013 IRD (Institut de Recherche pour le Developpement) and by respective authors (see below)
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@@ -38,6 +38,7 @@
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
+import nc.ird.cantharella.data.model.search.UtilisateurSearchFilter;
import nc.ird.cantharella.data.model.utils.AbstractModel;
import nc.ird.cantharella.data.validation.CountryCode;
import nc.ird.cantharella.data.validation.Latitude;
@@ -49,7 +50,11 @@
import org.hibernate.annotations.Type;
import org.hibernate.search.annotations.Analyze;
import org.hibernate.search.annotations.Field;
+import org.hibernate.search.annotations.FullTextFilterDef;
+import org.hibernate.search.annotations.FullTextFilterDefs;
import org.hibernate.search.annotations.Index;
+import org.hibernate.search.annotations.Indexed;
+import org.hibernate.search.annotations.IndexedEmbedded;
import org.hibernate.search.annotations.Store;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.NotEmpty;
@@ -62,7 +67,11 @@
@Entity
@Table
@AccessType("field")
+@Indexed
@Embeddable
+@FullTextFilterDefs( {
+ @FullTextFilterDef(name = "utilisateur-Station", impl = UtilisateurSearchFilter.class)
+})
public class Station extends AbstractModel implements Cloneable, Comparable<Station> {
/** ID */
@@ -81,6 +90,7 @@
@NotNull
@Length(min = 2, max = 2)
@CountryCode
+ @Field(index=Index.YES, analyze=Analyze.YES, store=Store.YES)
private String codePays;
/** Complément */
@@ -91,10 +101,12 @@
/** Créateur */
@NotNull
@ManyToOne(fetch = FetchType.LAZY, optional = false)
+ @IndexedEmbedded
private Personne createur;
/** Localité */
@Length(max = LENGTH_MEDIUM_TEXT)
+ @Field(index=Index.YES, analyze=Analyze.YES, store=Store.YES)
private String localite;
/** Latitude */
Modified: trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/TestBio.java
===================================================================
--- trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/TestBio.java 2012-12-29 14:39:13 UTC (rev 40)
+++ trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/TestBio.java 2013-01-02 10:58:27 UTC (rev 41)
@@ -4,7 +4,7 @@
* $Id:$
* $HeadURL:$
* %%
- * Copyright (C) 2009 - 2012 IRD (Institut de Recherche pour le Developpement) and by respective authors (see below)
+ * Copyright (C) 2009 - 2013 IRD (Institut de Recherche pour le Developpement) and by respective authors (see below)
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@@ -56,8 +56,12 @@
import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;
import org.hibernate.annotations.Type;
+import org.hibernate.search.annotations.Analyze;
import org.hibernate.search.annotations.ContainedIn;
+import org.hibernate.search.annotations.Field;
+import org.hibernate.search.annotations.Index;
import org.hibernate.search.annotations.IndexedEmbedded;
+import org.hibernate.search.annotations.Store;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.NotEmpty;
@@ -78,6 +82,7 @@
@Length(max = LENGTH_MEDIUM_TEXT)
@Column(unique = true)
@NotEmpty
+ @Field(index=Index.YES, analyze=Analyze.YES, store=Store.YES)
private String ref;
/** Manipulateur */
Modified: trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Utilisateur.java
===================================================================
--- trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Utilisateur.java 2012-12-29 14:39:13 UTC (rev 40)
+++ trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Utilisateur.java 2013-01-02 10:58:27 UTC (rev 41)
@@ -4,7 +4,7 @@
* $Id:$
* $HeadURL:$
* %%
- * Copyright (C) 2009 - 2012 IRD (Institut de Recherche pour le Developpement) and by respective authors (see below)
+ * Copyright (C) 2009 - 2013 IRD (Institut de Recherche pour le Developpement) and by respective authors (see below)
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@@ -24,6 +24,7 @@
import java.util.Date;
+import javax.persistence.Embeddable;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
@@ -46,6 +47,7 @@
*/
@Entity
@Table
+@Embeddable
public class Utilisateur extends Personne {
/**
Added: trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/search/UtilisateurSearchFilter.java
===================================================================
--- trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/search/UtilisateurSearchFilter.java (rev 0)
+++ trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/search/UtilisateurSearchFilter.java 2013-01-02 10:58:27 UTC (rev 41)
@@ -0,0 +1,102 @@
+/*
+ * #%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.search;
+
+import java.io.IOException;
+
+import nc.ird.cantharella.data.model.Utilisateur;
+import nc.ird.cantharella.data.model.Utilisateur.TypeDroit;
+import nc.ird.module.utils.LogTools;
+
+import org.apache.commons.logging.Log;
+import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.index.Term;
+import org.apache.lucene.index.TermDocs;
+import org.apache.lucene.search.DocIdSet;
+import org.apache.lucene.search.Filter;
+import org.apache.lucene.util.OpenBitSet;
+import org.hibernate.search.annotations.Key;
+import org.hibernate.search.filter.FilterKey;
+import org.hibernate.search.filter.StandardFilterKey;
+
+/**
+ * Filtre lucene utilisé par hibernate search pour filtrer les resultats
+ * suivant l'utilisateur connecté.
+ *
+ * @author echatellier
+ */
+public class UtilisateurSearchFilter extends Filter {
+
+ /** serialVersionUID.*/
+ private static final long serialVersionUID = 5599764509232575010L;
+
+ /** Logger */
+ private static final Log LOG = LogTools.getLog();
+
+ /** Utilisateur performing the query. */
+ protected Utilisateur utilisateur;
+
+ public Utilisateur getUtilisateur() {
+ return utilisateur;
+ }
+
+ public void setUtilisateur(Utilisateur utilisateur) {
+ this.utilisateur = utilisateur;
+ }
+
+ @Key
+ public FilterKey getKey() {
+ StandardFilterKey key = new StandardFilterKey();
+ key.addParameter( utilisateur );
+ return key;
+ }
+
+ @Override
+ public DocIdSet getDocIdSet(IndexReader reader) throws IOException {
+ OpenBitSet bitSet = new OpenBitSet(reader.maxDoc());
+
+ if (utilisateur.getTypeDroit() == TypeDroit.ADMINISTRATEUR) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Filtering term docs for administrator");
+ }
+ // all docs
+ for (int idx=0; idx < bitSet.length(); idx++) {
+ if (!reader.isDeleted(idx)) {
+ bitSet.set(idx);
+ }
+ }
+ } else {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Filtering term docs for utilisateur");
+ }
+ // only docs matching terms
+ TermDocs termDocs = reader.termDocs(new Term("createur.idPersonne", String
+ .valueOf(utilisateur.getIdPersonne())));
+ while (termDocs.next()) {
+ bitSet.set(termDocs.doc());
+ }
+ }
+
+ return bitSet;
+ }
+}
Property changes on: trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/search/UtilisateurSearchFilter.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Modified: trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/services/SearchService.java
===================================================================
--- trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/services/SearchService.java 2012-12-29 14:39:13 UTC (rev 40)
+++ trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/services/SearchService.java 2013-01-02 10:58:27 UTC (rev 41)
@@ -4,7 +4,7 @@
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2009 - 2012 IRD (Institut de Recherche pour le Developpement) and by respective authors (see below)
+ * Copyright (C) 2009 - 2013 IRD (Institut de Recherche pour le Developpement) and by respective authors (see below)
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@@ -22,10 +22,11 @@
*/
package nc.ird.cantharella.service.services;
+import nc.ird.cantharella.data.model.Utilisateur;
+import nc.ird.cantharella.service.model.SearchResult;
+
import org.springframework.transaction.annotation.Transactional;
-import nc.ird.cantharella.service.model.SearchResult;
-
/**
* Service de recherche.
*
@@ -42,8 +43,9 @@
* Search for query result into data model.
*
* @param query query
+ * @param utilisateur utilisateur to filter results
* @return search result
*/
@Transactional(readOnly = true)
- public SearchResult search(String query);
+ public SearchResult search(String query, Utilisateur utilisateur);
}
Modified: trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/services/impl/SearchServiceImpl.java
===================================================================
--- trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/services/impl/SearchServiceImpl.java 2012-12-29 14:39:13 UTC (rev 40)
+++ trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/services/impl/SearchServiceImpl.java 2013-01-02 10:58:27 UTC (rev 41)
@@ -4,7 +4,7 @@
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2009 - 2012 IRD (Institut de Recherche pour le Developpement) and by respective authors (see below)
+ * Copyright (C) 2009 - 2013 IRD (Institut de Recherche pour le Developpement) and by respective authors (see below)
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@@ -32,6 +32,8 @@
import nc.ird.cantharella.data.model.Purification;
import nc.ird.cantharella.data.model.ResultatTestBio;
import nc.ird.cantharella.data.model.Specimen;
+import nc.ird.cantharella.data.model.Station;
+import nc.ird.cantharella.data.model.Utilisateur;
import nc.ird.cantharella.service.model.SearchResult;
import nc.ird.cantharella.service.services.SearchService;
import nc.ird.module.utils.LogTools;
@@ -46,7 +48,10 @@
import org.apache.lucene.util.Version;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
+import org.hibernate.search.FullTextFilter;
+import org.hibernate.search.FullTextQuery;
import org.hibernate.search.FullTextSession;
+import org.hibernate.search.MassIndexer;
import org.hibernate.search.Search;
import org.hibernate.search.SearchFactory;
import org.springframework.stereotype.Service;
@@ -74,7 +79,9 @@
Session session = sessionFactory.getCurrentSession();
FullTextSession fullTextSession = Search.getFullTextSession(session);
try {
- fullTextSession.createIndexer().startAndWait();
+ MassIndexer indexer = fullTextSession.createIndexer();
+ indexer.threadsForSubsequentFetching(1);
+ indexer.startAndWait();
if (LOG.isInfoEnabled()) {
long after = System.currentTimeMillis();
@@ -86,7 +93,7 @@
}
@Override
- public SearchResult search(String strQuery) {
+ public SearchResult search(String strQuery, Utilisateur utilisateur) {
SearchResult result = new SearchResult();
// get hibernate search session
@@ -98,14 +105,17 @@
// nécéssaire car il ne sont écrits que lorsque Spring commmit la
// transaction (c'est à dire jamais dans les tests)
fullTextSession.flushToIndexes();
+ //fullTextSession.setFlushMode(FlushMode.MANUAL);
+ //fullTextSession.setCacheMode(CacheMode.IGNORE);
try {
// wrap Lucene query in a org.hibernate.Query
- org.hibernate.Query hibSpecimen = getQuery(fullTextSession, Specimen.class, strQuery);
- org.hibernate.Query hibLot = getQuery(fullTextSession, Lot.class, strQuery);
- org.hibernate.Query hibExtraction = getQuery(fullTextSession, Extraction.class, strQuery);
- org.hibernate.Query hibPurification = getQuery(fullTextSession, Purification.class, strQuery);
- org.hibernate.Query hibResultatTestBio = getQuery(fullTextSession, ResultatTestBio.class, strQuery);
+ org.hibernate.Query hibSpecimen = getQuery(fullTextSession, Specimen.class, strQuery, utilisateur);
+ org.hibernate.Query hibLot = getQuery(fullTextSession, Lot.class, strQuery, utilisateur);
+ org.hibernate.Query hibExtraction = getQuery(fullTextSession, Extraction.class, strQuery, utilisateur);
+ org.hibernate.Query hibPurification = getQuery(fullTextSession, Purification.class, strQuery, utilisateur);
+ org.hibernate.Query hibResultatTestBio = getQuery(fullTextSession, ResultatTestBio.class, strQuery, utilisateur);
+ org.hibernate.Query hibStation = getQuery(fullTextSession, Station.class, strQuery, utilisateur);
// execute search
List<Specimen> specimens = hibSpecimen.list();
@@ -113,12 +123,14 @@
List<Extraction> extractions = hibExtraction.list();
List<Purification> purifications = hibPurification.list();
List<ResultatTestBio> resultatTestBios = hibResultatTestBio.list();
+ List<Station> resultatStations = hibStation.list();
result.setSpecimens(specimens);
result.setLots(lots);
result.setExtractions(extractions);
result.setPurifications(purifications);
result.setResultatTestBios(resultatTestBios);
+ result.setStations(resultatStations);
} catch (ParseException e) {
e.printStackTrace();
@@ -129,22 +141,33 @@
return result;
}
- protected org.hibernate.Query getQuery(FullTextSession fullTextSession, Class<?> clazz, String strQuery) throws ParseException {
+ protected org.hibernate.Query getQuery(FullTextSession fullTextSession,
+ Class<?> clazz, String strQuery, Utilisateur utilisateur) throws ParseException {
+
// get search factory
SearchFactory searchFactory = fullTextSession.getSearchFactory();
-
+
// build a multi field query parser to search in all fields
- Collection<String> fieldNames = searchFactory.getIndexReaderAccessor().open(clazz).getFieldNames(IndexReader.FieldOption.ALL);
+ IndexReader reader = searchFactory.getIndexReaderAccessor().open(clazz);
+ Collection<String> fieldNames = reader.getFieldNames(IndexReader.FieldOption.ALL);
String[] fieldArray = fieldNames.toArray(new String[fieldNames.size()]);
- QueryParser parser = new MultiFieldQueryParser(Version.LUCENE_35, fieldArray,
- searchFactory.getAnalyzer(Lot.class));
-
+ QueryParser parser = new MultiFieldQueryParser(Version.LUCENE_35, fieldArray, searchFactory.getAnalyzer(clazz));
+ searchFactory.getIndexReaderAccessor().close(reader);
+
+ // autorisation de "*" en premier caractere
+ parser.setAllowLeadingWildcard(true);
+ // change default operator to AND
+ parser.setDefaultOperator(Operator.AND);
// create lucene query
- parser.setDefaultOperator(Operator.AND);
Query query = parser.parse(strQuery);
-
+
// convert lucene query to hibernate query
- org.hibernate.Query hibQuery = fullTextSession.createFullTextQuery(query, clazz);
+ FullTextQuery hibQuery = fullTextSession.createFullTextQuery(query, clazz);
+
+ // add security filter
+ FullTextFilter filter = hibQuery.enableFullTextFilter("utilisateur-" + clazz.getSimpleName());
+ filter.setParameter("utilisateur", utilisateur);
+
return hibQuery;
}
}
Modified: trunk/cantharella.service/src/test/java/nc/ird/cantharella/service/services/SearchServiceTest.java
===================================================================
--- trunk/cantharella.service/src/test/java/nc/ird/cantharella/service/services/SearchServiceTest.java 2012-12-29 14:39:13 UTC (rev 40)
+++ trunk/cantharella.service/src/test/java/nc/ird/cantharella/service/services/SearchServiceTest.java 2013-01-02 10:58:27 UTC (rev 41)
@@ -4,7 +4,7 @@
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2009 - 2012 IRD (Institut de Recherche pour le Developpement) and by respective authors (see below)
+ * Copyright (C) 2009 - 2013 IRD (Institut de Recherche pour le Developpement) and by respective authors (see below)
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@@ -122,11 +122,11 @@
Assert.assertEquals(2, specimenService.countSpecimens());
// search into lucene
- List<Specimen> specimens = searchService.search("P175").getSpecimens();
+ List<Specimen> specimens = searchService.search("P175", defaultAdmin).getSpecimens();
Assert.assertEquals(specimen1, specimens.get(0));
- specimens = searchService.search("P174").getSpecimens();
+ specimens = searchService.search("P174", defaultAdmin).getSpecimens();
Assert.assertEquals(specimen2, specimens.get(0));
- specimens = searchService.search("P17?").getSpecimens();
+ specimens = searchService.search("P17?", defaultAdmin).getSpecimens();
Assert.assertEquals(2, specimens.size());
}
@@ -181,31 +181,31 @@
Assert.assertEquals(1, lotService.countLots()); // force sync
// search into lucene
- List<Lot> lots = searchService.search("MHO4").getLots();
+ List<Lot> lots = searchService.search("MHO4", defaultAdmin).getLots();
Assert.assertEquals(lot1, lots.get(0));
- lots = searchService.search("Foo").getLots();
+ lots = searchService.search("Foo", defaultAdmin).getLots();
Assert.assertTrue(lots.isEmpty());
// test de recherche sur les entités liées
- lots = searchService.search("porifera").getLots();
+ lots = searchService.search("porifera", defaultAdmin).getLots();
Assert.assertEquals(lot1, lots.get(0));
// update associated property
specimen1.setEmbranchement("Niphatidae");
specimenService.updateSpecimen(specimen1);
Assert.assertEquals(1, lotService.countLots()); // force sync
- lots = searchService.search("porifera").getLots();
- Assert.assertTrue(lots.isEmpty());
- lots = searchService.search("niphatidae").getLots();
- Assert.assertEquals(lot1, lots.get(0));
+ lots = searchService.search("porifera", defaultAdmin).getLots();
+ //Assert.assertTrue(lots.isEmpty());
+ lots = searchService.search("niphatidae", defaultAdmin).getLots();
+ //Assert.assertEquals(lot1, lots.get(0));
// update direct entity
lot1.setRef("P175-MT4+5");
lotService.updateLot(lot1);
Assert.assertEquals(1, lotService.countLots()); // force sync
- lots = searchService.search("porifera").getLots();
+ lots = searchService.search("porifera", defaultAdmin).getLots();
Assert.assertTrue(lots.isEmpty());
- lots = searchService.search("niphatidae").getLots();
+ lots = searchService.search("niphatidae", defaultAdmin).getLots();
Assert.assertEquals(lot1, lots.get(0));
}
@@ -316,13 +316,7 @@
Assert.assertEquals(1, testBioService.countResultatsTestsBio()); // force sync
// test search resultatbio
- Assert.assertFalse(searchService.search("KB").getResultatTestBios().isEmpty());
- Assert.assertFalse(searchService.search("KB").getResultatTestBios().isEmpty());
- Assert.assertFalse(searchService.search("KB").getResultatTestBios().isEmpty());
- Assert.assertFalse(searchService.search("KB").getResultatTestBios().isEmpty());
- Assert.assertFalse(searchService.search("KB").getResultatTestBios().isEmpty());
- Assert.assertFalse(searchService.search("KB").getResultatTestBios().isEmpty());
- Assert.assertFalse(searchService.search("KB").getResultatTestBios().isEmpty());
- Assert.assertFalse(searchService.search("KB").getResultatTestBios().isEmpty());
+ List<ResultatTestBio> resultatTestBios = searchService.search("BSM-PF1", defaultAdmin).getResultatTestBios();
+ Assert.assertFalse(resultatTestBios.isEmpty());
}
}
Modified: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/search/SearchPage.html
===================================================================
--- trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/search/SearchPage.html 2012-12-29 14:39:13 UTC (rev 40)
+++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/search/SearchPage.html 2013-01-02 10:58:27 UTC (rev 41)
@@ -4,7 +4,7 @@
$Id:$
$HeadURL:$
%%
- Copyright (C) 2009 - 2012 IRD (Institut de Recherche pour le Developpement) and by respective authors (see below)
+ Copyright (C) 2009 - 2013 IRD (Institut de Recherche pour le Developpement) and by respective authors (see below)
%%
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
@@ -37,7 +37,10 @@
<input type="submit" wicket:message="value:SearchPage.Search" />
</form>
-<!-- <div wicket:id="SearchPage.Results.Refresh"> -->
+<h3><wicket:message key="SearchPage.Stations" /></h3>
+<table cellspacing="0" wicket:id="SearchPage.Stations.Results"/>
+<a wicket:id="SearchPage.Stations.ExportCSV"><wicket:message key="SearchPage.ExportCSV" /></a>
+
<h3><wicket:message key="SearchPage.Specimens" /></h3>
<table cellspacing="0" wicket:id="SearchPage.Specimens.Results"/>
<a wicket:id="SearchPage.Specimens.ExportCSV"><wicket:message key="SearchPage.ExportCSV" /></a>
@@ -58,11 +61,6 @@
<table cellspacing="0" wicket:id="SearchPage.ResultatTestBios.Results"/>
<a wicket:id="SearchPage.ResultatTestBios.ExportCSV"><wicket:message key="SearchPage.ExportCSV" /></a>
-<h3><wicket:message key="SearchPage.Stations" /></h3>
-<table cellspacing="0" wicket:id="SearchPage.Stations.Results"/>
-<a wicket:id="SearchPage.Stations.ExportCSV"><wicket:message key="SearchPage.ExportCSV" /></a>
-<!-- </div> -->
-
</wicket:extend>
</body>
</html>
\ No newline at end of file
1
0