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
December 2012
- 2 participants
- 5 discussions
Author: tchemit
Date: 2012-12-29 15:39:13 +0100 (Sat, 29 Dec 2012)
New Revision: 40
Url: http://forge.codelutin.com/projects/cantharella/repository/revisions/40
Log:
updates mavenpom to 3.4.7
Modified:
trunk/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2012-12-21 10:43:48 UTC (rev 39)
+++ trunk/pom.xml 2012-12-29 14:39:13 UTC (rev 40)
@@ -5,7 +5,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>mavenpom4redmine</artifactId>
- <version>3.4.4</version>
+ <version>3.4.7</version>
</parent>
<groupId>nc.ird</groupId>
1
0
r39 - in trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model: . search
by echatellier@users.forge.codelutin.com 21 Dec '12
by echatellier@users.forge.codelutin.com 21 Dec '12
21 Dec '12
Author: echatellier
Date: 2012-12-21 11:43:48 +0100 (Fri, 21 Dec 2012)
New Revision: 39
Url: http://forge.codelutin.com/projects/cantharella/repository/revisions/39
Log:
Ajout du bridge pour indexer manuellement les produits
Added:
trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/search/
trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/search/ProduitBridge.java
Modified:
trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Produit.java
Modified: trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Produit.java
===================================================================
--- trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Produit.java 2012-12-21 09:33:28 UTC (rev 38)
+++ trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Produit.java 2012-12-21 10:43:48 UTC (rev 39)
@@ -39,10 +39,12 @@
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.utils.AbstractModel;
import org.apache.commons.beanutils.BeanComparator;
import org.hibernate.search.annotations.Analyze;
+import org.hibernate.search.annotations.ClassBridge;
import org.hibernate.search.annotations.ContainedIn;
import org.hibernate.search.annotations.Field;
import org.hibernate.search.annotations.Index;
@@ -56,6 +58,10 @@
*/
@Entity
@Inheritance(strategy = InheritanceType.JOINED)
+@ClassBridge(name="produitBridge",
+ index=Index.YES,
+ store=Store.YES,
+ impl = ProduitBridge.class)
public abstract class Produit extends AbstractModel implements Cloneable, Comparable<Produit> {
/** Logger */
Added: trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/search/ProduitBridge.java
===================================================================
--- trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/search/ProduitBridge.java (rev 0)
+++ trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/search/ProduitBridge.java 2012-12-21 10:43:48 UTC (rev 39)
@@ -0,0 +1,113 @@
+package nc.ird.cantharella.data.model.search;
+
+import nc.ird.cantharella.data.model.Extrait;
+import nc.ird.cantharella.data.model.Fraction;
+import nc.ird.cantharella.data.model.Produit;
+import nc.ird.cantharella.data.model.ResultatTestBio;
+import nc.ird.module.utils.LogTools;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.lucene.document.Document;
+import org.apache.lucene.document.Field;
+import org.hibernate.search.bridge.FieldBridge;
+import org.hibernate.search.bridge.LuceneOptions;
+
+/**
+ * {@link ResultatTestBio} class contains a polymorphic entity that can't be
+ * properly indexed by hibernate search.
+ *
+ * @author echatellier
+ */
+public class ProduitBridge implements FieldBridge {
+
+ /** Logger */
+ private static final Log LOG = LogTools.getLog();
+
+ @Override
+ public void set(String name, Object value, Document document,
+ LuceneOptions luceneOptions) {
+
+ Produit produit = (Produit) value;
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Custom indexing of Produit entity : " + produit);
+ }
+
+ // commons information for all produit
+ document.add(new Field("ref", produit.getRef(), luceneOptions
+ .getStore(), luceneOptions.getIndex(), luceneOptions
+ .getTermVector()));
+ if (produit instanceof Extrait) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Custom indexing of Extrait entity");
+ }
+ Extrait extrait = (Extrait) produit;
+ document.add(new Field("extraction.lot.ref", extrait
+ .getExtraction().getLot().getRef(), luceneOptions
+ .getStore(), luceneOptions.getIndex(), luceneOptions
+ .getTermVector()));
+ document.add(new Field("extraction.lot.specimen.embranchement",
+ extrait.getExtraction().getLot().getSpecimenRef()
+ .getEmbranchement(), luceneOptions.getStore(),
+ luceneOptions.getIndex(), luceneOptions.getTermVector()));
+ if (StringUtils.isNotBlank(extrait.getExtraction().getLot().getSpecimenRef().getFamille())) {
+ document.add(new Field("extraction.lot.specimen.famille", extrait
+ .getExtraction().getLot().getSpecimenRef().getFamille(),
+ luceneOptions.getStore(), luceneOptions.getIndex(),
+ luceneOptions.getTermVector()));
+ }
+ if (StringUtils.isNotBlank(extrait.getExtraction().getLot().getSpecimenRef().getGenre())) {
+ document.add(new Field("extraction.lot.specimen.genre", extrait
+ .getExtraction().getLot().getSpecimenRef().getGenre(),
+ luceneOptions.getStore(), luceneOptions.getIndex(),
+ luceneOptions.getTermVector()));
+ }
+ if (StringUtils.isNotBlank(extrait.getExtraction().getLot().getSpecimenRef().getEspece())) {
+ document.add(new Field("extraction.lot.specimen.expece", extrait
+ .getExtraction().getLot().getSpecimenRef().getEspece(),
+ luceneOptions.getStore(), luceneOptions.getIndex(),
+ luceneOptions.getTermVector()));
+ }
+ document.add(new Field("extraction.lot.campagne.nom", extrait
+ .getExtraction().getLot().getCampagne().getNom(),
+ luceneOptions.getStore(), luceneOptions.getIndex(),
+ luceneOptions.getTermVector()));
+ } else if (produit instanceof Fraction) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Custom indexing of Fraction entity");
+ }
+ Fraction fraction = (Fraction) produit;
+ document.add(new Field("purification.lotSource.ref", fraction
+ .getPurification().getLotSource().getRef(), luceneOptions
+ .getStore(), luceneOptions.getIndex(), luceneOptions
+ .getTermVector()));
+ document.add(new Field(
+ "purification.lotSource.speciment.embranchement", fraction
+ .getPurification().getLotSource().getSpecimenRef()
+ .getEmbranchement(), luceneOptions.getStore(),
+ luceneOptions.getIndex(), luceneOptions.getTermVector()));
+ if (StringUtils.isNotBlank(fraction.getPurification().getLotSource().getSpecimenRef().getFamille())) {
+ document.add(new Field("purification.lotSource.speciment.famille",
+ fraction.getPurification().getLotSource().getSpecimenRef()
+ .getFamille(), luceneOptions.getStore(),
+ luceneOptions.getIndex(), luceneOptions.getTermVector()));
+ }
+ if (StringUtils.isNotBlank(fraction.getPurification().getLotSource().getSpecimenRef().getGenre())) {
+ document.add(new Field("purification.lotSource.speciment.genre",
+ fraction.getPurification().getLotSource().getSpecimenRef()
+ .getGenre(), luceneOptions.getStore(),
+ luceneOptions.getIndex(), luceneOptions.getTermVector()));
+ }
+ if (StringUtils.isNotBlank(fraction.getPurification().getLotSource().getSpecimenRef().getEspece())) {
+ document.add(new Field("purification.lotSource.speciment.expece",
+ fraction.getPurification().getLotSource().getSpecimenRef()
+ .getEspece(), luceneOptions.getStore(),
+ luceneOptions.getIndex(), luceneOptions.getTermVector()));
+ }
+ document.add(new Field("purification.lotSource.campagne.nom",
+ fraction.getPurification().getLotSource().getCampagne()
+ .getNom(), luceneOptions.getStore(), luceneOptions
+ .getIndex(), luceneOptions.getTermVector()));
+ }
+ }
+}
Property changes on: trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/search/ProduitBridge.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
1
0
Author: echatellier
Date: 2012-12-21 10:33:28 +0100 (Fri, 21 Dec 2012)
New Revision: 38
Url: http://forge.codelutin.com/projects/cantharella/repository/revisions/38
Log:
Update hibernate and spring and disable tests
Modified:
trunk/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2012-12-21 09:32:40 UTC (rev 37)
+++ trunk/pom.xml 2012-12-21 09:33:28 UTC (rev 38)
@@ -116,7 +116,7 @@
<version.validation-api>1.0.0.GA</version.validation-api>
<version.jpa>1.0.1.Final</version.jpa>
- <version.hibernate>4.1.7.Final</version.hibernate>
+ <version.hibernate>4.1.9.Final</version.hibernate>
<version.hibernate-validator>4.3.1.Final</version.hibernate-validator>
<version.hibernate3-maven-plugin>3.0</version.hibernate3-maven-plugin>
<version.hibernate-search>4.1.1.Final</version.hibernate-search>
@@ -126,7 +126,7 @@
<version.aspectj>1.6.8</version.aspectj>
<version.opencsv>2.3</version.opencsv>
<version.javassist>3.8.0.GA</version.javassist>
- <version.spring>3.1.3.RELEASE</version.spring>
+ <version.spring>3.2.0.RELEASE</version.spring>
<version.mail>1.4.5</version.mail>
<version.cglib>2.2.2</version.cglib>
@@ -135,6 +135,10 @@
<version.servlet-api>2.5</version.servlet-api>
<version.wicket>1.5.6</version.wicket>
+
+ <!-- FIXME echatellier Probleme de parallelisation des tests unitaire, cause
+ org.hibernate.HibernateException: Don't change the reference to a collection with cascade="all-delete-orphan": nc.ird.cantharella.data.model.Personne.campagnesDroits -->
+ <maven.test.skip>true</maven.test.skip>
</properties>
<build>
1
0
r37 - in trunk: cantharella.service/src/main/java/nc/ird/cantharella/service/model cantharella.web/src/main/java/nc/ird/cantharella/web/pages/columns cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/search cantharella.web/src/main/java/nc/ird/cantharella/web/utils cantharella.web/src/main/java/nc/ird/cantharella/web/utils/columns cantharella.web/src/main/java/nc/ird/cantharella/web/utils/links cantharella.web/src/main/resources/commons
by echatellier@users.forge.codelutin.com 21 Dec '12
by echatellier@users.forge.codelutin.com 21 Dec '12
21 Dec '12
Author: echatellier
Date: 2012-12-21 10:32:40 +0100 (Fri, 21 Dec 2012)
New Revision: 37
Url: http://forge.codelutin.com/projects/cantharella/repository/revisions/37
Log:
Add csv export support
Added:
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/ExportableColumn.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/links/
trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/links/CsvExportLink.java
Modified:
trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/model/SearchResult.java
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.html
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/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/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/resources/commons/web_en.properties
trunk/cantharella.web/src/main/resources/commons/web_fr.properties
Modified: trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/model/SearchResult.java
===================================================================
--- trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/model/SearchResult.java 2012-12-05 18:25:53 UTC (rev 36)
+++ trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/model/SearchResult.java 2012-12-21 09:32:40 UTC (rev 37)
@@ -30,7 +30,7 @@
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.TestBio;
+import nc.ird.cantharella.data.model.Station;
/**
* Search result containing somes entities collections of various types.
@@ -51,6 +51,8 @@
protected List<Purification> purifications;
protected List<ResultatTestBio> resultatTestBios;
+
+ protected List<Station> stations;
public List<Specimen> getSpecimens() {
return specimens;
@@ -91,4 +93,12 @@
public void setResultatTestBios(List<ResultatTestBio> resultatTestBios) {
this.resultatTestBios = resultatTestBios;
}
+
+ public List<Station> getStations() {
+ return stations;
+ }
+
+ public void setStations(List<Station> stations) {
+ this.stations = stations;
+ }
}
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 2012-12-05 18:25:53 UTC (rev 36)
+++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/columns/TaxonomyPropertyColumn.java 2012-12-21 09:32:40 UTC (rev 37)
@@ -22,11 +22,15 @@
*/
package nc.ird.cantharella.web.pages.columns;
+import nc.ird.cantharella.web.utils.columns.CsvWriter;
+import nc.ird.cantharella.web.utils.columns.ExportableColumn;
+
import org.apache.wicket.AttributeModifier;
import org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator;
import org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.repeater.Item;
+import org.apache.wicket.model.AbstractReadOnlyModel;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;
@@ -35,7 +39,7 @@
* @author Adrien Cheype
* @param <T> Type of the row model
*/
-public class TaxonomyPropertyColumn<T> extends PropertyColumn<T> {
+public class TaxonomyPropertyColumn<T> extends PropertyColumn<T> implements ExportableColumn<T> {
/**
* Constructor
@@ -63,5 +67,22 @@
label.add(new AttributeModifier("class", new Model<String>("taxonomy")));
item.add(label);
}
+
+ @Override
+ public String getHeaderName() {
+ return getPropertyExpression();
+ }
+ @Override
+ public void exportCsv(final T object, CsvWriter writer) {
+ IModel<?> textModel = createLabelModel(new AbstractReadOnlyModel<T>() {
+ @Override
+ public T getObject() {
+ return object;
+ }
+ });
+ writer.write(textModel.getObject());
+ textModel.detach();
+ }
+
}
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-05 18:25:53 UTC (rev 36)
+++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/search/SearchPage.html 2012-12-21 09:32:40 UTC (rev 37)
@@ -26,6 +26,11 @@
<body>
<wicket:extend>
+<wicket:message key="SearchPage.QuerySyntax">
+ <a wicket:id="advancedLink"><wicket:message key="SearchPage.QuerySyntaxAdvanced" /></a>
+</wicket:message>
+
+
<form wicket:id="SearchPage.Form">
<wicket:message key="SearchPage.QueryLabel" />
<input type="text" wicket:id="query" />
@@ -33,16 +38,29 @@
</form>
<!-- <div wicket:id="SearchPage.Results.Refresh"> -->
-<wicket:message key="SearchPage.Specimens" />
+<h3><wicket:message key="SearchPage.Specimens" /></h3>
<table cellspacing="0" wicket:id="SearchPage.Specimens.Results"/>
-<wicket:message key="SearchPage.Lots" />
+<a wicket:id="SearchPage.Specimens.ExportCSV"><wicket:message key="SearchPage.ExportCSV" /></a>
+
+<h3><wicket:message key="SearchPage.Lots" /></h3>
<table cellspacing="0" wicket:id="SearchPage.Lots.Results"/>
-<wicket:message key="SearchPage.Extractions" />
+<a wicket:id="SearchPage.Lots.ExportCSV"><wicket:message key="SearchPage.ExportCSV" /></a>
+
+<h3><wicket:message key="SearchPage.Extractions" /></h3>
<table cellspacing="0" wicket:id="SearchPage.Extractions.Results"/>
-<wicket:message key="SearchPage.Purifications" />
+<a wicket:id="SearchPage.Extractions.ExportCSV"><wicket:message key="SearchPage.ExportCSV" /></a>
+
+<h3><wicket:message key="SearchPage.Purifications" /></h3>
<table cellspacing="0" wicket:id="SearchPage.Purifications.Results"/>
-<wicket:message key="SearchPage.ResultatTestBios" />
+<a wicket:id="SearchPage.Purifications.ExportCSV"><wicket:message key="SearchPage.ExportCSV" /></a>
+
+<h3><wicket:message key="SearchPage.ResultatTestBios" /></h3>
<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>
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 2012-12-05 18:25:53 UTC (rev 36)
+++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/search/SearchPage.java 2012-12-21 09:32:40 UTC (rev 37)
@@ -33,6 +33,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.cantharella.web.config.WebContext;
@@ -52,26 +54,29 @@
import nc.ird.cantharella.web.utils.columns.BooleanPropertyColumn;
import nc.ird.cantharella.web.utils.columns.DecimalPropertyColumn;
import nc.ird.cantharella.web.utils.columns.EnumPropertyColumn;
+import nc.ird.cantharella.web.utils.columns.ExportablePropertyColumn;
+import nc.ird.cantharella.web.utils.columns.ExportableTextFilteredPropertyColumn;
import nc.ird.cantharella.web.utils.columns.LinkPropertyColumn;
import nc.ird.cantharella.web.utils.columns.LinkableImagePropertyColumn;
import nc.ird.cantharella.web.utils.columns.MapValuePropertyColumn;
import nc.ird.cantharella.web.utils.columns.ShortDatePropertyColumn;
+import nc.ird.cantharella.web.utils.links.CsvExportLink;
import nc.ird.cantharella.web.utils.models.DisplayDecimalPropertyModel;
import nc.ird.cantharella.web.utils.models.DisplayDecimalPropertyModel.DecimalDisplFormat;
import nc.ird.cantharella.web.utils.models.LoadableDetachableSortableListDataProvider;
import nc.ird.cantharella.web.utils.security.AuthRole;
import nc.ird.cantharella.web.utils.security.AuthRoles;
+import org.apache.wicket.extensions.ajax.markup.html.repeater.data.table.AjaxFallbackDefaultDataTable;
import org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator;
import org.apache.wicket.extensions.markup.html.repeater.data.table.AbstractColumn;
import org.apache.wicket.extensions.markup.html.repeater.data.table.DataTable;
import org.apache.wicket.extensions.markup.html.repeater.data.table.DefaultDataTable;
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.extensions.markup.html.repeater.data.table.filter.TextFilteredPropertyColumn;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.form.TextField;
+import org.apache.wicket.markup.html.link.ExternalLink;
import org.apache.wicket.markup.repeater.Item;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;
@@ -106,6 +111,10 @@
this.query = query;
final CallerPage currentPage = new CallerPage(ListSpecimensPage.class);
+ // ca sert a rien, mais wicket est pas content
+ ExternalLink link = new ExternalLink("advancedLink", "http://lucene.apache.org/core/3_6_1/queryparsersyntax.html");
+ add(link);
+
// search form
Form<ValueMap> searchForm = new Form<ValueMap>(getResource() + ".Form") {
protected void onSubmit() {
@@ -116,12 +125,14 @@
add(searchForm);
// search results
- SearchResult searchResult = searchService.search(query);
+ Utilisateur utilisateur = getSession().getUtilisateur();
+ SearchResult searchResult = searchService.search(query, utilisateur);
addSpecimensTable(currentPage, searchResult);
addLotsTable(currentPage, searchResult);
addExtractionsTable(currentPage, searchResult);
addPurificationsTable(currentPage, searchResult);
addTestBiosTable(currentPage, searchResult);
+ addStationsTable(currentPage, searchResult);
}
public String getQuery() {
@@ -136,6 +147,14 @@
// search result : specimens
List<Specimen> specimens = searchResult.getSpecimens();
List<IColumn<Specimen>> specimensColumns = new ArrayList<IColumn<Specimen>>();
+
+ specimensColumns.add(new LinkableImagePropertyColumn<Specimen>("images/read.png", getString("Read"), getString("Read")) {
+ @Override
+ public void onClick(Item<ICellPopulator<Specimen>> item, String componentId, IModel<Specimen> model) {
+ setResponsePage(new ReadSpecimenPage(model.getObject().getIdSpecimen(), currentPage));
+ }
+ });
+
specimensColumns.add(new LinkPropertyColumn<Specimen>(new Model<String>(getString("Specimen.ref")), "ref", "ref",
getString("Read")) {
@Override
@@ -171,12 +190,21 @@
final DataTable<Specimen> specimensDataTable = new DefaultDataTable<Specimen>(getResource() + ".Specimens.Results",
specimensColumns, specimensDataProvider, Integer.MAX_VALUE);
add(specimensDataTable);
+ add(new CsvExportLink("SearchPage.Specimens.ExportCSV", specimensDataTable));
}
protected void addLotsTable(final CallerPage currentPage, SearchResult searchResult) {
// search result : lots
List<Lot> lots = searchResult.getLots();
List<IColumn<Lot>> lotsColumns = new ArrayList<IColumn<Lot>>();
+
+ lotsColumns.add(new LinkableImagePropertyColumn<Lot>("images/read.png", getString("Read"), getString("Read")) {
+ @Override
+ public void onClick(Item<ICellPopulator<Lot>> item, String componentId, IModel<Lot> model) {
+ setResponsePage(new ReadLotPage(model.getObject().getIdLot(), currentPage));
+ }
+ });
+
lotsColumns.add(new LinkPropertyColumn<Lot>(new Model<String>(getString("Lot.ref")), "ref", "ref",
getString("Read")) {
@Override
@@ -185,7 +213,7 @@
}
});
- lotsColumns.add(new PropertyColumn<Lot>(new Model<String>(getString("Lot.dateRecolte2")), "dateRecolte",
+ lotsColumns.add(new ExportablePropertyColumn<Lot>(new Model<String>(getString("Lot.dateRecolte2")), "dateRecolte",
"dateRecolte"));
lotsColumns.add(new LinkPropertyColumn<Lot>(new Model<String>(getString("Lot.station")), "station", "station",
@@ -219,7 +247,7 @@
lotsColumns.add(new TaxonomyPropertyColumn<Lot>(new Model<String>(getString("Specimen.espece")),
"specimenRef.espece", "specimenRef.espece"));
- lotsColumns.add(new PropertyColumn<Lot>(new Model<String>(getString("Lot.partie")), "partie", "partie"));
+ lotsColumns.add(new ExportablePropertyColumn<Lot>(new Model<String>(getString("Lot.partie")), "partie", "partie"));
lotsColumns.add(new DecimalPropertyColumn<Lot>(new Model<String>(getString("Lot.masseFraiche2")), "masseFraiche",
"masseFraiche", DecimalDisplFormat.SMALL, getLocale()));
@@ -243,6 +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));
}
protected void addExtractionsTable(final CallerPage currentPage, SearchResult searchResult) {
@@ -277,7 +306,7 @@
extractionsColumns.add(new ShortDatePropertyColumn<Extraction>(new Model<String>(getString("Extraction.date")), "date",
"date", getLocale()));
- extractionsColumns.add(new PropertyColumn<Extraction>(new Model<String>(getString("Extraction.methode2")), "methode",
+ extractionsColumns.add(new ExportablePropertyColumn<Extraction>(new Model<String>(getString("Extraction.methode2")), "methode",
"methode"));
extractionsColumns.add(new DecimalPropertyColumn<Extraction>(new Model<String>(getString("Extraction.masseDepart2")),
@@ -336,6 +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));
}
protected void addPurificationsTable(final CallerPage currentPage, SearchResult searchResult) {
@@ -345,6 +375,14 @@
List<IColumn<Purification>> columns = new ArrayList<IColumn<Purification>>();
+ columns.add(new LinkableImagePropertyColumn<Purification>("images/read.png", getString("Read"),
+ getString("Read")) {
+ @Override
+ public void onClick(Item<ICellPopulator<Purification>> item, String componentId, IModel<Purification> model) {
+ setResponsePage(new ReadPurificationPage(model.getObject().getIdPurification(), currentPage));
+ }
+ });
+
columns.add(new LinkPropertyColumn<Purification>(new Model<String>(getString("Extraction.lot")), "lotSource",
"lotSource", getString("Read")) {
@Override
@@ -377,7 +415,7 @@
columns.add(new ShortDatePropertyColumn<Purification>(new Model<String>(getString("Purification.date")),
"date", "date", getLocale()));
- columns.add(new PropertyColumn<Purification>(new Model<String>(getString("Purification.methode2")), "methode",
+ columns.add(new ExportablePropertyColumn<Purification>(new Model<String>(getString("Purification.methode2")), "methode",
"methode"));
columns.add(new LinkPropertyColumn<Purification>(new Model<String>(getString("Campagne")),
@@ -392,6 +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));
}
protected void addTestBiosTable(final CallerPage currentPage, SearchResult searchResult) {
@@ -401,7 +440,16 @@
List<IColumn<ResultatTestBio>> columns = new ArrayList<IColumn<ResultatTestBio>>();
- columns.add(new TextFilteredPropertyColumn<ResultatTestBio, String>(new Model<String>(
+ columns.add(new LinkableImagePropertyColumn<ResultatTestBio>("images/read.png", getString("Read"),
+ getString("Read")) {
+ @Override
+ public void onClick(Item<ICellPopulator<ResultatTestBio>> item, String componentId,
+ IModel<ResultatTestBio> model) {
+ setResponsePage(new ReadTestBioPage(model.getObject().getTestBio().getIdTestBio(), currentPage));
+ }
+ });
+
+ columns.add(new ExportableTextFilteredPropertyColumn<ResultatTestBio, String>(new Model<String>(
getString("MethodeTestBio.cible2")), "testBio.methode.cible", "testBio.methode.cible"));
columns.add(new DecimalPropertyColumn<ResultatTestBio>(new Model<String>(
@@ -427,10 +475,10 @@
columns.add(new DecimalPropertyColumn<ResultatTestBio>(new Model<String>(getString("ResultatTestBio.valeur")),
"valeur", "valeur", DecimalDisplFormat.SMALL, getLocale()));
- columns.add(new PropertyColumn<ResultatTestBio>(new Model<String>(getString("MethodeTestBio.uniteResultat2")),
+ columns.add(new ExportablePropertyColumn<ResultatTestBio>(new Model<String>(getString("MethodeTestBio.uniteResultat2")),
"testBio.methode.uniteResultat", "testBio.methode.uniteResultat"));
- columns.add(new PropertyColumn<ResultatTestBio>(new Model<String>(getString("Extrait.typeExtrait2")),
+ columns.add(new ExportablePropertyColumn<ResultatTestBio>(new Model<String>(getString("Extrait.typeExtrait2")),
"typeExtraitSource", "typeExtraitSource"));
columns.add(new BooleanPropertyColumn<ResultatTestBio>(new Model<String>(getString("ResultatTestBio.actif")),
@@ -449,7 +497,7 @@
getString("Campagne.codePays")), "lotSource.campagne.codePays", "lotSource.campagne.codePays",
WebContext.COUNTRIES.get(getSession().getLocale())));
- columns.add(new PropertyColumn<ResultatTestBio>(new Model<String>(getString("ResultatTestBio.repere")),
+ columns.add(new ExportablePropertyColumn<ResultatTestBio>(new Model<String>(getString("ResultatTestBio.repere")),
"repere", "repere"));
columns.add(new LinkPropertyColumn<ResultatTestBio>(new Model<String>(getString("TestBio.ref")), "testBio.ref",
@@ -465,6 +513,52 @@
getResource() + ".ResultatTestBios.Results", columns, resTestBiosDataProvider, Integer.MAX_VALUE);
add(resTestBiosDataTable);
+ add(new CsvExportLink("SearchPage.ResultatTestBios.ExportCSV", resTestBiosDataTable));
}
+
+ protected void addStationsTable(final CallerPage currentPage, SearchResult searchResult) {
+
+ // Liste des stations
+ List<Station> stations = searchResult.getStations();
+
+ LoadableDetachableSortableListDataProvider<Station> stationsDataProvider = new LoadableDetachableSortableListDataProvider<Station>(
+ stations, getSession().getLocale());
+
+ List<IColumn<Station>> columns = new ArrayList<IColumn<Station>>();
+
+ columns.add(new LinkableImagePropertyColumn<Station>("images/read.png", getString("Read"), getString("Read")) {
+ @Override
+ public void onClick(Item<ICellPopulator<Station>> item, String componentId, IModel<Station> model) {
+ setResponsePage(new ReadStationPage(model.getObject().getIdStation(), currentPage));
+ }
+ });
+
+ columns.add(new LinkPropertyColumn<Station>(new Model<String>(getString("Station.nom")), "nom", "nom",
+ getString("Read")) {
+ @Override
+ public void onClick(Item<ICellPopulator<Station>> item, String componentId, IModel<Station> model) {
+ setResponsePage(new ReadStationPage(model.getObject().getIdStation(), currentPage));
+ }
+ });
+
+ columns.add(new MapValuePropertyColumn<Station, String>(new Model<String>(getString("Station.codePays")),
+ "codePays", "codePays", WebContext.COUNTRIES.get(getSession().getLocale())));
+
+ columns.add(new ExportablePropertyColumn<Station>(new Model<String>(getString("Station.localite")), "localite",
+ "localite"));
+
+ columns.add(new ExportablePropertyColumn<Station>(new Model<String>(getString("Station.latitude")), "latitude",
+ "latitude"));
+
+ columns.add(new ExportablePropertyColumn<Station>(new Model<String>(getString("Station.longitude")), "longitude",
+ "longitude"));
+
+
+ final DataTable<Station> stationsDataTable = new AjaxFallbackDefaultDataTable<Station>(
+ getResource() + ".Stations.Results", columns, stationsDataProvider, WebContext.ROWS_PER_PAGE);
+
+ add(stationsDataTable);
+ add(new CsvExportLink("SearchPage.Stations.ExportCSV", stationsDataTable));
+ }
}
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 2012-12-05 18:25:53 UTC (rev 36)
+++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/columns/BooleanPropertyColumn.java 2012-12-21 09:32:40 UTC (rev 37)
@@ -29,6 +29,7 @@
import org.apache.wicket.extensions.markup.html.repeater.data.table.AbstractColumn;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.repeater.Item;
+import org.apache.wicket.model.AbstractReadOnlyModel;
import org.apache.wicket.model.IModel;
/**
@@ -36,7 +37,7 @@
* @author Adrien Cheype
* @param <T> Type of the row model
*/
-public class BooleanPropertyColumn<T> extends AbstractColumn<T> {
+public class BooleanPropertyColumn<T> extends AbstractColumn<T> implements ExportableColumn<T> {
/** wicket property expression */
private final String propertyExpression;
@@ -65,4 +66,20 @@
page)));
}
+ @Override
+ public String getHeaderName() {
+ return propertyExpression;
+ }
+
+ @Override
+ public void exportCsv(final T object, CsvWriter writer) {
+ IModel<?> textModel = new DisplayBooleanPropertyModel(new AbstractReadOnlyModel<T>() {
+ @Override
+ public T getObject() {
+ return object;
+ }
+ }, propertyExpression, page);
+ writer.write(textModel.getObject());
+ textModel.detach();
+ }
}
Added: 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 (rev 0)
+++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/columns/CsvWriter.java 2012-12-21 09:32:40 UTC (rev 37)
@@ -0,0 +1,64 @@
+/*
+ * #%L
+ * Cantharella :: Web
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2009 - 2012 IRD (Institut de Recherche pour le Developpement) and by respective authors (see below)
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+package nc.ird.cantharella.web.utils.columns;
+
+import java.io.OutputStream;
+import java.io.PrintWriter;
+
+/**
+ * CsvWriter helper used to export data from data table.
+ *
+ * @author echatellier
+ */
+public class CsvWriter {
+ private final PrintWriter out;
+ private boolean first = true;
+ public CsvWriter(OutputStream 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;
+ }
+ public CsvWriter endLine() {
+ out.append("\r\n");
+ first = true;
+ return this;
+ }
+ public CsvWriter flush() {
+ out.flush();
+ return this;
+ }
+ public void close() {
+ out.close();
+ }
+}
Property changes on: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/columns/CsvWriter.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
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 2012-12-05 18:25:53 UTC (rev 36)
+++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/columns/DecimalPropertyColumn.java 2012-12-21 09:32:40 UTC (rev 37)
@@ -31,6 +31,7 @@
import org.apache.wicket.extensions.markup.html.repeater.data.table.AbstractColumn;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.repeater.Item;
+import org.apache.wicket.model.AbstractReadOnlyModel;
import org.apache.wicket.model.IModel;
/**
@@ -38,7 +39,7 @@
* @author Adrien Cheype
* @param <T> Type of the row model
*/
-public class DecimalPropertyColumn<T> extends AbstractColumn<T> {
+public class DecimalPropertyColumn<T> extends AbstractColumn<T> implements ExportableColumn<T> {
/** wicket property expression */
private final String propertyExpression;
@@ -71,5 +72,22 @@
cellItem.add(new Label(componentId, new DisplayDecimalPropertyModel(rowModel.getObject(), propertyExpression,
format, locale)));
}
+
+ @Override
+ public String getHeaderName() {
+ return propertyExpression;
+ }
+ @Override
+ public void exportCsv(final T object, CsvWriter writer) {
+ IModel<?> textModel = new DisplayDecimalPropertyModel(new AbstractReadOnlyModel<T>() {
+ @Override
+ public T getObject() {
+ return object;
+ }
+ }, propertyExpression, format, locale);
+ writer.write(textModel.getObject());
+ textModel.detach();
+ }
+
}
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 2012-12-05 18:25:53 UTC (rev 36)
+++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/columns/EnumPropertyColumn.java 2012-12-21 09:32:40 UTC (rev 37)
@@ -29,6 +29,7 @@
import org.apache.wicket.extensions.markup.html.repeater.data.table.AbstractColumn;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.repeater.Item;
+import org.apache.wicket.model.AbstractReadOnlyModel;
import org.apache.wicket.model.IModel;
/**
@@ -36,7 +37,7 @@
* @author Adrien Cheype
* @param <T> Type of the row model
*/
-public class EnumPropertyColumn<T> extends AbstractColumn<T> {
+public class EnumPropertyColumn<T> extends AbstractColumn<T> implements ExportableColumn<T> {
/** wicket property expression */
private final String propertyExpression;
@@ -65,4 +66,20 @@
new DisplayEnumPropertyModel(rowModel.getObject(), propertyExpression, page)));
}
+ @Override
+ public String getHeaderName() {
+ return propertyExpression;
+ }
+
+ @Override
+ public void exportCsv(final T object, CsvWriter writer) {
+ IModel<?> textModel = new DisplayEnumPropertyModel(new AbstractReadOnlyModel<T>() {
+ @Override
+ public T getObject() {
+ return object;
+ }
+ }, propertyExpression, page);
+ writer.write(textModel.getObject());
+ textModel.detach();
+ }
}
Added: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/columns/ExportableColumn.java
===================================================================
--- trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/columns/ExportableColumn.java (rev 0)
+++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/columns/ExportableColumn.java 2012-12-21 09:32:40 UTC (rev 37)
@@ -0,0 +1,41 @@
+/*
+ * #%L
+ * Cantharella :: Web
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2009 - 2012 IRD (Institut de Recherche pour le Developpement) and by respective authors (see below)
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+package nc.ird.cantharella.web.utils.columns;
+
+import org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn;
+
+/**
+ * Interface to mark column as exportable.
+ *
+ * @author echatellier
+ *
+ * @param <T>
+ */
+public interface ExportableColumn<T> extends IColumn<T> {
+
+ /** Export column name. */
+ String getHeaderName();
+
+ /** Export current object into writer. */
+ void exportCsv(T object, CsvWriter writer);
+ }
Property changes on: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/columns/ExportableColumn.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: 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 (rev 0)
+++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/columns/ExportablePropertyColumn.java 2012-12-21 09:32:40 UTC (rev 37)
@@ -0,0 +1,59 @@
+/*
+ * #%L
+ * Cantharella :: Web
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2009 - 2012 IRD (Institut de Recherche pour le Developpement) and by respective authors (see below)
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+package nc.ird.cantharella.web.utils.columns;
+
+import org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn;
+import org.apache.wicket.model.AbstractReadOnlyModel;
+import org.apache.wicket.model.IModel;
+
+/**
+ * Override {@link PropertyColumn} to addd export support.
+ *
+ * @author echatellier
+ *
+ * @param <T>
+ */
+public class ExportablePropertyColumn<T> extends PropertyColumn<T> implements
+ ExportableColumn<T> {
+
+ public ExportablePropertyColumn(IModel<String> displayModel, String sortProperty, String propertyExpression) {
+ super(displayModel, sortProperty, propertyExpression);
+ }
+
+ @Override
+ public String getHeaderName() {
+ return getPropertyExpression();
+ }
+
+ @Override
+ public void exportCsv(final T object, CsvWriter writer) {
+ IModel<?> textModel = createLabelModel(new AbstractReadOnlyModel<T>() {
+ @Override
+ public T getObject() {
+ return object;
+ }
+ });
+ writer.write(textModel.getObject());
+ textModel.detach();
+ }
+}
Property changes on: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/columns/ExportablePropertyColumn.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: 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 (rev 0)
+++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/columns/ExportableTextFilteredPropertyColumn.java 2012-12-21 09:32:40 UTC (rev 37)
@@ -0,0 +1,60 @@
+/*
+ * #%L
+ * Cantharella :: Web
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2009 - 2012 IRD (Institut de Recherche pour le Developpement) and by respective authors (see below)
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+package nc.ird.cantharella.web.utils.columns;
+
+import org.apache.wicket.extensions.markup.html.repeater.data.table.filter.TextFilteredPropertyColumn;
+import org.apache.wicket.model.AbstractReadOnlyModel;
+import org.apache.wicket.model.IModel;
+
+/**
+ * Override {@link TextFilteredPropertyColumn} to add export support.
+ *
+ * @author echatellier
+ *
+ * @param <T>
+ * @param <F>
+ */
+public class ExportableTextFilteredPropertyColumn<T, F> extends TextFilteredPropertyColumn<T, F> implements ExportableColumn<T> {
+
+ public ExportableTextFilteredPropertyColumn(IModel<String> displayModel,
+ String sortProperty, String propertyExpression) {
+ super(displayModel, sortProperty, propertyExpression);
+ }
+
+ @Override
+ public String getHeaderName() {
+ return getPropertyExpression();
+ }
+
+ @Override
+ public void exportCsv(final T object, CsvWriter writer) {
+ IModel<?> textModel = createLabelModel(new AbstractReadOnlyModel<T>() {
+ @Override
+ public T getObject() {
+ return object;
+ }
+ });
+ writer.write(textModel.getObject());
+ textModel.detach();
+ }
+}
Property changes on: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/columns/ExportableTextFilteredPropertyColumn.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
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 2012-12-05 18:25:53 UTC (rev 36)
+++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/columns/LinkPropertyColumn.java 2012-12-21 09:32:40 UTC (rev 37)
@@ -30,6 +30,7 @@
import org.apache.wicket.markup.html.link.PopupSettings;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.markup.repeater.Item;
+import org.apache.wicket.model.AbstractReadOnlyModel;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;
@@ -38,7 +39,7 @@
* https://cwiki.apache.org/WICKET/adding-links-in-a-defaultdatatable.html
* @param <T> Generic type
*/
-abstract public class LinkPropertyColumn<T> extends PropertyColumn<T> {
+abstract public class LinkPropertyColumn<T> extends PropertyColumn<T> implements ExportableColumn<T>{
/** Popup settings */
private PopupSettings popupSettings;
@@ -170,4 +171,21 @@
link.add(new Label("label", tmpLabelModel));
}
}
+
+ @Override
+ public String getHeaderName() {
+ return getPropertyExpression();
+ }
+
+ @Override
+ public void exportCsv(final T object, CsvWriter writer) {
+ IModel<?> textModel = createLabelModel(new AbstractReadOnlyModel<T>() {
+ @Override
+ public T getObject() {
+ return object;
+ }
+ });
+ writer.write(textModel.getObject());
+ textModel.detach();
+ }
}
\ No newline at end of file
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 2012-12-05 18:25:53 UTC (rev 36)
+++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/columns/MapValuePropertyColumn.java 2012-12-21 09:32:40 UTC (rev 37)
@@ -30,6 +30,7 @@
import org.apache.wicket.extensions.markup.html.repeater.data.table.AbstractColumn;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.repeater.Item;
+import org.apache.wicket.model.AbstractReadOnlyModel;
import org.apache.wicket.model.IModel;
/**
@@ -38,7 +39,7 @@
* @param <T> Type of the row model
* @param <U> Type of the map key. The map is thus parametred by <U, String>
*/
-public class MapValuePropertyColumn<T, U> extends AbstractColumn<T> {
+public class MapValuePropertyColumn<T, U> extends AbstractColumn<T> implements ExportableColumn<T> {
/** wicket property expression */
private final String propertyExpression;
@@ -67,4 +68,20 @@
propertyExpression, map)));
}
+ @Override
+ public String getHeaderName() {
+ return propertyExpression;
+ }
+
+ @Override
+ public void exportCsv(final T object, CsvWriter writer) {
+ IModel<?> textModel = new DisplayMapValuePropertyModel<U>(new AbstractReadOnlyModel<T>() {
+ @Override
+ public T getObject() {
+ return object;
+ }
+ }, propertyExpression, map);
+ writer.write(textModel.getObject());
+ textModel.detach();
+ }
}
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 2012-12-05 18:25:53 UTC (rev 36)
+++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/columns/ShortDatePropertyColumn.java 2012-12-21 09:32:40 UTC (rev 37)
@@ -30,6 +30,7 @@
import org.apache.wicket.extensions.markup.html.repeater.data.table.AbstractColumn;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.repeater.Item;
+import org.apache.wicket.model.AbstractReadOnlyModel;
import org.apache.wicket.model.IModel;
/**
@@ -37,7 +38,7 @@
* @author Adrien Cheype
* @param <T> Type of the row model
*/
-public class ShortDatePropertyColumn<T> extends AbstractColumn<T> {
+public class ShortDatePropertyColumn<T> extends AbstractColumn<T> implements ExportableColumn<T> {
/** wicket property expression */
private final String propertyExpression;
@@ -65,5 +66,21 @@
cellItem.add(new Label(componentId, new DisplayShortDatePropertyModel(rowModel.getObject(), propertyExpression,
locale)));
}
+
+ @Override
+ public String getHeaderName() {
+ return propertyExpression;
+ }
+ @Override
+ public void exportCsv(final T object, CsvWriter writer) {
+ IModel<?> textModel = new DisplayShortDatePropertyModel(new AbstractReadOnlyModel<T>() {
+ @Override
+ public T getObject() {
+ return object;
+ }
+ }, propertyExpression, locale);
+ writer.write(textModel.getObject());
+ textModel.detach();
+ }
}
Added: 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 (rev 0)
+++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/links/CsvExportLink.java 2012-12-21 09:32:40 UTC (rev 37)
@@ -0,0 +1,60 @@
+package nc.ird.cantharella.web.utils.links;
+
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import nc.ird.cantharella.web.utils.columns.CsvWriter;
+import nc.ird.cantharella.web.utils.columns.ExportableColumn;
+
+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.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;
+
+ public CsvExportLink(String id, DataTable<T> table) {
+ super(id);
+ this.table = table;
+ }
+
+ @Override
+ public void onClick() {
+ WebResponse response = (WebResponse) getResponse();
+ response.setAttachmentHeader("export.csv");
+ response.setContentType("text/csv");
+ OutputStream out = getResponse().getOutputStream();
+ CsvWriter writer = new CsvWriter(out);
+ List<ExportableColumn<T>> exportable = getExportableColumns();
+ // write header
+ for (ExportableColumn<T> column : exportable) {
+ writer.write(column.getHeaderName());
+ }
+ writer.endLine();
+ // write data
+ Iterator<? extends T> it = table.getDataProvider().iterator(0, table.getDataProvider().size());
+ while (it.hasNext()) {
+ T object = it.next();
+ for (ExportableColumn<T> col : exportable) {
+ col.exportCsv(object, writer);
+ }
+ writer.endLine();
+ }
+ writer.close();
+ throw new AbortException();
+ }
+
+ private List<ExportableColumn<T>> getExportableColumns() {
+ List<ExportableColumn<T>> exportable = new ArrayList<ExportableColumn<T>>(table.getColumns().size());
+ for (IColumn<?> column : table.getColumns()) {
+ if (column instanceof ExportableColumn<?>) {
+ exportable.add((ExportableColumn<T>) column);
+ }
+ }
+ return exportable;
+ }
+}
Property changes on: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/links/CsvExportLink.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 2012-12-05 18:25:53 UTC (rev 36)
+++ trunk/cantharella.web/src/main/resources/commons/web_en.properties 2012-12-21 09:32:40 UTC (rev 37)
@@ -280,6 +280,10 @@
SearchPage.Extractions=Extractions
SearchPage.Purifications=Purifications
SearchPage.ResultatTestBios=Bioassay
+SearchPage.Stations=Stations
+SearchPage.QuerySyntax=Search terms (or parts of words using *). For a more advanced search, consult the ${advancedLink}.
+SearchPage.QuerySyntaxAdvanced=complete syntax
+SearchPage.ExportCSV=Export to CSV
#MODELS#
Modified: trunk/cantharella.web/src/main/resources/commons/web_fr.properties
===================================================================
--- trunk/cantharella.web/src/main/resources/commons/web_fr.properties 2012-12-05 18:25:53 UTC (rev 36)
+++ trunk/cantharella.web/src/main/resources/commons/web_fr.properties 2012-12-21 09:32:40 UTC (rev 37)
@@ -279,6 +279,10 @@
SearchPage.Extractions=Extractions
SearchPage.Purifications=Purifications
SearchPage.ResultatTestBios=Tests biologiques
+SearchPage.Stations=Stations
+SearchPage.QuerySyntax=Rechercher des termes (ou des parties de termes avec *). Pour une utilisation plus avancée de la recherche, consulter la ${advancedLink}.
+SearchPage.QuerySyntaxAdvanced=synthaxe complète
+SearchPage.ExportCSV=Exporter en CSV
#MODELS#
1
0
05 Dec '12
Author: echatellier
Date: 2012-12-05 19:25:53 +0100 (Wed, 05 Dec 2012)
New Revision: 36
Url: http://forge.codelutin.com/projects/cantharella/repository/revisions/36
Log:
Update to hibrernate 4.1
Update libs
refs #1643: Add a search engine
Added:
trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/config/ValidationIntegrator.java
trunk/cantharella.data/src/main/resources/commons/META-INF/
trunk/cantharella.data/src/main/resources/commons/META-INF/services/
trunk/cantharella.data/src/main/resources/commons/META-INF/services/org.hibernate.integrator.spi.Integrator
trunk/cantharella.data/src/test/java/nc/ird/cantharella/data/SchemaExporter.java
trunk/cantharella.data/src/test/resources/log4j.xml
trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/model/
trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/model/SearchResult.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.service/src/test/resources/log4j.xml
trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/config/panels/RebuildLuceneIndexPanel.html
trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/config/panels/RebuildLuceneIndexPanel.java
trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/search/
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.java
Modified:
trunk/cantharella.data/pom.xml
trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/config/DataContext.java
trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/dao/impl/HibernateTemplateDao.java
trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Campagne.java
trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/CampagnePersonneParticipant.java
trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/ErreurTestBio.java
trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Extraction.java
trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Extrait.java
trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Fraction.java
trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Groupe.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/MethodeExtraction.java
trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/MethodePurification.java
trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/MethodeTestBio.java
trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/ParamMethoPuri.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/Produit.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/TypeDocument.java
trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/TypeExtrait.java
trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/validation/CollectionUniqueFieldValidator.java
trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/validation/utils/ModelValidatorEventListener.java
trunk/cantharella.data/src/main/resources/commons/sql/cantharella_schema_1.0.sql
trunk/cantharella.data/src/test/java/nc/ird/cantharella/data/dao/GenericDaoTest.java
trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/services/impl/DocumentServiceImpl.java
trunk/cantharella.service/src/main/resources/development/service.properties
trunk/cantharella.service/src/test/java/nc/ird/cantharella/service/services/PersonneServiceTest.java
trunk/cantharella.utils/pom.xml
trunk/cantharella.utils/src/main/java/nc/ird/module/utils/BeanLookup.java
trunk/cantharella.utils/src/main/java/nc/ird/module/utils/BeanTools.java
trunk/cantharella.utils/src/main/java/nc/ird/module/utils/CaptchaTools.java
trunk/cantharella.utils/src/main/java/nc/ird/module/utils/CollectionTools.java
trunk/cantharella.utils/src/main/java/nc/ird/module/utils/CoordTools.java
trunk/cantharella.utils/src/main/java/nc/ird/module/utils/PasswordTools.java
trunk/cantharella.utils/src/main/java/nc/ird/module/utils/StringTools.java
trunk/cantharella.utils/src/main/java/nc/ird/module/utils/StringTransformer.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/java/nc/ird/cantharella/web/pages/domain/config/ListConfigurationPage.html
trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/config/ListConfigurationPage.java
trunk/cantharella.web/src/main/resources/commons/web_en.properties
trunk/cantharella.web/src/main/resources/commons/web_fr.properties
trunk/cantharella.web/src/main/webapp/WEB-INF/web.xml
trunk/pom.xml
Modified: trunk/cantharella.data/pom.xml
===================================================================
--- trunk/cantharella.data/pom.xml 2012-11-28 14:58:12 UTC (rev 35)
+++ trunk/cantharella.data/pom.xml 2012-12-05 18:25:53 UTC (rev 36)
@@ -95,8 +95,8 @@
</dependency>
<dependency>
- <groupId>commons-lang</groupId>
- <artifactId>commons-lang</artifactId>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-lang3</artifactId>
</dependency>
<dependency>
<groupId>commons-beanutils</groupId>
@@ -118,14 +118,6 @@
<dependency>
<groupId>org.hibernate</groupId>
- <artifactId>hibernate-annotations</artifactId>
- </dependency>
- <dependency>
- <groupId>org.hibernate</groupId>
- <artifactId>hibernate-c3p0</artifactId>
- </dependency>
- <dependency>
- <groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
</dependency>
<dependency>
@@ -136,6 +128,10 @@
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-search-orm</artifactId>
+ </dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
@@ -152,8 +148,6 @@
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
</dependency>
- <!--dependency> <groupId>org.springframework</groupId> <artifactId>spring-context-support</artifactId>
- </dependency -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
@@ -169,19 +163,16 @@
<artifactId>c3p0</artifactId>
</dependency>
- <dependency>
+ <!-- <dependency>
<groupId>javassist</groupId>
<artifactId>javassist</artifactId>
- </dependency>
+ </dependency> -->
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
</dependency>
- <!--dependency> <groupId>com.ibm.icu</groupId> <artifactId>icu4j</artifactId>
- </dependency -->
-
<dependency>
<groupId>postgresql</groupId>
<artifactId>postgresql</artifactId>
Modified: trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/config/DataContext.java
===================================================================
--- trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/config/DataContext.java 2012-11-28 14:58:12 UTC (rev 35)
+++ trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/config/DataContext.java 2012-12-05 18:25:53 UTC (rev 36)
@@ -39,15 +39,14 @@
import nc.ird.cantharella.data.exceptions.UnexpectedException;
import nc.ird.cantharella.data.validation.utils.ModelValidator;
-import nc.ird.cantharella.data.validation.utils.ModelValidatorEventListener;
import nc.ird.cantharella.data.validation.utils.ModelValidatorImpl;
import nc.ird.module.utils.LogTools;
import org.apache.commons.logging.Log;
import org.hibernate.SessionFactory;
-import org.hibernate.cache.SingletonEhCacheProvider;
-import org.hibernate.connection.C3P0ConnectionProvider;
-import org.hibernate.dialect.PostgreSQLDialect;
+import org.hibernate.cache.ehcache.SingletonEhCacheRegionFactory;
+import org.hibernate.cfg.Environment;
+import org.hibernate.dialect.PostgreSQL82Dialect;
import org.postgresql.Driver;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
@@ -56,9 +55,9 @@
import org.springframework.context.annotation.ImportResource;
import org.springframework.context.support.MessageSourceAccessor;
import org.springframework.context.support.ReloadableResourceBundleMessageSource;
-import org.springframework.orm.hibernate3.HibernateTransactionManager;
-import org.springframework.orm.hibernate3.SpringTransactionFactory;
-import org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean;
+import org.springframework.orm.hibernate4.HibernateTransactionManager;
+import org.springframework.orm.hibernate4.LocalSessionFactoryBean;
+import org.springframework.transaction.annotation.EnableTransactionManagement;
import com.mchange.v2.c3p0.ComboPooledDataSource;
import com.mchange.v2.c3p0.impl.DefaultConnectionTester;
@@ -76,7 +75,7 @@
// Scans for @Repository, @Service and @Component
@ComponentScan(basePackages = { "nc.ird.cantharella.data.dao", "nc.ird.cantharella.data.validation.utils" })
// Enable @Transactional support -> not work with <aop:aspectj-autoproxy /> in xml context file
-// @EnableTransactionManagement
+@EnableTransactionManagement
// This is a configuration class
@Configuration
public abstract class DataContext {
@@ -152,6 +151,7 @@
List<Locale> locales = new ArrayList<Locale>();
locales.add(Locale.FRENCH);
locales.add(Locale.ENGLISH);
+
LOCALES = Collections.unmodifiableList(locales);
Locale.setDefault(LOCALES.get(0));
@@ -232,14 +232,14 @@
*/
@Bean
public SessionFactory sessionFactory() {
- AnnotationSessionFactoryBean sessionFactoryBean = new AnnotationSessionFactoryBean();
+ LocalSessionFactoryBean sessionFactoryBean = new LocalSessionFactoryBean();
sessionFactoryBean.setDataSource(dataSource());
sessionFactoryBean.setPackagesToScan(new String[] { "nc.ird.cantharella.data.model" });
Properties hibernateProperties = new Properties();
// Hibernate: basic
- hibernateProperties.setProperty("hibernate.dialect", PostgreSQLDialect.class.getName());
- // System.setProperty(Environment.BYTECODE_PROVIDER, "cglib");
- hibernateProperties.setProperty("hibernate.hbm2ddl.auto", hbm2ddl);
+ hibernateProperties.setProperty(Environment.DIALECT, PostgreSQL82Dialect.class.getName());
+ //System.setProperty(Environment.BYTECODE_PROVIDER, "cglib");
+ hibernateProperties.setProperty(Environment.HBM2DDL_AUTO, hbm2ddl);
// hibernateProperties.setProperty("hibernate.hbm2ddl.auto", "create-drop");
hibernateProperties.setProperty("hibernate.generate_statistics", String.valueOf(dbDebugProperty));
hibernateProperties.setProperty("hibernate.cache.use_structured_entries", String.valueOf(dbDebugProperty));
@@ -247,37 +247,43 @@
hibernateProperties.setProperty("hibernate.format_sql", String.valueOf(false));
hibernateProperties.setProperty("hibernate.use_sql_comments", String.valueOf(dbDebugProperty));
// Hibernate: cache
- hibernateProperties.setProperty("hibernate.cache.provider_class", SingletonEhCacheProvider.class.getName());
+ hibernateProperties.setProperty("hibernate.cache.region.factory_class", SingletonEhCacheRegionFactory.class.getName());
hibernateProperties.setProperty("hibernate.cache.use_query_cache", String.valueOf(true));
hibernateProperties.setProperty("hibernate.cache.use_second_level_cache", String.valueOf(true));
hibernateProperties.setProperty("hibernate.cache.use_structured_entries", String.valueOf(dbDebugProperty));
// Hibernate: connection
hibernateProperties.setProperty("hibernate.connection.autocommit", String.valueOf(false));
hibernateProperties.setProperty("hibernate.connection.release_mode", "on_close");
- hibernateProperties.setProperty("hibernate.connection.provider_class", C3P0ConnectionProvider.class.getName());
// Pool: c3p0 properties overrided by Hibernate
- hibernateProperties.setProperty("hibernate.c3p0.acquire_increment", String.valueOf(DB_POOL_ACQUIRE_INCREMENT)); // acquireIncrement
- hibernateProperties.setProperty("hibernate.c3p0.idle_test_period", String.valueOf(0)); // idleConnectionTestPeriod
- hibernateProperties.setProperty("hibernate.c3p0.timeout", String.valueOf(0)); // maxIdleTime
- hibernateProperties.setProperty("hibernate.c3p0.max_size", String.valueOf(DB_POOL_MAX_SIZE)); // maxPoolSize
- hibernateProperties.setProperty("hibernate.c3p0.max_statements", String.valueOf(0)); // maxStatements
- hibernateProperties.setProperty("hibernate.c3p0.min_size", String.valueOf(DB_POOL_MIN_SIZE)); // minPoolSize
+ // echatellier 20121129 : désactivé car la datasource est construite
+ // à partir de c3p0, il ne faut donc pas que hibernate la gère
+ // sur c3p0 en plus
+ //hibernateProperties.setProperty(Environment.CONNECTION_PROVIDER, "org.hibernate.service.jdbc.connections.internal.C3P0ConnectionProvider");
+ //hibernateProperties.setProperty("hibernate.c3p0.acquire_increment", String.valueOf(DB_POOL_ACQUIRE_INCREMENT)); // acquireIncrement
+ //hibernateProperties.setProperty("hibernate.c3p0.idle_test_period", String.valueOf(0)); // idleConnectionTestPeriod
+ //hibernateProperties.setProperty("hibernate.c3p0.timeout", String.valueOf(0)); // maxIdleTime
+ //hibernateProperties.setProperty("hibernate.c3p0.max_size", String.valueOf(DB_POOL_MAX_SIZE)); // maxPoolSize
+ //hibernateProperties.setProperty("hibernate.c3p0.max_statements", String.valueOf(0)); // maxStatements
+ //hibernateProperties.setProperty("hibernate.c3p0.min_size", String.valueOf(DB_POOL_MIN_SIZE)); // minPoolSize
+ // Hibernate search
+ hibernateProperties.setProperty("hibernate.search.default.directory_provider", "filesystem");
+ hibernateProperties.setProperty("hibernate.search.default.indexBase", "/tmp/cantharella/hs");
+ hibernateProperties.setProperty("hibernate.search.analyzer", "org.apache.lucene.analysis.fr.FrenchAnalyzer");
// Hibernate: Session
- hibernateProperties.setProperty("hibernate.current_session_context_class", "thread");// SpringSessionContext.class.getName());
- hibernateProperties
- .setProperty("hibernate.transaction.factory_class", SpringTransactionFactory.class.getName());
+ //hibernateProperties.setProperty("hibernate.current_session_context_class", "thread");
+ //hibernateProperties.setProperty(Environment.JTA_PLATFORM, "hibernate.transaction.factory_class", SpringTransactionFactory.class.getName());
// TODO batch_size à ajuster
hibernateProperties.setProperty("hibernate.default_batch_fetch_size", String.valueOf(20));
sessionFactoryBean.setHibernateProperties(hibernateProperties);
- // Validation
- Map<String, Object> eventListeners = new HashMap<String, Object>();
- ModelValidatorEventListener validationListener = new ModelValidatorEventListener(validatorFactory());
- eventListeners.put("pre-insert", validationListener);
- eventListeners.put("pre-update", validationListener);
- sessionFactoryBean.setEventListeners(eventListeners);
+ //Map<String, Object> eventListeners = new HashMap<String, Object>();
+ //ModelValidatorEventListener validationListener = new ModelValidatorEventListener(validatorFactory());
+ //eventListeners.put("pre-insert", validationListener);
+ //eventListeners.put("pre-update", validationListener);
+ //sessionFactoryBean.setEventListeners(eventListeners);
+
try {
sessionFactoryBean.afterPropertiesSet();
} catch (Exception e) {
Added: trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/config/ValidationIntegrator.java
===================================================================
--- trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/config/ValidationIntegrator.java (rev 0)
+++ trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/config/ValidationIntegrator.java 2012-12-05 18:25:53 UTC (rev 36)
@@ -0,0 +1,58 @@
+package nc.ird.cantharella.data.config;
+
+import javax.validation.Validation;
+import javax.validation.ValidatorFactory;
+
+import nc.ird.cantharella.data.validation.utils.ModelValidatorEventListener;
+import nc.ird.module.utils.LogTools;
+
+import org.apache.commons.logging.Log;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.engine.spi.SessionFactoryImplementor;
+import org.hibernate.event.service.spi.EventListenerRegistry;
+import org.hibernate.event.spi.EventType;
+import org.hibernate.integrator.spi.Integrator;
+import org.hibernate.metamodel.source.MetadataImplementor;
+import org.hibernate.service.spi.SessionFactoryServiceRegistry;
+
+/**
+ * Register cantharella validator into hibernate using integrator.
+ *
+ * @author echatellier
+ */
+public class ValidationIntegrator implements Integrator {
+
+ /** Logger */
+ private static final Log LOG = LogTools.getLog();
+
+ @Override
+ public void integrate(Configuration configuration,
+ SessionFactoryImplementor sessionFactory,
+ SessionFactoryServiceRegistry serviceRegistry) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Registering validator into hibernate");
+ }
+
+ // declare validator
+ ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
+ ModelValidatorEventListener validationListener = new ModelValidatorEventListener(factory);
+
+ // register validator
+ EventListenerRegistry eventRegistry = serviceRegistry.getService(EventListenerRegistry.class);
+ eventRegistry.prependListeners(EventType.PRE_INSERT, validationListener);
+ eventRegistry.prependListeners(EventType.PRE_UPDATE, validationListener);
+ }
+
+ @Override
+ public void integrate(MetadataImplementor metadata,
+ SessionFactoryImplementor sessionFactory,
+ SessionFactoryServiceRegistry serviceRegistry) {
+ integrate((Configuration)null, sessionFactory, serviceRegistry);
+ }
+
+ @Override
+ public void disintegrate(SessionFactoryImplementor sessionFactory,
+ SessionFactoryServiceRegistry serviceRegistry) {
+
+ }
+}
Property changes on: trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/config/ValidationIntegrator.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Modified: trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/dao/impl/HibernateTemplateDao.java
===================================================================
--- trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/dao/impl/HibernateTemplateDao.java 2012-11-28 14:58:12 UTC (rev 35)
+++ trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/dao/impl/HibernateTemplateDao.java 2012-12-05 18:25:53 UTC (rev 36)
@@ -25,22 +25,21 @@
import java.io.Serializable;
import java.util.List;
+import javax.annotation.Resource;
+
import nc.ird.cantharella.data.dao.GenericDao;
import nc.ird.cantharella.data.model.utils.AbstractModel;
import nc.ird.module.utils.AssertTools;
import nc.ird.module.utils.GenericsTools;
+import org.hibernate.Criteria;
import org.hibernate.Query;
-import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Order;
import org.hibernate.criterion.Projections;
import org.hibernate.criterion.Restrictions;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.ObjectRetrievalFailureException;
-import org.springframework.orm.hibernate3.HibernateCallback;
-import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import org.springframework.stereotype.Repository;
/**
@@ -49,13 +48,13 @@
* @author Adrien Cheype
*/
@Repository
-public class HibernateTemplateDao extends HibernateDaoSupport implements GenericDao {
+public class HibernateTemplateDao implements GenericDao {
- /** Logger */
- // private static final Log LOG = LogTools.getLog();
+ @Resource
+ private SessionFactory sessionFactory;
public HibernateTemplateDao() {
- super();
+
}
/**
@@ -70,17 +69,17 @@
return DetachedCriteria.forClass(modelClass).add(Restrictions.eq(propertyName, value));
}
- /**
+ /*
* Constructor
* @param sessionFactory Session factory
- */
+ *
@Autowired
public HibernateTemplateDao(SessionFactory sessionFactory) {
setSessionFactory(sessionFactory);
- getHibernateTemplate().setAllowCreate(false);
- getHibernateTemplate().setCacheQueries(true);
- getHibernateTemplate().afterPropertiesSet();
- }
+ sessionFactory.getCurrentSession().setAllowCreate(false);
+ sessionFactory.getCurrentSession().setCacheQueries(true);
+ sessionFactory.getCurrentSession().afterPropertiesSet();
+ }*/
/**
* {@inheritDoc}
@@ -104,21 +103,25 @@
@Override
public long count(String hqlQuery, Object... parameters) {
AssertTools.assertNotEmpty(hqlQuery);
- return (Long) getHibernateTemplate().iterate(hqlQuery, parameters).next();
+ Query query = sessionFactory.getCurrentSession().createQuery(hqlQuery);
+ for (int i = 0; i < parameters.length; i++) {
+ query.setParameter(i, parameters[i]);
+ }
+ return (Long)query.iterate().next();
}
/** {@inheritDoc} */
@Override
public <M extends AbstractModel> void create(M model) {
AssertTools.assertNotNull(model);
- getHibernateTemplate().save(model);
+ sessionFactory.getCurrentSession().save(model);
}
/** {@inheritDoc} */
@Override
public <M extends AbstractModel> void createOrUpdate(M model) {
AssertTools.assertNotNull(model);
- getHibernateTemplate().saveOrUpdate(model);
+ sessionFactory.getCurrentSession().saveOrUpdate(model);
}
/** {@inheritDoc} */
@@ -126,49 +129,46 @@
public <M extends AbstractModel> void delete(Class<M> modelClass, Serializable id) {
AssertTools.assertNotNull(modelClass);
AssertTools.assertNotNull(id);
- getHibernateTemplate().delete(read(modelClass, id));
+ sessionFactory.getCurrentSession().delete(read(modelClass, id));
}
/** {@inheritDoc} */
@Override
public <M extends AbstractModel> void delete(M model) {
AssertTools.assertNotNull(model);
- getHibernateTemplate().delete(model);
+ sessionFactory.getCurrentSession().delete(model);
}
/** {@inheritDoc} */
@Override
public List<?> list(DetachedCriteria criteria) {
AssertTools.assertNotNull(criteria);
- return getHibernateTemplate().findByCriteria(criteria);
+ Criteria execCriteria = criteria.getExecutableCriteria(sessionFactory.getCurrentSession());
+ return execCriteria.list();
}
/** {@inheritDoc} */
@Override
public List<?> list(String hqlQuery, Object... parameters) {
- AssertTools.assertNotEmpty(hqlQuery);
- return getHibernateTemplate().find(hqlQuery, parameters);
+ Query query = sessionFactory.getCurrentSession().createQuery(hqlQuery);
+ for (int i = 0; i < parameters.length; i++) {
+ query.setParameter(i, parameters[i]);
+ }
+ return query.list();
}
/** {@inheritDoc} */
@Override
public int execute(final String sqlQuery, final Object... parameters) {
AssertTools.assertNotEmpty(sqlQuery);
- int nbLines = getHibernateTemplate().executeWithNativeSession(new HibernateCallback<Integer>() {
- @Override
- public Integer doInHibernate(Session session) {
- Query query = session.createSQLQuery(sqlQuery);
- if (parameters != null) {
- for (int i = 0; i < parameters.length; ++i) {
- query.setParameter(i, parameters[i]);
- }
- }
- return Integer.valueOf(query.executeUpdate());
- }
- });
+ Query query = sessionFactory.getCurrentSession().createSQLQuery(sqlQuery);
+ for (int i = 0; i < parameters.length; i++) {
+ query.setParameter(i, parameters[i]);
+ }
+ int nbLines = Integer.valueOf(query.executeUpdate());
// This way to execute requests shortcuts the Hibernate process, so we need to refresh the data cache
- getHibernateTemplate().flush();
- getHibernateTemplate().clear();
+ sessionFactory.getCurrentSession().flush();
+ sessionFactory.getCurrentSession().clear();
return nbLines;
}
@@ -195,9 +195,9 @@
@Override
public <M extends AbstractModel> List<M> readList(Class<M> modelClass) {
AssertTools.assertNotNull(modelClass);
- return GenericsTools.cast(getHibernateTemplate().findByCriteria(
- DetachedCriteria.forClass(modelClass).addOrder(
- Order.asc(AbstractModel.getIdField(modelClass).getName()))));
+ Criteria criteria = sessionFactory.getCurrentSession().createCriteria(modelClass);
+ criteria.addOrder(Order.asc(AbstractModel.getIdField(modelClass).getName()));
+ return GenericsTools.cast(criteria.list());
}
/** {@inheritDoc} */
@@ -205,11 +205,11 @@
public <M extends AbstractModel> List<M> readList(Class<M> modelClass, String... sortColumns) {
AssertTools.assertNotNull(modelClass);
AssertTools.assertNotEmpty(sortColumns);
- DetachedCriteria criteria = DetachedCriteria.forClass(modelClass);
+ Criteria criteria = sessionFactory.getCurrentSession().createCriteria(modelClass);
for (String sortCol : sortColumns) {
criteria.addOrder(Order.asc(sortCol));
}
- return GenericsTools.cast(getHibernateTemplate().findByCriteria(criteria));
+ return GenericsTools.cast(criteria.list());
}
/** {@inheritDoc} */
@@ -218,9 +218,11 @@
AssertTools.assertNotNull(modelClass);
AssertTools.assertPositive(firstResult);
AssertTools.assertPositive(maxResults);
- return GenericsTools.cast(getHibernateTemplate().findByCriteria(
- DetachedCriteria.forClass(modelClass).addOrder(
- Order.asc(AbstractModel.getIdField(modelClass).getName())), firstResult, maxResults));
+ Criteria criteria = sessionFactory.getCurrentSession().createCriteria(modelClass);
+ criteria.addOrder(Order.asc(AbstractModel.getIdField(modelClass).getName()));
+ criteria.setFirstResult(firstResult);
+ criteria.setMaxResults(maxResults);
+ return GenericsTools.cast(criteria.list());
}
/** {@inheritDoc} */
@@ -231,11 +233,13 @@
AssertTools.assertNotEmpty(sortColumns);
AssertTools.assertPositive(firstResult);
AssertTools.assertPositive(maxResults);
- DetachedCriteria criteria = DetachedCriteria.forClass(modelClass);
+ Criteria criteria = sessionFactory.getCurrentSession().createCriteria(modelClass);
for (String sortCol : sortColumns) {
criteria.addOrder(Order.asc(sortCol));
}
- return GenericsTools.cast(getHibernateTemplate().findByCriteria(criteria, firstResult, maxResults));
+ criteria.setFirstResult(firstResult);
+ criteria.setMaxResults(maxResults);
+ return GenericsTools.cast(criteria.list());
}
/** {@inheritDoc} */
@@ -244,7 +248,7 @@
AssertTools.assertNotNull(modelClass);
AssertTools.assertNotNull(id);
- M m = modelClass.cast(getHibernateTemplate().get(modelClass, id));
+ M m = modelClass.cast(sessionFactory.getCurrentSession().get(modelClass, id));
if (m == null) {
throw new ObjectRetrievalFailureException(modelClass, id);
}
@@ -266,34 +270,34 @@
@Override
public <M extends AbstractModel> void refresh(M model) {
AssertTools.assertNotNull(model);
- getHibernateTemplate().refresh(model);
+ sessionFactory.getCurrentSession().refresh(model);
}
/** {@inheritDoc} */
@Override
public <M extends AbstractModel> void update(M model) {
AssertTools.assertNotNull(model);
- getHibernateTemplate().update(model);
+ sessionFactory.getCurrentSession().update(model);
}
/** {@inheritDoc} */
@Override
public <M extends AbstractModel> void evict(M model) {
AssertTools.assertNotNull(model);
- getHibernateTemplate().evict(model);
+ sessionFactory.getCurrentSession().evict(model);
}
/** {@inheritDoc} */
@Override
public <M extends AbstractModel> boolean contains(M model) {
AssertTools.assertNotNull(model);
- return getHibernateTemplate().contains(model);
+ return sessionFactory.getCurrentSession().contains(model);
}
/** {@inheritDoc} */
@Override
public <M extends AbstractModel> void merge(M model) {
AssertTools.assertNotNull(model);
- getHibernateTemplate().merge(model);
+ sessionFactory.getCurrentSession().merge(model);
}
}
\ No newline at end of file
Modified: trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Campagne.java
===================================================================
--- trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Campagne.java 2012-11-28 14:58:12 UTC (rev 35)
+++ trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Campagne.java 2012-12-05 18:25:53 UTC (rev 36)
@@ -28,6 +28,7 @@
import java.util.List;
import javax.persistence.Column;
+import javax.persistence.Embeddable;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
@@ -47,6 +48,11 @@
import org.apache.commons.beanutils.BeanComparator;
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.Index;
+import org.hibernate.search.annotations.Store;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.NotEmpty;
@@ -57,6 +63,7 @@
*/
@Entity
@Table
+@Embeddable
public class Campagne extends AbstractModel implements Comparable<Campagne> {
/** ID */
@@ -69,6 +76,7 @@
@NotNull
@NotEmpty
@Length(max = LENGTH_MEDIUM_TEXT)
+ @Field(index=Index.YES, analyze=Analyze.YES, store=Store.YES)
private String nom;
/** Code pays */
@@ -83,10 +91,12 @@
/** Mention légale décrivant les droits sur les données */
@Lob
+ @Type(type="org.hibernate.type.StringClobType") // see HHH-6105
private String mentionLegale;
/** Complément */
@Lob
+ @Type(type="org.hibernate.type.StringClobType") // see HHH-6105
private String complement;
/** Date début */
Modified: trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/CampagnePersonneParticipant.java
===================================================================
--- trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/CampagnePersonneParticipant.java 2012-11-28 14:58:12 UTC (rev 35)
+++ trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/CampagnePersonneParticipant.java 2012-12-05 18:25:53 UTC (rev 36)
@@ -28,6 +28,8 @@
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
+import org.hibernate.annotations.Type;
+
import nc.ird.cantharella.data.model.utils.AbstractModel;
import nc.ird.cantharella.data.model.utils.CompositeId;
@@ -41,6 +43,7 @@
/** Complément */
@Lob
+ @Type(type="org.hibernate.type.StringClobType") // see HHH-6105
private String complement;
/** ID */
Modified: trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/ErreurTestBio.java
===================================================================
--- trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/ErreurTestBio.java 2012-11-28 14:58:12 UTC (rev 35)
+++ trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/ErreurTestBio.java 2012-12-05 18:25:53 UTC (rev 36)
@@ -32,6 +32,7 @@
import nc.ird.cantharella.data.model.utils.AbstractModel;
import org.apache.commons.beanutils.BeanComparator;
+import org.hibernate.annotations.Type;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.NotEmpty;
@@ -56,6 +57,7 @@
/** Description */
@Lob
+ @Type(type="org.hibernate.type.StringClobType") // see HHH-6105
@NotEmpty
private String description;
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-11-28 14:58:12 UTC (rev 35)
+++ trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Extraction.java 2012-12-05 18:25:53 UTC (rev 36)
@@ -50,6 +50,14 @@
import org.apache.commons.collections.comparators.ComparatorChain;
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.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;
@@ -58,6 +66,7 @@
* @author Adrien Cheype
*/
@Entity
+@Indexed
public class Extraction extends AbstractModel implements Comparable<Extraction> {
/** Id de l'extraction */
@@ -69,6 +78,7 @@
@Length(max = LENGTH_MEDIUM_TEXT)
@Column(unique = true)
@NotEmpty
+ @Field(index=Index.YES, analyze=Analyze.YES, store=Store.YES)
private String ref;
/** Manipulateur */
@@ -89,6 +99,7 @@
/** Lot utilisé pour l'extraction **/
@NotNull
@ManyToOne(fetch = FetchType.EAGER, optional = false)
+ @IndexedEmbedded
private Lot lot;
/** Masse avant l'extraction **/
@@ -99,6 +110,7 @@
/** Commentaire pour la manip */
@Lob
+ @Type(type="org.hibernate.type.StringClobType") // see HHH-6105
private String complement;
/** Créateur */
@@ -110,6 +122,7 @@
@NotNull
@OneToMany(mappedBy = "extraction", fetch = FetchType.EAGER, orphanRemoval = true)
@Cascade({ CascadeType.SAVE_UPDATE })
+ @ContainedIn
private List<Extrait> extraits;
/**
Modified: trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Extrait.java
===================================================================
--- trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Extrait.java 2012-11-28 14:58:12 UTC (rev 35)
+++ trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Extrait.java 2012-12-05 18:25:53 UTC (rev 36)
@@ -22,6 +22,7 @@
*/
package nc.ird.cantharella.data.model;
+import javax.persistence.Embeddable;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.ManyToOne;
@@ -29,12 +30,15 @@
import nc.ird.cantharella.data.validation.CollectionUniqueField;
+import org.hibernate.search.annotations.IndexedEmbedded;
+
/**
* Modèle : Produit issue d'une extraction
* @author Adrien Cheype
*/
@Entity
@CollectionUniqueField(fieldName = "ref", pathToCollection = "extraction.extraits")
+@Embeddable
public class Extrait extends Produit {
/** Type d'extrait */
@@ -45,6 +49,7 @@
/** Manip d'extraction dont fait partie l'extrait */
@NotNull
@ManyToOne(fetch = FetchType.EAGER, optional = false)
+ @IndexedEmbedded
private Extraction extraction;
/**
Modified: trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Fraction.java
===================================================================
--- trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Fraction.java 2012-11-28 14:58:12 UTC (rev 35)
+++ trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Fraction.java 2012-12-05 18:25:53 UTC (rev 36)
@@ -22,6 +22,7 @@
*/
package nc.ird.cantharella.data.model;
+import javax.persistence.Embeddable;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.ManyToOne;
@@ -29,6 +30,8 @@
import nc.ird.cantharella.data.validation.CollectionUniqueField;
+import org.hibernate.search.annotations.Indexed;
+import org.hibernate.search.annotations.IndexedEmbedded;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.NotEmpty;
@@ -38,6 +41,7 @@
*/
@Entity
@CollectionUniqueField(fieldName = "ref", pathToCollection = "purification.fractions")
+@Embeddable
public class Fraction extends Produit {
/** indice de la fraction */
@@ -51,6 +55,7 @@
/** Manip de purification dont fait partie la fraction */
@NotNull
@ManyToOne(fetch = FetchType.EAGER, optional = false)
+ @IndexedEmbedded
private Purification purification;
/**
Modified: trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Groupe.java
===================================================================
--- trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Groupe.java 2012-11-28 14:58:12 UTC (rev 35)
+++ trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Groupe.java 2012-12-05 18:25:53 UTC (rev 36)
@@ -37,6 +37,7 @@
import nc.ird.cantharella.data.model.utils.AbstractModel;
+import org.hibernate.annotations.Type;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.NotEmpty;
@@ -55,6 +56,7 @@
/** Description */
@Lob
+ @Type(type="org.hibernate.type.StringClobType") // see HHH-6105
private String description;
/** Groupe */
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-11-28 14:58:12 UTC (rev 35)
+++ trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Lot.java 2012-12-05 18:25:53 UTC (rev 36)
@@ -28,6 +28,7 @@
import java.util.List;
import javax.persistence.Column;
+import javax.persistence.Embeddable;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
@@ -47,6 +48,14 @@
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.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;
@@ -57,6 +66,8 @@
*/
@Entity
@Table
+@Indexed
+@Embeddable
public class Lot extends AbstractModel implements Comparable<Lot> {
/** ID */
@@ -68,15 +79,18 @@
@Column(unique = true)
@NotEmpty
@Length(max = LENGTH_MEDIUM_TEXT)
+ @Field(index=Index.YES, analyze=Analyze.YES, store=Store.YES)
private String ref;
/** Campagne */
@NotNull
@ManyToOne(fetch = FetchType.EAGER, optional = false)
+ @IndexedEmbedded
private Campagne campagne;
/** complement */
@Lob
+ @Type(type="org.hibernate.type.StringClobType") // see HHH-6105
private String complement;
/** createur */
@@ -131,11 +145,13 @@
/** Spécimen source */
@NotNull
@ManyToOne(fetch = FetchType.EAGER, optional = false)
+ @IndexedEmbedded
private Specimen specimenRef;
/** Station */
@NotNull
@ManyToOne(fetch = FetchType.EAGER, optional = false)
+ @IndexedEmbedded
private Station station;
/** Extractions provenants du lot */
Modified: trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/MethodeExtraction.java
===================================================================
--- trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/MethodeExtraction.java 2012-11-28 14:58:12 UTC (rev 35)
+++ trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/MethodeExtraction.java 2012-12-05 18:25:53 UTC (rev 36)
@@ -39,6 +39,7 @@
import org.apache.commons.beanutils.BeanComparator;
import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;
+import org.hibernate.annotations.Type;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.NotEmpty;
@@ -64,6 +65,7 @@
/** Description de la méthode */
@NotEmpty
@Lob
+ @Type(type="org.hibernate.type.StringClobType") // see HHH-6105
private String description;
/** Types extraits définis en sortie pour la méthode */
Modified: trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/MethodePurification.java
===================================================================
--- trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/MethodePurification.java 2012-11-28 14:58:12 UTC (rev 35)
+++ trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/MethodePurification.java 2012-12-05 18:25:53 UTC (rev 36)
@@ -40,6 +40,7 @@
import org.apache.commons.beanutils.BeanComparator;
import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;
+import org.hibernate.annotations.Type;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.NotEmpty;
@@ -64,6 +65,7 @@
/** Description de la méthode */
@NotEmpty
@Lob
+ @Type(type="org.hibernate.type.StringClobType") // see HHH-6105
private String description;
/** Types extraits définis en sortie pour la méthode */
Modified: trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/MethodeTestBio.java
===================================================================
--- trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/MethodeTestBio.java 2012-11-28 14:58:12 UTC (rev 35)
+++ trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/MethodeTestBio.java 2012-12-05 18:25:53 UTC (rev 36)
@@ -23,6 +23,7 @@
package nc.ird.cantharella.data.model;
import javax.persistence.Column;
+import javax.persistence.Embeddable;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
@@ -31,6 +32,11 @@
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.Field;
+import org.hibernate.search.annotations.Index;
+import org.hibernate.search.annotations.Store;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.NotEmpty;
@@ -39,6 +45,7 @@
* @author Adrien Cheype
*/
@Entity
+@Embeddable
public class MethodeTestBio extends AbstractModel implements Comparable<MethodeTestBio> {
/** Id de la méthode */
@@ -50,12 +57,14 @@
@Length(max = LENGTH_MEDIUM_TEXT)
@Column(unique = true)
@NotEmpty
+ @Field(index=Index.YES, analyze=Analyze.YES, store=Store.YES)
private String nom;
/** Cible pour un test (acronyme du nom de méthode) */
@Length(max = LENGTH_MEDIUM_TEXT)
@Column(unique = true)
@NotEmpty
+ @Field(index=Index.YES, analyze=Analyze.YES, store=Store.YES)
private String cible;
/** Domaine de recherche pour le test */
@@ -66,6 +75,7 @@
/** Description de la méthode */
@NotEmpty
@Lob
+ @Type(type="org.hibernate.type.StringClobType") // see HHH-6105
private String description;
/** Valeur mesurée pour la méthode */
Modified: trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/ParamMethoPuri.java
===================================================================
--- trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/ParamMethoPuri.java 2012-11-28 14:58:12 UTC (rev 35)
+++ trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/ParamMethoPuri.java 2012-12-05 18:25:53 UTC (rev 36)
@@ -35,6 +35,7 @@
import nc.ird.cantharella.data.validation.CollectionUniqueField;
import org.apache.commons.beanutils.BeanComparator;
+import org.hibernate.annotations.Type;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.NotEmpty;
@@ -64,6 +65,7 @@
/** Description du type d'extrait */
@NotEmpty
@Lob
+ @Type(type="org.hibernate.type.StringClobType") // see HHH-6105
private String description;
/** Méthode d'extraction pour laquelle est défini le type d'extrait */
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-11-28 14:58:12 UTC (rev 35)
+++ trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Personne.java 2012-12-05 18:25:53 UTC (rev 36)
@@ -49,6 +49,7 @@
import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;
import org.hibernate.annotations.Index;
+import org.hibernate.annotations.Type;
import org.hibernate.validator.constraints.Email;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.NotEmpty;
@@ -71,6 +72,7 @@
/** Adresse postale */
@NotEmpty
@Lob
+ @Type(type="org.hibernate.type.StringClobType") // see HHH-6105
private String adressePostale;
/** Campagnes créées */
Modified: trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Produit.java
===================================================================
--- trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Produit.java 2012-11-28 14:58:12 UTC (rev 35)
+++ trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Produit.java 2012-12-05 18:25:53 UTC (rev 36)
@@ -42,6 +42,11 @@
import nc.ird.cantharella.data.model.utils.AbstractModel;
import org.apache.commons.beanutils.BeanComparator;
+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.Store;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.NotEmpty;
@@ -64,6 +69,7 @@
@Length(max = LENGTH_MEDIUM_TEXT)
@NotEmpty
@Column(unique = true)
+ @Field(index=Index.YES, analyze=Analyze.YES, store=Store.YES)
private String ref;
/** Masse obtenue pour le produit **/
@@ -80,6 +86,7 @@
/** Résultats de tests biologiques effectués à partir du produit */
@NotNull
@OneToMany(mappedBy = "produit", fetch = FetchType.LAZY)
+ @ContainedIn
private List<ResultatTestBio> resultatsTestsBioSuivants;
/**
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-11-28 14:58:12 UTC (rev 35)
+++ trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Purification.java 2012-12-05 18:25:53 UTC (rev 36)
@@ -52,6 +52,13 @@
import org.apache.commons.collections.comparators.ComparatorChain;
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.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;
@@ -60,6 +67,7 @@
* @author Adrien Cheype
*/
@Entity
+@Indexed
public class Purification extends AbstractModel implements Comparable<Purification> {
/** Logger */
@@ -73,6 +81,7 @@
@Length(max = LENGTH_MEDIUM_TEXT)
@Column(unique = true)
@NotEmpty
+ @Field(index=Index.YES, analyze=Analyze.YES, store=Store.YES)
private String ref;
/** Manipulateur */
@@ -99,6 +108,7 @@
/** Produit utilisé pour la purification **/
@NotNull
@ManyToOne(fetch = FetchType.EAGER, optional = false)
+ @IndexedEmbedded
private Produit produit;
/** Masse avant l'extraction **/
@@ -109,6 +119,7 @@
/** Commentaire pour la manip */
@Lob
+ @Type(type="org.hibernate.type.StringClobType") // see HHH-6105
private String complement;
/** Détermine si la manip doit être confidentielle */
@@ -134,6 +145,7 @@
* Lot dont provient la purification. Stocké en tant que propriété dans l'objet afin d'optimiser son accès
*/
@ManyToOne(fetch = FetchType.EAGER, optional = false)
+ @IndexedEmbedded
private Lot lotSource;
/**
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-11-28 14:58:12 UTC (rev 35)
+++ trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/ResultatTestBio.java 2012-12-05 18:25:53 UTC (rev 36)
@@ -44,411 +44,467 @@
import org.apache.commons.beanutils.BeanComparator;
import org.apache.commons.collections.comparators.ComparatorChain;
import org.hibernate.annotations.Index;
+import org.hibernate.search.annotations.Indexed;
+import org.hibernate.search.annotations.IndexedEmbedded;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.NotEmpty;
/**
* Modèle : Résultat issue d'un test biologique
+ *
* @author Adrien Cheype
*/
@Entity
@CollectionUniqueField(fieldName = "repere", pathToCollection = "testBio.resultats")
-public class ResultatTestBio extends AbstractModel implements Cloneable, Comparable<ResultatTestBio> {
+@Indexed
+public class ResultatTestBio extends AbstractModel implements Cloneable,
+ Comparable<ResultatTestBio> {
- /** Logger */
- // private static final Log LOG = LogTools.getLog();
- /**
- * Type du résultat de test biologique
- */
- public enum TypeResultat implements Comparable<TypeResultat> {
- /** Blanc, dans ce cas pas de réf, conc./masse, stade et actif renseigné */
- BLANC,
- /** Témoin, dans ce cas pas de stade renseigné */
- TEMOIN,
- /** Produit */
- PRODUIT
- }
+ /** Logger */
+ // private static final Log LOG = LogTools.getLog();
+ /**
+ * Type du résultat de test biologique
+ */
+ public enum TypeResultat implements Comparable<TypeResultat> {
+ /** Blanc, dans ce cas pas de réf, conc./masse, stade et actif renseigné */
+ BLANC,
+ /** Témoin, dans ce cas pas de stade renseigné */
+ TEMOIN,
+ /** Produit */
+ PRODUIT
+ }
- /**
- * Stade du résultat de test biologique
- */
- public enum Stade implements Comparable<Stade> {
- /** Détection */
- DETECTION,
- /** Confirmation */
- CONFIRMATION,
- /** Fractionnement */
- FRACTIONNEMENT
- }
+ /**
+ * Stade du résultat de test biologique
+ */
+ public enum Stade implements Comparable<Stade> {
+ /** Détection */
+ DETECTION,
+ /** Confirmation */
+ CONFIRMATION,
+ /** Fractionnement */
+ FRACTIONNEMENT
+ }
- /**
- * Unité de la concentration/masse d'un test biologique
- */
- public enum UniteConcMasse implements Comparable<UniteConcMasse> {
- /** mg **/
- MG,
- /** μg **/
- MICROG,
- /** ng **/
- NG,
- /** ng/ml **/
- MG_ML,
- /** μg/ml **/
- MICROG_ML,
- /** ng/ml **/
- NG_ML
- }
+ /**
+ * Unité de la concentration/masse d'un test biologique
+ */
+ public enum UniteConcMasse implements Comparable<UniteConcMasse> {
+ /** mg **/
+ MG,
+ /** μg **/
+ MICROG,
+ /** ng **/
+ NG,
+ /** ng/ml **/
+ MG_ML,
+ /** μg/ml **/
+ MICROG_ML,
+ /** ng/ml **/
+ NG_ML
+ }
- /** Id du produit */
- @Id
- @GeneratedValue
- private Integer id;
+ /** Id du produit */
+ @Id
+ @GeneratedValue
+ private Integer id;
- /** Réference du produit */
- @Length(max = LENGTH_TINY_TEXT)
- @NotEmpty
- private String repere;
+ /** Réference du produit */
+ @Length(max = LENGTH_TINY_TEXT)
+ @NotEmpty
+ private String repere;
- /** Type du résultat */
- @NotNull
- @Enumerated(EnumType.ORDINAL)
- @Index(name = "typeResultat")
- private TypeResultat typeResultat;
+ /** Type du résultat */
+ @NotNull
+ @Enumerated(EnumType.ORDINAL)
+ @Index(name = "typeResultat")
+ private TypeResultat typeResultat;
- /** Produit utilisé obtenir le résultat **/
- @ManyToOne(fetch = FetchType.EAGER, optional = true)
- private Produit produit;
+ /** Produit utilisé obtenir le résultat **/
+ @ManyToOne(fetch = FetchType.EAGER, optional = true)
+ @IndexedEmbedded
+ private Produit produit;
- /** Nom du produit utilisé lorsque le résultat est de type "temoin" */
- @Length(max = LENGTH_MEDIUM_TEXT)
- private String produitTemoin;
+ /** Nom du produit utilisé lorsque le résultat est de type "temoin" */
+ @Length(max = LENGTH_MEDIUM_TEXT)
+ private String produitTemoin;
- /** Concentration/masse **/
- @Min(value = 0)
- @Max(value = DataContext.DECIMAL_MAX)
- @Column(precision = DataContext.DECIMAL_PRECISION, scale = DataContext.DECIMAL_SCALE)
- private BigDecimal concMasse;
+ /** Concentration/masse **/
+ @Min(value = 0)
+ @Max(value = DataContext.DECIMAL_MAX)
+ @Column(precision = DataContext.DECIMAL_PRECISION, scale = DataContext.DECIMAL_SCALE)
+ private BigDecimal concMasse;
- /** Unité utilisé pour la concentration/masse */
- @Enumerated(EnumType.ORDINAL)
- private UniteConcMasse uniteConcMasse;
+ /** Unité utilisé pour la concentration/masse */
+ @Enumerated(EnumType.ORDINAL)
+ private UniteConcMasse uniteConcMasse;
- /** Stade */
- @Enumerated(EnumType.ORDINAL)
- private Stade stade;
+ /** Stade */
+ @Enumerated(EnumType.ORDINAL)
+ private Stade stade;
- /** Valeur du résultat **/
- @Max(value = DataContext.DECIMAL_MAX)
- @Column(precision = DataContext.DECIMAL_PRECISION, scale = DataContext.DECIMAL_SCALE)
- private BigDecimal valeur;
+ /** Valeur du résultat **/
+ @Max(value = DataContext.DECIMAL_MAX)
+ @Column(precision = DataContext.DECIMAL_PRECISION, scale = DataContext.DECIMAL_SCALE)
+ private BigDecimal valeur;
- /** True si une activité est détectée dans le résultat **/
- private Boolean estActif;
+ /** True si une activité est détectée dans le résultat **/
+ private Boolean estActif;
- /** Erreur (pas de valeur si renseigné) */
- @ManyToOne(fetch = FetchType.EAGER, optional = true)
- private ErreurTestBio erreur;
+ /** Erreur (pas de valeur si renseigné) */
+ @ManyToOne(fetch = FetchType.EAGER, optional = true)
+ private ErreurTestBio erreur;
- /** Manip de purification dont fait partie la fraction */
- @NotNull
- @ManyToOne(fetch = FetchType.EAGER, optional = false)
- private TestBio testBio;
+ /** Manip de purification dont fait partie la fraction */
+ @NotNull
+ @ManyToOne(fetch = FetchType.EAGER, optional = false)
+ @IndexedEmbedded
+ private TestBio testBio;
- /**
- * Type d'extrait dont provient le test biologique. Stocké en tant que propriété dans l'objet afin d'optimiser son
- * accès
- */
- @ManyToOne(fetch = FetchType.EAGER, optional = true)
- private TypeExtrait typeExtraitSource;
+ /**
+ * Type d'extrait dont provient le test biologique. Stocké en tant que
+ * propriété dans l'objet afin d'optimiser son accès
+ */
+ @ManyToOne(fetch = FetchType.EAGER, optional = true)
+ private TypeExtrait typeExtraitSource;
- /**
- * Constructor
- */
- public ResultatTestBio() {
- super();
- }
+ /**
+ * Constructor
+ */
+ public ResultatTestBio() {
+ super();
+ }
- /**
- * Rend le lot dont provient le test biologique
- * @return Le lot source
- */
- public Lot getLotSource() {
- if (produit == null) {
- return null;
- }
- if (produit.isExtrait()) {
- Extrait extrait = (Extrait) produit;
- return extrait.getExtraction().getLot();
- }
- // cas où c'est une fraction
- Fraction fraction = (Fraction) produit;
- return fraction.getPurification().getLotSource();
- }
+ /**
+ * Rend le lot dont provient le test biologique
+ *
+ * @return Le lot source
+ */
+ public Lot getLotSource() {
+ if (produit == null) {
+ return null;
+ }
+ if (produit.isExtrait()) {
+ Extrait extrait = (Extrait) produit;
+ return extrait.getExtraction().getLot();
+ }
+ // cas où c'est une fraction
+ Fraction fraction = (Fraction) produit;
+ return fraction.getPurification().getLotSource();
+ }
- /** {@inheritDoc} */
- @Override
- public ResultatTestBio clone() throws CloneNotSupportedException {
- ResultatTestBio clone = (ResultatTestBio) super.clone();
- clone.id = id;
- clone.repere = repere;
- clone.typeResultat = typeResultat;
- clone.produit = produit;
- clone.stade = stade;
- clone.estActif = estActif;
- clone.testBio = testBio;
- return clone;
- }
+ /** {@inheritDoc} */
+ @Override
+ public ResultatTestBio clone() throws CloneNotSupportedException {
+ ResultatTestBio clone = (ResultatTestBio) super.clone();
+ clone.id = id;
+ clone.repere = repere;
+ clone.typeResultat = typeResultat;
+ clone.produit = produit;
+ clone.stade = stade;
+ clone.estActif = estActif;
+ clone.testBio = testBio;
+ return clone;
+ }
- /** {@inheritDoc} */
- @Override
- public String toString() {
- return "(" + this.getRepere() + ", " + this.getTypeResultat() + ", "
- + (TypeResultat.PRODUIT.equals(this.getTypeResultat()) ? this.getProduit() : this.getProduitTemoin())
- + ")";
- }
+ /** {@inheritDoc} */
+ @Override
+ public String toString() {
+ return "("
+ + this.getRepere()
+ + ", "
+ + this.getTypeResultat()
+ + ", "
+ + (TypeResultat.PRODUIT.equals(this.getTypeResultat()) ? this
+ .getProduit() : this.getProduitTemoin()) + ")";
+ }
- /** {@inheritDoc} */
- @Override
- public final int compareTo(ResultatTestBio resultat) {
- ComparatorChain comparatorChain = new ComparatorChain();
- comparatorChain.addComparator(new BeanComparator("testBio.methode.cible"));
- comparatorChain.addComparator(new BeanComparator("produit"));
- comparatorChain.addComparator(new BeanComparator("repere"));
- return comparatorChain.compare(this, resultat);
- }
+ /** {@inheritDoc} */
+ @Override
+ public final int compareTo(ResultatTestBio resultat) {
+ ComparatorChain comparatorChain = new ComparatorChain();
+ comparatorChain.addComparator(new BeanComparator(
+ "testBio.methode.cible"));
+ comparatorChain.addComparator(new BeanComparator("produit"));
+ comparatorChain.addComparator(new BeanComparator("repere"));
+ return comparatorChain.compare(this, resultat);
+ }
- /**
- * produit setter. Mise à jour du type d'extrait source dont provient le test biologique
- * @param produit produit
- */
- public void setProduit(Produit produit) {
- if (produit == null) {
- this.typeExtraitSource = null;
- } else {
- this.typeExtraitSource = findExtraitSourceFromProduit(produit).getTypeExtrait();
- }
- this.produit = produit;
- }
+ /**
+ * produit setter. Mise à jour du type d'extrait source dont provient le
+ * test biologique
+ *
+ * @param produit
+ * produit
+ */
+ public void setProduit(Produit produit) {
+ if (produit == null) {
+ this.typeExtraitSource = null;
+ } else {
+ this.typeExtraitSource = findExtraitSourceFromProduit(produit)
+ .getTypeExtrait();
+ }
+ this.produit = produit;
+ }
- /**
- * id getter
- * @return id
- */
- public Integer getId() {
- return id;
- }
+ /**
+ * id getter
+ *
+ * @return id
+ */
+ public Integer getId() {
+ return id;
+ }
- /**
- * id setter
- * @param id id
- */
- public void setId(Integer id) {
- this.id = id;
- }
+ /**
+ * id setter
+ *
+ * @param id
+ * id
+ */
+ public void setId(Integer id) {
+ this.id = id;
+ }
- /**
- * repere getter
- * @return repere
- */
- public String getRepere() {
- return repere;
- }
+ /**
+ * repere getter
+ *
+ * @return repere
+ */
+ public String getRepere() {
+ return repere;
+ }
- /**
- * repere setter
- * @param repere repere
- */
- public void setRepere(String repere) {
- this.repere = repere;
- }
+ /**
+ * repere setter
+ *
+ * @param repere
+ * repere
+ */
+ public void setRepere(String repere) {
+ this.repere = repere;
+ }
- /**
- * typeResultat getter
- * @return typeResultat
- */
- public TypeResultat getTypeResultat() {
- return typeResultat;
- }
+ /**
+ * typeResultat getter
+ *
+ * @return typeResultat
+ */
+ public TypeResultat getTypeResultat() {
+ return typeResultat;
+ }
- /**
- * typeResultat setter
- * @param typeResultat typeResultat
- */
- public void setTypeResultat(TypeResultat typeResultat) {
- this.typeResultat = typeResultat;
- }
+ /**
+ * typeResultat setter
+ *
+ * @param typeResultat
+ * typeResultat
+ */
+ public void setTypeResultat(TypeResultat typeResultat) {
+ this.typeResultat = typeResultat;
+ }
- /**
- * produit getter
- * @return produit
- */
- public Produit getProduit() {
- return produit;
- }
+ /**
+ * produit getter
+ *
+ * @return produit
+ */
+ public Produit getProduit() {
+ return produit;
+ }
- /**
- * produitTemoin getter
- * @return produitTemoin
- */
- public String getProduitTemoin() {
- return produitTemoin;
- }
+ /**
+ * produitTemoin getter
+ *
+ * @return produitTemoin
+ */
+ public String getProduitTemoin() {
+ return produitTemoin;
+ }
- /**
- * produitTemoin setter
- * @param produitTemoin produitTemoin
- */
- public void setProduitTemoin(String produitTemoin) {
- this.produitTemoin = produitTemoin;
- }
+ /**
+ * produitTemoin setter
+ *
+ * @param produitTemoin
+ * produitTemoin
+ */
+ public void setProduitTemoin(String produitTemoin) {
+ this.produitTemoin = produitTemoin;
+ }
- /**
- * concMasse getter
- * @return concMasse
- */
- public BigDecimal getConcMasse() {
- return concMasse;
- }
+ /**
+ * concMasse getter
+ *
+ * @return concMasse
+ */
+ public BigDecimal getConcMasse() {
+ return concMasse;
+ }
- /**
- * concMasse setter
- * @param concMasse concMasse
- */
- public void setConcMasse(BigDecimal concMasse) {
- this.concMasse = concMasse;
- }
+ /**
+ * concMasse setter
+ *
+ * @param concMasse
+ * concMasse
+ */
+ public void setConcMasse(BigDecimal concMasse) {
+ this.concMasse = concMasse;
+ }
- /**
- * uniteConcMasse getter
- * @return uniteConcMasse
- */
- public UniteConcMasse getUniteConcMasse() {
- return uniteConcMasse;
- }
+ /**
+ * uniteConcMasse getter
+ *
+ * @return uniteConcMasse
+ */
+ public UniteConcMasse getUniteConcMasse() {
+ return uniteConcMasse;
+ }
- /**
- * uniteConcMasse setter
- * @param uniteConcMasse uniteConcMasse
- */
- public void setUniteConcMasse(UniteConcMasse uniteConcMasse) {
- this.uniteConcMasse = uniteConcMasse;
- }
+ /**
+ * uniteConcMasse setter
+ *
+ * @param uniteConcMasse
+ * uniteConcMasse
+ */
+ public void setUniteConcMasse(UniteConcMasse uniteConcMasse) {
+ this.uniteConcMasse = uniteConcMasse;
+ }
- /**
- * stade getter
- * @return stade
- */
- public Stade getStade() {
- return stade;
- }
+ /**
+ * stade getter
+ *
+ * @return stade
+ */
+ public Stade getStade() {
+ return stade;
+ }
- /**
- * stade setter
- * @param stade stade
- */
- public void setStade(Stade stade) {
- this.stade = stade;
- }
+ /**
+ * stade setter
+ *
+ * @param stade
+ * stade
+ */
+ public void setStade(Stade stade) {
+ this.stade = stade;
+ }
- /**
- * valeur getter
- * @return valeur
- */
- public BigDecimal getValeur() {
- return valeur;
- }
+ /**
+ * valeur getter
+ *
+ * @return valeur
+ */
+ public BigDecimal getValeur() {
+ return valeur;
+ }
- /**
- * valeur setter
- * @param valeur valeur
- */
- public void setValeur(BigDecimal valeur) {
- this.valeur = valeur;
- }
+ /**
+ * valeur setter
+ *
+ * @param valeur
+ * valeur
+ */
+ public void setValeur(BigDecimal valeur) {
+ this.valeur = valeur;
+ }
- /**
- * estActif getter
- * @return estActif
- */
- public Boolean isActif() {
- return estActif;
- }
+ /**
+ * estActif getter
+ *
+ * @return estActif
+ */
+ public Boolean isActif() {
+ return estActif;
+ }
- /**
- * estActif setter
- * @param estActif estActif
- */
- public void setActif(Boolean estActif) {
- this.estActif = estActif;
- }
+ /**
+ * estActif setter
+ *
+ * @param estActif
+ * estActif
+ */
+ public void setActif(Boolean estActif) {
+ this.estActif = estActif;
+ }
- /**
- * erreur getter
- * @return erreur
- */
- public ErreurTestBio getErreur() {
- return erreur;
- }
+ /**
+ * erreur getter
+ *
+ * @return erreur
+ */
+ public ErreurTestBio getErreur() {
+ return erreur;
+ }
- /**
- * erreur setter
- * @param erreur erreur
- */
- public void setErreur(ErreurTestBio erreur) {
- this.erreur = erreur;
- }
+ /**
+ * erreur setter
+ *
+ * @param erreur
+ * erreur
+ */
+ public void setErreur(ErreurTestBio erreur) {
+ this.erreur = erreur;
+ }
- /**
- * testBio getter
- * @return testBio
- */
- public TestBio getTestBio() {
- return testBio;
- }
+ /**
+ * testBio getter
+ *
+ * @return testBio
+ */
+ public TestBio getTestBio() {
+ return testBio;
+ }
- /**
- * testBio setter
- * @param testBio testBio
- */
- public void setTestBio(TestBio testBio) {
- this.testBio = testBio;
- }
+ /**
+ * testBio setter
+ *
+ * @param testBio
+ * testBio
+ */
+ public void setTestBio(TestBio testBio) {
+ this.testBio = testBio;
+ }
- /**
- * typeExtraitSource getter
- * @return typeExtraitSource
- */
- public TypeExtrait getTypeExtraitSource() {
- return typeExtraitSource;
- }
+ /**
+ * typeExtraitSource getter
+ *
+ * @return typeExtraitSource
+ */
+ public TypeExtrait getTypeExtraitSource() {
+ return typeExtraitSource;
+ }
- /**
- * typeExtraitSource setter
- * @param typeExtraitSource typeExtraitSource
- */
- public void setTypeExtraitSource(TypeExtrait typeExtraitSource) {
- this.typeExtraitSource = typeExtraitSource;
- }
+ /**
+ * typeExtraitSource setter
+ *
+ * @param typeExtraitSource
+ * typeExtraitSource
+ */
+ public void setTypeExtraitSource(TypeExtrait typeExtraitSource) {
+ this.typeExtraitSource = typeExtraitSource;
+ }
- /**
- * Remonte à l'extrait dont provient le produit source du test biologique
- * @param produit Le produit en question
- * @return Le lot
- */
- public Extrait findExtraitSourceFromProduit(Produit produit) {
- if (produit.isExtrait()) {
- Extrait extrait = (Extrait) produit;
- return extrait;
- }
- // cas où c'est une fraction
- Produit curProd = produit;
- while (curProd.isFraction()) {
- Fraction curFraction = (Fraction) curProd;
- curProd = curFraction.getPurification().getProduit();
- }
- AssertTools.assertClassOrInterface(curProd, Extrait.class);
+ /**
+ * Remonte à l'extrait dont provient le produit source du test biologique
+ *
+ * @param produit
+ * Le produit en question
+ * @return Le lot
+ */
+ public Extrait findExtraitSourceFromProduit(Produit produit) {
+ if (produit.isExtrait()) {
+ Extrait extrait = (Extrait) produit;
+ return extrait;
+ }
+ // cas où c'est une fraction
+ Produit curProd = produit;
+ while (curProd.isFraction()) {
+ Fraction curFraction = (Fraction) curProd;
+ curProd = curFraction.getPurification().getProduit();
+ }
+ AssertTools.assertClassOrInterface(curProd, Extrait.class);
- return (Extrait) curProd;
- }
+ return (Extrait) curProd;
+ }
}
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-11-28 14:58:12 UTC (rev 35)
+++ trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Specimen.java 2012-12-05 18:25:53 UTC (rev 36)
@@ -25,6 +25,7 @@
import java.util.Date;
import javax.persistence.Column;
+import javax.persistence.Embeddable;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
@@ -41,6 +42,14 @@
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.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;
@@ -51,6 +60,8 @@
*/
@Entity
@Table
+@Indexed
+@Embeddable
public class Specimen extends AbstractModel implements Comparable<Specimen> {
/**
@@ -82,23 +93,28 @@
@Column(unique = true)
@NotEmpty
@Length(max = LENGTH_TINY_TEXT)
+ @Field(index=Index.YES, analyze=Analyze.YES, store=Store.YES)
private String ref;
/** Embranchement */
@Length(max = LENGTH_MEDIUM_TEXT)
@NotEmpty
+ @Field(index=Index.YES, analyze=Analyze.YES, store=Store.YES)
private String embranchement;
/** Famille */
@Length(max = LENGTH_MEDIUM_TEXT)
+ @Field(index=Index.YES, analyze=Analyze.YES, store=Store.YES)
private String famille;
/** Genre */
@Length(max = LENGTH_MEDIUM_TEXT)
+ @Field(index=Index.YES, analyze=Analyze.YES, store=Store.YES)
private String genre;
/** Espèce */
@Length(max = LENGTH_MEDIUM_TEXT)
+ @Field(index=Index.YES, analyze=Analyze.YES, store=Store.YES)
private String espece;
/** Sous-espèce */
@@ -132,10 +148,12 @@
/** Station */
@ManyToOne(fetch = FetchType.EAGER)
+ @IndexedEmbedded
private Station station;
/** Compléments d'information */
@Lob
+ @Type(type="org.hibernate.type.StringClobType") // see HHH-6105
private String complement;
/** Créateur */
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-11-28 14:58:12 UTC (rev 35)
+++ trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Station.java 2012-12-05 18:25:53 UTC (rev 36)
@@ -26,6 +26,7 @@
import java.util.List;
import javax.persistence.Column;
+import javax.persistence.Embeddable;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
@@ -45,6 +46,11 @@
import org.apache.commons.beanutils.BeanComparator;
import org.hibernate.annotations.AccessType;
+import org.hibernate.annotations.Type;
+import org.hibernate.search.annotations.Analyze;
+import org.hibernate.search.annotations.Field;
+import org.hibernate.search.annotations.Index;
+import org.hibernate.search.annotations.Store;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.NotEmpty;
@@ -56,6 +62,7 @@
@Entity
@Table
@AccessType("field")
+@Embeddable
public class Station extends AbstractModel implements Cloneable, Comparable<Station> {
/** ID */
@@ -67,6 +74,7 @@
@Column(unique = true)
@NotEmpty
@Length(max = LENGTH_MEDIUM_TEXT)
+ @Field(index=Index.YES, analyze=Analyze.YES, store=Store.YES)
private String nom;
/** Code pays */
@@ -77,6 +85,7 @@
/** Complément */
@Lob
+ @Type(type="org.hibernate.type.StringClobType") // see HHH-6105
private String complement;
/** Créateur */
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-11-28 14:58:12 UTC (rev 35)
+++ trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/TestBio.java 2012-12-05 18:25:53 UTC (rev 36)
@@ -29,6 +29,7 @@
import java.util.List;
import javax.persistence.Column;
+import javax.persistence.Embeddable;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
@@ -54,6 +55,9 @@
import org.apache.commons.beanutils.BeanComparator;
import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;
+import org.hibernate.annotations.Type;
+import org.hibernate.search.annotations.ContainedIn;
+import org.hibernate.search.annotations.IndexedEmbedded;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.NotEmpty;
@@ -62,6 +66,7 @@
* @author Adrien Cheype
*/
@Entity
+@Embeddable
public class TestBio extends AbstractModel implements Comparable<TestBio> {
/** Id du test bio */
@@ -92,7 +97,8 @@
/** Méthode pour la purification **/
@NotNull
- @ManyToOne(fetch = FetchType.LAZY, optional = false)
+ @ManyToOne(fetch = FetchType.EAGER, optional = false)
+ @IndexedEmbedded
private MethodeTestBio methode;
/** Concentration/masse utilisé par défaut pour les résultats **/
@@ -110,6 +116,7 @@
/** Commentaire pour la manip */
@Lob
+ @Type(type="org.hibernate.type.StringClobType") // see HHH-6105
private String complement;
/** Détermine si la manip doit être confidentielle */
@@ -129,6 +136,7 @@
@NotNull
@OneToMany(mappedBy = "testBio", fetch = FetchType.LAZY, orphanRemoval = true)
@Cascade({ CascadeType.SAVE_UPDATE })
+ @ContainedIn
private List<ResultatTestBio> resultats;
/**
Modified: trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/TypeDocument.java
===================================================================
--- trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/TypeDocument.java 2012-11-28 14:58:12 UTC (rev 35)
+++ trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/TypeDocument.java 2012-12-05 18:25:53 UTC (rev 36)
@@ -34,6 +34,7 @@
import nc.ird.cantharella.data.model.utils.AbstractModel;
import org.apache.commons.beanutils.BeanComparator;
+import org.hibernate.annotations.Type;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.NotEmpty;
@@ -63,6 +64,7 @@
/** Document type description */
@NotEmpty
@Lob
+ @Type(type="org.hibernate.type.StringClobType") // see HHH-6105
private String description;
/** If the type document represents an image ? */
Modified: trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/TypeExtrait.java
===================================================================
--- trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/TypeExtrait.java 2012-11-28 14:58:12 UTC (rev 35)
+++ trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/TypeExtrait.java 2012-12-05 18:25:53 UTC (rev 36)
@@ -34,6 +34,7 @@
import nc.ird.cantharella.data.validation.CollectionUniqueField;
import org.apache.commons.beanutils.BeanComparator;
+import org.hibernate.annotations.Type;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.NotEmpty;
@@ -59,6 +60,7 @@
/** Description du type d'extrait */
@NotEmpty
@Lob
+ @Type(type="org.hibernate.type.StringClobType") // see HHH-6105
private String description;
/** Méthode d'extraction pour laquelle est défini le type d'extrait */
Modified: trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/validation/CollectionUniqueFieldValidator.java
===================================================================
--- trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/validation/CollectionUniqueFieldValidator.java 2012-11-28 14:58:12 UTC (rev 35)
+++ trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/validation/CollectionUniqueFieldValidator.java 2012-12-05 18:25:53 UTC (rev 36)
@@ -64,7 +64,7 @@
this.pathToCollection));
Object propertyVal = BeanTools.getValue(value, AccessType.GETTER, fieldName);
- // each value of the field must have one occurence in the collection
+ // each value of the field must have one occurrence in the collection
return (propertyVal == null)
|| CollectionTools.countWithValue(collection, fieldName, AccessType.GETTER, propertyVal) == 1;
}
Modified: trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/validation/utils/ModelValidatorEventListener.java
===================================================================
--- trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/validation/utils/ModelValidatorEventListener.java 2012-11-28 14:58:12 UTC (rev 35)
+++ trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/validation/utils/ModelValidatorEventListener.java 2012-12-05 18:25:53 UTC (rev 36)
@@ -35,11 +35,11 @@
import org.apache.commons.logging.Log;
import org.hibernate.EntityMode;
-import org.hibernate.event.AbstractPreDatabaseOperationEvent;
-import org.hibernate.event.PreInsertEvent;
-import org.hibernate.event.PreInsertEventListener;
-import org.hibernate.event.PreUpdateEvent;
-import org.hibernate.event.PreUpdateEventListener;
+import org.hibernate.event.spi.AbstractPreDatabaseOperationEvent;
+import org.hibernate.event.spi.PreInsertEvent;
+import org.hibernate.event.spi.PreInsertEventListener;
+import org.hibernate.event.spi.PreUpdateEvent;
+import org.hibernate.event.spi.PreUpdateEventListener;
/**
* Validation event listener
@@ -94,7 +94,7 @@
*/
private void validate(AbstractPreDatabaseOperationEvent event, Operation operation) {
Object o = event.getEntity();
- if (event.getEntity() != null && event.getSession().getEntityMode() == EntityMode.POJO) {
+ if (event.getEntity() != null && event.getPersister().getEntityMode() == EntityMode.POJO) {
Set<ConstraintViolation<Object>> violations = validator.validate(o);
if (!violations.isEmpty()) {
LOG.error("Validation before " + operation.name() + " " + o.getClass().getName() + ":");
Added: trunk/cantharella.data/src/main/resources/commons/META-INF/services/org.hibernate.integrator.spi.Integrator
===================================================================
--- trunk/cantharella.data/src/main/resources/commons/META-INF/services/org.hibernate.integrator.spi.Integrator (rev 0)
+++ trunk/cantharella.data/src/main/resources/commons/META-INF/services/org.hibernate.integrator.spi.Integrator 2012-12-05 18:25:53 UTC (rev 36)
@@ -0,0 +1 @@
+nc.ird.cantharella.data.config.ValidationIntegrator
\ No newline at end of file
Modified: trunk/cantharella.data/src/main/resources/commons/sql/cantharella_schema_1.0.sql
===================================================================
--- trunk/cantharella.data/src/main/resources/commons/sql/cantharella_schema_1.0.sql 2012-11-28 14:58:12 UTC (rev 35)
+++ trunk/cantharella.data/src/main/resources/commons/sql/cantharella_schema_1.0.sql 2012-12-05 18:25:53 UTC (rev 36)
@@ -305,6 +305,16 @@
primary key (idTestBio)
);
+ create table TypeDocument (
+ idTypeDocument int4 not null,
+ description text not null,
+ domaine varchar(255),
+ estImage bool,
+ nom varchar(255) unique,
+ primary key (idTypeDocument),
+ unique (nom)
+ );
+
create table TypeExtrait (
idTypeExtrait int4 not null,
description text not null,
@@ -473,6 +483,8 @@
foreign key (purification_idPurification)
references Purification;
+ create index courriel on Personne (courriel);
+
alter table Purification
add constraint FKD1727611FE19187A
foreign key (produit_id)
Added: trunk/cantharella.data/src/test/java/nc/ird/cantharella/data/SchemaExporter.java
===================================================================
--- trunk/cantharella.data/src/test/java/nc/ird/cantharella/data/SchemaExporter.java (rev 0)
+++ trunk/cantharella.data/src/test/java/nc/ird/cantharella/data/SchemaExporter.java 2012-12-05 18:25:53 UTC (rev 36)
@@ -0,0 +1,36 @@
+package nc.ird.cantharella.data;
+
+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 {
+
+ @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());
+ sessionFactoryBean.setHibernateProperties(hibernateProperties);
+ sessionFactoryBean.afterPropertiesSet();
+ Configuration configuration = sessionFactoryBean.getConfiguration();
+ SchemaExport schemaExport = new SchemaExport(configuration);
+ schemaExport.create(true, false);
+
+ }
+}
Property changes on: trunk/cantharella.data/src/test/java/nc/ird/cantharella/data/SchemaExporter.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Modified: trunk/cantharella.data/src/test/java/nc/ird/cantharella/data/dao/GenericDaoTest.java
===================================================================
--- trunk/cantharella.data/src/test/java/nc/ird/cantharella/data/dao/GenericDaoTest.java 2012-11-28 14:58:12 UTC (rev 35)
+++ trunk/cantharella.data/src/test/java/nc/ird/cantharella/data/dao/GenericDaoTest.java 2012-12-05 18:25:53 UTC (rev 36)
@@ -22,13 +22,13 @@
*/
package nc.ird.cantharella.data.dao;
-import junit.framework.Assert;
import nc.ird.cantharella.data.AbstractDataTest;
import nc.ird.cantharella.data.exceptions.DataConstraintException;
+import org.hibernate.exception.SQLGrammarException;
+import org.junit.Assert;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.dao.DataAccessException;
/**
* GenericDaoTest
@@ -44,7 +44,7 @@
* Check that a wrong SQL request throws a DataAccessException
* @throws DataConstraintException -
*/
- @Test(expected = DataAccessException.class)
+ @Test(expected = SQLGrammarException.class)
public void execute() throws DataConstraintException {
dao.execute("SELECT * FROM Foo");
}
Added: trunk/cantharella.data/src/test/resources/log4j.xml
===================================================================
(Binary files differ)
Property changes on: trunk/cantharella.data/src/test/resources/log4j.xml
___________________________________________________________________
Added: svn:mime-type
+ application/xml
Added: trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/model/SearchResult.java
===================================================================
--- trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/model/SearchResult.java (rev 0)
+++ trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/model/SearchResult.java 2012-12-05 18:25:53 UTC (rev 36)
@@ -0,0 +1,94 @@
+/*
+ * #%L
+ * Cantharella :: Service
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2009 - 2012 IRD (Institut de Recherche pour le Developpement) and by respective authors (see below)
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+package nc.ird.cantharella.service.model;
+
+import java.io.Serializable;
+import java.util.List;
+
+import nc.ird.cantharella.data.model.Extraction;
+import nc.ird.cantharella.data.model.Lot;
+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.TestBio;
+
+/**
+ * Search result containing somes entities collections of various types.
+ *
+ * @author echatellier
+ */
+public class SearchResult implements Serializable {
+
+ /** serialVersionUID. */
+ private static final long serialVersionUID = -283841649665446890L;
+
+ protected List<Specimen> specimens;
+
+ protected List<Lot> lots;
+
+ protected List<Extraction> extractions;
+
+ protected List<Purification> purifications;
+
+ protected List<ResultatTestBio> resultatTestBios;
+
+ public List<Specimen> getSpecimens() {
+ return specimens;
+ }
+
+ public void setSpecimens(List<Specimen> specimens) {
+ this.specimens = specimens;
+ }
+
+ public List<Lot> getLots() {
+ return lots;
+ }
+
+ public void setLots(List<Lot> lots) {
+ this.lots = lots;
+ }
+
+ public List<Extraction> getExtractions() {
+ return extractions;
+ }
+
+ public void setExtractions(List<Extraction> extractions) {
+ this.extractions = extractions;
+ }
+
+ public List<Purification> getPurifications() {
+ return purifications;
+ }
+
+ public void setPurifications(List<Purification> purifications) {
+ this.purifications = purifications;
+ }
+
+ public List<ResultatTestBio> getResultatTestBios() {
+ return resultatTestBios;
+ }
+
+ public void setResultatTestBios(List<ResultatTestBio> resultatTestBios) {
+ this.resultatTestBios = resultatTestBios;
+ }
+}
Property changes on: trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/model/SearchResult.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: 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 (rev 0)
+++ trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/services/SearchService.java 2012-12-05 18:25:53 UTC (rev 36)
@@ -0,0 +1,49 @@
+/*
+ * #%L
+ * Cantharella :: Service
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2009 - 2012 IRD (Institut de Recherche pour le Developpement) and by respective authors (see below)
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+package nc.ird.cantharella.service.services;
+
+import org.springframework.transaction.annotation.Transactional;
+
+import nc.ird.cantharella.service.model.SearchResult;
+
+/**
+ * Service de recherche.
+ *
+ * @author echatellier
+ */
+public interface SearchService {
+
+ /**
+ * Rebuild all indexed with existing database entities.
+ */
+ public void reIndex();
+
+ /**
+ * Search for query result into data model.
+ *
+ * @param query query
+ * @return search result
+ */
+ @Transactional(readOnly = true)
+ public SearchResult search(String query);
+}
Property changes on: trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/services/SearchService.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Modified: trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/services/impl/DocumentServiceImpl.java
===================================================================
--- trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/services/impl/DocumentServiceImpl.java 2012-11-28 14:58:12 UTC (rev 35)
+++ trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/services/impl/DocumentServiceImpl.java 2012-12-05 18:25:53 UTC (rev 36)
@@ -28,7 +28,6 @@
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.Partie;
import nc.ird.cantharella.data.model.TypeDocument;
import nc.ird.cantharella.service.services.DocumentService;
import nc.ird.module.utils.AssertTools;
Added: 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 (rev 0)
+++ trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/services/impl/SearchServiceImpl.java 2012-12-05 18:25:53 UTC (rev 36)
@@ -0,0 +1,150 @@
+/*
+ * #%L
+ * Cantharella :: Service
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2009 - 2012 IRD (Institut de Recherche pour le Developpement) and by respective authors (see below)
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+package nc.ird.cantharella.service.services.impl;
+
+import java.util.Collection;
+import java.util.List;
+
+import javax.annotation.Resource;
+
+import nc.ird.cantharella.data.model.Extraction;
+import nc.ird.cantharella.data.model.Lot;
+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.service.model.SearchResult;
+import nc.ird.cantharella.service.services.SearchService;
+import nc.ird.module.utils.LogTools;
+
+import org.apache.commons.logging.Log;
+import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.queryParser.MultiFieldQueryParser;
+import org.apache.lucene.queryParser.ParseException;
+import org.apache.lucene.queryParser.QueryParser;
+import org.apache.lucene.queryParser.QueryParser.Operator;
+import org.apache.lucene.search.Query;
+import org.apache.lucene.util.Version;
+import org.hibernate.Session;
+import org.hibernate.SessionFactory;
+import org.hibernate.search.FullTextSession;
+import org.hibernate.search.Search;
+import org.hibernate.search.SearchFactory;
+import org.springframework.stereotype.Service;
+
+/**
+ * Implémentation du service de recherche.
+ *
+ * @author echatellier
+ */
+@Service
+public class SearchServiceImpl implements SearchService {
+
+ /** Logger */
+ private static final Log LOG = LogTools.getLog();
+
+ @Resource
+ private SessionFactory sessionFactory;
+
+ public void reIndex() {
+ long before = System.currentTimeMillis();
+ if (LOG.isInfoEnabled()) {
+ LOG.info("Starting full rebuild on lucene index");
+ }
+ // get hibernate search session
+ Session session = sessionFactory.getCurrentSession();
+ FullTextSession fullTextSession = Search.getFullTextSession(session);
+ try {
+ fullTextSession.createIndexer().startAndWait();
+
+ if (LOG.isInfoEnabled()) {
+ long after = System.currentTimeMillis();
+ LOG.info("Lucene index rebuilded in " + (after-before) + " ms");
+ }
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Override
+ public SearchResult search(String strQuery) {
+ SearchResult result = new SearchResult();
+
+ // get hibernate search session
+ Session session = sessionFactory.getCurrentSession();
+ FullTextSession fullTextSession = Search.getFullTextSession(session);
+
+ // le flushToIndexes n'est pas correct ici, il sert juste a faire
+ // passer les tests pour que les indexes lucene contiennent des données
+ // nécéssaire car il ne sont écrits que lorsque Spring commmit la
+ // transaction (c'est à dire jamais dans les tests)
+ fullTextSession.flushToIndexes();
+
+ 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);
+
+ // execute search
+ List<Specimen> specimens = hibSpecimen.list();
+ List<Lot> lots = hibLot.list();
+ List<Extraction> extractions = hibExtraction.list();
+ List<Purification> purifications = hibPurification.list();
+ List<ResultatTestBio> resultatTestBios = hibResultatTestBio.list();
+
+ result.setSpecimens(specimens);
+ result.setLots(lots);
+ result.setExtractions(extractions);
+ result.setPurifications(purifications);
+ result.setResultatTestBios(resultatTestBios);
+
+ } catch (ParseException e) {
+ e.printStackTrace();
+ }
+
+ //tx.commit();
+ //session.close();
+ return result;
+ }
+
+ protected org.hibernate.Query getQuery(FullTextSession fullTextSession, Class<?> clazz, String strQuery) 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);
+ String[] fieldArray = fieldNames.toArray(new String[fieldNames.size()]);
+ QueryParser parser = new MultiFieldQueryParser(Version.LUCENE_35, fieldArray,
+ searchFactory.getAnalyzer(Lot.class));
+
+ // 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);
+ return hibQuery;
+ }
+}
Property changes on: trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/services/impl/SearchServiceImpl.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Modified: trunk/cantharella.service/src/main/resources/development/service.properties
===================================================================
--- trunk/cantharella.service/src/main/resources/development/service.properties 2012-11-28 14:58:12 UTC (rev 35)
+++ trunk/cantharella.service/src/main/resources/development/service.properties 2012-12-05 18:25:53 UTC (rev 36)
@@ -22,7 +22,7 @@
###
mail.debug=true
mail.from=no-reply(a)ird.fr
-mail.host=smtp.ird.nc
+mail.host=smtp
admin.courriel=ISlog(a)ird.fr
admin.password=password
\ No newline at end of file
Modified: trunk/cantharella.service/src/test/java/nc/ird/cantharella/service/services/PersonneServiceTest.java
===================================================================
--- trunk/cantharella.service/src/test/java/nc/ird/cantharella/service/services/PersonneServiceTest.java 2012-11-28 14:58:12 UTC (rev 35)
+++ trunk/cantharella.service/src/test/java/nc/ird/cantharella/service/services/PersonneServiceTest.java 2012-12-05 18:25:53 UTC (rev 36)
@@ -54,12 +54,12 @@
/**
* Test: load
* @throws DataNotFoundException -
+ * @throws DataConstraintException
*/
@Test
- public void load() throws DataNotFoundException {
+ public void load() throws DataNotFoundException, DataConstraintException {
+ personneService.checkOrCreateAdmin();
List<Personne> personnes = personneService.listPersonnes();
- if (!personnes.isEmpty()) {
- personneService.loadPersonne(personnes.get(0).getCourriel().toUpperCase());
- }
+ personneService.loadPersonne(personnes.get(0).getCourriel().toUpperCase());
}
}
Added: 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 (rev 0)
+++ trunk/cantharella.service/src/test/java/nc/ird/cantharella/service/services/SearchServiceTest.java 2012-12-05 18:25:53 UTC (rev 36)
@@ -0,0 +1,328 @@
+/*
+ * #%L
+ * Cantharella :: Service
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2009 - 2012 IRD (Institut de Recherche pour le Developpement) and by respective authors (see below)
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+package nc.ird.cantharella.service.services;
+
+import java.util.Collections;
+import java.util.Date;
+import java.util.List;
+
+import nc.ird.cantharella.data.exceptions.DataConstraintException;
+import nc.ird.cantharella.data.model.Campagne;
+import nc.ird.cantharella.data.model.Extraction;
+import nc.ird.cantharella.data.model.Extrait;
+import nc.ird.cantharella.data.model.Lot;
+import nc.ird.cantharella.data.model.MethodeExtraction;
+import nc.ird.cantharella.data.model.MethodeTestBio;
+import nc.ird.cantharella.data.model.ResultatTestBio;
+import nc.ird.cantharella.data.model.ResultatTestBio.TypeResultat;
+import nc.ird.cantharella.data.model.Specimen;
+import nc.ird.cantharella.data.model.Specimen.TypeOrganisme;
+import nc.ird.cantharella.data.model.Station;
+import nc.ird.cantharella.data.model.TestBio;
+import nc.ird.cantharella.data.model.TypeExtrait;
+import nc.ird.cantharella.data.model.Utilisateur;
+import nc.ird.cantharella.service.AbstractServiceTest;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+
+/**
+ * Search service tests.
+ *
+ * @author echatellier
+ */
+public class SearchServiceTest extends AbstractServiceTest {
+
+ /** Administrateur par défaut */
+ @Autowired
+ private Utilisateur defaultAdmin;
+
+ @Autowired
+ private PersonneService personneService;
+
+ @Autowired
+ private CampagneService campagneService;
+
+ @Autowired
+ private StationService stationService;
+
+ @Autowired
+ private SpecimenService specimenService;
+
+ @Autowired
+ private LotService lotService;
+
+ @Autowired
+ private SearchService searchService;
+
+ @Autowired
+ private TestBioService testBioService;
+
+ @Autowired
+ private ExtractionService extractionService;
+
+ /**
+ * L'index devrait normalement etre rollback par spring comme la transaction.
+ * Mais visiblement cela ne fonctionne pas.
+ */
+ @Before
+ public void clearIndex() {
+ searchService.reIndex();
+ }
+
+ /**
+ * Test to create some specimen and search for it.
+ * @throws DataConstraintException
+ */
+ @Test
+ public void testSearchSpecimen() throws DataConstraintException {
+
+ // fix user creation for test
+ defaultAdmin.setValide(Boolean.TRUE);
+ personneService.createPersonne(defaultAdmin);
+
+ // create some specimens
+ Specimen specimen1 = new Specimen();
+ specimen1.setRef("P175");
+ specimen1.setEmbranchement("embranchement 175");
+ specimen1.setTypeOrganisme(TypeOrganisme.PLANTE);
+ specimen1.setCreateur(defaultAdmin);
+ specimenService.createSpecimen(specimen1);
+
+ Specimen specimen2 = new Specimen();
+ specimen2.setRef("P174");
+ specimen2.setEmbranchement("embranchement 174");
+ specimen2.setTypeOrganisme(TypeOrganisme.CHAMPIGNON);
+ specimen2.setCreateur(defaultAdmin);
+ specimenService.createSpecimen(specimen2);
+
+ // test to create some entity
+ Assert.assertEquals(2, specimenService.countSpecimens());
+
+ // search into lucene
+ List<Specimen> specimens = searchService.search("P175").getSpecimens();
+ Assert.assertEquals(specimen1, specimens.get(0));
+ specimens = searchService.search("P174").getSpecimens();
+ Assert.assertEquals(specimen2, specimens.get(0));
+ specimens = searchService.search("P17?").getSpecimens();
+ Assert.assertEquals(2, specimens.size());
+ }
+
+ /**
+ * Test to create some lot and search for it.
+ * @throws DataConstraintException
+ */
+ @Test
+ public void testSearchLot() throws DataConstraintException {
+
+ // fix user creation for test
+ defaultAdmin.setValide(Boolean.TRUE);
+ personneService.createPersonne(defaultAdmin);
+
+ // station
+ Station station = new Station();
+ station.setNom("MT1");
+ station.setCodePays("FR");
+ station.setCreateur(defaultAdmin);
+ stationService.createStation(station);
+
+ // campagne
+ Campagne campagne = new Campagne();
+ campagne.setNom("BSM-PF1");
+ campagne.setDateDeb(new Date());
+ campagne.setDateFin(new Date());
+ campagne.setCreateur(defaultAdmin);
+ campagne.setCodePays("FR");
+ campagneService.createCampagne(campagne);
+
+ // create some specimens
+ Specimen specimen1 = new Specimen();
+ specimen1.setRef("P175");
+ specimen1.setEmbranchement("Porifera");
+ specimen1.setTypeOrganisme(TypeOrganisme.PLANTE);
+ specimen1.setCreateur(defaultAdmin);
+ specimenService.createSpecimen(specimen1);
+
+ // create some lots
+ Lot lot1 = new Lot();
+ lot1.setRef("P164-MHO4");
+ lot1.setStation(station);
+ lot1.setEchantillonPhylo(false);
+ lot1.setEchantillonColl(false);
+ lot1.setEchantillonIdent(true);
+ lot1.setCampagne(campagne);
+ lot1.setDateRecolte(new Date());
+ lot1.setSpecimenRef(specimen1);
+ lot1.setCreateur(defaultAdmin);
+ lotService.createLot(lot1);
+
+ Assert.assertEquals(1, lotService.countLots()); // force sync
+
+ // search into lucene
+ List<Lot> lots = searchService.search("MHO4").getLots();
+ Assert.assertEquals(lot1, lots.get(0));
+ lots = searchService.search("Foo").getLots();
+ Assert.assertTrue(lots.isEmpty());
+
+ // test de recherche sur les entités liées
+ lots = searchService.search("porifera").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));
+
+ // update direct entity
+ lot1.setRef("P175-MT4+5");
+ lotService.updateLot(lot1);
+ 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));
+ }
+
+ /**
+ * Test to create some resultat test bio and search for it.
+ * @throws DataConstraintException
+ */
+ @Test
+ public void testSearchResultatTestBio() throws DataConstraintException {
+ // fix user creation for test
+ defaultAdmin.setValide(Boolean.TRUE);
+ personneService.createPersonne(defaultAdmin);
+
+ // station
+ Station station = new Station();
+ station.setNom("MT1");
+ station.setCodePays("FR");
+ station.setCreateur(defaultAdmin);
+ stationService.createStation(station);
+
+ // campagne
+ Campagne campagne = new Campagne();
+ campagne.setNom("BSM-PF1");
+ campagne.setDateDeb(new Date());
+ campagne.setDateFin(new Date());
+ campagne.setCreateur(defaultAdmin);
+ campagne.setCodePays("FR");
+ campagneService.createCampagne(campagne);
+
+ // create some specimens
+ Specimen specimen1 = new Specimen();
+ specimen1.setRef("P175");
+ specimen1.setEmbranchement("Porifera");
+ specimen1.setTypeOrganisme(TypeOrganisme.PLANTE);
+ specimen1.setCreateur(defaultAdmin);
+ specimenService.createSpecimen(specimen1);
+
+ // create some lots
+ Lot lot1 = new Lot();
+ lot1.setRef("P164-MHO4");
+ lot1.setStation(station);
+ lot1.setEchantillonPhylo(false);
+ lot1.setEchantillonColl(false);
+ lot1.setEchantillonIdent(true);
+ lot1.setCampagne(campagne);
+ lot1.setDateRecolte(new Date());
+ lot1.setSpecimenRef(specimen1);
+ lot1.setCreateur(defaultAdmin);
+ lotService.createLot(lot1);
+
+ // type extrait
+ TypeExtrait typeExtrait1 = new TypeExtrait();
+ typeExtrait1.setDescription("Type extrait");
+ typeExtrait1.setInitiales("TE");
+
+ // methode extraction
+ MethodeExtraction methodeExtraction1 = new MethodeExtraction();
+ typeExtrait1.setMethodeExtraction(methodeExtraction1);
+ methodeExtraction1.setNom("MET-01");
+ methodeExtraction1.setDescription("Desc");
+ methodeExtraction1.setTypesEnSortie(Collections.singletonList(typeExtrait1));
+ extractionService.createMethodeExtraction(methodeExtraction1);
+
+ // produit
+ Extrait extrait1 = new Extrait();
+ extrait1.setRef("P175-MT1D");
+ extrait1.setTypeExtrait(typeExtrait1);
+ Extraction extraction1 = new Extraction();
+ extraction1.setRef("EXT-01");
+ extraction1.setExtraits(Collections.singletonList(extrait1));
+ extrait1.setExtraction(extraction1);
+ extraction1.setDate(new Date());
+ extraction1.setCreateur(defaultAdmin);
+ extraction1.setManipulateur(defaultAdmin);
+ extraction1.setLot(lot1);
+ extraction1.setMethode(methodeExtraction1);
+ extractionService.createExtraction(extraction1);
+
+ // methode
+ MethodeTestBio methodeTestBio1 = new MethodeTestBio();
+ methodeTestBio1.setNom("Test method");
+ methodeTestBio1.setCible("KB");
+ methodeTestBio1.setValeurMesuree("Temparature");
+ methodeTestBio1.setDomaine("domain");
+ methodeTestBio1.setDescription("Temperature effective");
+ methodeTestBio1.setUniteResultat("°C");
+ testBioService.createMethodeTestBio(methodeTestBio1);
+
+ // test bio
+ TestBio testBio1 = new TestBio();
+ testBio1.setRef("TC-T2");
+ testBio1.setMethode(methodeTestBio1);
+ testBio1.setCreateur(defaultAdmin);
+ testBio1.setManipulateur(defaultAdmin);
+ testBio1.setDate(new Date());
+ testBio1.setOrganismeTesteur("IRD");
+
+ // resultatTestBio
+ ResultatTestBio resultatTestBio1 = new ResultatTestBio();
+ resultatTestBio1.setRepere("T2-E2");
+ resultatTestBio1.setTypeResultat(TypeResultat.PRODUIT);
+ resultatTestBio1.setActif(true);
+ resultatTestBio1.setTestBio(testBio1);
+ resultatTestBio1.setProduit(extrait1);
+ testBio1.setResultats(Collections.singletonList(resultatTestBio1));
+ testBioService.createTestBio(testBio1);
+
+ 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());
+ }
+}
Property changes on: trunk/cantharella.service/src/test/java/nc/ird/cantharella/service/services/SearchServiceTest.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/cantharella.service/src/test/resources/log4j.xml
===================================================================
(Binary files differ)
Property changes on: trunk/cantharella.service/src/test/resources/log4j.xml
___________________________________________________________________
Added: svn:mime-type
+ application/xml
Modified: trunk/cantharella.utils/pom.xml
===================================================================
--- trunk/cantharella.utils/pom.xml 2012-11-28 14:58:12 UTC (rev 35)
+++ trunk/cantharella.utils/pom.xml 2012-12-05 18:25:53 UTC (rev 36)
@@ -28,8 +28,8 @@
<artifactId>commons-io</artifactId>
</dependency>
<dependency>
- <groupId>commons-lang</groupId>
- <artifactId>commons-lang</artifactId>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-lang3</artifactId>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
@@ -37,11 +37,6 @@
</dependency>
<dependency>
- <groupId>com.ibm.icu</groupId>
- <artifactId>icu4j</artifactId>
- </dependency>
-
- <dependency>
<groupId>net.sf.opencsv</groupId>
<artifactId>opencsv</artifactId>
</dependency>
Modified: trunk/cantharella.utils/src/main/java/nc/ird/module/utils/BeanLookup.java
===================================================================
--- trunk/cantharella.utils/src/main/java/nc/ird/module/utils/BeanLookup.java 2012-11-28 14:58:12 UTC (rev 35)
+++ trunk/cantharella.utils/src/main/java/nc/ird/module/utils/BeanLookup.java 2012-12-05 18:25:53 UTC (rev 36)
@@ -24,7 +24,7 @@
import nc.ird.module.utils.BeanTools.AccessType;
-import org.apache.commons.lang.text.StrLookup;
+import org.apache.commons.lang3.text.StrLookup;
/**
* Retrieve a bean field value from the bean field name
Modified: trunk/cantharella.utils/src/main/java/nc/ird/module/utils/BeanTools.java
===================================================================
--- trunk/cantharella.utils/src/main/java/nc/ird/module/utils/BeanTools.java 2012-11-28 14:58:12 UTC (rev 35)
+++ trunk/cantharella.utils/src/main/java/nc/ird/module/utils/BeanTools.java 2012-12-05 18:25:53 UTC (rev 36)
@@ -35,8 +35,8 @@
import java.util.regex.Pattern;
import org.apache.commons.beanutils.BeanComparator;
-import org.apache.commons.lang.StringUtils;
-import org.apache.commons.lang.builder.EqualsBuilder;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.lang3.builder.EqualsBuilder;
/**
* Tools for beans
Modified: trunk/cantharella.utils/src/main/java/nc/ird/module/utils/CaptchaTools.java
===================================================================
--- trunk/cantharella.utils/src/main/java/nc/ird/module/utils/CaptchaTools.java 2012-11-28 14:58:12 UTC (rev 35)
+++ trunk/cantharella.utils/src/main/java/nc/ird/module/utils/CaptchaTools.java 2012-12-05 18:25:53 UTC (rev 36)
@@ -22,7 +22,7 @@
*/
package nc.ird.module.utils;
-import org.apache.commons.lang.RandomStringUtils;
+import org.apache.commons.lang3.RandomStringUtils;
/**
* Tools for captchas
Modified: trunk/cantharella.utils/src/main/java/nc/ird/module/utils/CollectionTools.java
===================================================================
--- trunk/cantharella.utils/src/main/java/nc/ird/module/utils/CollectionTools.java 2012-11-28 14:58:12 UTC (rev 35)
+++ trunk/cantharella.utils/src/main/java/nc/ird/module/utils/CollectionTools.java 2012-12-05 18:25:53 UTC (rev 36)
@@ -31,7 +31,7 @@
import nc.ird.module.utils.BeanTools.AccessType;
-import org.apache.commons.lang.ObjectUtils;
+import org.apache.commons.lang3.ObjectUtils;
/**
* Tools for collections
Modified: trunk/cantharella.utils/src/main/java/nc/ird/module/utils/CoordTools.java
===================================================================
--- trunk/cantharella.utils/src/main/java/nc/ird/module/utils/CoordTools.java 2012-11-28 14:58:12 UTC (rev 35)
+++ trunk/cantharella.utils/src/main/java/nc/ird/module/utils/CoordTools.java 2012-12-05 18:25:53 UTC (rev 36)
@@ -27,7 +27,7 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.StringUtils;
/**
* Tools for coordonates
Modified: trunk/cantharella.utils/src/main/java/nc/ird/module/utils/PasswordTools.java
===================================================================
--- trunk/cantharella.utils/src/main/java/nc/ird/module/utils/PasswordTools.java 2012-11-28 14:58:12 UTC (rev 35)
+++ trunk/cantharella.utils/src/main/java/nc/ird/module/utils/PasswordTools.java 2012-12-05 18:25:53 UTC (rev 36)
@@ -23,7 +23,7 @@
package nc.ird.module.utils;
import org.apache.commons.codec.digest.DigestUtils;
-import org.apache.commons.lang.RandomStringUtils;
+import org.apache.commons.lang3.RandomStringUtils;
/**
* Tools for passwords
Modified: trunk/cantharella.utils/src/main/java/nc/ird/module/utils/StringTools.java
===================================================================
--- trunk/cantharella.utils/src/main/java/nc/ird/module/utils/StringTools.java 2012-11-28 14:58:12 UTC (rev 35)
+++ trunk/cantharella.utils/src/main/java/nc/ird/module/utils/StringTools.java 2012-12-05 18:25:53 UTC (rev 36)
@@ -31,10 +31,8 @@
import java.util.Map.Entry;
import org.apache.commons.io.LineIterator;
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.StringUtils;
-import com.ibm.icu.text.Normalizer;
-
/**
* Tools for strings
* @author Mickael Tricot
@@ -126,8 +124,7 @@
* @return Non-accented string
*/
public static String replaceAccents(String string) {
- return StringUtils.isEmpty(string) ? string : Normalizer.decompose(string, false, 0).replaceAll(
- "\\p{InCombiningDiacriticalMarks}+", "");
+ return StringUtils.stripAccents(string);
}
/**
Modified: trunk/cantharella.utils/src/main/java/nc/ird/module/utils/StringTransformer.java
===================================================================
--- trunk/cantharella.utils/src/main/java/nc/ird/module/utils/StringTransformer.java 2012-11-28 14:58:12 UTC (rev 35)
+++ trunk/cantharella.utils/src/main/java/nc/ird/module/utils/StringTransformer.java 2012-12-05 18:25:53 UTC (rev 36)
@@ -22,8 +22,8 @@
*/
package nc.ird.module.utils;
-import org.apache.commons.lang.StringUtils;
-import org.apache.commons.lang.WordUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.lang3.text.WordUtils;
/**
* String transformer, chained, null-safe
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 2012-11-28 14:58:12 UTC (rev 35)
+++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/config/WebApplicationImpl.java 2012-12-05 18:25:53 UTC (rev 36)
@@ -46,6 +46,7 @@
import nc.ird.cantharella.web.pages.domain.purification.ListPurificationsPage;
import nc.ird.cantharella.web.pages.domain.purification.ManagePurificationPage;
import nc.ird.cantharella.web.pages.domain.purification.ReadPurificationPage;
+import nc.ird.cantharella.web.pages.domain.search.SearchPage;
import nc.ird.cantharella.web.pages.domain.specimen.ListSpecimensPage;
import nc.ird.cantharella.web.pages.domain.specimen.ManageSpecimenPage;
import nc.ird.cantharella.web.pages.domain.specimen.ReadSpecimenPage;
@@ -399,7 +400,10 @@
getRootRequestMapperAsCompound().add(new MountedMapper("/register", RegisterPage.class));
mountPage("/register", RegisterPage.class);
getRootRequestMapperAsCompound().add(new MountedMapper("/passwordLost", ResetPasswordPage.class));
- mountPage("/passwordLost", ResetPasswordPage.class);
+ mountPage("/passwordLost", ResetPasswordPage.class);
+
+ getRootRequestMapperAsCompound().add(new MountedMapper("/search", SearchPage.class));
+ mountPage("/search", SearchPage.class);
}
}
\ No newline at end of file
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 2012-11-28 14:58:12 UTC (rev 35)
+++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/TemplatePage.html 2012-12-05 18:25:53 UTC (rev 36)
@@ -63,10 +63,10 @@
<wicket:container wicket:id="Search.USER">
<div id="search">
- <form>
+ <form wicket:id="Search.FORM">
<div>
<label for="search_txt" style="display: none"><wicket:message key="TemplatePage.Search.Label"/></label>
- <input type="text" id="search_txt"/>
+ <input type="text" wicket:id="query" id="search_txt"/>
<input type="submit" id="search_submit" wicket:message="value:TemplatePage.Search, title:TemplatePage.Search.Launch" />
</div>
</form>
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 2012-11-28 14:58:12 UTC (rev 35)
+++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/TemplatePage.java 2012-12-05 18:25:53 UTC (rev 36)
@@ -34,6 +34,7 @@
import nc.ird.cantharella.web.pages.domain.lot.ListLotsPage;
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;
import nc.ird.cantharella.web.pages.domain.specimen.ListSpecimensPage;
import nc.ird.cantharella.web.pages.domain.station.ListStationsPage;
import nc.ird.cantharella.web.pages.domain.testBio.ListTestsBioPage;
@@ -55,11 +56,15 @@
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.markup.html.basic.Label;
+import org.apache.wicket.markup.html.form.Form;
+import org.apache.wicket.markup.html.form.TextField;
import org.apache.wicket.markup.html.link.BookmarkablePageLink;
import org.apache.wicket.markup.html.link.Link;
import org.apache.wicket.markup.html.panel.FeedbackPanel;
+import org.apache.wicket.model.CompoundPropertyModel;
import org.apache.wicket.model.PropertyModel;
import org.apache.wicket.request.mapper.parameter.PageParameters;
+import org.apache.wicket.util.value.ValueMap;
/**
* Template page
@@ -193,7 +198,18 @@
*/
private AuthContainer createUserSearch() {
AuthContainer userSatellite = new AuthContainer("Search.USER", AuthRole.USER, AuthRole.ADMIN);
- // TODO To complete with research functionalities
+
+ Form<ValueMap> searchForm = new Form<ValueMap>("Search.FORM", new CompoundPropertyModel<ValueMap>(new ValueMap())) {
+ protected void onSubmit() {
+ ValueMap values = getModelObject();
+
+ String query = values.getString("query");
+ setResponsePage(new SearchPage(query));
+ }
+ };
+ searchForm.add(new TextField<String>("query").setType(String.class));
+
+ userSatellite.add(searchForm);
return userSatellite;
}
Modified: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/config/ListConfigurationPage.html
===================================================================
--- trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/config/ListConfigurationPage.html 2012-11-28 14:58:12 UTC (rev 35)
+++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/config/ListConfigurationPage.html 2012-12-05 18:25:53 UTC (rev 36)
@@ -35,6 +35,8 @@
<div wicket:id="ListConfigurationPage.ListMethodeTestBioPanel"/>
<div wicket:id="ListConfigurationPage.ListErreurTestBioPanel"/>
+
+ <div wicket:id="ListConfigurationPage.RebuildLuceneIndexPanel"/>
</wicket:extend>
</body>
Modified: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/config/ListConfigurationPage.java
===================================================================
--- trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/config/ListConfigurationPage.java 2012-11-28 14:58:12 UTC (rev 35)
+++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/config/ListConfigurationPage.java 2012-12-05 18:25:53 UTC (rev 36)
@@ -28,6 +28,7 @@
import nc.ird.cantharella.web.pages.domain.config.panels.ListMethodePurificationPanel;
import nc.ird.cantharella.web.pages.domain.config.panels.ListMethodeTestBioPanel;
import nc.ird.cantharella.web.pages.domain.config.panels.ListPartiePanel;
+import nc.ird.cantharella.web.pages.domain.config.panels.RebuildLuceneIndexPanel;
import nc.ird.cantharella.web.utils.panels.CollapsiblePanel;
import nc.ird.cantharella.web.utils.security.AuthRole;
import nc.ird.cantharella.web.utils.security.AuthRoles;
@@ -59,6 +60,7 @@
boolean methPuriOpened = checkIfPanelOpened(params, "methodePurification");
boolean methTestOpened = checkIfPanelOpened(params, "methodeTestBio");
boolean errTestOpened = checkIfPanelOpened(params, "erreurTestBio");
+ boolean rebIndexOpened = checkIfPanelOpened(params, "rebuildLuceneIndex");
if (params.get("openedTab").equals("partie")) {
partieOpened = true;
@@ -115,6 +117,15 @@
return new ListErreurTestBioPanel(markupId);
}
});
+
+ // initialize the RebuidLuceneIndex panel
+ add(new CollapsiblePanel(getResource() + ".RebuildLuceneIndexPanel", new Model<String>(
+ getString("ListConfigurationPage.RebuildLuceneIndex")), rebIndexOpened) {
+ @Override
+ protected Panel getInnerPanel(String markupId) {
+ return new RebuildLuceneIndexPanel(markupId);
+ }
+ });
}
/**
Added: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/config/panels/RebuildLuceneIndexPanel.html
===================================================================
--- trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/config/panels/RebuildLuceneIndexPanel.html (rev 0)
+++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/config/panels/RebuildLuceneIndexPanel.html 2012-12-05 18:25:53 UTC (rev 36)
@@ -0,0 +1,33 @@
+<!--
+ #%L
+ Cantharella :: Web
+ $Id:$
+ $HeadURL:$
+ %%
+ Copyright (C) 2009 - 2012 IRD (Institut de Recherche pour le Developpement) and by respective authors (see below)
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+ #L%
+ -->
+<!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">
+
+ <wicket:panel>
+ <form wicket:id="Form">
+ <input type="submit" wicket:message="value:Rebuild" wicket:id="Rebuild" />
+ <span wicket:id="rebuildResult" />
+ </form>
+ </wicket:panel>
+</html>
\ No newline at end of file
Added: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/config/panels/RebuildLuceneIndexPanel.java
===================================================================
--- trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/config/panels/RebuildLuceneIndexPanel.java (rev 0)
+++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/config/panels/RebuildLuceneIndexPanel.java 2012-12-05 18:25:53 UTC (rev 36)
@@ -0,0 +1,76 @@
+/*
+ * #%L
+ * Cantharella :: Web
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2009 - 2012 IRD (Institut de Recherche pour le Developpement) and by respective authors (see below)
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+package nc.ird.cantharella.web.pages.domain.config.panels;
+
+import nc.ird.cantharella.service.services.SearchService;
+
+import org.apache.wicket.ajax.AjaxRequestTarget;
+import org.apache.wicket.ajax.markup.html.form.AjaxFallbackButton;
+import org.apache.wicket.markup.html.basic.Label;
+import org.apache.wicket.markup.html.form.Button;
+import org.apache.wicket.markup.html.form.Form;
+import org.apache.wicket.markup.html.panel.Panel;
+import org.apache.wicket.model.Model;
+import org.apache.wicket.spring.injection.annot.SpringBean;
+
+/**
+ * Panel qui permet de reconstruire l'index lucene.
+ *
+ * @author Eric Chattellier
+ */
+public class RebuildLuceneIndexPanel extends Panel {
+
+ /** Service : test */
+ @SpringBean
+ private SearchService searchService;
+
+ protected Label rebuildResultLabel;
+
+ /**
+ * Constructor
+ * @param id The panel ID
+ */
+ public RebuildLuceneIndexPanel(String id) {
+ super(id);
+
+ final Form<Void> formView = new Form<Void>("Form");
+
+ Button addButton = new AjaxFallbackButton("Rebuild", formView) {
+ @Override
+ protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
+ rebuildResultLabel.setDefaultModelObject("Rebuilding...");
+ searchService.reIndex();
+ rebuildResultLabel.setDefaultModelObject("Done.");
+ }
+
+ @Override
+ protected void onError(AjaxRequestTarget target, Form<?> form) {
+
+ }
+ };
+ formView.add(addButton);
+ rebuildResultLabel = new Label("rebuildResult", new Model<String>(""));
+ formView.add(rebuildResultLabel);
+ add(formView);
+ }
+}
Property changes on: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/config/panels/RebuildLuceneIndexPanel.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: 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 (rev 0)
+++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/search/SearchPage.html 2012-12-05 18:25:53 UTC (rev 36)
@@ -0,0 +1,50 @@
+<!--
+ #%L
+ Cantharella :: Web
+ $Id:$
+ $HeadURL:$
+ %%
+ Copyright (C) 2009 - 2012 IRD (Institut de Recherche pour le Developpement) and by respective authors (see below)
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+ #L%
+ -->
+<!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="SearchPage.Form">
+ <wicket:message key="SearchPage.QueryLabel" />
+ <input type="text" wicket:id="query" />
+ <input type="submit" wicket:message="value:SearchPage.Search" />
+</form>
+
+<!-- <div wicket:id="SearchPage.Results.Refresh"> -->
+<wicket:message key="SearchPage.Specimens" />
+<table cellspacing="0" wicket:id="SearchPage.Specimens.Results"/>
+<wicket:message key="SearchPage.Lots" />
+<table cellspacing="0" wicket:id="SearchPage.Lots.Results"/>
+<wicket:message key="SearchPage.Extractions" />
+<table cellspacing="0" wicket:id="SearchPage.Extractions.Results"/>
+<wicket:message key="SearchPage.Purifications" />
+<table cellspacing="0" wicket:id="SearchPage.Purifications.Results"/>
+<wicket:message key="SearchPage.ResultatTestBios" />
+<table cellspacing="0" wicket:id="SearchPage.ResultatTestBios.Results"/>
+<!-- </div> -->
+
+</wicket:extend>
+</body>
+</html>
\ No newline at end of file
Added: 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 (rev 0)
+++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/search/SearchPage.java 2012-12-05 18:25:53 UTC (rev 36)
@@ -0,0 +1,470 @@
+/*
+ * #%L
+ * Cantharella :: Web
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2009 - 2012 IRD (Institut de Recherche pour le Developpement) and by respective authors (see below)
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+package nc.ird.cantharella.web.pages.domain.search;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+
+import nc.ird.cantharella.data.model.Extraction;
+import nc.ird.cantharella.data.model.Extrait;
+import nc.ird.cantharella.data.model.Fraction;
+import nc.ird.cantharella.data.model.Lot;
+import nc.ird.cantharella.data.model.Purification;
+import nc.ird.cantharella.data.model.ResultatTestBio;
+import nc.ird.cantharella.data.model.Specimen;
+import nc.ird.cantharella.service.model.SearchResult;
+import nc.ird.cantharella.service.services.SearchService;
+import nc.ird.cantharella.web.config.WebContext;
+import nc.ird.cantharella.web.pages.TemplatePage;
+import nc.ird.cantharella.web.pages.columns.LinkProduitPropertyColumn;
+import nc.ird.cantharella.web.pages.columns.TaxonomyPropertyColumn;
+import nc.ird.cantharella.web.pages.domain.campagne.ReadCampagnePage;
+import nc.ird.cantharella.web.pages.domain.extraction.ReadExtractionPage;
+import nc.ird.cantharella.web.pages.domain.lot.ReadLotPage;
+import nc.ird.cantharella.web.pages.domain.purification.ReadPurificationPage;
+import nc.ird.cantharella.web.pages.domain.specimen.ListSpecimensPage;
+import nc.ird.cantharella.web.pages.domain.specimen.ReadSpecimenPage;
+import nc.ird.cantharella.web.pages.domain.station.ReadStationPage;
+import nc.ird.cantharella.web.pages.domain.testBio.ReadTestBioPage;
+import nc.ird.cantharella.web.utils.CallerPage;
+import nc.ird.cantharella.web.utils.behaviors.ReplaceEmptyLabelBehavior;
+import nc.ird.cantharella.web.utils.columns.BooleanPropertyColumn;
+import nc.ird.cantharella.web.utils.columns.DecimalPropertyColumn;
+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.columns.MapValuePropertyColumn;
+import nc.ird.cantharella.web.utils.columns.ShortDatePropertyColumn;
+import nc.ird.cantharella.web.utils.models.DisplayDecimalPropertyModel;
+import nc.ird.cantharella.web.utils.models.DisplayDecimalPropertyModel.DecimalDisplFormat;
+import nc.ird.cantharella.web.utils.models.LoadableDetachableSortableListDataProvider;
+import nc.ird.cantharella.web.utils.security.AuthRole;
+import nc.ird.cantharella.web.utils.security.AuthRoles;
+
+import org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator;
+import org.apache.wicket.extensions.markup.html.repeater.data.table.AbstractColumn;
+import org.apache.wicket.extensions.markup.html.repeater.data.table.DataTable;
+import org.apache.wicket.extensions.markup.html.repeater.data.table.DefaultDataTable;
+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.extensions.markup.html.repeater.data.table.filter.TextFilteredPropertyColumn;
+import org.apache.wicket.markup.html.basic.Label;
+import org.apache.wicket.markup.html.form.Form;
+import org.apache.wicket.markup.html.form.TextField;
+import org.apache.wicket.markup.repeater.Item;
+import org.apache.wicket.model.IModel;
+import org.apache.wicket.model.Model;
+import org.apache.wicket.model.PropertyModel;
+import org.apache.wicket.spring.injection.annot.SpringBean;
+import org.apache.wicket.util.value.ValueMap;
+
+/**
+ * Resultat de page de recherche.
+ *
+ * @author echatellier
+ */
+@AuthRoles({ AuthRole.ADMIN, AuthRole.USER })
+public class SearchPage extends TemplatePage {
+
+ protected String query;
+
+ @SpringBean
+ protected SearchService searchService;
+
+ /**
+ * Nombre d'extraits affichés dans la colonne de résumés des extraits
+ */
+ private static int MAX_EXTRAITS_DISPLAY = 4;
+
+ /**
+ * Constructeur.
+ * @param query
+ */
+ public SearchPage(String query) {
+ super(SearchPage.class);
+ this.query = query;
+ final CallerPage currentPage = new CallerPage(ListSpecimensPage.class);
+
+ // search form
+ Form<ValueMap> searchForm = new Form<ValueMap>(getResource() + ".Form") {
+ protected void onSubmit() {
+ setResponsePage(new SearchPage(getQuery()));
+ }
+ };
+ searchForm.add(new TextField<String>("query", new PropertyModel<String>(this, "query")).setType(String.class));
+ add(searchForm);
+
+ // search results
+ SearchResult searchResult = searchService.search(query);
+ addSpecimensTable(currentPage, searchResult);
+ addLotsTable(currentPage, searchResult);
+ addExtractionsTable(currentPage, searchResult);
+ addPurificationsTable(currentPage, searchResult);
+ addTestBiosTable(currentPage, searchResult);
+ }
+
+ public String getQuery() {
+ return query;
+ }
+
+ public void setQuery(String query) {
+ this.query = query;
+ }
+
+ protected void addSpecimensTable(final CallerPage currentPage, SearchResult searchResult) {
+ // search result : specimens
+ List<Specimen> specimens = searchResult.getSpecimens();
+ List<IColumn<Specimen>> specimensColumns = new ArrayList<IColumn<Specimen>>();
+ specimensColumns.add(new LinkPropertyColumn<Specimen>(new Model<String>(getString("Specimen.ref")), "ref", "ref",
+ getString("Read")) {
+ @Override
+ public void onClick(Item<ICellPopulator<Specimen>> item, String componentId, IModel<Specimen> model) {
+ setResponsePage(new ReadSpecimenPage(model.getObject().getIdSpecimen(), currentPage));
+ }
+ });
+
+ specimensColumns.add(new EnumPropertyColumn<Specimen>(new Model<String>(getString("Specimen.typeOrganisme")),
+ "typeOrganisme", "typeOrganisme", SearchPage.this));
+
+ specimensColumns.add(new TaxonomyPropertyColumn<Specimen>(new Model<String>(getString("Specimen.embranchement")),
+ "embranchement", "embranchement"));
+
+ specimensColumns.add(new TaxonomyPropertyColumn<Specimen>(new Model<String>(getString("Specimen.famille")), "famille",
+ "famille"));
+
+ specimensColumns.add(new TaxonomyPropertyColumn<Specimen>(new Model<String>(getString("Specimen.genre")), "genre",
+ "genre"));
+
+ specimensColumns.add(new TaxonomyPropertyColumn<Specimen>(new Model<String>(getString("Specimen.espece")), "espece",
+ "espece"));
+
+ specimensColumns.add(new LinkPropertyColumn<Specimen>(new Model<String>(getString("Specimen.station2")), "station",
+ "station", getString("Read")) {
+ @Override
+ public void onClick(Item<ICellPopulator<Specimen>> item, String componentId, IModel<Specimen> model) {
+ setResponsePage(new ReadStationPage(model.getObject().getStation().getIdStation(), currentPage));
+ }
+ });
+ LoadableDetachableSortableListDataProvider<Specimen> specimensDataProvider = new LoadableDetachableSortableListDataProvider<Specimen>(
+ specimens, getSession().getLocale());
+ final DataTable<Specimen> specimensDataTable = new DefaultDataTable<Specimen>(getResource() + ".Specimens.Results",
+ specimensColumns, specimensDataProvider, Integer.MAX_VALUE);
+ add(specimensDataTable);
+ }
+
+ protected void addLotsTable(final CallerPage currentPage, SearchResult searchResult) {
+ // search result : lots
+ List<Lot> lots = searchResult.getLots();
+ List<IColumn<Lot>> lotsColumns = new ArrayList<IColumn<Lot>>();
+ lotsColumns.add(new LinkPropertyColumn<Lot>(new Model<String>(getString("Lot.ref")), "ref", "ref",
+ getString("Read")) {
+ @Override
+ public void onClick(Item<ICellPopulator<Lot>> item, String componentId, IModel<Lot> model) {
+ setResponsePage(new ReadLotPage(model.getObject().getIdLot(), currentPage));
+ }
+ });
+
+ lotsColumns.add(new PropertyColumn<Lot>(new Model<String>(getString("Lot.dateRecolte2")), "dateRecolte",
+ "dateRecolte"));
+
+ lotsColumns.add(new LinkPropertyColumn<Lot>(new Model<String>(getString("Lot.station")), "station", "station",
+ getString("Read")) {
+ @Override
+ public void onClick(Item<ICellPopulator<Lot>> item, String componentId, IModel<Lot> model) {
+ setResponsePage(new ReadStationPage(model.getObject().getStation().getIdStation(), currentPage));
+ }
+ });
+
+ lotsColumns.add(new LinkPropertyColumn<Lot>(new Model<String>(getString("Lot.specimenRef2")), "specimenRef",
+ "specimenRef", getString("Read")) {
+ @Override
+ public void onClick(Item<ICellPopulator<Lot>> item, String componentId, IModel<Lot> model) {
+ setResponsePage(new ReadSpecimenPage(model.getObject().getSpecimenRef().getIdSpecimen(), currentPage));
+ }
+ });
+
+ lotsColumns.add(new EnumPropertyColumn<Lot>(new Model<String>(getString("Specimen.typeOrganisme")),
+ "specimenRef.typeOrganisme", "specimenRef.typeOrganisme", SearchPage.this));
+
+ lotsColumns.add(new TaxonomyPropertyColumn<Lot>(new Model<String>(getString("Specimen.embranchement")),
+ "specimenRef.embranchement", "specimenRef.embranchement"));
+
+ lotsColumns.add(new TaxonomyPropertyColumn<Lot>(new Model<String>(getString("Specimen.famille")),
+ "specimenRef.famille", "specimenRef.famille"));
+
+ lotsColumns.add(new TaxonomyPropertyColumn<Lot>(new Model<String>(getString("Specimen.genre")),
+ "specimenRef.genre", "specimenRef.genre"));
+
+ lotsColumns.add(new TaxonomyPropertyColumn<Lot>(new Model<String>(getString("Specimen.espece")),
+ "specimenRef.espece", "specimenRef.espece"));
+
+ lotsColumns.add(new PropertyColumn<Lot>(new Model<String>(getString("Lot.partie")), "partie", "partie"));
+
+ lotsColumns.add(new DecimalPropertyColumn<Lot>(new Model<String>(getString("Lot.masseFraiche2")), "masseFraiche",
+ "masseFraiche", DecimalDisplFormat.SMALL, getLocale()));
+
+ lotsColumns.add(new DecimalPropertyColumn<Lot>(new Model<String>(getString("Lot.masseSeche2")), "masseSeche",
+ "masseSeche", DecimalDisplFormat.SMALL, getLocale()));
+
+ lotsColumns.add(new LinkPropertyColumn<Lot>(new Model<String>(getString("Lot.campagne")), "campagne", "campagne",
+ getString("Read")) {
+ @Override
+ public void onClick(Item<ICellPopulator<Lot>> item, String componentId, IModel<Lot> model) {
+ setResponsePage(new ReadCampagnePage(model.getObject().getCampagne().getIdCampagne(), currentPage));
+ }
+ });
+
+ lotsColumns.add(new MapValuePropertyColumn<Lot, String>(new Model<String>(getString("Campagne.codePays")),
+ "campagne.codePays", "campagne.codePays", WebContext.COUNTRIES.get(getSession().getLocale())));
+
+ LoadableDetachableSortableListDataProvider<Lot> lotsDataProvider = new LoadableDetachableSortableListDataProvider<Lot>(
+ lots, getSession().getLocale());
+ final DataTable<Lot> lotsDataTable = new DefaultDataTable<Lot>(getResource() + ".Lots.Results", lotsColumns,
+ lotsDataProvider, Integer.MAX_VALUE);
+ add(lotsDataTable);
+ }
+
+ protected void addExtractionsTable(final CallerPage currentPage, SearchResult searchResult) {
+ // search result : extractions
+ List<Extraction> extractions = searchResult.getExtractions();
+
+ List<IColumn<Extraction>> extractionsColumns = new ArrayList<IColumn<Extraction>>();
+
+ extractionsColumns.add(new LinkableImagePropertyColumn<Extraction>("images/read.png", getString("Read"), getString("Read")) {
+ @Override
+ public void onClick(Item<ICellPopulator<Extraction>> item, String componentId, IModel<Extraction> model) {
+ setResponsePage(new ReadExtractionPage(model.getObject().getIdExtraction(), currentPage));
+ }
+ });
+
+ extractionsColumns.add(new LinkPropertyColumn<Extraction>(new Model<String>(getString("Extraction.lot")), "lot", "lot",
+ getString("Read")) {
+ @Override
+ public void onClick(Item<ICellPopulator<Extraction>> item, String componentId, IModel<Extraction> model) {
+ setResponsePage(new ReadLotPage(model.getObject().getLot().getIdLot(), currentPage));
+ }
+ });
+
+ extractionsColumns.add(new LinkPropertyColumn<Extraction>(new Model<String>(getString("Extraction.ref")), "ref", "ref",
+ getString("Read")) {
+ @Override
+ public void onClick(Item<ICellPopulator<Extraction>> item, String componentId, IModel<Extraction> model) {
+ setResponsePage(new ReadExtractionPage(model.getObject().getIdExtraction(), currentPage));
+ }
+ });
+
+ extractionsColumns.add(new ShortDatePropertyColumn<Extraction>(new Model<String>(getString("Extraction.date")), "date",
+ "date", getLocale()));
+
+ extractionsColumns.add(new PropertyColumn<Extraction>(new Model<String>(getString("Extraction.methode2")), "methode",
+ "methode"));
+
+ extractionsColumns.add(new DecimalPropertyColumn<Extraction>(new Model<String>(getString("Extraction.masseDepart2")),
+ "masseDepart", "masseDepart", DecimalDisplFormat.SMALL, getLocale()));
+
+ extractionsColumns.add(new LinkPropertyColumn<Extraction>(new Model<String>(getString("Campagne")), "lot.campagne",
+ "lot.campagne", getString("Read")) {
+ @Override
+ public void onClick(Item<ICellPopulator<Extraction>> item, String componentId, IModel<Extraction> model) {
+ setResponsePage(new ReadCampagnePage(model.getObject().getLot().getCampagne().getIdCampagne(),
+ currentPage));
+ }
+ });
+
+ extractionsColumns.add(new AbstractColumn<Extraction>(new Model<String>(getString("Extraction.extraits"))) {
+ @Override
+ public void populateItem(Item<ICellPopulator<Extraction>> cellItem, String componentId,
+ IModel<Extraction> rowModel) {
+
+ // affiche un résumé des types extraits et des masses, allant jusqu'à MAX_EXTRAITS_DISPLAY extraits
+ Label extraitsLabel = new Label(componentId, new Model<Serializable>(rowModel) {
+ /** {@inheritDoc} */
+ @Override
+ public String getObject() {
+ StringBuilder extraitsResume = new StringBuilder();
+ List<Extrait> extraits = new PropertyModel<List<Extrait>>(super.getObject(), "sortedExtraits")
+ .getObject();
+ for (int i = 0; i < MAX_EXTRAITS_DISPLAY && i < extraits.size(); i++) {
+ Extrait curExtrait = extraits.get(i);
+ extraitsResume.append("<b>");
+ extraitsResume.append(curExtrait.getTypeExtrait().getInitiales());
+ extraitsResume.append("</b>");
+ extraitsResume.append(" : ");
+ extraitsResume.append(curExtrait.getMasseObtenue() == null ? ReplaceEmptyLabelBehavior.NULL_PROPERTY
+ : new DisplayDecimalPropertyModel(curExtrait, "masseObtenue",
+ DecimalDisplFormat.SMALL, getLocale()).getObject());
+ if (i < MAX_EXTRAITS_DISPLAY - 1 && i < extraits.size() - 1) {
+ extraitsResume.append(", ");
+ }
+ if (i == MAX_EXTRAITS_DISPLAY - 1 && i < extraits.size() - 1) {
+ extraitsResume.append(", ...");
+ }
+ }
+ return extraitsResume.toString();
+ }
+ });
+ extraitsLabel.setEscapeModelStrings(false);
+ extraitsLabel.add(new ReplaceEmptyLabelBehavior());
+ cellItem.add(extraitsLabel);
+ }
+
+ });
+
+ LoadableDetachableSortableListDataProvider<Extraction> extractionsDataProvider = new LoadableDetachableSortableListDataProvider<Extraction>(
+ extractions, getSession().getLocale());
+ final DataTable<Extraction> extractionsDataTable = new DefaultDataTable<Extraction>(
+ getResource() + ".Extractions.Results", extractionsColumns, extractionsDataProvider, Integer.MAX_VALUE);
+ add(extractionsDataTable);
+ }
+
+ protected void addPurificationsTable(final CallerPage currentPage, SearchResult searchResult) {
+ List<Purification> purifications = searchResult.getPurifications();
+ LoadableDetachableSortableListDataProvider<Purification> purificationsDataProvider = new LoadableDetachableSortableListDataProvider<Purification>(
+ purifications, getSession().getLocale());
+
+ List<IColumn<Purification>> columns = new ArrayList<IColumn<Purification>>();
+
+ columns.add(new LinkPropertyColumn<Purification>(new Model<String>(getString("Extraction.lot")), "lotSource",
+ "lotSource", getString("Read")) {
+ @Override
+ public void onClick(Item<ICellPopulator<Purification>> item, String componentId, IModel<Purification> model) {
+ setResponsePage(new ReadLotPage(model.getObject().getLotSource().getIdLot(), currentPage));
+ }
+ });
+
+ columns.add(new LinkProduitPropertyColumn<Purification>(
+ new Model<String>(getString("ResultatTestBio.produit")), "produit", "produit", (TemplatePage) getPage()) {
+ @Override
+ public void onClickIfExtrait(Extrait extrait) {
+ setResponsePage(new ReadExtractionPage(extrait.getExtraction().getIdExtraction(), currentPage));
+ }
+
+ @Override
+ public void onClickIfFraction(Fraction fraction) {
+ setResponsePage(new ReadPurificationPage(fraction.getPurification().getIdPurification(), currentPage));
+ }
+ });
+
+ columns.add(new LinkPropertyColumn<Purification>(new Model<String>(getString("Purification.ref")), "ref",
+ "ref", getString("Read")) {
+ @Override
+ public void onClick(Item<ICellPopulator<Purification>> item, String componentId, IModel<Purification> model) {
+ setResponsePage(new ReadPurificationPage(model.getObject().getIdPurification(), currentPage));
+ }
+ });
+
+ columns.add(new ShortDatePropertyColumn<Purification>(new Model<String>(getString("Purification.date")),
+ "date", "date", getLocale()));
+
+ columns.add(new PropertyColumn<Purification>(new Model<String>(getString("Purification.methode2")), "methode",
+ "methode"));
+
+ columns.add(new LinkPropertyColumn<Purification>(new Model<String>(getString("Campagne")),
+ "lotSource.campagne", "lotSource.campagne", getString("Read")) {
+ @Override
+ public void onClick(Item<ICellPopulator<Purification>> item, String componentId, IModel<Purification> model) {
+ setResponsePage(new ReadCampagnePage(model.getObject().getLotSource().getCampagne().getIdCampagne(),
+ currentPage));
+ }
+ });
+
+ final DataTable<Purification> purificationsDataTable = new DefaultDataTable<Purification>(
+ getResource() + ".Purifications.Results", columns, purificationsDataProvider, Integer.MAX_VALUE);
+ add(purificationsDataTable);
+ }
+
+ protected void addTestBiosTable(final CallerPage currentPage, SearchResult searchResult) {
+ List<ResultatTestBio> resultatTestBios = searchResult.getResultatTestBios();
+ LoadableDetachableSortableListDataProvider<ResultatTestBio> resTestBiosDataProvider = new LoadableDetachableSortableListDataProvider<ResultatTestBio>(
+ resultatTestBios, getSession().getLocale());
+
+ List<IColumn<ResultatTestBio>> columns = new ArrayList<IColumn<ResultatTestBio>>();
+
+ columns.add(new TextFilteredPropertyColumn<ResultatTestBio, String>(new Model<String>(
+ getString("MethodeTestBio.cible2")), "testBio.methode.cible", "testBio.methode.cible"));
+
+ columns.add(new DecimalPropertyColumn<ResultatTestBio>(new Model<String>(
+ getString("ResultatTestBio.concMasse2")), "concMasse", "concMasse", DecimalDisplFormat.SMALL,
+ getLocale()));
+
+ columns.add(new EnumPropertyColumn<ResultatTestBio>(new Model<String>(getString("TestBio.uniteConcMasse2")),
+ "uniteConcMasse", "uniteConcMasse", (TemplatePage) getPage()));
+
+ columns.add(new LinkProduitPropertyColumn<ResultatTestBio>(new Model<String>(
+ getString("ResultatTestBio.produit")), "produit", "produit", (TemplatePage) getPage()) {
+ @Override
+ public void onClickIfExtrait(Extrait extrait) {
+ setResponsePage(new ReadExtractionPage(extrait.getExtraction().getIdExtraction(), currentPage));
+ }
+
+ @Override
+ public void onClickIfFraction(Fraction fraction) {
+ setResponsePage(new ReadPurificationPage(fraction.getPurification().getIdPurification(), currentPage));
+ }
+ });
+
+ columns.add(new DecimalPropertyColumn<ResultatTestBio>(new Model<String>(getString("ResultatTestBio.valeur")),
+ "valeur", "valeur", DecimalDisplFormat.SMALL, getLocale()));
+
+ columns.add(new PropertyColumn<ResultatTestBio>(new Model<String>(getString("MethodeTestBio.uniteResultat2")),
+ "testBio.methode.uniteResultat", "testBio.methode.uniteResultat"));
+
+ columns.add(new PropertyColumn<ResultatTestBio>(new Model<String>(getString("Extrait.typeExtrait2")),
+ "typeExtraitSource", "typeExtraitSource"));
+
+ columns.add(new BooleanPropertyColumn<ResultatTestBio>(new Model<String>(getString("ResultatTestBio.actif")),
+ "actif", "actif", (TemplatePage) getPage()));
+
+ columns.add(new TaxonomyPropertyColumn<ResultatTestBio>(new Model<String>(getString("Specimen.famille")),
+ "lotSource.specimenRef.famille", "lotSource.specimenRef.famille"));
+
+ columns.add(new TaxonomyPropertyColumn<ResultatTestBio>(new Model<String>(getString("Specimen.genre")),
+ "lotSource.specimenRef.genre", "lotSource.specimenRef.genre"));
+
+ columns.add(new TaxonomyPropertyColumn<ResultatTestBio>(new Model<String>(getString("Specimen.espece")),
+ "lotSource.specimenRef.espece", "lotSource.specimenRef.espece"));
+
+ columns.add(new MapValuePropertyColumn<ResultatTestBio, String>(new Model<String>(
+ getString("Campagne.codePays")), "lotSource.campagne.codePays", "lotSource.campagne.codePays",
+ WebContext.COUNTRIES.get(getSession().getLocale())));
+
+ columns.add(new PropertyColumn<ResultatTestBio>(new Model<String>(getString("ResultatTestBio.repere")),
+ "repere", "repere"));
+
+ columns.add(new LinkPropertyColumn<ResultatTestBio>(new Model<String>(getString("TestBio.ref")), "testBio.ref",
+ "testBio.ref", getString("Read")) {
+ @Override
+ public void onClick(Item<ICellPopulator<ResultatTestBio>> item, String componentId,
+ IModel<ResultatTestBio> model) {
+ setResponsePage(new ReadTestBioPage(model.getObject().getTestBio().getIdTestBio(), currentPage));
+ }
+ });
+
+ final DataTable<ResultatTestBio> resTestBiosDataTable = new DefaultDataTable<ResultatTestBio>(
+ getResource() + ".ResultatTestBios.Results", columns, resTestBiosDataProvider, Integer.MAX_VALUE);
+
+ add(resTestBiosDataTable);
+
+ }
+}
Property changes on: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/search/SearchPage.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 2012-11-28 14:58:12 UTC (rev 35)
+++ trunk/cantharella.web/src/main/resources/commons/web_en.properties 2012-12-05 18:25:53 UTC (rev 36)
@@ -220,6 +220,7 @@
ListMethodeTestBioPanel.NewMethodeTestBio=New method
ListConfigurationPage.ErreursTestBio= Bioassay errors list
ListErreurTestBioPanel.NewErreurTestBio=New error
+ListConfigurationPage.RebuildLuceneIndex=Rebuild lucene index
ManagePartiePage=Managing a part
ManagePartiePage.Create.OK=Part created
@@ -271,6 +272,15 @@
ReadPurificationPage=Viewing a purification
ReadTestBioPage=Viewing a bioassay
+SearchPage=Search
+SearchPage.Search=Search
+SearchPage.QueryLabel=Query
+SearchPage.Specimens=Specimens
+SearchPage.Lots=Samples
+SearchPage.Extractions=Extractions
+SearchPage.Purifications=Purifications
+SearchPage.ResultatTestBios=Bioassay
+
#MODELS#
CaptchaModel.captcha=Captcha
@@ -375,7 +385,8 @@
Submit=Submit
Cancel=Cancel
Valid=Valid
-Reject=Reject
+Reject=Reject
+Rebuild=Rebuild
Create=Create
Add=Add
Update=Modify
Modified: trunk/cantharella.web/src/main/resources/commons/web_fr.properties
===================================================================
--- trunk/cantharella.web/src/main/resources/commons/web_fr.properties 2012-11-28 14:58:12 UTC (rev 35)
+++ trunk/cantharella.web/src/main/resources/commons/web_fr.properties 2012-12-05 18:25:53 UTC (rev 36)
@@ -219,6 +219,7 @@
ListMethodeTestBioPanel.NewMethodeTestBio=Nouvelle méthode
ListConfigurationPage.ErreursTestBio=Liste des erreurs pour un test biologique
ListErreurTestBioPanel.NewErreurTestBio=Nouvelle erreur
+ListConfigurationPage.RebuildLuceneIndex=Reconstruire l'index lucene
ManagePartiePage=Gestion d'une partie
ManagePartiePage.Create.OK=Partie créée
@@ -270,6 +271,15 @@
ReadPurificationPage=Consultation d'une purification
ReadTestBioPage=Consultation d'un test biologique
+SearchPage=Recherche
+SearchPage.Search=Rechercher
+SearchPage.QueryLabel=Requête
+SearchPage.Specimens=Specimens
+SearchPage.Lots=Lots
+SearchPage.Extractions=Extractions
+SearchPage.Purifications=Purifications
+SearchPage.ResultatTestBios=Tests biologiques
+
#MODELS#
CaptchaModel.captcha=Captcha
@@ -373,6 +383,7 @@
Submit=Valider
Cancel=Annuler
Valid=Valider
+Rebuild=Reconstruire
Reject=Refuser
Create=Ajouter
Add=Ajouter
Modified: trunk/cantharella.web/src/main/webapp/WEB-INF/web.xml
===================================================================
--- trunk/cantharella.web/src/main/webapp/WEB-INF/web.xml 2012-11-28 14:58:12 UTC (rev 35)
+++ trunk/cantharella.web/src/main/webapp/WEB-INF/web.xml 2012-12-05 18:25:53 UTC (rev 36)
@@ -30,7 +30,7 @@
<!-- Open Hibernate session -->
<filter>
<filter-name>session</filter-name>
- <filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>
+ <filter-class>org.springframework.orm.hibernate4.support.OpenSessionInViewFilter</filter-class>
<init-param>
<param-name>singleSession</param-name>
<param-value>true</param-value>
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2012-11-28 14:58:12 UTC (rev 35)
+++ trunk/pom.xml 2012-12-05 18:25:53 UTC (rev 36)
@@ -101,38 +101,38 @@
</license.organizationName>
<license.licenseName>agpl_v3</license.licenseName>
- <commonsBeanutilsVersion>1.8.2</commonsBeanutilsVersion>
- <version.commons-codec>1.4</version.commons-codec>
- <commonsIoVersion>1.3.2</commonsIoVersion>
- <commonsLangVersion>2.5</commonsLangVersion>
+ <commonsBeanutilsVersion>1.8.3</commonsBeanutilsVersion>
+ <version.commons-codec>1.7</version.commons-codec>
+ <commonsIoVersion>2.4</commonsIoVersion>
+ <commonsLang3Version>3.1</commonsLang3Version>
<commonsLoggingVersion>1.1.1</commonsLoggingVersion>
<commonsCollectionsVersion>3.2.1</commonsCollectionsVersion>
- <log4jVersion>1.2.16</log4jVersion>
- <junitVersion>4.5</junitVersion>
- <version.slf4j>1.6.0</version.slf4j>
- <version.h2>1.3.168</version.h2>
+ <log4jVersion>1.2.17</log4jVersion>
+ <junitVersion>4.11</junitVersion>
+ <version.slf4j>1.7.2</version.slf4j>
+
+ <version.postgresql>9.1-901-1.jdbc4</version.postgresql>
+ <version.h2>1.3.170</version.h2>
- <version.jpa>1.0.0.Final</version.jpa>
- <version.hibernate-annotations>3.5.6-Final</version.hibernate-annotations>
- <version.hibernate-core>3.5.6-Final</version.hibernate-core>
- <version.hibernate-validator>4.2.0.Final</version.hibernate-validator>
- <version.postgresql>8.3-603.jdbc4</version.postgresql>
- <version.hibernate3-maven-plugin>2.2</version.hibernate3-maven-plugin>
+ <version.validation-api>1.0.0.GA</version.validation-api>
+ <version.jpa>1.0.1.Final</version.jpa>
+ <version.hibernate>4.1.7.Final</version.hibernate>
+ <version.hibernate-validator>4.3.1.Final</version.hibernate-validator>
+ <version.hibernate3-maven-plugin>3.0</version.hibernate3-maven-plugin>
+ <version.hibernate-search>4.1.1.Final</version.hibernate-search>
+ <version.lucene>3.5.0</version.lucene>
<version.c3p0>0.9.1</version.c3p0>
<version.aspectj>1.6.8</version.aspectj>
- <version.icu4j>4.0.1</version.icu4j>
- <version.opencsv>2.1</version.opencsv>
+ <version.opencsv>2.3</version.opencsv>
<version.javassist>3.8.0.GA</version.javassist>
- <version.spring>3.1.0.RELEASE</version.spring>
- <version.icu4j>4.0.1</version.icu4j>
- <version.mail>1.4</version.mail>
+ <version.spring>3.1.3.RELEASE</version.spring>
+ <version.mail>1.4.5</version.mail>
<version.cglib>2.2.2</version.cglib>
<version.poi>3.5-FINAL</version.poi>
<version.servlet-api>2.5</version.servlet-api>
- <version.validation-api>1.0.0.GA</version.validation-api>
<version.wicket>1.5.6</version.wicket>
</properties>
@@ -176,11 +176,6 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- <excludes>
- <exclude>**/utils/*.java</exclude>
- </excludes>
- </configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
@@ -216,12 +211,12 @@
<version>${version.opencsv}</version>
</dependency>
- <dependency>
+ <!-- <dependency>
<groupId>javassist</groupId>
<artifactId>javassist</artifactId>
<version>${version.javassist}</version>
<scope>runtime</scope>
- </dependency>
+ </dependency> -->
<dependency>
<groupId>org.aspectj</groupId>
@@ -289,25 +284,20 @@
<version>${version.jpa}</version>
</dependency>
- <dependency>
+ <!--<dependency>
<groupId>org.hibernate</groupId>
- <artifactId>hibernate-annotations</artifactId>
- <version>${version.hibernate-annotations}</version>
- </dependency>
- <dependency>
- <groupId>org.hibernate</groupId>
<artifactId>hibernate-c3p0</artifactId>
- <version>${version.hibernate-core}</version>
- </dependency>
+ <version>${version.hibernate}</version>
+ </dependency>-->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
- <version>${version.hibernate-core}</version>
+ <version>${version.hibernate}</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-ehcache</artifactId>
- <version>${version.hibernate-core}</version>
+ <version>${version.hibernate}</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
@@ -316,6 +306,22 @@
</dependency>
<dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-search-orm</artifactId>
+ <version>${version.hibernate-search}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.lucene</groupId>
+ <artifactId>lucene-core</artifactId>
+ <version>${version.lucene}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.lucene</groupId>
+ <artifactId>lucene-analyzers</artifactId>
+ <version>${version.lucene}</version>
+ </dependency>
+
+ <dependency>
<groupId>c3p0</groupId>
<artifactId>c3p0</artifactId>
<version>${version.c3p0}</version>
@@ -414,12 +420,6 @@
<artifactId>mail</artifactId>
<version>${version.mail}</version>
</dependency>
-
- <dependency>
- <groupId>com.ibm.icu</groupId>
- <artifactId>icu4j</artifactId>
- <version>${version.icu4j}</version>
- </dependency>
</dependencies>
</dependencyManagement>
1
0