Cantharella-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
February 2013
- 3 participants
- 101 discussions
r146 - in trunk/cantharella.web/src/main: java/nc/ird/cantharella/web/config java/nc/ird/cantharella/web/pages java/nc/ird/cantharella/web/pages/domain/document java/nc/ird/cantharella/web/pages/domain/molecule resources
by echatellier@users.forge.codelutin.com 21 Feb '13
by echatellier@users.forge.codelutin.com 21 Feb '13
21 Feb '13
Author: echatellier
Date: 2013-02-21 13:33:49 +0100 (Thu, 21 Feb 2013)
New Revision: 146
Url: http://forge.codelutin.com/projects/cantharella/repository/revisions/146
Log:
Move document table init in helper class to be used in multiple class.
Fix configuration (in wicket application class)
Fix display messages.
Added:
trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/document/DocumentPageHelper.java
Modified:
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.java
trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/document/ManageDocumentPage.java
trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/molecule/ManageMoleculePage.html
trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/molecule/ManageMoleculePage.java
trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/molecule/ReadMoleculePage.java
trunk/cantharella.web/src/main/resources/cantharella.conf
trunk/cantharella.web/src/main/resources/web_en.properties
trunk/cantharella.web/src/main/resources/web_fr.properties
Modified: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/config/WebApplicationImpl.java
===================================================================
--- trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/config/WebApplicationImpl.java 2013-02-21 12:30:01 UTC (rev 145)
+++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/config/WebApplicationImpl.java 2013-02-21 12:33:49 UTC (rev 146)
@@ -28,6 +28,7 @@
import nc.ird.cantharella.data.exceptions.DataConstraintException;
import nc.ird.cantharella.data.exceptions.UnexpectedException;
import nc.ird.cantharella.service.services.PersonneService;
+import nc.ird.cantharella.utils.AssertTools;
import nc.ird.cantharella.web.pages.ContactPage;
import nc.ird.cantharella.web.pages.HomePage;
import nc.ird.cantharella.web.pages.domain.campagne.ListCampagnesPage;
@@ -72,7 +73,6 @@
import nc.ird.cantharella.web.utils.converters.DoubleConverterImpl;
import nc.ird.cantharella.web.utils.security.AuthSession;
import nc.ird.cantharella.web.utils.security.AuthStrategy;
-import nc.ird.cantharella.utils.AssertTools;
import org.apache.wicket.ConverterLocator;
import org.apache.wicket.IConverterLocator;
@@ -99,6 +99,7 @@
import org.apache.wicket.util.time.Duration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Value;
/**
* Web application
@@ -134,6 +135,10 @@
/** Wicket configuration (Application.DEVELOPMENT or Application.DEPLOYMENT) */
private final RuntimeConfigurationType wicketConfiguration;
+ /** Configuration document max upload size. */
+ @Value("${document.maxUploadSize}")
+ protected long documentMaxUploadSize;
+
/**
* Constructor
* @param debug Debug mode
@@ -423,4 +428,12 @@
mountPage("/search", SearchPage.class);
}
+ /**
+ * Get document max upload size.
+ *
+ * @return document max upload size
+ */
+ public long getDocumentMaxUploadSize() {
+ return documentMaxUploadSize;
+ }
}
\ No newline at end of file
Modified: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/TemplatePage.java
===================================================================
--- trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/TemplatePage.java 2013-02-21 12:30:01 UTC (rev 145)
+++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/TemplatePage.java 2013-02-21 12:33:49 UTC (rev 146)
@@ -378,7 +378,7 @@
* Refresh feedback page and scroll up to the anchor if any feedback message
* @param target Ajax target
*/
- protected final void refreshFeedbackPage(AjaxRequestTarget target) {
+ public final void refreshFeedbackPage(AjaxRequestTarget target) {
if (target != null) {
target.add(feedbackPanelContainer);
// scroll up to the anchor if any feedback message
Added: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/document/DocumentPageHelper.java
===================================================================
--- trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/document/DocumentPageHelper.java (rev 0)
+++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/document/DocumentPageHelper.java 2013-02-21 12:33:49 UTC (rev 146)
@@ -0,0 +1,208 @@
+/*
+ * #%L
+ * Cantharella :: Web
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2009 - 2013 IRD (Institut de Recherche pour le Developpement) and by respective authors (see below)
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+package nc.ird.cantharella.web.pages.domain.document;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+import nc.ird.cantharella.data.model.Document;
+import nc.ird.cantharella.data.model.utils.DocumentAttachable;
+import nc.ird.cantharella.web.config.WebContext;
+import nc.ird.cantharella.web.pages.TemplatePage;
+import nc.ird.cantharella.web.utils.CallerPage;
+import nc.ird.cantharella.web.utils.columns.AjaxButtonPropertyColumn;
+import nc.ird.cantharella.web.utils.columns.LinkPropertyColumn;
+import nc.ird.cantharella.web.utils.columns.LinkableImagePropertyColumn;
+import nc.ird.cantharella.web.utils.models.SimpleSortableListDataProvider;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.wicket.MarkupContainer;
+import org.apache.wicket.ajax.AjaxRequestTarget;
+import org.apache.wicket.ajax.markup.html.form.AjaxSubmitLink;
+import org.apache.wicket.extensions.ajax.markup.html.repeater.data.table.AjaxFallbackDefaultDataTable;
+import org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator;
+import org.apache.wicket.extensions.markup.html.repeater.data.table.DataTable;
+import org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn;
+import org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn;
+import org.apache.wicket.markup.html.WebMarkupContainer;
+import org.apache.wicket.markup.html.form.Form;
+import org.apache.wicket.markup.repeater.Item;
+import org.apache.wicket.model.IModel;
+import org.apache.wicket.model.Model;
+import org.apache.wicket.request.http.WebResponse;
+
+/**
+ * Helper providing static method to init document list into entity Read or
+ * Manager page.
+ *
+ * @author Eric Chatellier
+ */
+public abstract class DocumentPageHelper {
+
+ /**
+ * Init attached document table for current entity.
+ *
+ * @param templatePage parent page
+ * @param formView form to add table to
+ * @param documentAttachable entity to get documents
+ * @param currentPage current page
+ */
+ public static void initAttachedDocumentsManageTable(final TemplatePage templatePage,
+ final Form<Void> formView, final DocumentAttachable documentAttachable, final CallerPage currentPage) {
+
+ List<Document> documents = documentAttachable.getDocuments();
+
+ // On englobe le "DataView" dans un composant neutre que l'on pourra
+ // rafraichir quand la liste évoluera
+ final MarkupContainer attachedDocumentRefresh = new WebMarkupContainer(
+ "ListDocumentsPage.AttachedDocuments.Refresh");
+ attachedDocumentRefresh.setOutputMarkupId(true);
+ formView.add(attachedDocumentRefresh);
+
+ SimpleSortableListDataProvider<Document> attachedDocumentsDataProvider = new SimpleSortableListDataProvider<Document>(
+ documents, templatePage.getSession().getLocale());
+
+ List<IColumn<Document, String>> columns = new ArrayList<IColumn<Document, String>>();
+
+ columns.add(new LinkPropertyColumn<Document, String>(new Model<String>(templatePage.getString("Document.titre")), "titre",
+ "titre") {
+ @Override
+ public void onClick(Item<ICellPopulator<Document>> item, String componentId, IModel<Document> model) {
+ templatePage.setResponsePage(new ReadDocumentPage(model.getObject(), documentAttachable, currentPage));
+ }
+ });
+
+ columns.add(new PropertyColumn<Document, String>(new Model<String>(templatePage.getString("Document.typeDocument")),
+ "typeDocument.nom", "typeDocument.nom"));
+
+ columns.add(new PropertyColumn<Document, String>(new Model<String>(templatePage.getString("Document.createur")), "createur",
+ "createur"));
+
+ columns.add(new LinkableImagePropertyColumn<Document, String>(new Model<String>(templatePage.getString("Document.link")),
+ "images/download.png", templatePage.getString("Document.link"), templatePage.getString("Document.link")) {
+ @Override
+ public void onClick(Item<ICellPopulator<Document>> item, String componentId, IModel<Document> model) {
+ Document document = model.getObject();
+ WebResponse response = (WebResponse) templatePage.getResponse();
+ response.setContentType(document.getFileMimetype());
+ response.setAttachmentHeader(document.getFileName());
+ response.write(document.getFileContent());
+ }
+ });
+
+ final DataTable<Document, String> attachedDocumentTable = new AjaxFallbackDefaultDataTable<Document, String>(
+ "ListDocumentsPage.AttachedDocuments", columns, attachedDocumentsDataProvider, WebContext.ROWS_PER_PAGE);
+
+ columns.add(new AjaxButtonPropertyColumn<Document, String>(new Model<String>(templatePage.getString("Actions")),
+ new Model<String>(templatePage.getString("Delete")), formView) {
+ @Override
+ public void onSubmit(AjaxRequestTarget target, Form<?> form, IModel<Document> model) {
+ Document document = model.getObject();
+ documentAttachable.removeDocument(document);
+
+ if (target != null) {
+ target.add(attachedDocumentTable);
+ templatePage.refreshFeedbackPage(target);
+ }
+ }
+ });
+
+ attachedDocumentRefresh.add(attachedDocumentTable);
+
+ // Action : création d'un nouveau document
+ // ajaxSubmitLink permet de sauvegarder l'état du formulaire
+ formView.add(new AjaxSubmitLink("NewDocument") {
+ @Override
+ protected void onSubmit(AjaxRequestTarget request, Form<?> form) {
+ setResponsePage(new ManageDocumentPage(currentPage, documentAttachable, false));
+ }
+
+ // si erreur, le formulaire est également enregistré puis la redirection effectuée
+ @Override
+ protected void onError(AjaxRequestTarget target, Form<?> form) {
+ setResponsePage(new ManageDocumentPage(currentPage, documentAttachable, false));
+ }
+ }.setVisibilityAllowed(true));
+ }
+
+ /**
+ * Init attached document table for current entity.
+ *
+ * @param templatePage parent page
+ * @param formView form to add table to
+ * @param documentAttachable entity to get documents
+ * @param currentPage current page
+ */
+ public static void initAttachedDocumentsReadTable(final TemplatePage templatePage, final DocumentAttachable documentAttachable,
+ final CallerPage currentPage) {
+
+ List<Document> documents = documentAttachable.getDocuments();
+
+ SimpleSortableListDataProvider<Document> attachedDocumentsDataProvider = new SimpleSortableListDataProvider<Document>(
+ documents, templatePage.getSession().getLocale());
+
+ List<IColumn<Document, String>> columns = new ArrayList<IColumn<Document, String>>();
+
+ columns.add(new LinkPropertyColumn<Document, String>(new Model<String>(templatePage.getString("Document.titre")), "titre",
+ "titre") {
+ @Override
+ public void onClick(Item<ICellPopulator<Document>> item, String componentId, IModel<Document> model) {
+ templatePage.setResponsePage(new ReadDocumentPage(model.getObject(), documentAttachable, currentPage));
+ }
+ });
+
+ columns.add(new PropertyColumn<Document, String>(new Model<String>(templatePage.getString("Document.typeDocument")),
+ "typeDocument.nom", "typeDocument.nom"));
+
+ columns.add(new PropertyColumn<Document, String>(new Model<String>(templatePage.getString("Document.createur")), "createur",
+ "createur"));
+
+ columns.add(new LinkableImagePropertyColumn<Document, String>(new Model<String>(templatePage.getString("Document.link")),
+ "images/download.png", templatePage.getString("Document.link"), templatePage.getString("Document.link")) {
+ @Override
+ public void onClick(Item<ICellPopulator<Document>> item, String componentId, IModel<Document> model) {
+
+ Document document = model.getObject();
+ WebResponse response = (WebResponse) templatePage.getResponse();
+ response.setContentType(document.getFileMimetype());
+ response.setAttachmentHeader(document.getFileName());
+
+ OutputStream out = templatePage.getResponse().getOutputStream();
+ InputStream in = new ByteArrayInputStream(document.getFileContent());
+ try {
+ IOUtils.copy(in, out);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ });
+
+ final DataTable<Document, String> attachedDocumentTable = new AjaxFallbackDefaultDataTable<Document, String>(
+ "ListDocumentsPage.AttachedDocuments", columns, attachedDocumentsDataProvider, WebContext.ROWS_PER_PAGE);
+ templatePage.add(attachedDocumentTable);
+ }
+}
Property changes on: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/document/DocumentPageHelper.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Modified: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/document/ManageDocumentPage.java
===================================================================
--- trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/document/ManageDocumentPage.java 2013-02-21 12:30:01 UTC (rev 145)
+++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/document/ManageDocumentPage.java 2013-02-21 12:33:49 UTC (rev 146)
@@ -35,6 +35,7 @@
import nc.ird.cantharella.data.validation.utils.ModelValidator;
import nc.ird.cantharella.service.services.DocumentService;
import nc.ird.cantharella.service.services.PersonneService;
+import nc.ird.cantharella.web.config.WebApplicationImpl;
import nc.ird.cantharella.web.config.WebContext;
import nc.ird.cantharella.web.pages.TemplatePage;
import nc.ird.cantharella.web.pages.domain.personne.ManagePersonnePage;
@@ -68,7 +69,6 @@
import org.apache.wicket.util.lang.Bytes;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Value;
/**
* Document management page (creation/edition).
@@ -110,10 +110,6 @@
/** Multiple entry. */
private boolean multipleEntry;
- /** Configuration document max upload size. */
- @Value("${document.maxUploadSize}")
- protected long documentMaxUploadSize;
-
/**
* Constructeur (mode création)
* @param callerPage Page appelante
@@ -162,6 +158,9 @@
final CallerPage currentPage = new CallerPage(this);
+ // get configuration
+ long documentMaxUploadSize = ((WebApplicationImpl)getApplication()).getDocumentMaxUploadSize();
+
// Initialisation du modèle
try {
documentModel = new Model<Document>(idDocument == null && document == null ? new Document()
@@ -267,7 +266,8 @@
});
// Fichier
- formView.add(new SimpleTooltipPanel("Document.file.info", new Model<String>(getString("Document.file.info"))));
+ formView.add(new SimpleTooltipPanel("Document.file.info", new Model<String>(getString("Document.file.info",
+ Model.of(new Object[]{documentMaxUploadSize})))));
formView.add(fileUploadField);
// Action : création du document
@@ -290,7 +290,6 @@
documentModel.getObject().setFileContent(uploadedFile.getBytes());
documentModel.getObject().setFileName(uploadedFile.getClientFileName());
documentModel.getObject().setFileMimetype(uploadedFile.getContentType());
-
}
validateModel();
}
Modified: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/molecule/ManageMoleculePage.html
===================================================================
--- trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/molecule/ManageMoleculePage.html 2013-02-21 12:30:01 UTC (rev 145)
+++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/molecule/ManageMoleculePage.html 2013-02-21 12:33:49 UTC (rev 146)
@@ -99,7 +99,7 @@
<fieldset>
<legend><wicket:message key="Molecule.provenance" /></legend>
- <table class="large" cellspacing="0" wicket:id="Molecule.provenance.Table">
+ <table cellspacing="0" wicket:id="Molecule.provenance.Table">
<thead>
<tr>
<th class="required">
@@ -182,7 +182,7 @@
<fieldset>
<legend><wicket:message key="ListDocumentsPage.AttachedDocuments" /></legend>
<div wicket:id="ListDocumentsPage.AttachedDocuments.Refresh">
- <table class="large" cellspacing="0" wicket:id="ListDocumentsPage.AttachedDocuments"/>
+ <table cellspacing="0" wicket:id="ListDocumentsPage.AttachedDocuments"/>
</div>
<a wicket:id="NewDocument" class="add"><wicket:message key="ListDocumentsPage.NewDocument" /></a>
</fieldset>
Modified: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/molecule/ManageMoleculePage.java
===================================================================
--- trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/molecule/ManageMoleculePage.java 2013-02-21 12:30:01 UTC (rev 145)
+++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/molecule/ManageMoleculePage.java 2013-02-21 12:33:49 UTC (rev 146)
@@ -22,10 +22,6 @@
*/
package nc.ird.cantharella.web.pages.domain.molecule;
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
@@ -34,23 +30,19 @@
import nc.ird.cantharella.data.exceptions.DataNotFoundException;
import nc.ird.cantharella.data.exceptions.UnexpectedException;
import nc.ird.cantharella.data.model.Campagne;
-import nc.ird.cantharella.data.model.Document;
import nc.ird.cantharella.data.model.Extrait;
import nc.ird.cantharella.data.model.Fraction;
import nc.ird.cantharella.data.model.Molecule;
import nc.ird.cantharella.data.model.MoleculeProvenance;
import nc.ird.cantharella.data.model.Produit;
import nc.ird.cantharella.data.model.Utilisateur;
-import nc.ird.cantharella.data.model.utils.DocumentAttachable;
import nc.ird.cantharella.data.validation.utils.ModelValidator;
import nc.ird.cantharella.service.services.CampagneService;
import nc.ird.cantharella.service.services.MoleculeService;
import nc.ird.cantharella.service.services.ProduitService;
-import nc.ird.cantharella.web.config.WebContext;
import nc.ird.cantharella.web.pages.TemplatePage;
import nc.ird.cantharella.web.pages.domain.campagne.ManageCampagnePage;
-import nc.ird.cantharella.web.pages.domain.document.ManageDocumentPage;
-import nc.ird.cantharella.web.pages.domain.document.ReadDocumentPage;
+import nc.ird.cantharella.web.pages.domain.document.DocumentPageHelper;
import nc.ird.cantharella.web.pages.domain.extraction.ReadExtractionPage;
import nc.ird.cantharella.web.pages.domain.purification.ReadPurificationPage;
import nc.ird.cantharella.web.pages.renderers.ProduitRenderer;
@@ -58,34 +50,24 @@
import nc.ird.cantharella.web.utils.behaviors.JSConfirmationBehavior;
import nc.ird.cantharella.web.utils.behaviors.MoleculeEditorBehavior;
import nc.ird.cantharella.web.utils.behaviors.MoleculeViewBehavior;
-import nc.ird.cantharella.web.utils.columns.AjaxButtonPropertyColumn;
-import nc.ird.cantharella.web.utils.columns.LinkPropertyColumn;
-import nc.ird.cantharella.web.utils.columns.LinkableImagePropertyColumn;
import nc.ird.cantharella.web.utils.forms.AutoCompleteTextFieldString;
import nc.ird.cantharella.web.utils.forms.AutoCompleteTextFieldString.ComparisonMode;
import nc.ird.cantharella.web.utils.forms.SubmittableButton;
import nc.ird.cantharella.web.utils.forms.SubmittableButtonEvents;
import nc.ird.cantharella.web.utils.models.DisplayDecimalPropertyModel;
import nc.ird.cantharella.web.utils.models.DisplayDecimalPropertyModel.DecimalDisplFormat;
-import nc.ird.cantharella.web.utils.models.SimpleSortableListDataProvider;
import nc.ird.cantharella.web.utils.panels.PropertyLabelLinkProduitPanel;
import nc.ird.cantharella.web.utils.panels.SimpleTooltipPanel;
import nc.ird.cantharella.web.utils.security.AuthRole;
import nc.ird.cantharella.web.utils.security.AuthRoles;
import nc.ird.cantharella.web.utils.security.AuthSession;
-import org.apache.commons.io.IOUtils;
import org.apache.wicket.AttributeModifier;
import org.apache.wicket.MarkupContainer;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior;
import org.apache.wicket.ajax.markup.html.form.AjaxFallbackButton;
import org.apache.wicket.ajax.markup.html.form.AjaxSubmitLink;
-import org.apache.wicket.extensions.ajax.markup.html.repeater.data.table.AjaxFallbackDefaultDataTable;
-import org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator;
-import org.apache.wicket.extensions.markup.html.repeater.data.table.DataTable;
-import org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn;
-import org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.form.Button;
@@ -98,13 +80,11 @@
import org.apache.wicket.markup.html.link.Link;
import org.apache.wicket.markup.html.list.ListItem;
import org.apache.wicket.markup.html.list.ListView;
-import org.apache.wicket.markup.repeater.Item;
import org.apache.wicket.model.AbstractPropertyModel;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.LoadableDetachableModel;
import org.apache.wicket.model.Model;
import org.apache.wicket.model.PropertyModel;
-import org.apache.wicket.request.http.WebResponse;
import org.apache.wicket.spring.injection.annot.SpringBean;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -202,7 +182,7 @@
final Form<Void> formView = new Form<Void>("Form");
initProvenanceFields(formView, currentPage);
- initAttachedDocumentsTable(formView, moleculeModel.getObject(), currentPage);
+ DocumentPageHelper.initAttachedDocumentsManageTable(this, formView, moleculeModel.getObject(), currentPage);
// page can be accessed by anyone for editing provenance
// but molecule fields can be edited only by administrators or
@@ -606,99 +586,6 @@
}
/**
- * Init attached document table for current entity.
- *
- * @param formView form to add table to
- * @param documentAttachable entity to get documents
- * @param currentPage current page
- */
- private void initAttachedDocumentsTable(final Form<Void> formView, final DocumentAttachable documentAttachable,
- final CallerPage currentPage) {
-
- List<Document> documents = documentAttachable.getDocuments();
-
- // On englobe le "DataView" dans un composant neutre que l'on pourra
- // rafraichir quand la liste évoluera
- final MarkupContainer attachedDocumentRefresh = new WebMarkupContainer(
- "ListDocumentsPage.AttachedDocuments.Refresh");
- attachedDocumentRefresh.setOutputMarkupId(true);
- formView.add(attachedDocumentRefresh);
-
- SimpleSortableListDataProvider<Document> attachedDocumentsDataProvider = new SimpleSortableListDataProvider<Document>(
- documents, getSession().getLocale());
-
- List<IColumn<Document, String>> columns = new ArrayList<IColumn<Document, String>>();
-
- columns.add(new LinkPropertyColumn<Document, String>(new Model<String>(getString("Document.titre")), "titre",
- "titre") {
- @Override
- public void onClick(Item<ICellPopulator<Document>> item, String componentId, IModel<Document> model) {
- setResponsePage(new ReadDocumentPage(model.getObject(), documentAttachable, currentPage));
- }
- });
-
- columns.add(new PropertyColumn<Document, String>(new Model<String>(getString("Document.typeDocument")),
- "typeDocument.nom", "typeDocument.nom"));
-
- columns.add(new PropertyColumn<Document, String>(new Model<String>(getString("Document.createur")), "createur",
- "createur"));
-
- columns.add(new LinkableImagePropertyColumn<Document, String>(new Model<String>(getString("Document.link")),
- "images/download.png", getString("Document.link"), getString("Document.link")) {
- @Override
- public void onClick(Item<ICellPopulator<Document>> item, String componentId, IModel<Document> model) {
-
- Document document = model.getObject();
- WebResponse response = (WebResponse) getResponse();
- response.setContentType(document.getFileMimetype());
- response.setAttachmentHeader(document.getFileName());
-
- OutputStream out = getResponse().getOutputStream();
- InputStream in = new ByteArrayInputStream(document.getFileContent());
- try {
- IOUtils.copy(in, out);
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- });
-
- final DataTable<Document, String> attachedDocumentTable = new AjaxFallbackDefaultDataTable<Document, String>(
- "ListDocumentsPage.AttachedDocuments", columns, attachedDocumentsDataProvider, WebContext.ROWS_PER_PAGE);
-
- columns.add(new AjaxButtonPropertyColumn<Document, String>(new Model<String>(getString("Actions")),
- new Model<String>(getString("Delete")), formView) {
- @Override
- public void onSubmit(AjaxRequestTarget target, Form<?> form, IModel<Document> model) {
- Document document = model.getObject();
- documentAttachable.removeDocument(document);
-
- if (target != null) {
- target.add(attachedDocumentTable);
- refreshFeedbackPage(target);
- }
- }
- });
-
- attachedDocumentRefresh.add(attachedDocumentTable);
-
- // Action : création d'un nouveau document
- // ajaxSubmitLink permet de sauvegarder l'état du formulaire
- formView.add(new AjaxSubmitLink("NewDocument") {
- @Override
- protected void onSubmit(AjaxRequestTarget request, Form<?> form) {
- setResponsePage(new ManageDocumentPage(currentPage, moleculeModel.getObject(), false));
- }
-
- // si erreur, le formulaire est également enregistré puis la redirection effectuée
- @Override
- protected void onError(AjaxRequestTarget target, Form<?> form) {
- setResponsePage(new ManageDocumentPage(currentPage, moleculeModel.getObject(), false));
- }
- }.setVisibilityAllowed(true));
- }
-
- /**
* Redirection vers une autre page. Cas où le formulaire est validé
*/
private void redirect() {
Modified: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/molecule/ReadMoleculePage.java
===================================================================
--- trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/molecule/ReadMoleculePage.java 2013-02-21 12:30:01 UTC (rev 145)
+++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/molecule/ReadMoleculePage.java 2013-02-21 12:33:49 UTC (rev 146)
@@ -22,27 +22,20 @@
*/
package nc.ird.cantharella.web.pages.domain.molecule;
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;
import nc.ird.cantharella.data.exceptions.DataConstraintException;
import nc.ird.cantharella.data.model.Campagne;
-import nc.ird.cantharella.data.model.Document;
import nc.ird.cantharella.data.model.Extrait;
import nc.ird.cantharella.data.model.Fraction;
import nc.ird.cantharella.data.model.Molecule;
import nc.ird.cantharella.data.model.MoleculeProvenance;
import nc.ird.cantharella.data.model.Personne;
import nc.ird.cantharella.data.model.Produit;
-import nc.ird.cantharella.data.model.utils.DocumentAttachable;
import nc.ird.cantharella.service.services.MoleculeService;
-import nc.ird.cantharella.web.config.WebContext;
import nc.ird.cantharella.web.pages.TemplatePage;
-import nc.ird.cantharella.web.pages.domain.document.ReadDocumentPage;
+import nc.ird.cantharella.web.pages.domain.document.DocumentPageHelper;
import nc.ird.cantharella.web.pages.domain.extraction.ReadExtractionPage;
import nc.ird.cantharella.web.pages.domain.lot.ManageLotPage;
import nc.ird.cantharella.web.pages.domain.personne.ReadPersonnePage;
@@ -51,29 +44,20 @@
import nc.ird.cantharella.web.utils.behaviors.JSConfirmationBehavior;
import nc.ird.cantharella.web.utils.behaviors.MoleculeViewBehavior;
import nc.ird.cantharella.web.utils.behaviors.ReplaceEmptyLabelBehavior;
-import nc.ird.cantharella.web.utils.columns.LinkPropertyColumn;
-import nc.ird.cantharella.web.utils.columns.LinkableImagePropertyColumn;
import nc.ird.cantharella.web.utils.forms.SubmittableButton;
import nc.ird.cantharella.web.utils.forms.SubmittableButtonEvents;
import nc.ird.cantharella.web.utils.models.DisplayBooleanPropertyModel;
import nc.ird.cantharella.web.utils.models.DisplayDecimalPropertyModel;
import nc.ird.cantharella.web.utils.models.DisplayDecimalPropertyModel.DecimalDisplFormat;
import nc.ird.cantharella.web.utils.models.GenericLoadableDetachableModel;
-import nc.ird.cantharella.web.utils.models.SimpleSortableListDataProvider;
import nc.ird.cantharella.web.utils.panels.PropertyLabelLinkPanel;
import nc.ird.cantharella.web.utils.panels.PropertyLabelLinkProduitPanel;
import nc.ird.cantharella.web.utils.security.AuthRole;
import nc.ird.cantharella.web.utils.security.AuthRoles;
import nc.ird.cantharella.web.utils.security.AuthSession;
-import org.apache.commons.io.IOUtils;
import org.apache.wicket.AttributeModifier;
import org.apache.wicket.MarkupContainer;
-import org.apache.wicket.extensions.ajax.markup.html.repeater.data.table.AjaxFallbackDefaultDataTable;
-import org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator;
-import org.apache.wicket.extensions.markup.html.repeater.data.table.DataTable;
-import org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn;
-import org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.form.Button;
@@ -82,12 +66,9 @@
import org.apache.wicket.markup.html.link.ResourceLink;
import org.apache.wicket.markup.html.list.ListItem;
import org.apache.wicket.markup.html.list.ListView;
-import org.apache.wicket.markup.repeater.Item;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.LoadableDetachableModel;
-import org.apache.wicket.model.Model;
import org.apache.wicket.model.PropertyModel;
-import org.apache.wicket.request.http.WebResponse;
import org.apache.wicket.request.resource.ByteArrayResource;
import org.apache.wicket.spring.injection.annot.SpringBean;
@@ -103,14 +84,14 @@
public static final String ACTION_DELETE = "Delete";
/** Modèle : molecule */
- private final IModel<Molecule> moleculeModel;
+ private IModel<Molecule> moleculeModel;
/** Service : molecule */
@SpringBean
private MoleculeService moleculeService;
/** Page appelante */
- private final CallerPage callerPage;
+ private CallerPage callerPage;
/**
* Constructor with molecule id to render.
@@ -127,7 +108,7 @@
moleculeModel = new GenericLoadableDetachableModel<Molecule>(Molecule.class, idMolecule);
initProvenanceFields(currentPage);
- initAttachedDocumentsTable(moleculeModel.getObject(), currentPage);
+ DocumentPageHelper.initAttachedDocumentsReadTable(this, moleculeModel.getObject(), currentPage);
add(new Label("Molecule.idMolecule", new PropertyModel<String>(moleculeModel, "idMolecule")));
add(new Label("Molecule.nomCommun", new PropertyModel<String>(moleculeModel, "nomCommun"))
@@ -318,59 +299,4 @@
};
add(noTableProvenances);
}
-
- /**
- * Init attached document table for current entity.
- *
- * @param formView form to add table to
- * @param documentAttachable entity to get documents
- * @param currentPage current page
- */
- private void initAttachedDocumentsTable(final DocumentAttachable documentAttachable, final CallerPage currentPage) {
-
- List<Document> documents = documentAttachable.getDocuments();
-
- SimpleSortableListDataProvider<Document> attachedDocumentsDataProvider = new SimpleSortableListDataProvider<Document>(
- documents, getSession().getLocale());
-
- List<IColumn<Document, String>> columns = new ArrayList<IColumn<Document, String>>();
-
- columns.add(new LinkPropertyColumn<Document, String>(new Model<String>(getString("Document.titre")), "titre",
- "titre") {
- @Override
- public void onClick(Item<ICellPopulator<Document>> item, String componentId, IModel<Document> model) {
- setResponsePage(new ReadDocumentPage(model.getObject(), documentAttachable, currentPage));
- }
- });
-
- columns.add(new PropertyColumn<Document, String>(new Model<String>(getString("Document.typeDocument")),
- "typeDocument.nom", "typeDocument.nom"));
-
- columns.add(new PropertyColumn<Document, String>(new Model<String>(getString("Document.createur")), "createur",
- "createur"));
-
- columns.add(new LinkableImagePropertyColumn<Document, String>(new Model<String>(getString("Document.link")),
- "images/download.png", getString("Document.link"), getString("Document.link")) {
- @Override
- public void onClick(Item<ICellPopulator<Document>> item, String componentId, IModel<Document> model) {
-
- Document document = model.getObject();
- WebResponse response = (WebResponse) getResponse();
- response.setContentType(document.getFileMimetype());
- response.setAttachmentHeader(document.getFileName());
-
- OutputStream out = getResponse().getOutputStream();
- InputStream in = new ByteArrayInputStream(document.getFileContent());
- try {
- IOUtils.copy(in, out);
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- });
-
- final DataTable<Document, String> attachedDocumentTable = new AjaxFallbackDefaultDataTable<Document, String>(
- "ListDocumentsPage.AttachedDocuments", columns, attachedDocumentsDataProvider, WebContext.ROWS_PER_PAGE);
- add(attachedDocumentTable);
- }
}
Modified: trunk/cantharella.web/src/main/resources/cantharella.conf
===================================================================
--- trunk/cantharella.web/src/main/resources/cantharella.conf 2013-02-21 12:30:01 UTC (rev 145)
+++ trunk/cantharella.web/src/main/resources/cantharella.conf 2013-02-21 12:33:49 UTC (rev 146)
@@ -36,4 +36,4 @@
# value for production
#log4j.config=/home/tomcat/.config/log4j_prod.xml
#document file max upload size (Mb)
-document.maxUploadSize=1
\ No newline at end of file
+document.maxUploadSize=1
Modified: trunk/cantharella.web/src/main/resources/web_en.properties
===================================================================
--- trunk/cantharella.web/src/main/resources/web_en.properties 2013-02-21 12:30:01 UTC (rev 145)
+++ trunk/cantharella.web/src/main/resources/web_en.properties 2013-02-21 12:33:49 UTC (rev 146)
@@ -131,7 +131,7 @@
ListTestsBioPage2=Bioassays
ListTestsBioPage.NewTestBio=New bioassay
-ListDocumentsPage.NewDocument=New document
+ListDocumentsPage.NewDocument=Attach new document
ListDocumentsPage.AttachedDocuments=Attached documents
ManageCampagnePage=Campaign management
@@ -414,7 +414,7 @@
Document.link=Link
Document.type=Type
Document.file=File
-Document.file.info=File size must be less than 1Mb
+Document.file.info=File size must be less than ${0}Mb
#BASIC#
Actions=Actions
Modified: trunk/cantharella.web/src/main/resources/web_fr.properties
===================================================================
--- trunk/cantharella.web/src/main/resources/web_fr.properties 2013-02-21 12:30:01 UTC (rev 145)
+++ trunk/cantharella.web/src/main/resources/web_fr.properties 2013-02-21 12:33:49 UTC (rev 146)
@@ -130,7 +130,7 @@
ListTestsBioPage2=Tests biologiques
ListTestsBioPage.NewTestBio=Nouveau test biologique
-ListDocumentsPage.NewDocument=Nouveau document
+ListDocumentsPage.NewDocument=Joindre un nouveau document
ListDocumentsPage.AttachedDocuments=Document(s) attaché(s)
ManageCampagnePage=Gestion d'une campagne
@@ -412,7 +412,7 @@
Document.link=Lien
Document.type=Type
Document.file=Fichier
-Document.file.info=La taille du fichier doit faire moins de 1Mo
+Document.file.info=La taille du fichier doit faire moins de ${0}Mo
#BASIC#
Actions=Actions
1
0
r145 - trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/search
by echatellier@users.forge.codelutin.com 21 Feb '13
by echatellier@users.forge.codelutin.com 21 Feb '13
21 Feb '13
Author: echatellier
Date: 2013-02-21 13:30:01 +0100 (Thu, 21 Feb 2013)
New Revision: 145
Url: http://forge.codelutin.com/projects/cantharella/repository/revisions/145
Log:
Fix back link to search page
Modified:
trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/search/SearchPage.java
Modified: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/search/SearchPage.java
===================================================================
--- trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/search/SearchPage.java 2013-02-21 12:15:33 UTC (rev 144)
+++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/search/SearchPage.java 2013-02-21 12:30:01 UTC (rev 145)
@@ -113,7 +113,7 @@
public SearchPage(String query) {
super(SearchPage.class);
this.query = query;
- final CallerPage currentPage = new CallerPage(SearchPage.class);
+ final CallerPage currentPage = new CallerPage(this);
// ca sert a rien, mais wicket est pas content
ExternalLink link = new ExternalLink("advancedLink",
1
0
r144 - in trunk: cantharella.data/src/main/java/nc/ird/cantharella/data/model cantharella.service/src/main/java/nc/ird/cantharella/service/services/impl
by echatellier@users.forge.codelutin.com 21 Feb '13
by echatellier@users.forge.codelutin.com 21 Feb '13
21 Feb '13
Author: echatellier
Date: 2013-02-21 13:15:33 +0100 (Thu, 21 Feb 2013)
New Revision: 144
Url: http://forge.codelutin.com/projects/cantharella/repository/revisions/144
Log:
Correction des droits pour les mol?\195?\169cules (visible par tout le monde)
Modified:
trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Molecule.java
trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/services/impl/SearchServiceImpl.java
Modified: trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Molecule.java
===================================================================
--- trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Molecule.java 2013-02-21 11:32:04 UTC (rev 143)
+++ trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Molecule.java 2013-02-21 12:15:33 UTC (rev 144)
@@ -41,7 +41,6 @@
import javax.validation.constraints.NotNull;
import nc.ird.cantharella.data.config.DataContext;
-import nc.ird.cantharella.data.model.search.UtilisateurSearchFilter;
import nc.ird.cantharella.data.model.utils.AbstractModel;
import nc.ird.cantharella.data.model.utils.DocumentAttachable;
@@ -49,8 +48,6 @@
import org.hibernate.annotations.CascadeType;
import org.hibernate.annotations.Type;
import org.hibernate.search.annotations.Field;
-import org.hibernate.search.annotations.FullTextFilterDef;
-import org.hibernate.search.annotations.FullTextFilterDefs;
import org.hibernate.search.annotations.Indexed;
import org.hibernate.search.annotations.IndexedEmbedded;
import org.hibernate.validator.constraints.Length;
@@ -63,7 +60,6 @@
*/
@Entity
@Indexed
-@FullTextFilterDefs( { @FullTextFilterDef(name = "utilisateur-Molecule", impl = UtilisateurSearchFilter.class) })
public class Molecule extends AbstractModel implements DocumentAttachable {
/** ID */
Modified: trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/services/impl/SearchServiceImpl.java
===================================================================
--- trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/services/impl/SearchServiceImpl.java 2013-02-21 11:32:04 UTC (rev 143)
+++ trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/services/impl/SearchServiceImpl.java 2013-02-21 12:15:33 UTC (rev 144)
@@ -58,6 +58,7 @@
import org.hibernate.search.MassIndexer;
import org.hibernate.search.Search;
import org.hibernate.search.SearchFactory;
+import org.hibernate.search.annotations.FullTextFilterDefs;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
@@ -211,9 +212,11 @@
// convert lucene query to hibernate query
FullTextQuery hibQuery = fullTextSession.createFullTextQuery(query, clazz);
- // add security filter
- FullTextFilter filter = hibQuery.enableFullTextFilter("utilisateur-" + clazz.getSimpleName());
- filter.setParameter("utilisateur", utilisateur);
+ // add security filter (if class has filter defined)
+ if (clazz.getAnnotation(FullTextFilterDefs.class) != null) {
+ FullTextFilter filter = hibQuery.enableFullTextFilter("utilisateur-" + clazz.getSimpleName());
+ filter.setParameter("utilisateur", utilisateur);
+ }
return hibQuery;
}
1
0
r143 - in trunk: cantharella.data/src/main/java/nc/ird/cantharella/data/model cantharella.service/src/main/java/nc/ird/cantharella/service/services/impl
by echatellier@users.forge.codelutin.com 21 Feb '13
by echatellier@users.forge.codelutin.com 21 Feb '13
21 Feb '13
Author: echatellier
Date: 2013-02-21 12:32:04 +0100 (Thu, 21 Feb 2013)
New Revision: 143
Url: http://forge.codelutin.com/projects/cantharella/repository/revisions/143
Log:
Exlude id from search query parser
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/Extraction.java
trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Lot.java
trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/MethodeTestBio.java
trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Molecule.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/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.service/src/main/java/nc/ird/cantharella/service/services/impl/SearchServiceImpl.java
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 2013-02-21 09:37:08 UTC (rev 142)
+++ trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Campagne.java 2013-02-21 11:32:04 UTC (rev 143)
@@ -49,9 +49,7 @@
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;
@@ -76,7 +74,7 @@
@NotNull
@NotEmpty
@Length(max = LENGTH_MEDIUM_TEXT)
- @Field(index = Index.YES, analyze = Analyze.YES, store = Store.YES)
+ @Field(store = Store.YES)
private String nom;
/** Code pays */
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 2013-02-21 09:37:08 UTC (rev 142)
+++ trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Extraction.java 2013-02-21 11:32:04 UTC (rev 143)
@@ -52,12 +52,10 @@
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.FullTextFilterDef;
import org.hibernate.search.annotations.FullTextFilterDefs;
-import org.hibernate.search.annotations.Index;
import org.hibernate.search.annotations.Indexed;
import org.hibernate.search.annotations.IndexedEmbedded;
import org.hibernate.search.annotations.Store;
@@ -82,7 +80,7 @@
@Length(max = LENGTH_MEDIUM_TEXT)
@Column(unique = true)
@NotEmpty
- @Field(index = Index.YES, analyze = Analyze.YES, store = Store.YES)
+ @Field(store = Store.YES)
private String ref;
/** Manipulateur */
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 2013-02-21 09:37:08 UTC (rev 142)
+++ trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Lot.java 2013-02-21 11:32:04 UTC (rev 143)
@@ -50,11 +50,9 @@
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.FullTextFilterDef;
import org.hibernate.search.annotations.FullTextFilterDefs;
-import org.hibernate.search.annotations.Index;
import org.hibernate.search.annotations.Indexed;
import org.hibernate.search.annotations.IndexedEmbedded;
import org.hibernate.search.annotations.Store;
@@ -82,7 +80,7 @@
@Column(unique = true)
@NotEmpty
@Length(max = LENGTH_MEDIUM_TEXT)
- @Field(index = Index.YES, analyze = Analyze.YES, store = Store.YES)
+ @Field(store = Store.YES)
private String ref;
/** Campagne */
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 2013-02-21 09:37:08 UTC (rev 142)
+++ trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/MethodeTestBio.java 2013-02-21 11:32:04 UTC (rev 143)
@@ -33,10 +33,7 @@
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;
@@ -57,14 +54,14 @@
@Length(max = LENGTH_MEDIUM_TEXT)
@Column(unique = true)
@NotEmpty
- @Field(index = Index.YES, analyze = Analyze.YES, store = Store.YES)
+ @Field
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)
+ @Field
private String cible;
/** Domaine de recherche pour le test */
Modified: trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Molecule.java
===================================================================
--- trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Molecule.java 2013-02-21 09:37:08 UTC (rev 142)
+++ trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Molecule.java 2013-02-21 11:32:04 UTC (rev 143)
@@ -48,14 +48,11 @@
import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;
import org.hibernate.annotations.Type;
-import org.hibernate.search.annotations.Analyze;
import org.hibernate.search.annotations.Field;
import org.hibernate.search.annotations.FullTextFilterDef;
import org.hibernate.search.annotations.FullTextFilterDefs;
-import org.hibernate.search.annotations.Index;
import org.hibernate.search.annotations.Indexed;
import org.hibernate.search.annotations.IndexedEmbedded;
-import org.hibernate.search.annotations.Store;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.NotEmpty;
@@ -77,12 +74,12 @@
/** Nom commun */
@Length(max = LENGTH_LONG_TEXT)
- @Field(index = Index.YES, analyze = Analyze.YES, store = Store.YES)
+ @Field
private String nomCommun;
/** Famille chimique */
@Length(max = LENGTH_MEDIUM_TEXT)
- @Field(index = Index.YES, analyze = Analyze.YES, store = Store.YES)
+ @Field
private String familleChimique;
/** Famille developpée */
@@ -93,7 +90,7 @@
/** Nom IUPAC */
@Length(max = LENGTH_BIG_TEXT)
- @Field(index = Index.YES, analyze = Analyze.YES, store = Store.YES)
+ @Field
private String nomIupca;
/** Formule brute */
@@ -117,7 +114,7 @@
/** Identifiee par. */
@Length(max = LENGTH_MEDIUM_TEXT)
- @Field(index = Index.YES, analyze = Analyze.YES, store = Store.YES)
+ @Field
private String identifieePar;
/** Publication d'origine */
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 2013-02-21 09:37:08 UTC (rev 142)
+++ trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Produit.java 2013-02-21 11:32:04 UTC (rev 143)
@@ -43,7 +43,6 @@
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;
@@ -70,7 +69,7 @@
@Length(max = LENGTH_MEDIUM_TEXT)
@NotEmpty
@Column(unique = true)
- @Field(index = Index.YES, analyze = Analyze.YES, store = Store.YES)
+ @Field(store = Store.YES)
private String ref;
/** Masse obtenue pour le produit **/
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 2013-02-21 09:37:08 UTC (rev 142)
+++ trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Purification.java 2013-02-21 11:32:04 UTC (rev 143)
@@ -54,11 +54,9 @@
import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;
import org.hibernate.annotations.Type;
-import org.hibernate.search.annotations.Analyze;
import org.hibernate.search.annotations.Field;
import org.hibernate.search.annotations.FullTextFilterDef;
import org.hibernate.search.annotations.FullTextFilterDefs;
-import org.hibernate.search.annotations.Index;
import org.hibernate.search.annotations.Indexed;
import org.hibernate.search.annotations.IndexedEmbedded;
import org.hibernate.search.annotations.Store;
@@ -83,7 +81,7 @@
@Length(max = LENGTH_MEDIUM_TEXT)
@Column(unique = true)
@NotEmpty
- @Field(index = Index.YES, analyze = Analyze.YES, store = Store.YES)
+ @Field(store = Store.YES)
private String ref;
/** Manipulateur */
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 2013-02-21 09:37:08 UTC (rev 142)
+++ trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Specimen.java 2013-02-21 11:32:04 UTC (rev 143)
@@ -44,11 +44,9 @@
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.FullTextFilterDef;
import org.hibernate.search.annotations.FullTextFilterDefs;
-import org.hibernate.search.annotations.Index;
import org.hibernate.search.annotations.Indexed;
import org.hibernate.search.annotations.IndexedEmbedded;
import org.hibernate.search.annotations.Store;
@@ -96,28 +94,28 @@
@Column(unique = true)
@NotEmpty
@Length(max = LENGTH_TINY_TEXT)
- @Field(index = Index.YES, analyze = Analyze.YES, store = Store.YES)
+ @Field(store = Store.YES)
private String ref;
/** Embranchement */
@Length(max = LENGTH_MEDIUM_TEXT)
@NotEmpty
- @Field(index = Index.YES, analyze = Analyze.YES, store = Store.YES)
+ @Field
private String embranchement;
/** Famille */
@Length(max = LENGTH_MEDIUM_TEXT)
- @Field(index = Index.YES, analyze = Analyze.YES, store = Store.YES)
+ @Field
private String famille;
/** Genre */
@Length(max = LENGTH_MEDIUM_TEXT)
- @Field(index = Index.YES, analyze = Analyze.YES, store = Store.YES)
+ @Field
private String genre;
/** Espèce */
@Length(max = LENGTH_MEDIUM_TEXT)
- @Field(index = Index.YES, analyze = Analyze.YES, store = Store.YES)
+ @Field
private String espece;
/** Sous-espèce */
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 2013-02-21 09:37:08 UTC (rev 142)
+++ trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Station.java 2013-02-21 11:32:04 UTC (rev 143)
@@ -48,14 +48,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.FullTextFilterDef;
import org.hibernate.search.annotations.FullTextFilterDefs;
-import org.hibernate.search.annotations.Index;
import org.hibernate.search.annotations.Indexed;
import org.hibernate.search.annotations.IndexedEmbedded;
-import org.hibernate.search.annotations.Store;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.NotEmpty;
@@ -81,14 +78,14 @@
@Column(unique = true)
@NotEmpty
@Length(max = LENGTH_MEDIUM_TEXT)
- @Field(index = Index.YES, analyze = Analyze.YES, store = Store.YES)
+ @Field
private String nom;
/** Code pays */
@NotNull
@Length(min = 2, max = 2)
@CountryCode
- @Field(index = Index.YES, analyze = Analyze.YES, store = Store.YES)
+ @Field
private String codePays;
/** Complément */
@@ -105,7 +102,7 @@
/** Localité */
@Length(max = LENGTH_MEDIUM_TEXT)
- @Field(index = Index.YES, analyze = Analyze.YES, store = Store.YES)
+ @Field
private String localite;
/** Latitude */
Modified: trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/TestBio.java
===================================================================
--- trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/TestBio.java 2013-02-21 09:37:08 UTC (rev 142)
+++ trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/TestBio.java 2013-02-21 11:32:04 UTC (rev 143)
@@ -56,10 +56,8 @@
import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;
import org.hibernate.annotations.Type;
-import org.hibernate.search.annotations.Analyze;
import org.hibernate.search.annotations.ContainedIn;
import org.hibernate.search.annotations.Field;
-import org.hibernate.search.annotations.Index;
import org.hibernate.search.annotations.IndexedEmbedded;
import org.hibernate.search.annotations.Store;
import org.hibernate.validator.constraints.Length;
@@ -82,7 +80,7 @@
@Length(max = LENGTH_MEDIUM_TEXT)
@Column(unique = true)
@NotEmpty
- @Field(index = Index.YES, analyze = Analyze.YES, store = Store.YES)
+ @Field(store = Store.YES)
private String ref;
/** Manipulateur */
Modified: trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/services/impl/SearchServiceImpl.java
===================================================================
--- trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/services/impl/SearchServiceImpl.java 2013-02-21 09:37:08 UTC (rev 142)
+++ trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/services/impl/SearchServiceImpl.java 2013-02-21 11:32:04 UTC (rev 143)
@@ -22,6 +22,7 @@
*/
package nc.ird.cantharella.service.services.impl;
+import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -187,11 +188,17 @@
// build a multi field query parser to search in all fields
IndexReader reader = searchFactory.getIndexReaderAccessor().open(clazz);
FieldInfos fieldInfos = ReaderUtil.getMergedFieldInfos(reader);
- String[] fieldArray = new String[fieldInfos.size()];
+ List<String> fieldList = new ArrayList<>();
for (int i = 0; i < fieldInfos.size(); i++) {
- fieldArray[i] = fieldInfos.fieldName(i);
+ String fieldName = fieldInfos.fieldName(i);
+ // il semble impossible de ne pas recuperer l'id du document
+ // on l'exclut donc manuellement
+ if (!fieldName.startsWith("id") && !fieldName.contains(".id")) {
+ fieldList.add(fieldInfos.fieldName(i));
+ }
}
- QueryParser parser = new MultiFieldQueryParser(Version.LUCENE_36, fieldArray, searchFactory.getAnalyzer(clazz));
+ QueryParser parser = new MultiFieldQueryParser(Version.LUCENE_36, fieldList.toArray(new String[fieldList.size()]),
+ searchFactory.getAnalyzer(clazz));
searchFactory.getIndexReaderAccessor().close(reader);
// autorisation de "*" en premier caractere
1
0
r142 - in trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/services: . impl
by echatellier@users.forge.codelutin.com 21 Feb '13
by echatellier@users.forge.codelutin.com 21 Feb '13
21 Feb '13
Author: echatellier
Date: 2013-02-21 10:37:08 +0100 (Thu, 21 Feb 2013)
New Revision: 142
Url: http://forge.codelutin.com/projects/cantharella/repository/revisions/142
Log:
Manage null or empty query to return empty lists
Modified:
trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/services/SearchService.java
trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/services/impl/SearchServiceImpl.java
Modified: trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/services/SearchService.java
===================================================================
--- trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/services/SearchService.java 2013-02-21 09:34:24 UTC (rev 141)
+++ trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/services/SearchService.java 2013-02-21 09:37:08 UTC (rev 142)
@@ -42,7 +42,7 @@
/**
* Search for query result into data model.
*
- * @param query query
+ * @param query query (null value handled : return empty lists)
* @param utilisateur utilisateur to filter results
* @return search result
*/
Modified: trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/services/impl/SearchServiceImpl.java
===================================================================
--- trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/services/impl/SearchServiceImpl.java 2013-02-21 09:34:24 UTC (rev 141)
+++ trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/services/impl/SearchServiceImpl.java 2013-02-21 09:37:08 UTC (rev 142)
@@ -22,6 +22,7 @@
*/
package nc.ird.cantharella.service.services.impl;
+import java.util.Collections;
import java.util.List;
import javax.annotation.Resource;
@@ -38,6 +39,7 @@
import nc.ird.cantharella.service.model.SearchResult;
import nc.ird.cantharella.service.services.SearchService;
+import org.apache.commons.lang3.StringUtils;
import org.apache.lucene.index.FieldInfos;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.queryParser.MultiFieldQueryParser;
@@ -117,25 +119,37 @@
//fullTextSession.setCacheMode(CacheMode.IGNORE);
try {
- // wrap Lucene query in a org.hibernate.Query
- org.hibernate.Query hibSpecimen = getQuery(fullTextSession, Specimen.class, strQuery, utilisateur);
- org.hibernate.Query hibLot = getQuery(fullTextSession, Lot.class, strQuery, utilisateur);
- org.hibernate.Query hibExtraction = getQuery(fullTextSession, Extraction.class, strQuery, utilisateur);
- org.hibernate.Query hibPurification = getQuery(fullTextSession, Purification.class, strQuery, utilisateur);
- org.hibernate.Query hibResultatTestBio = getQuery(fullTextSession, ResultatTestBio.class, strQuery,
- utilisateur);
- org.hibernate.Query hibStation = getQuery(fullTextSession, Station.class, strQuery, utilisateur);
- org.hibernate.Query hibMolecule = getQuery(fullTextSession, Molecule.class, strQuery, utilisateur);
- // 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();
- List<Station> resultatStations = hibStation.list();
- List<Molecule> resultatMolecules = hibMolecule.list();
+ // default init to empty list if query is null or empty
+ List<Specimen> specimens = Collections.EMPTY_LIST;
+ List<Lot> lots = Collections.EMPTY_LIST;
+ List<Extraction> extractions = Collections.EMPTY_LIST;
+ List<Purification> purifications = Collections.EMPTY_LIST;
+ List<ResultatTestBio> resultatTestBios = Collections.EMPTY_LIST;
+ List<Station> resultatStations = Collections.EMPTY_LIST;
+ List<Molecule> resultatMolecules = Collections.EMPTY_LIST;
+ if (StringUtils.isNotEmpty(strQuery)) {
+ // wrap Lucene query in a org.hibernate.Query
+ org.hibernate.Query hibSpecimen = getQuery(fullTextSession, Specimen.class, strQuery, utilisateur);
+ org.hibernate.Query hibLot = getQuery(fullTextSession, Lot.class, strQuery, utilisateur);
+ org.hibernate.Query hibExtraction = getQuery(fullTextSession, Extraction.class, strQuery, utilisateur);
+ org.hibernate.Query hibPurification = getQuery(fullTextSession, Purification.class, strQuery, utilisateur);
+ org.hibernate.Query hibResultatTestBio = getQuery(fullTextSession, ResultatTestBio.class, strQuery,
+ utilisateur);
+ org.hibernate.Query hibStation = getQuery(fullTextSession, Station.class, strQuery, utilisateur);
+ org.hibernate.Query hibMolecule = getQuery(fullTextSession, Molecule.class, strQuery, utilisateur);
+
+ // perform search
+ specimens = hibSpecimen.list();
+ lots = hibLot.list();
+ extractions = hibExtraction.list();
+ purifications = hibPurification.list();
+ resultatTestBios = hibResultatTestBio.list();
+ resultatStations = hibStation.list();
+ resultatMolecules = hibMolecule.list();
+ }
+
result.setSpecimens(specimens);
result.setLots(lots);
result.setExtractions(extractions);
1
0
Author: echatellier
Date: 2013-02-21 10:34:24 +0100 (Thu, 21 Feb 2013)
New Revision: 141
Url: http://forge.codelutin.com/projects/cantharella/repository/revisions/141
Log:
Update to wicket 6.6.0
Modified:
trunk/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2013-02-20 15:40:59 UTC (rev 140)
+++ trunk/pom.xml 2013-02-21 09:34:24 UTC (rev 141)
@@ -139,7 +139,7 @@
<version.poi>3.9</version.poi>
<version.nuiton-utils>2.6.8</version.nuiton-utils>
<version.servlet-api>2.5</version.servlet-api>
- <version.wicket>6.5.0</version.wicket>
+ <version.wicket>6.6.0</version.wicket>
<!-- FIXME echatellier Probleme de parallelisation des tests unitaire,
cause org.hibernate.HibernateException: Don't change the reference to a collection
1
0
r140 - in trunk: cantharella.data/src/main/java/nc/ird/cantharella/data/config cantharella.data/src/main/resources cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/document cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/molecule cantharella.web/src/main/resources
by echatellier@users.forge.codelutin.com 20 Feb '13
by echatellier@users.forge.codelutin.com 20 Feb '13
20 Feb '13
Author: echatellier
Date: 2013-02-20 16:40:59 +0100 (Wed, 20 Feb 2013)
New Revision: 140
Url: http://forge.codelutin.com/projects/cantharella/repository/revisions/140
Log:
Ajout d'infobulle manquante.
Passage des valeurs fixe en configuration.
Modified:
trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/config/DataContext.java
trunk/cantharella.data/src/main/resources/cantharella.conf
trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/document/ManageDocumentPage.html
trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/document/ManageDocumentPage.java
trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/molecule/ManageMoleculePage.html
trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/molecule/ManageMoleculePage.java
trunk/cantharella.web/src/main/resources/cantharella.conf
trunk/cantharella.web/src/main/resources/web_en.properties
trunk/cantharella.web/src/main/resources/web_fr.properties
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 2013-02-20 14:57:34 UTC (rev 139)
+++ trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/config/DataContext.java 2013-02-20 15:40:59 UTC (rev 140)
@@ -168,11 +168,23 @@
protected String dbUserProperty;
/**
- * DB user
+ * Hibernate schema validation property.
*/
- @Value("${db.hbm2ddl:validate}")
+ @Value("${db.hbm2ddl}")
protected String hbm2ddl;
+ /**
+ * Hibernate search lucene index location on filesystem.
+ */
+ @Value("${hibernate.search.indexBase}")
+ protected String hibernateSearchIndexBase;
+
+ /**
+ * Hibernate search analyzer.
+ */
+ @Value("${hibernate.search.analyzer}")
+ protected String hibernateSearchAnalyzer;
+
static {
// The first Locale in the list is the default one
List<Locale> locales = new ArrayList<Locale>();
@@ -295,8 +307,8 @@
//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");
+ hibernateProperties.setProperty("hibernate.search.default.indexBase", hibernateSearchIndexBase);
+ hibernateProperties.setProperty("hibernate.search.analyzer", hibernateSearchAnalyzer);
// Hibernate: Session
//hibernateProperties.setProperty("hibernate.current_session_context_class", "thread");
Modified: trunk/cantharella.data/src/main/resources/cantharella.conf
===================================================================
--- trunk/cantharella.data/src/main/resources/cantharella.conf 2013-02-20 14:57:34 UTC (rev 139)
+++ trunk/cantharella.data/src/main/resources/cantharella.conf 2013-02-20 15:40:59 UTC (rev 140)
@@ -31,3 +31,8 @@
# value for production
#db.debug=false
db.hbm2ddl=validate
+
+# Hibernate search lucene index location on filesystem.
+hibernate.search.indexBase=/tmp/cantharella
+# Hibernate search analyzer
+hibernate.search.analyzer=org.apache.lucene.analysis.fr.FrenchAnalyzer
\ No newline at end of file
Modified: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/document/ManageDocumentPage.html
===================================================================
--- trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/document/ManageDocumentPage.html 2013-02-20 14:57:34 UTC (rev 139)
+++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/document/ManageDocumentPage.html 2013-02-20 15:40:59 UTC (rev 140)
@@ -84,7 +84,8 @@
</div>
<div class="property required">
- <label for="Document.file"><wicket:message key="Document.file" /></label>
+ <label for="Document.file"><wicket:message key="Document.file" />
+ <wicket:container wicket:id="Document.file.info"/></label>
<input type="file" id="Document.file" wicket:id="Document.file" />
</div>
Modified: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/document/ManageDocumentPage.java
===================================================================
--- trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/document/ManageDocumentPage.java 2013-02-20 14:57:34 UTC (rev 139)
+++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/document/ManageDocumentPage.java 2013-02-20 15:40:59 UTC (rev 140)
@@ -44,6 +44,7 @@
import nc.ird.cantharella.web.utils.forms.SubmittableButton;
import nc.ird.cantharella.web.utils.forms.SubmittableButtonEvents;
import nc.ird.cantharella.web.utils.forms.AutoCompleteTextFieldString.ComparisonMode;
+import nc.ird.cantharella.web.utils.panels.SimpleTooltipPanel;
import nc.ird.cantharella.web.utils.renderers.MapChoiceRenderer;
import org.apache.wicket.ajax.AjaxRequestTarget;
@@ -67,6 +68,7 @@
import org.apache.wicket.util.lang.Bytes;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Value;
/**
* Document management page (creation/edition).
@@ -108,6 +110,10 @@
/** Multiple entry. */
private boolean multipleEntry;
+ /** Configuration document max upload size. */
+ @Value("${document.maxUploadSize}")
+ protected long documentMaxUploadSize;
+
/**
* Constructeur (mode création)
* @param callerPage Page appelante
@@ -189,7 +195,7 @@
}
};
formView.setMultiPart(true);
- formView.setMaxSize(Bytes.megabytes(1));
+ formView.setMaxSize(Bytes.megabytes(documentMaxUploadSize));
formView.add(new TextField<String>("Document.titre", new PropertyModel<String>(documentModel, "titre")));
@@ -261,6 +267,7 @@
});
// Fichier
+ formView.add(new SimpleTooltipPanel("Document.file.info", new Model<String>(getString("Document.file.info"))));
formView.add(fileUploadField);
// Action : création du document
Modified: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/molecule/ManageMoleculePage.html
===================================================================
--- trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/molecule/ManageMoleculePage.html 2013-02-20 14:57:34 UTC (rev 139)
+++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/molecule/ManageMoleculePage.html 2013-02-20 15:40:59 UTC (rev 140)
@@ -48,8 +48,9 @@
</div>
<div class="property required">
- <label for="Molecule.formuleBrute"><wicket:message key="Molecule.formuleBrute" /></label>
- <input type="text" id="Molecule.formuleBrute" wicket:id="Molecule.formuleBrute" />
+ <label for="Molecule.formuleBrute"><wicket:message key="Molecule.formuleBrute" />
+ <wicket:container wicket:id="Molecule.formuleBrute.info"/></label>
+ <input type="text" id="Molecule.formuleBrute" wicket:id="Molecule.formuleBrute" />
</div>
<div class="property required">
@@ -61,7 +62,8 @@
<legend><wicket:message key="Molecule.nouvMolecul" /></legend>
<div class="property">
- <label for="Molecule.nouvMolecul"><wicket:message key="Molecule.nouvMolecul" /></label>
+ <label for="Molecule.nouvMolecul"><wicket:message key="Molecule.nouvMolecul" />
+ <wicket:container wicket:id="Molecule.nouvMolecul.info"/></label>
<input type="checkbox" id="Molecule.nouvMolecul" wicket:id="Molecule.nouvMolecul" />
</div>
Modified: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/molecule/ManageMoleculePage.java
===================================================================
--- trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/molecule/ManageMoleculePage.java 2013-02-20 14:57:34 UTC (rev 139)
+++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/molecule/ManageMoleculePage.java 2013-02-20 15:40:59 UTC (rev 140)
@@ -69,6 +69,7 @@
import nc.ird.cantharella.web.utils.models.DisplayDecimalPropertyModel.DecimalDisplFormat;
import nc.ird.cantharella.web.utils.models.SimpleSortableListDataProvider;
import nc.ird.cantharella.web.utils.panels.PropertyLabelLinkProduitPanel;
+import nc.ird.cantharella.web.utils.panels.SimpleTooltipPanel;
import nc.ird.cantharella.web.utils.security.AuthRole;
import nc.ird.cantharella.web.utils.security.AuthRoles;
import nc.ird.cantharella.web.utils.security.AuthSession;
@@ -227,6 +228,8 @@
formView.add(new TextField<String>("Molecule.nomIupca", new PropertyModel<String>(moleculeModel, "nomIupca"))
.setEnabled(editEnabled));
+ formView.add(new SimpleTooltipPanel("Molecule.formuleBrute.info", new Model<String>(
+ getString("Molecule.formuleBrute.info"))));
formView.add(new TextField<String>("Molecule.formuleBrute", new PropertyModel<String>(moleculeModel,
"formuleBrute")).setEnabled(editEnabled));
@@ -243,6 +246,8 @@
formView.add(nouvMoleculRefresh);
// predéclaration des champs activé par la chec
+ formView.add(new SimpleTooltipPanel("Molecule.nouvMolecul.info", new Model<String>(
+ getString("Molecule.nouvMolecul.info"))));
formView.add(new CheckBox("Molecule.nouvMolecul", new PropertyModel<Boolean>(moleculeModel, "nouvMolecul")) {
@Override
protected void onSelectionChanged(Boolean newSelection) {
Modified: trunk/cantharella.web/src/main/resources/cantharella.conf
===================================================================
--- trunk/cantharella.web/src/main/resources/cantharella.conf 2013-02-20 14:57:34 UTC (rev 139)
+++ trunk/cantharella.web/src/main/resources/cantharella.conf 2013-02-20 15:40:59 UTC (rev 140)
@@ -35,4 +35,5 @@
log4j.config=classpath:log4j.xml
# value for production
#log4j.config=/home/tomcat/.config/log4j_prod.xml
-
+#document file max upload size (Mb)
+document.maxUploadSize=1
\ No newline at end of file
Modified: trunk/cantharella.web/src/main/resources/web_en.properties
===================================================================
--- trunk/cantharella.web/src/main/resources/web_en.properties 2013-02-20 14:57:34 UTC (rev 139)
+++ trunk/cantharella.web/src/main/resources/web_en.properties 2013-02-20 15:40:59 UTC (rev 140)
@@ -384,6 +384,8 @@
Molecule.masseMolaire.Required=Molar mass - can’t be null
Molecule.masseMolaire.IConverter.BigDecimal=Molar mass - must be a decimal number
Molecule.downloadMolFile=Download .mol file
+Molecule.formuleBrute.info=Specify in order : Carbon, Hydrogen and then alphabetically
+Molecule.nouvMolecul.info=All users can see molecules. Make sure that molecule is properly published.
TestBio.date.IConverter.Date=The date is incorrectly formatted (DD/MM/YY)
TestBio.concMasseDefaut.IConverter.BigDecimal=Default Conc./Mass - must be a decimal number
@@ -412,6 +414,7 @@
Document.link=Link
Document.type=Type
Document.file=File
+Document.file.info=File size must be less than 1Mb
#BASIC#
Actions=Actions
Modified: trunk/cantharella.web/src/main/resources/web_fr.properties
===================================================================
--- trunk/cantharella.web/src/main/resources/web_fr.properties 2013-02-20 14:57:34 UTC (rev 139)
+++ trunk/cantharella.web/src/main/resources/web_fr.properties 2013-02-20 15:40:59 UTC (rev 140)
@@ -382,6 +382,8 @@
Molecule.masseMolaire.Required=Masse molaire - ne peut être nul
Molecule.masseMolaire.IConverter.BigDecimal=Masse molaire - doit être un nombre décimal
Molecule.downloadMolFile=Télécharger au format mol
+Molecule.formuleBrute.info=Indiquez dans l'ordre : Carbone, Hydrogène puis ordre alphabetique
+Molecule.nouvMolecul.info=Les molécules sont visibles par tous les utilsateurs. Attention à ce que la molécule soit bien publiée.
TestBio.date.IConverter.Date=La date est mal formatée (JJ/MM/AA)
TestBio.concMasseDefaut.IConverter.BigDecimal=Conc./Masse par défaut - doit être un nombre décimal
@@ -410,6 +412,7 @@
Document.link=Lien
Document.type=Type
Document.file=Fichier
+Document.file.info=La taille du fichier doit faire moins de 1Mo
#BASIC#
Actions=Actions
1
0
r139 - trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/molecule
by echatellier@users.forge.codelutin.com 20 Feb '13
by echatellier@users.forge.codelutin.com 20 Feb '13
20 Feb '13
Author: echatellier
Date: 2013-02-20 15:57:34 +0100 (Wed, 20 Feb 2013)
New Revision: 139
Url: http://forge.codelutin.com/projects/cantharella/repository/revisions/139
Log:
Format code
Modified:
trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/molecule/ManageMoleculePage.java
trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/molecule/ReadMoleculePage.java
Modified: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/molecule/ManageMoleculePage.java
===================================================================
--- trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/molecule/ManageMoleculePage.java 2013-02-20 14:49:43 UTC (rev 138)
+++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/molecule/ManageMoleculePage.java 2013-02-20 14:57:34 UTC (rev 139)
@@ -220,10 +220,9 @@
"formuleDevMol")).add(new MoleculeEditorBehavior(new PropertyModel<String>(moleculeModel,
"formuleDevMol"))));
} else {
- formView
- .add(new HiddenField<String>("Molecule.formuleDevMol", new PropertyModel<String>(moleculeModel,
- "formuleDevMol")).setEnabled(false) // important otherwise, loose data
- .add(new MoleculeViewBehavior(new PropertyModel<String>(moleculeModel, "formuleDevMol"), true)));
+ formView.add(new HiddenField<String>("Molecule.formuleDevMol", new PropertyModel<String>(moleculeModel,
+ "formuleDevMol")).setEnabled(false) // important otherwise, loose data
+ .add(new MoleculeViewBehavior(new PropertyModel<String>(moleculeModel, "formuleDevMol"), true)));
}
formView.add(new TextField<String>("Molecule.nomIupca", new PropertyModel<String>(moleculeModel, "nomIupca"))
Modified: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/molecule/ReadMoleculePage.java
===================================================================
--- trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/molecule/ReadMoleculePage.java 2013-02-20 14:49:43 UTC (rev 138)
+++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/molecule/ReadMoleculePage.java 2013-02-20 14:57:34 UTC (rev 139)
@@ -137,8 +137,8 @@
add(new Label("Molecule.formuleDevMol", new PropertyModel<String>(moleculeModel, "formuleDevMol")).add(
new ReplaceEmptyLabelBehavior()).add(
new MoleculeViewBehavior(new PropertyModel<String>(moleculeModel, "formuleDevMol"), true)));
- add(new ResourceLink<Molecule>("DownloadMolFile", new ByteArrayResource("chemical/x-mdl-molfile",
- moleculeModel.getObject().getFormuleDevMol().getBytes(), "molecule.mol")));
+ add(new ResourceLink<Molecule>("DownloadMolFile", new ByteArrayResource("chemical/x-mdl-molfile", moleculeModel
+ .getObject().getFormuleDevMol().getBytes(), "molecule.mol")));
add(new Label("Molecule.nomIupca", new PropertyModel<String>(moleculeModel, "nomIupca"))
.add(new ReplaceEmptyLabelBehavior()));
add(new Label("Molecule.formuleBrute", new PropertyModel<String>(moleculeModel, "formuleBrute"))
@@ -281,7 +281,8 @@
}
});
- item.add(new Label("Molecule.provenance.List.presence", new DisplayDecimalPropertyModel(provenanceModel,
+ item.add(
+ new Label("Molecule.provenance.List.presence", new DisplayDecimalPropertyModel(provenanceModel,
"pourcentage", DecimalDisplFormat.SMALL, getLocale()))).add(
new ReplaceEmptyLabelBehavior());
if (provenanceModel.getObject().getProduit() instanceof Fraction) {
1
0
r138 - trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/molecule
by echatellier@users.forge.codelutin.com 20 Feb '13
by echatellier@users.forge.codelutin.com 20 Feb '13
20 Feb '13
Author: echatellier
Date: 2013-02-20 15:49:43 +0100 (Wed, 20 Feb 2013)
New Revision: 138
Url: http://forge.codelutin.com/projects/cantharella/repository/revisions/138
Log:
Fix provenance table in molecule read page
Modified:
trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/molecule/ReadMoleculePage.java
Modified: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/molecule/ReadMoleculePage.java
===================================================================
--- trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/molecule/ReadMoleculePage.java 2013-02-20 14:35:29 UTC (rev 137)
+++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/molecule/ReadMoleculePage.java 2013-02-20 14:49:43 UTC (rev 138)
@@ -281,18 +281,28 @@
}
});
- item.add(
- new Label("Molecule.provenance.List.presence", new DisplayDecimalPropertyModel(provenanceModel,
+ item.add(new Label("Molecule.provenance.List.presence", new DisplayDecimalPropertyModel(provenanceModel,
"pourcentage", DecimalDisplFormat.SMALL, getLocale()))).add(
new ReplaceEmptyLabelBehavior());
- item.add(new Label("Molecule.provenance.List.lot.ref", new PropertyModel<String>(provenanceModel,
- "pourcentage")).add(new ReplaceEmptyLabelBehavior()));
- item.add(new Label("Molecule.provenance.List.genre", new PropertyModel<String>(provenanceModel,
- "pourcentage")).add(new ReplaceEmptyLabelBehavior()));
- item.add(new Label("Molecule.provenance.List.espece", new PropertyModel<String>(provenanceModel,
- "pourcentage")).add(new ReplaceEmptyLabelBehavior()));
- item.add(new Label("Molecule.provenance.List.campagne", new PropertyModel<String>(provenanceModel,
- "pourcentage")).add(new ReplaceEmptyLabelBehavior()));
+ if (provenanceModel.getObject().getProduit() instanceof Fraction) {
+ item.add(new Label("Molecule.provenance.List.lot.ref", new PropertyModel<String>(provenanceModel,
+ "produit.purification.lotSource.ref")));
+ item.add(new Label("Molecule.provenance.List.genre", new PropertyModel<String>(provenanceModel,
+ "produit.purification.lotSource.specimenRef.genre")));
+ item.add(new Label("Molecule.provenance.List.espece", new PropertyModel<String>(provenanceModel,
+ "produit.purification.lotSource.specimenRef.espece")));
+ item.add(new Label("Molecule.provenance.List.campagne", new PropertyModel<String>(provenanceModel,
+ "produit.purification.lotSource.campagne.nom")));
+ } else {
+ item.add(new Label("Molecule.provenance.List.lot.ref", new PropertyModel<String>(provenanceModel,
+ "produit.extraction.lot.ref")));
+ item.add(new Label("Molecule.provenance.List.genre", new PropertyModel<String>(provenanceModel,
+ "produit.extraction.lot.specimenRef.genre")));
+ item.add(new Label("Molecule.provenance.List.espece", new PropertyModel<String>(provenanceModel,
+ "produit.extraction.lot.specimenRef.espece")));
+ item.add(new Label("Molecule.provenance.List.campagne", new PropertyModel<String>(provenanceModel,
+ "produit.extraction.lot.campagne.nom")));
+ }
}
};
provenanceTable.add(provenanceListView);
1
0
r137 - in trunk/cantharella.web/src/main: java/nc/ird/cantharella/web/pages/domain/molecule java/nc/ird/cantharella/web/utils/behaviors resources webapp/js
by echatellier@users.forge.codelutin.com 20 Feb '13
by echatellier@users.forge.codelutin.com 20 Feb '13
20 Feb '13
Author: echatellier
Date: 2013-02-20 15:35:29 +0100 (Wed, 20 Feb 2013)
New Revision: 137
Url: http://forge.codelutin.com/projects/cantharella/repository/revisions/137
Log:
Fix linkable canvas to download image and add download mol file link
Modified:
trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/molecule/ManageMoleculePage.java
trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/molecule/ReadMoleculePage.html
trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/molecule/ReadMoleculePage.java
trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/behaviors/MoleculeViewBehavior.java
trunk/cantharella.web/src/main/resources/web_en.properties
trunk/cantharella.web/src/main/resources/web_fr.properties
trunk/cantharella.web/src/main/webapp/js/molviewer.js
Modified: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/molecule/ManageMoleculePage.java
===================================================================
--- trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/molecule/ManageMoleculePage.java 2013-02-20 06:06:04 UTC (rev 136)
+++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/molecule/ManageMoleculePage.java 2013-02-20 14:35:29 UTC (rev 137)
@@ -223,9 +223,7 @@
formView
.add(new HiddenField<String>("Molecule.formuleDevMol", new PropertyModel<String>(moleculeModel,
"formuleDevMol")).setEnabled(false) // important otherwise, loose data
- .add(
- new MoleculeViewBehavior(new PropertyModel<String>(moleculeModel, "formuleDevMol"),
- 500, 300)));
+ .add(new MoleculeViewBehavior(new PropertyModel<String>(moleculeModel, "formuleDevMol"), true)));
}
formView.add(new TextField<String>("Molecule.nomIupca", new PropertyModel<String>(moleculeModel, "nomIupca"))
Modified: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/molecule/ReadMoleculePage.html
===================================================================
--- trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/molecule/ReadMoleculePage.html 2013-02-20 06:06:04 UTC (rev 136)
+++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/molecule/ReadMoleculePage.html 2013-02-20 14:35:29 UTC (rev 137)
@@ -42,7 +42,8 @@
<div class="property">
<span class="label"><wicket:message key="Molecule.formuleDevMol" /></span>
- <span class="value" wicket:id="Molecule.formuleDevMol"></span>
+ <div><span class="value" wicket:id="Molecule.formuleDevMol"></span><br />
+ <a wicket:id="DownloadMolFile"><wicket:message key="Molecule.downloadMolFile" /></a></div>
</div>
<div class="property">
Modified: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/molecule/ReadMoleculePage.java
===================================================================
--- trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/molecule/ReadMoleculePage.java 2013-02-20 06:06:04 UTC (rev 136)
+++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/molecule/ReadMoleculePage.java 2013-02-20 14:35:29 UTC (rev 137)
@@ -79,6 +79,7 @@
import org.apache.wicket.markup.html.form.Button;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.link.Link;
+import org.apache.wicket.markup.html.link.ResourceLink;
import org.apache.wicket.markup.html.list.ListItem;
import org.apache.wicket.markup.html.list.ListView;
import org.apache.wicket.markup.repeater.Item;
@@ -87,6 +88,7 @@
import org.apache.wicket.model.Model;
import org.apache.wicket.model.PropertyModel;
import org.apache.wicket.request.http.WebResponse;
+import org.apache.wicket.request.resource.ByteArrayResource;
import org.apache.wicket.spring.injection.annot.SpringBean;
/**
@@ -134,7 +136,9 @@
.add(new ReplaceEmptyLabelBehavior()));
add(new Label("Molecule.formuleDevMol", new PropertyModel<String>(moleculeModel, "formuleDevMol")).add(
new ReplaceEmptyLabelBehavior()).add(
- new MoleculeViewBehavior(new PropertyModel<String>(moleculeModel, "formuleDevMol"), 500, 300)));
+ new MoleculeViewBehavior(new PropertyModel<String>(moleculeModel, "formuleDevMol"), true)));
+ add(new ResourceLink<Molecule>("DownloadMolFile", new ByteArrayResource("chemical/x-mdl-molfile",
+ moleculeModel.getObject().getFormuleDevMol().getBytes(), "molecule.mol")));
add(new Label("Molecule.nomIupca", new PropertyModel<String>(moleculeModel, "nomIupca"))
.add(new ReplaceEmptyLabelBehavior()));
add(new Label("Molecule.formuleBrute", new PropertyModel<String>(moleculeModel, "formuleBrute"))
@@ -170,8 +174,7 @@
final Form<Void> formView = new Form<Void>("Form");
// Action : mise à jour (redirection vers le formulaire)
- Link<Molecule> updateLink = new Link<Molecule>(getResource() + ".Molecule.Update", new Model<Molecule>(
- moleculeModel.getObject())) {
+ Link<Molecule> updateLink = new Link<Molecule>(getResource() + ".Molecule.Update", moleculeModel) {
@Override
public void onClick() {
setResponsePage(new ManageMoleculePage(getModelObject().getIdMolecule(), currentPage));
Modified: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/behaviors/MoleculeViewBehavior.java
===================================================================
--- trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/behaviors/MoleculeViewBehavior.java 2013-02-20 06:06:04 UTC (rev 136)
+++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/utils/behaviors/MoleculeViewBehavior.java 2013-02-20 14:35:29 UTC (rev 137)
@@ -43,32 +43,27 @@
*/
public class MoleculeViewBehavior extends AttributeModifier {
- /** Canvas width. */
- protected int width;
+ /** Full view, with cliquable canvas and mol download support. */
+ protected boolean fullView;
- /** Canvas height. */
- protected int height;
-
/**
* Constructor with default canvas size.
*
* @param replaceModel replace model
*/
public MoleculeViewBehavior(IModel<?> replaceModel) {
- this(replaceModel, 100, 100);
+ this(replaceModel, false);
}
/**
* Constructor.
*
* @param replaceModel replace model
- * @param width canvas width
- * @param height canvas height
+ * @param fullView full view, with cliquable canvas and mol download support
*/
- public MoleculeViewBehavior(IModel<?> replaceModel, int width, int height) {
+ public MoleculeViewBehavior(IModel<?> replaceModel, boolean fullView) {
super("formula", replaceModel);
- this.width = width;
- this.height = height;
+ this.fullView = fullView;
}
/** {@inheritDoc} */
@@ -108,8 +103,11 @@
String id = component.getMarkupId();
response.write(JavaScriptUtils.SCRIPT_OPEN_TAG);
-
- response.write("addViewerMolecule('" + id + "', " + width + "," + height + ");");
+ if (fullView) {
+ response.write("addFullViewerMolecule('" + id + "');");
+ } else {
+ response.write("addViewerMolecule('" + id + "');");
+ }
response.write(JavaScriptUtils.SCRIPT_CLOSE_TAG);
}
Modified: trunk/cantharella.web/src/main/resources/web_en.properties
===================================================================
--- trunk/cantharella.web/src/main/resources/web_en.properties 2013-02-20 06:06:04 UTC (rev 136)
+++ trunk/cantharella.web/src/main/resources/web_en.properties 2013-02-20 14:35:29 UTC (rev 137)
@@ -383,6 +383,7 @@
Molecule.provenanceNotAccessibles=Some related products are not displayed because you don't have the required rights
Molecule.masseMolaire.Required=Molar mass - can’t be null
Molecule.masseMolaire.IConverter.BigDecimal=Molar mass - must be a decimal number
+Molecule.downloadMolFile=Download .mol file
TestBio.date.IConverter.Date=The date is incorrectly formatted (DD/MM/YY)
TestBio.concMasseDefaut.IConverter.BigDecimal=Default Conc./Mass - must be a decimal number
Modified: trunk/cantharella.web/src/main/resources/web_fr.properties
===================================================================
--- trunk/cantharella.web/src/main/resources/web_fr.properties 2013-02-20 06:06:04 UTC (rev 136)
+++ trunk/cantharella.web/src/main/resources/web_fr.properties 2013-02-20 14:35:29 UTC (rev 137)
@@ -381,6 +381,7 @@
Molecule.provenanceNotAccessibles=Certains produits associés ne sont pas affichés car vous n'avez pas les droits nécéssaires
Molecule.masseMolaire.Required=Masse molaire - ne peut être nul
Molecule.masseMolaire.IConverter.BigDecimal=Masse molaire - doit être un nombre décimal
+Molecule.downloadMolFile=Télécharger au format mol
TestBio.date.IConverter.Date=La date est mal formatée (JJ/MM/AA)
TestBio.concMasseDefaut.IConverter.BigDecimal=Conc./Masse par défaut - doit être un nombre décimal
Modified: trunk/cantharella.web/src/main/webapp/js/molviewer.js
===================================================================
--- trunk/cantharella.web/src/main/webapp/js/molviewer.js 2013-02-20 06:06:04 UTC (rev 136)
+++ trunk/cantharella.web/src/main/webapp/js/molviewer.js 2013-02-20 14:35:29 UTC (rev 137)
@@ -1,8 +1,8 @@
/*
* #%L
* Cantharella :: Web
- * $Id:$
- * $HeadURL:$
+ * $Id$
+ * $HeadURL$
* %%
* Copyright (C) 2009 - 2013 IRD (Institut de Recherche pour le Developpement) and by respective authors (see below)
* %%
@@ -20,7 +20,27 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
-function addViewerMolecule(tagId, width, height) {
+function addChemCanvas(id, formulaString, width, heigth) {
+ //initialize component and set visual specifications
+ var viewerCanvas = new ChemDoodle.ViewerCanvas(id, width, heigth);
+ viewerCanvas.specs.bonds_width_2D = .6;
+ viewerCanvas.specs.bonds_saturationWidth_2D = .18;
+ viewerCanvas.specs.bonds_hashSpacing_2D = 2.5;
+ viewerCanvas.specs.atoms_font_size_2D = 10;
+ viewerCanvas.specs.atoms_font_families_2D = ["Helvetica", "Arial", "sans-serif"];
+ viewerCanvas.specs.atoms_displayTerminalCarbonLabels_2D = true;
+
+ var formula = ChemDoodle.readMOL(formulaString);
+
+ // function to scale molecul to canvas
+ var size = formula.getDimension();
+ var scale = Math.min(viewerCanvas.width/size.x, viewerCanvas.height/size.y);
+ viewerCanvas.loadMolecule(formula);
+ viewerCanvas.specs.scale = scale*.8;
+ viewerCanvas.repaint();
+}
+
+function addViewerMolecule(tagId) {
if (tagId) {
tagId = '#' + tagId.replace( /(:|\.)/g, "\\$1" );
} else {
@@ -34,23 +54,28 @@
var id = $(formulaTag).attr('id');
$(formulaTag).replaceWith("<canvas id='"+id+"'/>");
- //initialize component and set visual specifications
- var viewerCanvas = new ChemDoodle.ViewerCanvas(id, width, height);
- viewerCanvas.specs.bonds_width_2D = .6;
- viewerCanvas.specs.bonds_saturationWidth_2D = .18;
- viewerCanvas.specs.bonds_hashSpacing_2D = 2.5;
- viewerCanvas.specs.atoms_font_size_2D = 10;
- viewerCanvas.specs.atoms_font_families_2D = ["Helvetica", "Arial", "sans-serif"];
- viewerCanvas.specs.atoms_displayTerminalCarbonLabels_2D = true;
+ addChemCanvas(id, formulaString, 100, 100);
+ });
+}
- var formula = ChemDoodle.readMOL(formulaString);
+function addFullViewerMolecule(tagId) {
+ if (tagId) {
+ tagId = '#' + tagId.replace( /(:|\.)/g, "\\$1" );
+ } else {
+ tagId = '[formula]';
+ }
- // function to scale molecul to canvas
- var size = formula.getDimension();
- var scale = Math.min(viewerCanvas.width/size.x, viewerCanvas.height/size.y);
- viewerCanvas.loadMolecule(formula);
- viewerCanvas.specs.scale = scale*.8;
- viewerCanvas.repaint();
+ $(tagId).each(function(i, formulaTag) {
+ // il faut faire un substring de 1 car on a ajoute un caractere pour
+ // forcer l'existance du tag'
+ var formulaString = $(formulaTag).attr('formula').substring(1);
+ var id = $(formulaTag).attr('id');
+ $(formulaTag).replaceWith("<a download='molecule'><canvas id='"+id+"'/></a>");
+
+ addChemCanvas(id, formulaString, 500, 300);
+
+ // add download link
+ var dataUrl = document.getElementById(id).toDataURL("image/png");
+ $('#' + id).parent().attr('href', dataUrl);
});
-
}
Property changes on: trunk/cantharella.web/src/main/webapp/js/molviewer.js
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
1
0