Echobase-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
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
November 2011
- 3 participants
- 137 discussions
r39 - trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui
by tchemit@users.forge.codelutin.com 11 Nov '11
by tchemit@users.forge.codelutin.com 11 Nov '11
11 Nov '11
Author: tchemit
Date: 2011-11-11 18:19:56 +0100 (Fri, 11 Nov 2011)
New Revision: 39
Url: http://forge.codelutin.com/repositories/revision/echobase/39
Log:
add options to create a lotf of admin (for dev purpose only)
Modified:
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/EchoBaseApplicationListener.java
Modified: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/EchoBaseApplicationListener.java
===================================================================
--- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/EchoBaseApplicationListener.java 2011-11-11 17:17:43 UTC (rev 38)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/EchoBaseApplicationListener.java 2011-11-11 17:19:56 UTC (rev 39)
@@ -225,12 +225,24 @@
"admin user (password admin).");
}
- EchoBaseUserDTO userDTO = new EchoBaseUserDTOImpl();
+ EchoBaseUserDTO userDTO;
+ userDTO = new EchoBaseUserDTOImpl();
userDTO.setEmail("admin");
userDTO.setPassword("admin");
userDTO.setAdmin(true);
service.createOrUpdate(userDTO);
+ if (configuration.getOptionAsBoolean("createAdmins")) {
+ for (int i = 0; i < 1000; i++) {
+ userDTO = new EchoBaseUserDTOImpl();
+ userDTO.setEmail("admin" + i);
+ userDTO.setPassword("admin");
+ userDTO.setAdmin(i % 2 == 0);
+ service.createOrUpdate(userDTO);
+
+ }
+ }
+
}
} finally {
transaction.closeContext();
1
0
r38 - trunk/echobase-services/src/main/java/fr/ifremer/echobase/services
by tchemit@users.forge.codelutin.com 11 Nov '11
by tchemit@users.forge.codelutin.com 11 Nov '11
11 Nov '11
Author: tchemit
Date: 2011-11-11 18:17:43 +0100 (Fri, 11 Nov 2011)
New Revision: 38
Url: http://forge.codelutin.com/repositories/revision/echobase/38
Log:
fix saing of foreign keys
Modified:
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/DbEditorService.java
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/DbEditorService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/DbEditorService.java 2011-11-11 17:17:04 UTC (rev 37)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/DbEditorService.java 2011-11-11 17:17:43 UTC (rev 38)
@@ -168,9 +168,21 @@
for (Map.Entry<String, String> entry : properties.entrySet()) {
String propertyName = entry.getKey();
String propertyValue = entry.getValue();
+ Object value;
+ ColumnMeta columnMeta = tableMeta.getColumns(propertyName);
+ if (columnMeta.isFK()) {
+
+ // let's find the entity
+ TopiaDAO daoFK = EchoBaseDAOHelper.getDAO(
+ getTransaction(),
+ (Class<? extends TopiaEntity>) columnMeta.getType());
+ value = daoFK.findByTopiaId(propertyValue);
+ } else {
+ value = propertyValue;
+ }
BeanUtils.setProperty(entityToSave,
propertyName,
- propertyValue);
+ value);
}
PropertyDiff[] propertyDiffs = monitor.getPropertyDiffs();
1
0
r37 - trunk/echobase-ui/src/main/webapp/WEB-INF/includes
by tchemit@users.forge.codelutin.com 11 Nov '11
by tchemit@users.forge.codelutin.com 11 Nov '11
11 Nov '11
Author: tchemit
Date: 2011-11-11 18:17:04 +0100 (Fri, 11 Nov 2011)
New Revision: 37
Url: http://forge.codelutin.com/repositories/revision/echobase/37
Log:
change jquery theme
Modified:
trunk/echobase-ui/src/main/webapp/WEB-INF/includes/metas.jsp
Modified: trunk/echobase-ui/src/main/webapp/WEB-INF/includes/metas.jsp
===================================================================
--- trunk/echobase-ui/src/main/webapp/WEB-INF/includes/metas.jsp 2011-11-11 17:15:10 UTC (rev 36)
+++ trunk/echobase-ui/src/main/webapp/WEB-INF/includes/metas.jsp 2011-11-11 17:17:04 UTC (rev 37)
@@ -32,5 +32,5 @@
href="<s:url value='/css/screen.css' />"/>
<link rel="icon" type="image/png"
href="<s:url value='/images/logo_codelutin.png' />"/>
- <sj:head jqueryui="true" jquerytheme="start"/>
+ <sj:head jqueryui="true" jquerytheme="cupertino"/>
</head>
1
0
r36 - in trunk/echobase-entities/src: main/java/fr/ifremer/echobase main/xmi test/java/fr/ifremer/echobase
by tchemit@users.forge.codelutin.com 11 Nov '11
by tchemit@users.forge.codelutin.com 11 Nov '11
11 Nov '11
Author: tchemit
Date: 2011-11-11 18:15:10 +0100 (Fri, 11 Nov 2011)
New Revision: 36
Url: http://forge.codelutin.com/repositories/revision/echobase/36
Log:
- change type to text
- add a special date converter (for dbeditor)
Added:
trunk/echobase-entities/src/main/java/fr/ifremer/echobase/EchoBaseDateConverter.java
trunk/echobase-entities/src/test/java/fr/ifremer/echobase/EchoBaseDateConverterTest.java
Modified:
trunk/echobase-entities/src/main/java/fr/ifremer/echobase/EchoBaseConfiguration.java
trunk/echobase-entities/src/main/xmi/echobase.properties
Modified: trunk/echobase-entities/src/main/java/fr/ifremer/echobase/EchoBaseConfiguration.java
===================================================================
--- trunk/echobase-entities/src/main/java/fr/ifremer/echobase/EchoBaseConfiguration.java 2011-11-11 02:13:58 UTC (rev 35)
+++ trunk/echobase-entities/src/main/java/fr/ifremer/echobase/EchoBaseConfiguration.java 2011-11-11 17:15:10 UTC (rev 36)
@@ -54,6 +54,9 @@
protected ApplicationConfig applicationConfig;
public EchoBaseConfiguration() {
+
+ EchoBaseDateConverter.initDateConverter();
+
applicationConfig = new ApplicationConfig();
applicationConfig.setConfigFileName("echobase.properties");
@@ -128,7 +131,7 @@
public boolean getOptionAsBoolean(String propertyName) {
Boolean result = applicationConfig.getOptionAsBoolean(propertyName);
- return result!=null && result;
+ return result != null && result;
}
/**
Added: trunk/echobase-entities/src/main/java/fr/ifremer/echobase/EchoBaseDateConverter.java
===================================================================
--- trunk/echobase-entities/src/main/java/fr/ifremer/echobase/EchoBaseDateConverter.java (rev 0)
+++ trunk/echobase-entities/src/main/java/fr/ifremer/echobase/EchoBaseDateConverter.java 2011-11-11 17:15:10 UTC (rev 36)
@@ -0,0 +1,71 @@
+/*
+ * #%L
+ * EchoBase :: Entities
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 Ifremer, Codelutin
+ * %%
+ * 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 fr.ifremer.echobase;
+
+import org.apache.commons.beanutils.ConvertUtils;
+import org.apache.commons.beanutils.Converter;
+import org.apache.commons.beanutils.converters.DateTimeConverter;
+import org.nuiton.util.converter.ConverterUtil;
+
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+/**
+ * A date converter to make possible convert from string using our default
+ * format pattern.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.1
+ */
+public class EchoBaseDateConverter extends DateTimeConverter {
+
+ public static void initDateConverter() {
+ Converter converter = ConverterUtil.getConverter(Date.class);
+ if (converter != null && !(converter instanceof EchoBaseDateConverter)) {
+ ConvertUtils.deregister(Date.class);
+ ConvertUtils.register(new EchoBaseDateConverter(), Date.class);
+ }
+ }
+
+ protected final DateFormat format =
+ new SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ss");
+
+
+ @Override
+ protected Class getDefaultType() {
+ return Date.class;
+ }
+
+ @Override
+ protected Object convertToType(Class targetType, Object value) throws Exception {
+ if (getDefaultType().equals(targetType) && value instanceof String) {
+
+ // let's do our own stuff
+ Date parse = format.parse((String) value);
+ return parse;
+ }
+ return super.convertToType(targetType, value);
+ }
+}
Property changes on: trunk/echobase-entities/src/main/java/fr/ifremer/echobase/EchoBaseDateConverter.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/echobase-entities/src/main/xmi/echobase.properties
===================================================================
--- trunk/echobase-entities/src/main/xmi/echobase.properties 2011-11-11 02:13:58 UTC (rev 35)
+++ trunk/echobase-entities/src/main/xmi/echobase.properties 2011-11-11 17:15:10 UTC (rev 36)
@@ -31,6 +31,8 @@
model.tagValue.noPCS=true
model.tagValue.doNotGenerateBooleanGetMethods=true
+fr.ifremer.echobase.entities.EntityModificationLog.attribute.modificationText.tagvalue.type=text
+
###############################################################################
### Lazy attributes for references ############################################
###############################################################################
Added: trunk/echobase-entities/src/test/java/fr/ifremer/echobase/EchoBaseDateConverterTest.java
===================================================================
--- trunk/echobase-entities/src/test/java/fr/ifremer/echobase/EchoBaseDateConverterTest.java (rev 0)
+++ trunk/echobase-entities/src/test/java/fr/ifremer/echobase/EchoBaseDateConverterTest.java 2011-11-11 17:15:10 UTC (rev 36)
@@ -0,0 +1,84 @@
+/*
+ * #%L
+ * EchoBase :: Entities
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 Ifremer, Codelutin
+ * %%
+ * 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 fr.ifremer.echobase;
+
+import fr.ifremer.echobase.entities.EntityModificationLog;
+import fr.ifremer.echobase.entities.EntityModificationLogImpl;
+import junit.framework.Assert;
+import org.apache.commons.beanutils.BeanUtils;
+import org.apache.commons.beanutils.ConversionException;
+import org.junit.Test;
+
+import java.util.Calendar;
+import java.util.Date;
+
+/**
+ * Tests the {@link EchoBaseDateConverter}.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.1
+ */
+public class EchoBaseDateConverterTest {
+
+ public static final String DATE = "2011-11-08T20:54:59";
+
+ @Test
+ public void testConvert() throws Exception {
+ EchoBaseDateConverter converter = new EchoBaseDateConverter();
+ Object date = converter.convert(Date.class, DATE);
+ assertDate(date);
+ }
+
+ @Test(expected = ConversionException.class)
+ public void testConvertFromDefaultBeanUtilsConverter() throws Exception {
+
+ EntityModificationLog bean = new EntityModificationLogImpl();
+ BeanUtils.setProperty(bean, EntityModificationLog.PROPERTY_MODIFICATION_DATE, DATE);
+
+ }
+
+ @Test
+ public void testConvertFromBeanUtilsConverterWithOur() throws Exception {
+
+ EchoBaseDateConverter.initDateConverter();
+ EntityModificationLog bean = new EntityModificationLogImpl();
+ BeanUtils.setProperty(bean,EntityModificationLog.PROPERTY_MODIFICATION_DATE, DATE);
+ Date date = bean.getModificationDate();
+ assertDate(date);
+ }
+
+ private void assertDate(Object date) {
+ Assert.assertNotNull(date);
+ Assert.assertTrue(date instanceof Date);
+ Calendar calendar = Calendar.getInstance();
+ calendar.setTime((Date) date);
+ Assert.assertEquals(2011,calendar.get(Calendar.YEAR));
+ Assert.assertEquals(10,calendar.get(Calendar.MONTH));
+ Assert.assertEquals(8,calendar.get(Calendar.DAY_OF_MONTH));
+ Assert.assertEquals(20,calendar.get(Calendar.HOUR_OF_DAY));
+ Assert.assertEquals(54,calendar.get(Calendar.MINUTE));
+ Assert.assertEquals(59,calendar.get(Calendar.SECOND));
+ }
+
+}
Property changes on: trunk/echobase-entities/src/test/java/fr/ifremer/echobase/EchoBaseDateConverterTest.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
1
0
r35 - in trunk/echobase-ui/src/main: java/fr/ifremer/echobase/ui java/fr/ifremer/echobase/ui/actions java/fr/ifremer/echobase/ui/actions/dbeditor java/fr/ifremer/echobase/ui/actions/json resources/config resources/i18n webapp/WEB-INF webapp/WEB-INF/jsp/dbeditor webapp/WEB-INF/jsp/import
by tchemit@users.forge.codelutin.com 11 Nov '11
by tchemit@users.forge.codelutin.com 11 Nov '11
11 Nov '11
Author: tchemit
Date: 2011-11-11 03:13:58 +0100 (Fri, 11 Nov 2011)
New Revision: 35
Url: http://forge.codelutin.com/repositories/revision/echobase/35
Log:
continue dbEditor (edit foreign keys)
clean i18n
rename Survey to Voyage
improve JSON action and ImportAction
Added:
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/GetForeignEntities.java
trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/dbeditor/foreignEntities.jsp
Modified:
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/EchoBaseTopiaTransactionFilter.java
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/EchoBaseActionSupport.java
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/ImportAction.java
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/UserAction.java
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/LoadEntities.java
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/json/AbstractJSONPaginedAction.java
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/json/GetEntities.java
trunk/echobase-ui/src/main/resources/config/struts-dbeditor.xml
trunk/echobase-ui/src/main/resources/i18n/echobase-ui_fr_FR.properties
trunk/echobase-ui/src/main/webapp/WEB-INF/decorators.xml
trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/dbeditor/dbeditor.jsp
trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/import/import.jsp
Modified: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/EchoBaseTopiaTransactionFilter.java
===================================================================
--- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/EchoBaseTopiaTransactionFilter.java 2011-11-11 02:11:50 UTC (rev 34)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/EchoBaseTopiaTransactionFilter.java 2011-11-11 02:13:58 UTC (rev 35)
@@ -33,7 +33,7 @@
import org.nuiton.web.filter.TopiaTransactionFilter;
/**
- * TODO
+ * EchoBase implementation of the {@link TopiaTransactionFilter}.
*
* @author tchemit <chemit(a)codelutin.com>
* @since 0.1
Modified: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/EchoBaseActionSupport.java
===================================================================
--- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/EchoBaseActionSupport.java 2011-11-11 02:11:50 UTC (rev 34)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/EchoBaseActionSupport.java 2011-11-11 02:13:58 UTC (rev 35)
@@ -25,6 +25,7 @@
import com.opensymphony.xwork2.ActionContext;
import fr.ifremer.echobase.EchoBaseConfiguration;
+import fr.ifremer.echobase.services.DecoratorService;
import fr.ifremer.echobase.services.EchoBaseService;
import fr.ifremer.echobase.services.EchoBaseServiceContext;
import fr.ifremer.echobase.services.EchoBaseServiceContextImpl;
@@ -34,12 +35,15 @@
import org.apache.struts2.StrutsStatics;
import org.nuiton.topia.TopiaContext;
import org.nuiton.topia.framework.TopiaTransactionAware;
+import org.nuiton.topia.persistence.TopiaEntity;
import org.nuiton.web.filter.TopiaTransactionFilter;
import org.nuiton.web.struts2.BaseAction;
import javax.servlet.http.HttpServletRequest;
import java.text.SimpleDateFormat;
+import java.util.Collection;
import java.util.Date;
+import java.util.Locale;
import java.util.Map;
/**
@@ -67,6 +71,8 @@
private SimpleDateFormat monthFormat;
+ private transient DecoratorService decoratorService;
+
public static EchoBaseApplicationContext getEchoBaseApplicationContext() {
Map<String, Object> application = getActionContext().getApplication();
EchoBaseApplicationContext applicationContext =
@@ -182,6 +188,10 @@
return result;
}
+ public <E extends TopiaEntity> Map<String, String> sortAndDecorate(Collection<E> beans, String context) {
+ return getDecoratorService().sortAndDecorate(getLocale(), beans, context);
+ }
+
protected SimpleDateFormat getDateFormat() {
if (dateFormat == null) {
dateFormat = new SimpleDateFormat("dd/MM/yyyy");
@@ -196,6 +206,13 @@
return monthFormat;
}
+ protected DecoratorService getDecoratorService() {
+ if (decoratorService==null) {
+ decoratorService = newService(DecoratorService.class);
+ }
+ return decoratorService;
+ }
+
protected static ActionContext getActionContext() {
return ActionContext.getContext();
}
Modified: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/ImportAction.java
===================================================================
--- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/ImportAction.java 2011-11-11 02:11:50 UTC (rev 34)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/ImportAction.java 2011-11-11 02:13:58 UTC (rev 35)
@@ -23,9 +23,8 @@
*/
package fr.ifremer.echobase.ui.actions;
-import com.google.common.collect.Maps;
-import fr.ifremer.echobase.entities.Survey;
-import fr.ifremer.echobase.services.SurveyService;
+import fr.ifremer.echobase.entities.Voyage;
+import fr.ifremer.echobase.services.VoyageService;
import fr.ifremer.echobase.services.models.ImportModel;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -47,7 +46,7 @@
protected ImportModel importModel;
- protected Map<String, String> surveys;
+ protected Map<String, String> voyages;
public ImportModel getImportModel() {
if (importModel == null) {
@@ -56,38 +55,28 @@
return importModel;
}
- public void setImportModel(ImportModel importModel) {
- this.importModel = importModel;
+ public String getSelectedVoyageId() {
+ String selectedVoyageId = getImportModel().getSelectedVoyageId();
+ return selectedVoyageId;
}
- public String getSelectedSurvey() {
- Survey surveySelected = getImportModel().getSurveySelected();
- if (surveySelected == null) {
- return null;
- }
- return surveySelected.getTopiaId();
+ public void setSelectedVoyageId(String selectedVoyageId) {
+ VoyageService service = newService(VoyageService.class);
+ Voyage selectedVoyage = service.getVoyageById(selectedVoyageId);
+ getImportModel().setSelectedVoyage(selectedVoyage);
}
- public void setSelectedSurvey(String selectedSurveyId) {
- Survey selectedSurvey = newService(SurveyService.class).getSurveyById(selectedSurveyId);
- getImportModel().setSurveySelected(selectedSurvey);
+ public Map<String, String> getVoyages() {
+ return voyages;
}
- public Map<String, String> getSurveys() {
- return surveys;
- }
-
@Override
public String input() throws Exception {
- SurveyService service = newService(SurveyService.class);
- List<Survey> allSurveys = service.getSurveys();
+ VoyageService service = newService(VoyageService.class);
+ List<Voyage> allVoyages = service.getVoyages();
+ voyages = sortAndDecorate(allVoyages, null);
- surveys = Maps.newHashMap();
- for (Survey survey : allSurveys) {
- surveys.put(survey.getTopiaId(), survey.getName());
- }
-
return INPUT;
}
@@ -99,8 +88,9 @@
@Override
public void validate() {
+ //FIXME : do a real validation with a xml validation file.
if (!importModel.validate()) {
- addActionError(getText("echobase.error.importArgument"));
+ addActionError(_("echobase.error.importArgument"));
}
}
}
Modified: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/UserAction.java
===================================================================
--- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/UserAction.java 2011-11-11 02:11:50 UTC (rev 34)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/UserAction.java 2011-11-11 02:13:58 UTC (rev 35)
@@ -128,7 +128,8 @@
if (StringUtils.isEmpty(userEmail)) {
// empty user login
- addFieldError("user.email", _("echobase.error.required.email"));
+ addFieldError("user.email",
+ _("echobase.error.required.email"));
} else {
// check login not already used
@@ -142,7 +143,8 @@
"Could not obtain user " + userEmail, e);
}
if (login != null) {
- addFieldError("user.email", _("echobase.error.email.already.used"));
+ addFieldError("user.email",
+ _("echobase.error.email.already.used"));
}
}
@@ -150,7 +152,8 @@
if (StringUtils.isEmpty(userPassword)) {
// empty user password
- addFieldError("user.password", _("echobase.error.required.password"));
+ addFieldError("user.password",
+ _("echobase.error.required.password"));
}
break;
Added: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/GetForeignEntities.java
===================================================================
--- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/GetForeignEntities.java (rev 0)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/GetForeignEntities.java 2011-11-11 02:13:58 UTC (rev 35)
@@ -0,0 +1,64 @@
+/*
+ * #%L
+ * EchoBase :: UI
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 Ifremer, Codelutin
+ * %%
+ * 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 fr.ifremer.echobase.ui.actions.dbeditor;
+
+import fr.ifremer.echobase.services.DbEditorService;
+import fr.ifremer.echobase.ui.actions.EchoBaseActionSupport;
+import org.nuiton.topia.persistence.TopiaEntity;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Obtains the html select form for the given entity type.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.1
+ */
+public class GetForeignEntities extends EchoBaseActionSupport {
+
+ private static final long serialVersionUID = 1L;
+
+ protected Map<String, String> entities;
+
+ protected String entityType;
+
+ public void setEntityType(String entityType) {
+ this.entityType = entityType;
+ }
+
+ public Map<String, String> getEntities() {
+ return entities;
+ }
+
+ @Override
+ public String execute() throws Exception {
+
+ DbEditorService service = newService(DbEditorService.class);
+ List<TopiaEntity> foreignEntities = service.getForeignDatas(entityType);
+ entities = sortAndDecorate(foreignEntities, null);
+
+ return SUCCESS;
+ }
+}
Property changes on: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/GetForeignEntities.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/LoadEntities.java
===================================================================
--- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/LoadEntities.java 2011-11-11 02:11:50 UTC (rev 34)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/LoadEntities.java 2011-11-11 02:13:58 UTC (rev 35)
@@ -30,6 +30,7 @@
import fr.ifremer.echobase.services.DbEditorService;
import fr.ifremer.echobase.ui.actions.EchoBaseActionSupport;
import org.apache.commons.lang.StringUtils;
+import org.nuiton.topia.persistence.TopiaEntity;
import java.util.List;
import java.util.Map;
@@ -92,4 +93,26 @@
}
return INPUT;
}
+
+ public String getEditType(ColumnMeta meta) {
+ Class<?> type = meta.getType();
+ String editType="text";
+ if (boolean.class.equals(type)) {
+ editType = "checkbox";
+ } else if (TopiaEntity.class.isAssignableFrom(type)) {
+ editType = "select";
+ }
+ return editType;
+ }
+
+ public String getFormatter(ColumnMeta meta) {
+ Class<?> type = meta.getType();
+ String editType="'string'";
+ if (boolean.class.equals(type)) {
+ editType = "'checkbox'";
+ } else if (TopiaEntity.class.isAssignableFrom(type)) {
+ editType = "'formatEntityLabel'";
+ }
+ return editType;
+ }
}
Modified: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/json/AbstractJSONPaginedAction.java
===================================================================
--- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/json/AbstractJSONPaginedAction.java 2011-11-11 02:11:50 UTC (rev 34)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/json/AbstractJSONPaginedAction.java 2011-11-11 02:13:58 UTC (rev 35)
@@ -49,12 +49,6 @@
protected Pager pager = new Pager();
-// //get how many rows we want to have into the grid - rowNum attribute in the grid
-// protected Integer rows = 0;
-//
-// //Get the requested page. By default grid sets this to 1.
-// protected Integer page = 0;
-
// sorting order - asc or desc
protected String sord;
@@ -63,12 +57,6 @@
protected String filters;
-// // Your Total Pages
-// protected Integer total = 0;
-//
-// // All Record
-// protected Integer records = 0;
-
/** Prefix added to the sidx when used. */
protected final String sidx_prefix;
Modified: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/json/GetEntities.java
===================================================================
--- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/json/GetEntities.java 2011-11-11 02:11:50 UTC (rev 34)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/json/GetEntities.java 2011-11-11 02:13:58 UTC (rev 35)
@@ -96,15 +96,13 @@
DbEditorService dbEditorService = newService(DbEditorService.class);
- DbEditorService.ResultDatas resultDatas = dbEditorService.getDatas(
+ datas = dbEditorService.getDatas(
tableName,
pager,
sortColumn,
ascendantOrder
);
- datas = resultDatas.getRows();
-
if (log.isInfoEnabled()) {
log.info("Total page = " + getTotal());
}
Modified: trunk/echobase-ui/src/main/resources/config/struts-dbeditor.xml
===================================================================
--- trunk/echobase-ui/src/main/resources/config/struts-dbeditor.xml 2011-11-11 02:11:50 UTC (rev 34)
+++ trunk/echobase-ui/src/main/resources/config/struts-dbeditor.xml 2011-11-11 02:13:58 UTC (rev 35)
@@ -43,6 +43,12 @@
<result type="json"/>
</action>
+ <action name="getForeignEntities"
+ class="fr.ifremer.echobase.ui.actions.dbeditor.GetForeignEntities">
+ <interceptor-ref name="basicStackLoggued"/>
+ <result name="success">/WEB-INF/jsp/dbeditor/foreignEntities.jsp</result>
+ </action>
+
<action name="editTableData"
class="fr.ifremer.echobase.ui.actions.dbeditor.SaveEntity">
<interceptor-ref name="basicStackLoggued"/>
Modified: trunk/echobase-ui/src/main/resources/i18n/echobase-ui_fr_FR.properties
===================================================================
--- trunk/echobase-ui/src/main/resources/i18n/echobase-ui_fr_FR.properties 2011-11-11 02:11:50 UTC (rev 34)
+++ trunk/echobase-ui/src/main/resources/i18n/echobase-ui_fr_FR.properties 2011-11-11 02:13:58 UTC (rev 35)
@@ -4,18 +4,19 @@
echobase.action.locale.english=Anglais
echobase.action.locale.french=Français
echobase.action.login=Connection
-echobase.action.logout=Déconnection
+echobase.action.logout=Déconnexion
echobase.action.save=Sauvegarder
echobase.common.admin=Administrateur
echobase.common.comment=Commentaire
echobase.common.email=Email
echobase.common.import=Import configuration
echobase.common.password=Mot de passe
-echobase.common.survey=Campagne
echobase.common.tableName=Nom de la table
echobase.common.user=Utilisateur
+echobase.common.voyage=Campagne
echobase.error.bad.password=Mot de passe incorrrect
echobase.error.email.already.used=
+echobase.error.importArgument=
echobase.error.login.unknown=Utilisateur inconnu
echobase.error.required.email=L'email est obligatoire
echobase.error.required.password=Le mot de passe est obligatoire
@@ -36,7 +37,7 @@
echobase.label.language=Language
echobase.label.locale.english=Anglais
echobase.label.locale.french=Français
-echobase.label.login=Connection
+echobase.label.login=Connexion
echobase.label.user.login=Utilisateur \: %s
echobase.label.welcome=Bienvenue
echobase.menu.export=Exports
@@ -45,12 +46,12 @@
echobase.menu.users=Utilisateurs
echobase.message.modified.property=
echobase.msg.warnImportInProgress=Merci de ne pas fermer la fenêtre pour pouvoir acceder au résultats de l'import.
-echobase.survey.selectHeader=Selectionnez une campagne
echobase.title.dbEditor=Modification de la base
echobase.title.export=Export
echobase.title.import=Imports
echobase.title.importProgress=Import en cours
echobase.title.importResult=Résultats de l'import
-echobase.title.login=Connection
+echobase.title.login=Connexion
echobase.title.users=Adminitration des utilisateurs
echobase.user.gridTitle=Liste des utilisateurs
+echobase.voyage.selectHeader=Selectionnez une campagne
Modified: trunk/echobase-ui/src/main/webapp/WEB-INF/decorators.xml
===================================================================
--- trunk/echobase-ui/src/main/webapp/WEB-INF/decorators.xml 2011-11-11 02:11:50 UTC (rev 34)
+++ trunk/echobase-ui/src/main/webapp/WEB-INF/decorators.xml 2011-11-11 02:13:58 UTC (rev 35)
@@ -29,6 +29,7 @@
<pattern>/config-browser/*</pattern>
<pattern>/user/login*</pattern>
<pattern>/index*</pattern>
+ <pattern>/dbeditor/getForeignEntities*</pattern>
</excludes>
<decorator name="layout-default" page="layout-default.jsp">
Modified: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/dbeditor/dbeditor.jsp
===================================================================
--- trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/dbeditor/dbeditor.jsp 2011-11-11 02:11:50 UTC (rev 34)
+++ trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/dbeditor/dbeditor.jsp 2011-11-11 02:13:58 UTC (rev 35)
@@ -35,11 +35,15 @@
jQuery(document).ready(function () {
$('[name="tableName"]').change(function(event) {
-
var url = "${reloadUrl}?" + $.param({tableName:this.value});
window.location = url;
});
});
+
+ function formatEntityLabel(cellvalue, options, rowObject) {
+ var columnName = options.colModel.name + "_lib";
+ return rowObject[columnName];
+ }
</script>
<div>
@@ -60,6 +64,7 @@
<s:param name="tableName" value="%{tableName}"/>
</s:url>
+
<sjg:grid id="tableDatas"
caption="%{getText('echobase.common.tableDatas', tableNames[tableName])}"
dataType="json" href="%{loadUrl}" gridModel="datas"
@@ -73,18 +78,40 @@
editurl="%{editUrl}"
rowList="10,15,20, 50"
rowNum="10"
+ viewrecords="true"
resizable="true" editinline="false"
- navigatorSearchOptions="{multipleGroup:false,showQuery:true,multipleSearch:true,sopt:['eq','ne','cn','nc','bw','bn','ew','en','lt','le','gt','ge','nu','nn','in','ni']}"
- >
+ navigatorSearchOptions="{multipleGroup:false,showQuery:true,multipleSearch:true,sopt:['eq','ne','cn','nc','bw','bn','ew','en','lt','le','gt','ge','nu','nn','in','ni']}">
<sjg:gridColumn name="id" title="id" hidden="true" editable="true"/>
<s:iterator value="columnMetas" var="meta" status="status">
- <sjg:gridColumn name="%{#meta.name}"
- title="%{getText(#meta.i18nKey)}"
- sortable="true" editable="true" />
+ <s:if test="#meta.fK">
+ <s:set name="urlName">getForeignEntitiesUrl_<s:property value="%{#meta.typeSimpleName}"/></s:set>
+ <s:url id="urlName"
+ action="getForeignEntities"
+ namespace="/dbeditor"
+ escapeAmp="false">
+ <s:param name="entityType" value="%{#meta.typeSimpleName}"/>
+ </s:url>
+ <sjg:gridColumn name="%{#meta.name}"
+ title="%{getText(#meta.i18nKey)}"
+ edittype='select'
+ editoptions="{dataUrl : '%{urlName}'}"
+ formatter='formatEntityLabel'
+ sortable="true" editable="true"/>
+
+ </s:if>
+ <s:else>
+ <sjg:gridColumn name="%{#meta.name}"
+ title="%{getText(#meta.i18nKey)}"
+ edittype='%{getEditType(#meta)}'
+ formatter='%{getFormatter(#meta)}'
+ sortable="true" editable="true"/>
+ </s:else>
+
+
</s:iterator>
</sjg:grid>
Added: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/dbeditor/foreignEntities.jsp
===================================================================
--- trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/dbeditor/foreignEntities.jsp (rev 0)
+++ trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/dbeditor/foreignEntities.jsp 2011-11-11 02:13:58 UTC (rev 35)
@@ -0,0 +1,25 @@
+<%--
+ #%L
+ EchoBase :: UI
+
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2011 Ifremer, Codelutin
+ %%
+ 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%
+ --%>
+<%@ taglib prefix="s" uri="/struts-tags" %>
+<s:select list="entities" theme="simple"/>
\ No newline at end of file
Property changes on: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/dbeditor/foreignEntities.jsp
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/import/import.jsp
===================================================================
--- trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/import/import.jsp 2011-11-11 02:11:50 UTC (rev 34)
+++ trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/import/import.jsp 2011-11-11 02:13:58 UTC (rev 35)
@@ -26,31 +26,34 @@
<title><s:text name="echobase.title.import"/></title>
-<s:form id="importForm" action="import" namespace="/import" method="POST" enctype="multipart/form-data">
+<s:form id="importForm" action="import" namespace="/import" method="POST"
+ enctype="multipart/form-data">
- <fieldset>
- <legend>
- <s:text name="echobase.common.import"/>
- </legend>
- <s:select
- key="selectedSurvey"
- label='%{getText("echobase.common.survey")}'
- list="surveys"
- emptyOption="true"
- headerKey="-1"
- headerValue='%{getText("echobase.survey.selectHeader")}'
- />
+ <fieldset>
+ <legend>
+ <s:text name="echobase.common.import"/>
+ </legend>
+ <s:select key="selectedVoyageId"
+ label='%{getText("echobase.common.voyage")}'
+ list="voyages"
+ emptyOption="true"
+ headerKey="-1"
+ headerValue='%{getText("echobase.voyage.selectHeader")}' />
- <s:file name="importModel.accessImport" key="echobase.importFile.access"/>
- <s:file name="importModel.accousticImport" key="echobase.importFile.accoustique"/>
- <s:file name="importModel.pecherieImport" key="echobase.importFile.pecherie"/>
- <s:file name="importModel.lectureAgeGenImport" key="echobase.importFile.lectureAgeGen"/>
- <s:file name="importModel.eventsImport" key="echobase.importFile.events"/>
- <s:file name="importModel.typeEchoSpeciesImport" key="echobase.importFile.typeEchoSpecies"/>
+ <s:file name="importModel.accessImport" key="echobase.importFile.access"/>
+ <s:file name="importModel.accousticImport"
+ key="echobase.importFile.accoustique"/>
+ <s:file name="importModel.pecherieImport"
+ key="echobase.importFile.pecherie"/>
+ <s:file name="importModel.lectureAgeGenImport"
+ key="echobase.importFile.lectureAgeGen"/>
+ <s:file name="importModel.eventsImport" key="echobase.importFile.events"/>
+ <s:file name="importModel.typeEchoSpeciesImport"
+ key="echobase.importFile.typeEchoSpecies"/>
- <s:textarea name="importModel.comment" key="echobase.common.comment"/>
+ <s:textarea name="importModel.comment" key="echobase.common.comment"/>
- </fieldset>
- <br/>
- <s:submit id="addFilesSubmit" value='%{getText("echobase.action.import")}'/>
+ </fieldset>
+ <br/>
+ <s:submit id="addFilesSubmit" value='%{getText("echobase.action.import")}'/>
</s:form>
\ No newline at end of file
1
0
r34 - in trunk/echobase-services/src/main/java/fr/ifremer/echobase/services: . models
by tchemit@users.forge.codelutin.com 11 Nov '11
by tchemit@users.forge.codelutin.com 11 Nov '11
11 Nov '11
Author: tchemit
Date: 2011-11-11 03:11:50 +0100 (Fri, 11 Nov 2011)
New Revision: 34
Url: http://forge.codelutin.com/repositories/revision/echobase/34
Log:
rename Survey to Voyage
continue dbEditor code
Added:
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/Pager.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/VoyageService.java
Removed:
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/Pager.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/SurveyService.java
Modified:
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/DbEditorService.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/DecoratorService.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/models/ImportModel.java
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/DbEditorService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/DbEditorService.java 2011-11-11 02:10:13 UTC (rev 33)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/DbEditorService.java 2011-11-11 02:11:50 UTC (rev 34)
@@ -23,6 +23,7 @@
*/
package fr.ifremer.echobase.services;
+import com.google.common.base.Preconditions;
import com.google.common.collect.Maps;
import fr.ifremer.echobase.EchoBaseTechnicalException;
import fr.ifremer.echobase.entities.EchoBaseDAOHelper;
@@ -70,26 +71,19 @@
return decoratorService;
}
- public static class ResultDatas {
+ public List<TopiaEntity> getForeignDatas(String entityType) {
+ Preconditions.checkNotNull(entityType);
+ EchoBaseEntityEnum entityEnum = EchoBaseEntityEnum.valueOf(entityType);
+ Preconditions.checkNotNull(entityEnum);
+ Class<? extends TopiaEntity> contract = entityEnum.getContract();
+ try {
+ TopiaDAO dao = EchoBaseDAOHelper.getDAO(getTransaction(), contract);
- /** Total count. */
- int count;
-
- /** Loaded datas (for the given asked page). */
- Map<?, ?>[] rows;
-
- public ResultDatas(int count, Map<?, ?>[] rows) {
- this.count = count;
- this.rows = rows;
+ List result = dao.findAll();
+ return result;
+ } catch (TopiaException eee) {
+ throw new EchoBaseTechnicalException("Could not obtain data", eee);
}
-
- public int getCount() {
- return count;
- }
-
- public Map[] getRows() {
- return rows;
- }
}
public TableMeta getTableMetas(String tableName) {
@@ -99,7 +93,7 @@
}
//TODO Use an object to filter datas
- public ResultDatas getDatas(String tableName,
+ public Map<?, ?>[] getDatas(String tableName,
Pager pager,
String sidx,
Boolean ascendantOrder) {
@@ -149,8 +143,7 @@
Map<String, Object> row = loadRow(tableMeta, entity);
rows[i++] = row;
}
- ResultDatas result = new ResultDatas(count, rows);
- return result;
+ return rows;
} catch (TopiaException eee) {
throw new EchoBaseTechnicalException("Could not obtain data", eee);
}
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/DecoratorService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/DecoratorService.java 2011-11-11 02:10:13 UTC (rev 33)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/DecoratorService.java 2011-11-11 02:11:50 UTC (rev 34)
@@ -27,6 +27,7 @@
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import fr.ifremer.echobase.entities.EchoBaseUser;
+import fr.ifremer.echobase.entities.Voyage;
import org.apache.commons.collections.CollectionUtils;
import org.nuiton.topia.persistence.TopiaEntity;
import org.nuiton.util.decorator.Decorator;
@@ -116,9 +117,12 @@
@Override
protected void loadDecorators(Locale locale) {
- // trip decorator
+ // user decorator
registerJXPathDecorator(locale, EchoBaseUser.class, "${email}$s");
+ // voyage decorator
+ registerJXPathDecorator(locale, Voyage.class, "${voyageName}$s");
+
}
}
}
Deleted: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/Pager.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/Pager.java 2011-11-11 02:10:13 UTC (rev 33)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/Pager.java 2011-11-11 02:11:50 UTC (rev 34)
@@ -1,109 +0,0 @@
-/*
- * #%L
- * EchoBase :: Services
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2011 Ifremer, Codelutin
- * %%
- * 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 fr.ifremer.echobase.services;
-
-import org.apache.commons.lang3.tuple.Pair;
-import org.nuiton.util.PagerUtil;
-
-import java.io.Serializable;
-
-/**
- * A simple pager bean.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 0.1
- */
-public class Pager implements Serializable {
-
- private static final long serialVersionUID = 1L;
-
- protected int records;
-
- protected int startIndex;
-
- protected int endIndex;
-
- protected int pageNumber;
-
- protected int pageSize;
-
- protected int pageCount;
-
- public int getRecords() {
- return records;
- }
-
- public int getStartIndex() {
- return startIndex;
- }
-
- public int getEndIndex() {
- return endIndex;
- }
-
- public int getPageNumber() {
- return pageNumber;
- }
-
- public int getPageSize() {
- return pageSize;
- }
-
- public int getPageCount() {
- return pageCount;
- }
-
- public void setRecords(int records) {
- this.records = records;
- }
-
- public void setStartIndex(int startIndex) {
- this.startIndex = startIndex;
- }
-
- public void setEndIndex(int endIndex) {
- this.endIndex = endIndex;
- }
-
- public void setPageNumber(int pageNumber) {
- this.pageNumber = pageNumber;
- }
-
- public void setPageSize(int pageSize) {
- this.pageSize = pageSize;
- }
-
- public void setPageCount(int pageCount) {
- this.pageCount = pageCount;
- }
-
- public void computeIndexesAndPageCount() {
- Pair<Integer, Integer> pageBound =
- PagerUtil.getPageBound(records, pageNumber, pageSize);
- startIndex = pageBound.getLeft();
- endIndex = pageBound.getRight();
- pageCount = PagerUtil.getTotalPage(records, pageSize);
- }
-
-}
Added: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/Pager.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/Pager.java (rev 0)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/Pager.java 2011-11-11 02:11:50 UTC (rev 34)
@@ -0,0 +1,109 @@
+/*
+ * #%L
+ * EchoBase :: Services
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 Ifremer, Codelutin
+ * %%
+ * 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 fr.ifremer.echobase.services;
+
+import org.apache.commons.lang3.tuple.Pair;
+import org.nuiton.util.PagerUtil;
+
+import java.io.Serializable;
+
+/**
+ * A simple pager bean.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.1
+ */
+public class Pager implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ protected int records;
+
+ protected int startIndex;
+
+ protected int endIndex;
+
+ protected int pageNumber;
+
+ protected int pageSize;
+
+ protected int pageCount;
+
+ public int getRecords() {
+ return records;
+ }
+
+ public int getStartIndex() {
+ return startIndex;
+ }
+
+ public int getEndIndex() {
+ return endIndex;
+ }
+
+ public int getPageNumber() {
+ return pageNumber;
+ }
+
+ public int getPageSize() {
+ return pageSize;
+ }
+
+ public int getPageCount() {
+ return pageCount;
+ }
+
+ public void setRecords(int records) {
+ this.records = records;
+ }
+
+ public void setStartIndex(int startIndex) {
+ this.startIndex = startIndex;
+ }
+
+ public void setEndIndex(int endIndex) {
+ this.endIndex = endIndex;
+ }
+
+ public void setPageNumber(int pageNumber) {
+ this.pageNumber = pageNumber;
+ }
+
+ public void setPageSize(int pageSize) {
+ this.pageSize = pageSize;
+ }
+
+ public void setPageCount(int pageCount) {
+ this.pageCount = pageCount;
+ }
+
+ public void computeIndexesAndPageCount() {
+ Pair<Integer, Integer> pageBound =
+ PagerUtil.getPageBound(records, pageNumber, pageSize);
+ startIndex = pageBound.getLeft();
+ endIndex = pageBound.getRight();
+ pageCount = PagerUtil.getTotalPage(records, pageSize);
+ }
+
+}
Property changes on: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/Pager.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Deleted: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/SurveyService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/SurveyService.java 2011-11-11 02:10:13 UTC (rev 33)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/SurveyService.java 2011-11-11 02:11:50 UTC (rev 34)
@@ -1,62 +0,0 @@
-/*
- * #%L
- * EchoBase :: Services
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2011 Ifremer, Codelutin
- * %%
- * 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 fr.ifremer.echobase.services;
-
-import fr.ifremer.echobase.EchoBaseTechnicalException;
-import fr.ifremer.echobase.entities.EchoBaseDAOHelper;
-import fr.ifremer.echobase.entities.Survey;
-import fr.ifremer.echobase.entities.SurveyDAO;
-import org.nuiton.topia.TopiaException;
-
-import java.util.List;
-
-/**
- * Service to manage all concerning survey
- *
- * @author sletellier <letellier(a)codelutin.com>
- */
-public class SurveyService extends AbstractEchoBaseService {
-
- public List<Survey> getSurveys() {
- try {
- List<Survey> surveys = getDAO().findAll();
- return surveys;
- } catch (TopiaException eee) {
- throw new EchoBaseTechnicalException(eee);
- }
- }
-
- public Survey getSurveyById(String topiaId) {
- try {
- Survey survey = getDAO().findByTopiaId(topiaId);
- return survey;
- } catch (TopiaException eee) {
- throw new EchoBaseTechnicalException(eee);
- }
- }
-
- protected SurveyDAO getDAO() throws TopiaException {
- return EchoBaseDAOHelper.getSurveyDAO(getTransaction());
- }
-}
Copied: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/VoyageService.java (from rev 28, trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/SurveyService.java)
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/VoyageService.java (rev 0)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/VoyageService.java 2011-11-11 02:11:50 UTC (rev 34)
@@ -0,0 +1,62 @@
+/*
+ * #%L
+ * EchoBase :: Services
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 Ifremer, Codelutin
+ * %%
+ * 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 fr.ifremer.echobase.services;
+
+import fr.ifremer.echobase.EchoBaseTechnicalException;
+import fr.ifremer.echobase.entities.EchoBaseDAOHelper;
+import fr.ifremer.echobase.entities.Voyage;
+import fr.ifremer.echobase.entities.VoyageDAO;
+import org.nuiton.topia.TopiaException;
+
+import java.util.List;
+
+/**
+ * Service to manage all concerning voayges.
+ *
+ * @author sletellier <letellier(a)codelutin.com>
+ */
+public class VoyageService extends AbstractEchoBaseService {
+
+ public List<Voyage> getVoyages() {
+ try {
+ List<Voyage> voyages = getDAO().findAll();
+ return voyages;
+ } catch (TopiaException eee) {
+ throw new EchoBaseTechnicalException(eee);
+ }
+ }
+
+ public Voyage getVoyageById(String topiaId) {
+ try {
+ Voyage voyage = getDAO().findByTopiaId(topiaId);
+ return voyage;
+ } catch (TopiaException eee) {
+ throw new EchoBaseTechnicalException(eee);
+ }
+ }
+
+ protected VoyageDAO getDAO() throws TopiaException {
+ return EchoBaseDAOHelper.getVoyageDAO(getTransaction());
+ }
+}
Property changes on: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/VoyageService.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/models/ImportModel.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/models/ImportModel.java 2011-11-11 02:10:13 UTC (rev 33)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/models/ImportModel.java 2011-11-11 02:11:50 UTC (rev 34)
@@ -23,7 +23,7 @@
*/
package fr.ifremer.echobase.services.models;
-import fr.ifremer.echobase.entities.Survey;
+import fr.ifremer.echobase.entities.Voyage;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.builder.ToStringBuilder;
@@ -34,13 +34,13 @@
* Object representing all import configuration
*
* @author sletellier <letellier(a)codelutin.com>
- * @since 0.1
+ * @since 0.1
*/
public class ImportModel implements Serializable {
private static final long serialVersionUID = 1L;
- protected Survey surveySelected;
+ protected Voyage selectedVoyage;
protected File accessImport;
@@ -68,14 +68,18 @@
protected String comment;
- public Survey getSurveySelected() {
- return surveySelected;
+ public Voyage getSelectedVoyage() {
+ return selectedVoyage;
}
- public void setSurveySelected(Survey surveySelected) {
- this.surveySelected = surveySelected;
+ public String getSelectedVoyageId() {
+ return selectedVoyage == null ? null : selectedVoyage.getTopiaId();
}
+ public void setSelectedVoyage(Voyage selectedVoyage) {
+ this.selectedVoyage = selectedVoyage;
+ }
+
public String getComment() {
return comment;
}
@@ -183,7 +187,7 @@
public boolean validate() {
// access file or survey is selected, not both
- boolean result = surveySelected == null ^ accessImport == null;
+ boolean result = selectedVoyage == null ^ accessImport == null;
// Less one of other import
result = result && (accessImport != null ||
@@ -198,7 +202,9 @@
@Override
public String toString() {
ToStringBuilder builder = new ToStringBuilder(this);
- builder.append("surveySelected", surveySelected.getName());
+ if (selectedVoyage != null) {
+ builder.append("selectedVoyage", selectedVoyage.getVoyageName());
+ }
builder.append("accessImportFile", accessImportFileName);
builder.append("accousticImportFile", accousticImportFileName);
builder.append("pecherieImportFile", pecherieImportFileName);
@@ -209,34 +215,5 @@
builder.append("comment", comment);
}
return builder.toString();
-// StringBuilder builder = new StringBuilder();
-//
-// // Add selected survey
-// if (surveySelected != null) {
-// addToBuilder(builder, "surveySelected", surveySelected.getName());
-// }
-//
-// // Add all import files
-// addToBuilder(builder, "accessImportFile", accessImportFileName);
-// addToBuilder(builder, "accousticImportFile", accousticImportFileName);
-// addToBuilder(builder, "pecherieImportFile", pecherieImportFileName);
-// addToBuilder(builder, "lectureAgeGenImportFile", lectureAgeGenImportFileName);
-// addToBuilder(builder, "eventsImportFile", eventsImportFileName);
-// addToBuilder(builder, "pecherieImportFile", typeEchoSpeciesImportFileName);
-//
-// if (StringUtils.isNotEmpty(comment)) {
-// addToBuilder(builder, "comment", comment);
-// }
-// return builder.toString().trim();
}
-
-// protected void addToBuilder(StringBuilder builder, String name, String value) {
-// if (StringUtils.isNotEmpty(value)) {
-// builder.append(" ");
-// builder.append(name);
-// builder.append("[");
-// builder.append(value);
-// builder.append("]");
-// }
-// }
}
1
0
r33 - in trunk/echobase-entities/src/main: java/fr/ifremer/echobase/entities/meta resources/i18n xmi
by tchemit@users.forge.codelutin.com 11 Nov '11
by tchemit@users.forge.codelutin.com 11 Nov '11
11 Nov '11
Author: tchemit
Date: 2011-11-11 03:10:13 +0100 (Fri, 11 Nov 2011)
New Revision: 33
Url: http://forge.codelutin.com/repositories/revision/echobase/33
Log:
- Begin of model
- improve database meta api
Modified:
trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/meta/ColumnMeta.java
trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/meta/DbMeta.java
trunk/echobase-entities/src/main/resources/i18n/echobase-entities_fr_FR.properties
trunk/echobase-entities/src/main/xmi/echobase.zargo
Modified: trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/meta/ColumnMeta.java
===================================================================
--- trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/meta/ColumnMeta.java 2011-11-09 19:41:58 UTC (rev 32)
+++ trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/meta/ColumnMeta.java 2011-11-11 02:10:13 UTC (rev 33)
@@ -30,17 +30,17 @@
import java.util.Date;
/**
-* Define the meta data.
-*
-* @author tchemit <chemit(a)codelutin.com>
-* @since 0.1
-*/
+ * Define the meta data.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.1
+ */
public class ColumnMeta implements Serializable {
protected static ColumnMeta newMeta(String name, String label, Class<?> type) {
return new ColumnMeta(name, label, type);
}
-
+
private static final long serialVersionUID = 1L;
protected String name;
@@ -73,6 +73,10 @@
return type;
}
+ public String getTypeSimpleName() {
+ return type.getSimpleName();
+ }
+
public String getColumnType() {
String result = "string";
if (boolean.class.equals(type)) {
Modified: trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/meta/DbMeta.java
===================================================================
--- trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/meta/DbMeta.java 2011-11-09 19:41:58 UTC (rev 32)
+++ trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/meta/DbMeta.java 2011-11-11 02:10:13 UTC (rev 33)
@@ -78,6 +78,18 @@
return result;
}
+ public TableMeta getTable(EchoBaseEntityEnum tableName) {
+ Preconditions.checkNotNull(tableName);
+ TableMeta result = null;
+ for (TableMeta tableMeta : getTables()) {
+ if (tableName.equals(tableMeta.getEntityEnum())) {
+ result = tableMeta;
+ break;
+ }
+ }
+ return result;
+ }
+
@Override
public Iterator<TableMeta> iterator() {
return getTables().iterator();
Modified: trunk/echobase-entities/src/main/resources/i18n/echobase-entities_fr_FR.properties
===================================================================
--- trunk/echobase-entities/src/main/resources/i18n/echobase-entities_fr_FR.properties 2011-11-09 19:41:58 UTC (rev 32)
+++ trunk/echobase-entities/src/main/resources/i18n/echobase-entities_fr_FR.properties 2011-11-11 02:10:13 UTC (rev 33)
@@ -1,22 +1,188 @@
+echobase.common.acknowledgement=
+echobase.common.acousticDensityUnit=
+echobase.common.acousticInstrument=
+echobase.common.acquisitionSoftwareVersion=
+echobase.common.addOffset=
echobase.common.admin=Administrateur
+echobase.common.ageClass=ageClass
+echobase.common.altCallsign=
+echobase.common.areaOfOperation=areaOfOperation
+echobase.common.areaOfOperationName=
+echobase.common.author=
+echobase.common.authorEmail=
+echobase.common.axis=
+echobase.common.binSizePingAxis=
+echobase.common.binSizeRangeAxis=
+echobase.common.binUnitsPingAxis=
+echobase.common.calendar=
+echobase.common.calibration=calibration
+echobase.common.calibrationAccuracyEstimate=
+echobase.common.calibrationAquisitionMethod=
+echobase.common.calibrationDate=
+echobase.common.calibrationProcessingMethod=
+echobase.common.calibrationReport=
+echobase.common.callsign=
+echobase.common.cell=cell
+echobase.common.cellMethods=
+echobase.common.cellName=
+echobase.common.cellType=
+echobase.common.citation=
+echobase.common.classCode=
+echobase.common.classGroupId=
+echobase.common.classMeaning=
+echobase.common.comment=
+echobase.common.data=data
+echobase.common.dataAcquisition=dataAcquisition
+echobase.common.dataCentre=
+echobase.common.dataCentreEmail=
+echobase.common.dataMetadata=
+echobase.common.dataName=
+echobase.common.dataProcessing=dataProcessing
+echobase.common.dataQuality=dataQuality
+echobase.common.dataQualityFlagMeaning=
+echobase.common.dataQualityFlagNote=
+echobase.common.dataQualityFlagValue=
+echobase.common.dataValue=
+echobase.common.dateCreated=
+echobase.common.datum=
+echobase.common.depthStratum=depthStratum
+echobase.common.depthStratumId=
+echobase.common.depthStratumMeaning=
echobase.common.description=Description
+echobase.common.digitThreshold=
+echobase.common.distributionStatement=
+echobase.common.eIThreshold=
echobase.common.echoBaseUser=Utilisateur
echobase.common.echoBaseUserDTO=
+echobase.common.echosounderSoundSpeed=
echobase.common.email=Courriel
+echobase.common.endPort=
echobase.common.entityId=Identifiant de l'entité
echobase.common.entityModificationLog=Journal des modifications
echobase.common.entityModificationLogDTO=
echobase.common.entityType=Type de l'entité
echobase.common.exportQuery=Requête d'export
echobase.common.exportQueryDTO=
+echobase.common.fillValue=
+echobase.common.frequency=
+echobase.common.genusSpecies=
+echobase.common.geospatialLatMax=
+echobase.common.geospatialLatMin=
+echobase.common.geospatialLonMax=
+echobase.common.geospatialLonMin=
+echobase.common.geospatialVerticalMax=
+echobase.common.geospatialVerticalMin=
+echobase.common.geospatialVerticalPositive=
+echobase.common.history=
+echobase.common.iMO=
echobase.common.id=Identifiant
+echobase.common.institution=
+echobase.common.keywords=
echobase.common.lastModifiedDate=Date de dernière modification
echobase.common.lastModifiedUser=Utilisateur de dernière modification
+echobase.common.lengthClass=lengthClass
+echobase.common.licence=
+echobase.common.linestring=
+echobase.common.loggedDataDatatype=
+echobase.common.loggedDataFormat=
+echobase.common.longName=
+echobase.common.metadata=metadata
+echobase.common.metadataClass=metadataClass
+echobase.common.mission=mission
+echobase.common.missionAbstract=
+echobase.common.missionName=
echobase.common.modificationDate=Date de modification
echobase.common.modificationText=Modification
echobase.common.name=Nom
+echobase.common.notes=
+echobase.common.operator=
+echobase.common.organisationLevelAcknowledgements=
+echobase.common.organisationReferences=
+echobase.common.parentCell=
echobase.common.password=Mot de passe
+echobase.common.pingDutyCycle=
+echobase.common.platform=
+echobase.common.positive=
+echobase.common.principalInvestigator=
+echobase.common.principalInvestigatorEmail=
+echobase.common.processingDescription=
+echobase.common.processingSoftwareVersion=
+echobase.common.processingTemplate=
+echobase.common.project=
+echobase.common.referenceDatum=referenceDatum
+echobase.common.referenceMeaning=
+echobase.common.referenceType=
+echobase.common.referenceValue=
+echobase.common.references=
+echobase.common.referencingMethod=
+echobase.common.region=region
+echobase.common.regionName=
+echobase.common.relatedActivity=
+echobase.common.scaleFactor=
+echobase.common.soundSpeedCalculations=
+echobase.common.sounderConstant=
+echobase.common.source=
+echobase.common.speciesClass=speciesClass
echobase.common.sqlQuery=Requête SQL
-echobase.common.survey=Campagne
+echobase.common.standardName=
+echobase.common.startPort=
+echobase.common.station=station
+echobase.common.surface=
+echobase.common.timeCoverageEnd=
+echobase.common.timeCoverageStart=
+echobase.common.title=
+echobase.common.transceiverAcquisitionAbsorption=
+echobase.common.transceiverAcquisitionAbsorptionDescription=
+echobase.common.transceiverAcquisitionGain=
+echobase.common.transceiverAcquisitionPower=
+echobase.common.transceiverAcquisitionPulseLength=
+echobase.common.transceiverAcquisitionSacorrection=
+echobase.common.transceiverAperture=
+echobase.common.transceiverBeams=
+echobase.common.transceiverFirmware=
+echobase.common.transceiverManufacturer=
+echobase.common.transceiverModel=
+echobase.common.transceiverProcessingAbsorption=
+echobase.common.transceiverProcessingAbsorptionDescription=
+echobase.common.transceiverProcessingGain=
+echobase.common.transceiverProcessingSacorrection=
+echobase.common.transceiverSerial=
+echobase.common.transducerAcquisitionBeamAngleAlongship=
+echobase.common.transducerAcquisitionBeamAngleAthwartship=
+echobase.common.transducerAcquisitionPsi=
+echobase.common.transducerAperture=
+echobase.common.transducerBeams=
+echobase.common.transducerDepth=
+echobase.common.transducerLocation=
+echobase.common.transducerModel=
+echobase.common.transducerOrientation=
+echobase.common.transducerProcessingBeamAngleAlongship=
+echobase.common.transducerProcessingBeamAngleAthwartship=
+echobase.common.transducerProcessingPsi=
+echobase.common.transducerSerial=
+echobase.common.transect=transect
+echobase.common.transectAbstract=
+echobase.common.transit=transit
+echobase.common.transitDescription=
+echobase.common.transitEndLocatlity=
+echobase.common.transitEndTime=
+echobase.common.transitStartLocality=
+echobase.common.transitStartTime=
+echobase.common.units=
echobase.common.user=Utilisateur
+echobase.common.validMax=
+echobase.common.validMin=
+echobase.common.vessel=Navire
+echobase.common.vesselCode=
+echobase.common.vesselEnginePower=
+echobase.common.vesselLength=
+echobase.common.vesselName=
+echobase.common.vesselNoiseDesign=
+echobase.common.vesselTonnage=
+echobase.common.vesselType=
+echobase.common.voyage=Campagne
+echobase.common.voyageDescription=
+echobase.common.voyageEndDate=
+echobase.common.voyageName=
+echobase.common.voyageStartDate=
echobase.config.data.directory.description=Chemin de l'application
Modified: trunk/echobase-entities/src/main/xmi/echobase.zargo
===================================================================
(Binary files differ)
1
0
09 Nov '11
Author: tchemit
Date: 2011-11-09 20:41:58 +0100 (Wed, 09 Nov 2011)
New Revision: 32
Url: http://forge.codelutin.com/repositories/revision/echobase/32
Log:
use new Pager object (should be pushed to nuiton-utils) + new filter
Added:
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/DecoratorService.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/Pager.java
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/EchoBaseTopiaTransactionFilter.java
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/json/AbstractJSONPaginedAction.java
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/json/GetEntities.java
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/json/GetUsers.java
Removed:
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/GetEntities.java
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/json/GetUsersDatas.java
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/interceptors/EchoBaseTransactionInterceptorImpl.java
Modified:
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/DbEditorService.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/UserService.java
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/EchoBaseActionSupport.java
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/interceptors/CheckLogguedInterceptor.java
trunk/echobase-ui/src/main/resources/config/struts-dbeditor.xml
trunk/echobase-ui/src/main/resources/config/struts-json.xml
trunk/echobase-ui/src/main/resources/config/struts-user.xml
trunk/echobase-ui/src/main/resources/struts.xml
trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/user/userList.jsp
trunk/echobase-ui/src/main/webapp/WEB-INF/web.xml
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/DbEditorService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/DbEditorService.java 2011-11-09 19:41:12 UTC (rev 31)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/DbEditorService.java 2011-11-09 19:41:58 UTC (rev 32)
@@ -35,6 +35,8 @@
import fr.ifremer.echobase.entities.meta.TableMeta;
import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.lang.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.nuiton.topia.TopiaException;
import org.nuiton.topia.framework.TopiaQuery;
import org.nuiton.topia.persistence.TopiaDAO;
@@ -55,29 +57,39 @@
*/
public class DbEditorService extends AbstractEchoBaseService {
+ /** Logger. */
+ private static final Log log = LogFactory.getLog(DbEditorService.class);
+
+ protected DecoratorService decoratorService;
+
+ protected DecoratorService getDecoratorService() {
+ if (decoratorService == null) {
+
+ decoratorService = serviceContext.newService(DecoratorService.class);
+ }
+ return decoratorService;
+ }
+
public static class ResultDatas {
/** Total count. */
int count;
/** Loaded datas (for the given asked page). */
- Map[] rows;
+ Map<?, ?>[] rows;
+ public ResultDatas(int count, Map<?, ?>[] rows) {
+ this.count = count;
+ this.rows = rows;
+ }
+
public int getCount() {
return count;
}
- public void setCount(int count) {
- this.count = count;
- }
-
public Map[] getRows() {
return rows;
}
-
- public void setRows(Map[] rows) {
- this.rows = rows;
- }
}
public TableMeta getTableMetas(String tableName) {
@@ -86,10 +98,9 @@
return result;
}
- //TODO Use an object to filter datas and do pagination
+ //TODO Use an object to filter datas
public ResultDatas getDatas(String tableName,
- int from,
- int to,
+ Pager pager,
String sidx,
Boolean ascendantOrder) {
@@ -99,7 +110,27 @@
Class<? extends TopiaEntity> contract = entityEnum.getContract();
try {
TopiaDAO dao = EchoBaseDAOHelper.getDAO(getTransaction(), contract);
- ResultDatas result = new ResultDatas();
+
+ // first query to count datas
+ TopiaQuery countQuery = dao.createQuery("e");
+ countQuery.addSelect("count(*)");
+ int count = dao.countByQuery(countQuery);
+
+ pager.setRecords(count);
+ pager.computeIndexesAndPageCount();
+
+ int from = pager.getStartIndex();
+ int to = pager.getEndIndex();
+
+ if (log.isInfoEnabled()) {
+ log.info("Count = " + count);
+ log.info("page = " + pager.getPageNumber());
+ log.info("pageSize = " + pager.getPageSize());
+ log.info("from = " + from);
+ log.info("to = " + to);
+ log.info("pageCount= " + pager.getPageCount());
+ }
+
TopiaQuery query = dao.createQuery("e");
if (StringUtils.isNotEmpty(sidx)) {
if (ascendantOrder) {
@@ -108,22 +139,17 @@
query.addOrderDesc(sidx);
}
}
+ query.setLimit(from, to - 1);
List<?> all = dao.findAllByQuery(query);
- int count = all.size();
- if (count < to) {
- to = count;
- }
- Map[] rows = new Map[to - from];
+ Map<?, ?>[] rows = new Map[to - from];
- int j = 0;
- for (int i = from; i < to; i++) {
- TopiaEntity entity = (TopiaEntity) all.get(i);
+ int i = 0;
+ for (Object o : all) {
+ TopiaEntity entity = (TopiaEntity) o;
Map<String, Object> row = loadRow(tableMeta, entity);
- rows[j++] = row;
+ rows[i++] = row;
}
-
- result.setCount(all.size());
- result.setRows(rows);
+ ResultDatas result = new ResultDatas(count, rows);
return result;
} catch (TopiaException eee) {
throw new EchoBaseTechnicalException("Could not obtain data", eee);
@@ -197,7 +223,6 @@
} finally {
monitor.setBean(null);
}
-
}
protected Map<String, Object> loadRow(TableMeta tableMeta, TopiaEntity entity) {
@@ -207,8 +232,24 @@
row.put("id", entity.getTopiaId());
for (ColumnMeta columnMeta : tableMeta) {
String propertyName = columnMeta.getName();
- Object property =
- operator.get(propertyName, entity);
+
+ // get property value
+ Object property = operator.get(propertyName, entity);
+ if (columnMeta.isFK() && property != null) {
+
+ // this is a foreign key, just keep the topiaid
+ String topiaId = ((TopiaEntity) property).getTopiaId();
+
+ // decorate the entity
+ String decorate = getDecoratorService().decorate(
+ getLocale(), property, null);
+
+ // keep the decorate value
+ row.put(propertyName + "_lib", decorate);
+
+ // use as the property his topiaid
+ property = topiaId;
+ }
row.put(propertyName, property);
}
return row;
Added: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/DecoratorService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/DecoratorService.java (rev 0)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/DecoratorService.java 2011-11-09 19:41:58 UTC (rev 32)
@@ -0,0 +1,124 @@
+/*
+ * #%L
+ * EchoBase :: Services
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 Ifremer, Codelutin
+ * %%
+ * 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 fr.ifremer.echobase.services;
+
+import com.google.common.base.Preconditions;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import fr.ifremer.echobase.entities.EchoBaseUser;
+import org.apache.commons.collections.CollectionUtils;
+import org.nuiton.topia.persistence.TopiaEntity;
+import org.nuiton.util.decorator.Decorator;
+import org.nuiton.util.decorator.DecoratorMulti18nProvider;
+import org.nuiton.util.decorator.DecoratorUtil;
+import org.nuiton.util.decorator.JXPathDecorator;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+
+/**
+ * Service to decorate entities.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.1
+ */
+public class DecoratorService extends AbstractEchoBaseService {
+
+ protected final DecoratorMulti18nProvider decoratorProvider;
+
+ public DecoratorService() {
+ decoratorProvider = new EchoBaseDecoratorProvider();
+ }
+
+ public <O> Decorator<O> getDecorator(Locale locale,
+ Class<O> type,
+ String context) {
+ Preconditions.checkNotNull(type, "Decorator type can not be null!");
+ Decorator<O> decorator = decoratorProvider.getDecoratorByType(locale, type, context);
+ Preconditions.checkNotNull(
+ decorator,
+ "Could not find decorator for type " + type +
+ " and context " + context
+ );
+ return decorator;
+ }
+
+ public String decorate(Locale locale, Object o, String context) {
+ Decorator<?> decorator = getDecorator(locale, o.getClass(), context);
+ String result = decorator.toString(o);
+ return result;
+ }
+
+ public <O> List<O> sortToList(Locale locale, Collection<O> beans, String context) {
+ Preconditions.checkNotNull(beans);
+ List<O> list = Lists.newArrayList(beans);
+ getDecoratorAndSort(locale, context, list);
+ return list;
+ }
+
+ public <E extends TopiaEntity> Map<String, String> sortAndDecorate(Locale locale,
+ Collection<E> beans,
+ String context) {
+ Preconditions.checkNotNull(beans);
+ List<E> list = Lists.newArrayList(beans);
+
+ Decorator<E> decorator = getDecoratorAndSort(locale, context, list);
+ Map<String, String> result = Maps.newLinkedHashMap();
+ for (E bean : list) {
+ result.put(bean.getTopiaId(), decorator.toString(bean));
+ }
+ return result;
+ }
+
+ protected <O> Decorator<O> getDecoratorAndSort(Locale locale,
+ String context,
+ List<O> list) {
+ Decorator<O> decorator = null;
+ if (CollectionUtils.isNotEmpty(list)) {
+ O object = list.get(0);
+ Preconditions.checkNotNull(object);
+ decorator = decoratorProvider.getDecorator(locale, object, context);
+ Preconditions.checkNotNull(
+ decorator,
+ "Could not find decorator for type " + object.getClass() +
+ " and context " + context
+ );
+ DecoratorUtil.sort((JXPathDecorator<O>) decorator, list, 0);
+ }
+ return decorator;
+ }
+
+ static class EchoBaseDecoratorProvider extends DecoratorMulti18nProvider {
+
+ @Override
+ protected void loadDecorators(Locale locale) {
+
+ // trip decorator
+ registerJXPathDecorator(locale, EchoBaseUser.class, "${email}$s");
+
+ }
+ }
+}
Property changes on: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/DecoratorService.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/Pager.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/Pager.java (rev 0)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/Pager.java 2011-11-09 19:41:58 UTC (rev 32)
@@ -0,0 +1,109 @@
+/*
+ * #%L
+ * EchoBase :: Services
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 Ifremer, Codelutin
+ * %%
+ * 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 fr.ifremer.echobase.services;
+
+import org.apache.commons.lang3.tuple.Pair;
+import org.nuiton.util.PagerUtil;
+
+import java.io.Serializable;
+
+/**
+ * A simple pager bean.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.1
+ */
+public class Pager implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ protected int records;
+
+ protected int startIndex;
+
+ protected int endIndex;
+
+ protected int pageNumber;
+
+ protected int pageSize;
+
+ protected int pageCount;
+
+ public int getRecords() {
+ return records;
+ }
+
+ public int getStartIndex() {
+ return startIndex;
+ }
+
+ public int getEndIndex() {
+ return endIndex;
+ }
+
+ public int getPageNumber() {
+ return pageNumber;
+ }
+
+ public int getPageSize() {
+ return pageSize;
+ }
+
+ public int getPageCount() {
+ return pageCount;
+ }
+
+ public void setRecords(int records) {
+ this.records = records;
+ }
+
+ public void setStartIndex(int startIndex) {
+ this.startIndex = startIndex;
+ }
+
+ public void setEndIndex(int endIndex) {
+ this.endIndex = endIndex;
+ }
+
+ public void setPageNumber(int pageNumber) {
+ this.pageNumber = pageNumber;
+ }
+
+ public void setPageSize(int pageSize) {
+ this.pageSize = pageSize;
+ }
+
+ public void setPageCount(int pageCount) {
+ this.pageCount = pageCount;
+ }
+
+ public void computeIndexesAndPageCount() {
+ Pair<Integer, Integer> pageBound =
+ PagerUtil.getPageBound(records, pageNumber, pageSize);
+ startIndex = pageBound.getLeft();
+ endIndex = pageBound.getRight();
+ pageCount = PagerUtil.getTotalPage(records, pageSize);
+ }
+
+}
Property changes on: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/Pager.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/UserService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/UserService.java 2011-11-09 19:41:12 UTC (rev 31)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/UserService.java 2011-11-09 19:41:58 UTC (rev 32)
@@ -31,6 +31,7 @@
import fr.ifremer.echobase.entities.EchoBaseUserDTO;
import org.apache.commons.lang3.StringUtils;
import org.nuiton.topia.TopiaException;
+import org.nuiton.topia.framework.TopiaQuery;
import org.nuiton.util.StringUtil;
import java.util.List;
@@ -42,8 +43,27 @@
public class UserService extends AbstractEchoBaseService {
public List<EchoBaseUser> getUsers() {
+ return getUsers(null);
+ }
+
+ public List<EchoBaseUser> getUsers(Pager pager) {
try {
- List<EchoBaseUser> users = getDAO().findAll();
+ List<EchoBaseUser> users;
+
+ EchoBaseUserDAO dao = getDAO();
+ if (pager == null) {
+
+ users = dao.findAll();
+ } else {
+
+ // get user count
+ long count = dao.count();
+ pager.setRecords((int) count);
+ pager.computeIndexesAndPageCount();
+ TopiaQuery query = dao.createQuery("e");
+ query.setLimit(pager.getStartIndex(), pager.getEndIndex() - 1);
+ users = dao.findAllByQuery(query);
+ }
return users;
} catch (TopiaException eee) {
throw new EchoBaseTechnicalException(eee);
Added: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/EchoBaseTopiaTransactionFilter.java
===================================================================
--- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/EchoBaseTopiaTransactionFilter.java (rev 0)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/EchoBaseTopiaTransactionFilter.java 2011-11-09 19:41:58 UTC (rev 32)
@@ -0,0 +1,66 @@
+/*
+ * #%L
+ * EchoBase :: UI
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 Ifremer, Codelutin
+ * %%
+ * 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 fr.ifremer.echobase.ui;
+
+import com.google.common.base.Supplier;
+import fr.ifremer.echobase.ui.actions.EchoBaseActionSupport;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.topia.TopiaContext;
+import org.nuiton.topia.TopiaException;
+import org.nuiton.topia.TopiaRuntimeException;
+import org.nuiton.web.filter.TopiaTransactionFilter;
+
+/**
+ * TODO
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.1
+ */
+public class EchoBaseTopiaTransactionFilter extends TopiaTransactionFilter {
+
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(EchoBaseTopiaTransactionFilter.class);
+
+ @Override
+ protected TopiaContext beginTransaction() throws TopiaRuntimeException {
+ EchoBaseApplicationContext applicationContext =
+ EchoBaseActionSupport.getEchoBaseApplicationContext();
+ Supplier<TopiaContext> rootContextSupplier =
+ applicationContext.getRootContextSupplier();
+
+ TopiaContext rootContext = rootContextSupplier.get();
+ TopiaContext transaction = null;
+ try {
+ transaction = rootContext.beginTransaction();
+ } catch (TopiaException eee) {
+ throw new TopiaRuntimeException("Could not start transaction", eee);
+ }
+ if (log.isDebugEnabled()) {
+ log.debug("Starts a new echo transaction " + transaction);
+ }
+ return transaction;
+ }
+}
Property changes on: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/EchoBaseTopiaTransactionFilter.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/EchoBaseActionSupport.java
===================================================================
--- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/EchoBaseActionSupport.java 2011-11-09 19:41:12 UTC (rev 31)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/EchoBaseActionSupport.java 2011-11-09 19:41:58 UTC (rev 32)
@@ -31,10 +31,13 @@
import fr.ifremer.echobase.services.EchoBaseServiceFactory;
import fr.ifremer.echobase.ui.EchoBaseApplicationContext;
import fr.ifremer.echobase.ui.EchoBaseSession;
+import org.apache.struts2.StrutsStatics;
import org.nuiton.topia.TopiaContext;
import org.nuiton.topia.framework.TopiaTransactionAware;
+import org.nuiton.web.filter.TopiaTransactionFilter;
import org.nuiton.web.struts2.BaseAction;
+import javax.servlet.http.HttpServletRequest;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Map;
@@ -54,9 +57,6 @@
private static final long serialVersionUID = 1L;
- public static final String LOG_LINE =
- "--------------------------------------------------------------------------------";
-
/** Key to store the {@link EchoBaseSession} instance in the session's map. */
protected static final String SESSION_PARAMETER = "echoBaseSession";
@@ -68,7 +68,7 @@
private SimpleDateFormat monthFormat;
public static EchoBaseApplicationContext getEchoBaseApplicationContext() {
- Map<String, Object> application = ActionContext.getContext().getApplication();
+ Map<String, Object> application = getActionContext().getApplication();
EchoBaseApplicationContext applicationContext =
(EchoBaseApplicationContext) application.get(APPLICATION_CONTEXT_PARAMETER);
return applicationContext;
@@ -87,8 +87,7 @@
* Actions may <strong>not</strong> call it directly by use
* {@link #newService(Class)} instead.
*/
- protected transient EchoBaseServiceFactory serviceFactory =
- new EchoBaseServiceFactory();
+ protected transient EchoBaseServiceFactory serviceFactory;
protected transient EchoBaseServiceContext serviceContext;
@@ -98,7 +97,8 @@
if (echoBaseSession == null) {
// load it from session
- Map<String, Object> strutsSession = ActionContext.getContext().getSession();
+ Map<String, Object> strutsSession =
+ getActionContext().getSession();
EchoBaseSession session = (EchoBaseSession)
strutsSession.get(SESSION_PARAMETER);
@@ -132,12 +132,19 @@
getTransaction(),
getConfiguration(),
getEchoBaseApplicationContext().getDbMeta(),
- serviceFactory
+ getServiceFactory()
);
}
return serviceContext;
}
+ public EchoBaseServiceFactory getServiceFactory() {
+ if (serviceFactory == null) {
+ serviceFactory = new EchoBaseServiceFactory();
+ }
+ return serviceFactory;
+ }
+
/**
* Sub-classes should use this method to easily get a service instance.
*
@@ -145,12 +152,18 @@
* @return A newly created service of the expected type with necessary data set
*/
public <E extends EchoBaseService> E newService(Class<E> serviceClass) {
- E service = serviceFactory.newService(serviceClass, getServiceContext());
+ E service = getServiceFactory().newService(serviceClass,
+ getServiceContext());
return service;
}
@Override
public TopiaContext getTransaction() {
+ if (transaction == null) {
+ HttpServletRequest request = (HttpServletRequest)
+ getActionContext().get(StrutsStatics.HTTP_REQUEST);
+ transaction = TopiaTransactionFilter.getTransaction(request);
+ }
return transaction;
}
@@ -183,4 +196,7 @@
return monthFormat;
}
+ protected static ActionContext getActionContext() {
+ return ActionContext.getContext();
+ }
}
Deleted: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/GetEntities.java
===================================================================
--- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/GetEntities.java 2011-11-09 19:41:12 UTC (rev 31)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/GetEntities.java 2011-11-09 19:41:58 UTC (rev 32)
@@ -1,220 +0,0 @@
-/*
- * #%L
- * EchoBase :: UI
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2011 Ifremer, Codelutin
- * %%
- * 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 fr.ifremer.echobase.ui.actions.dbeditor;
-
-import fr.ifremer.echobase.services.DbEditorService;
-import fr.ifremer.echobase.ui.actions.EchoBaseActionSupport;
-import org.apache.commons.lang.StringUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.struts2.json.JSONUtil;
-
-import java.util.Map;
-
-/**
- * To obtain the data for the given request.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 0.1
- */
-public class GetEntities extends EchoBaseActionSupport {
-
- private static final long serialVersionUID = 1L;
-
- /** Logger. */
- private static final Log log = LogFactory.getLog(GetEntities.class);
-
- private static final String SIDX_PREFIX = "tableDatas_";
-
- /** Name of the table to load. */
- protected String tableName;
-
- /** Datas of the given table. */
- protected Map<?,?>[] datas;
-
- //get how many rows we want to have into the grid - rowNum attribute in the grid
- protected Integer rows = 0;
-
- //Get the requested page. By default grid sets this to 1.
- protected Integer page = 0;
-
- // sorting order - asc or desc
- protected String sord;
-
- // get index row - i.e. user click to sort.
- protected String sidx;
-
- // Search Field
- protected String searchField;
-
- // The Search String
- protected String searchString;
-
- // he Search Operation ['eq','ne','lt','le','gt','ge','bw','bn','in','ni','ew','en','cn','nc']
- protected String searchOper;
-
- protected String filters;
-
- // Your Total Pages
- protected Integer total = 0;
-
- // All Record
- protected Integer records = 0;
-
- public Map<?,?>[] getDatas() {
- return datas;
- }
-
- public void setTableName(String tableName) {
- this.tableName = tableName;
- }
-
- @Override
- public String execute() throws Exception {
- DbEditorService dbEditorService = newService(DbEditorService.class);
-
- int to = rows * page;
- int from = to - rows;
-
- Boolean ascendantOrder = null;
-
- if (StringUtils.isNotEmpty(sidx)) {
-
- // there is a sort to do
- sidx = sidx.substring(SIDX_PREFIX.length());
-
- ascendantOrder = "asc".equals(sord);
- }
-
- Object filterObject = null;
-
-
- if (StringUtils.isNotEmpty(filters)) {
- filterObject = JSONUtil.deserialize(filters);
- }
-
- if (log.isInfoEnabled()) {
- log.info("searchField = " + searchField);
- log.info("searchField = " + searchField);
- log.info("searchString = " + searchString);
- log.info("searchOper = " + searchOper);
- log.info("filters = " + filters);
- log.info("filterObject = " + filterObject);
- log.info("sidx = " + sidx);
- log.info("sord = " + sord);
- }
-
- DbEditorService.ResultDatas resultDatas =
- dbEditorService.getDatas(tableName, from, to, sidx, ascendantOrder);
-
- datas = resultDatas.getRows();
-
- records = resultDatas.getCount();
-
- //calculate the total pages for the query
- total = (int) Math.ceil((double) records / (double) rows);
-
- return SUCCESS;
- }
-
- public Integer getRows() {
- return rows;
- }
-
- public void setRows(Integer rows) {
- this.rows = rows;
- }
-
- public Integer getPage() {
- return page;
- }
-
- public void setPage(Integer page) {
- this.page = page;
- }
-
- public String getSord() {
- return sord;
- }
-
- public void setSord(String sord) {
- this.sord = sord;
- }
-
- public String getSidx() {
- return sidx;
- }
-
- public void setSidx(String sidx) {
- this.sidx = sidx;
- }
-
- public String getSearchField() {
- return searchField;
- }
-
- public void setSearchField(String searchField) {
- this.searchField = searchField;
- }
-
- public String getSearchString() {
- return searchString;
- }
-
- public void setSearchString(String searchString) {
- this.searchString = searchString;
- }
-
- public String getSearchOper() {
- return searchOper;
- }
-
- public void setSearchOper(String searchOper) {
- this.searchOper = searchOper;
- }
-
- public Integer getTotal() {
- return total;
- }
-
- public void setTotal(Integer total) {
- this.total = total;
- }
-
- public Integer getRecords() {
- return records;
- }
-
- public void setRecords(Integer records) {
- this.records = records;
- }
-
- public String getFilters() {
- return filters;
- }
-
- public void setFilters(String filters) {
- this.filters = filters;
- }
-}
Added: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/json/AbstractJSONPaginedAction.java
===================================================================
--- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/json/AbstractJSONPaginedAction.java (rev 0)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/json/AbstractJSONPaginedAction.java 2011-11-09 19:41:58 UTC (rev 32)
@@ -0,0 +1,138 @@
+/*
+ * #%L
+ * EchoBase :: UI
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 Ifremer, Codelutin
+ * %%
+ * 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 fr.ifremer.echobase.ui.actions.json;
+
+import fr.ifremer.echobase.services.Pager;
+import fr.ifremer.echobase.ui.actions.EchoBaseActionSupport;
+import org.apache.commons.lang.StringUtils;
+import org.apache.struts2.json.JSONException;
+import org.apache.struts2.json.JSONUtil;
+
+/**
+ * Abstract JSON action with pagination support.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.1
+ */
+public abstract class AbstractJSONPaginedAction extends EchoBaseActionSupport {
+
+ private static final long serialVersionUID = 1L;
+
+ public abstract Integer getRows();
+
+ public abstract Integer getPage();
+
+ public abstract Integer getTotal();
+
+ public abstract Integer getRecords();
+
+ protected Pager pager = new Pager();
+
+// //get how many rows we want to have into the grid - rowNum attribute in the grid
+// protected Integer rows = 0;
+//
+// //Get the requested page. By default grid sets this to 1.
+// protected Integer page = 0;
+
+ // sorting order - asc or desc
+ protected String sord;
+
+ // get index row - i.e. user click to sort.
+ protected String sidx;
+
+ protected String filters;
+
+// // Your Total Pages
+// protected Integer total = 0;
+//
+// // All Record
+// protected Integer records = 0;
+
+ /** Prefix added to the sidx when used. */
+ protected final String sidx_prefix;
+
+ protected AbstractJSONPaginedAction(String sidx_prefix) {
+ this.sidx_prefix = sidx_prefix;
+ }
+
+ public void setRows(Integer rows) {
+ pager.setPageSize(rows);
+ }
+
+ public void setPage(Integer page) {
+ pager.setPageNumber(page);
+ }
+
+ public String getSord() {
+ return sord;
+ }
+
+ public void setSord(String sord) {
+ this.sord = sord;
+ }
+
+ public String getSidx() {
+ return sidx;
+ }
+
+ public void setSidx(String sidx) {
+ this.sidx = sidx;
+ }
+
+ public String getFilters() {
+ return filters;
+ }
+
+ public void setFilters(String filters) {
+ this.filters = filters;
+ }
+
+ protected String getSortColumn() {
+ String result = null;
+ if (useSort()) {
+ result = sidx.substring(sidx_prefix.length());
+ }
+ return result;
+ }
+
+ protected Boolean isSortAscendant() {
+ Boolean result = null;
+ if (useSort()) {
+ result = "asc".equals(sord);
+ }
+ return result;
+ }
+
+ protected boolean useSort() {
+ return StringUtils.isNotEmpty(sidx);
+ }
+
+ protected Object getFilterObject() throws JSONException {
+ Object filterObject = null;
+ if (StringUtils.isNotEmpty(filters)) {
+ filterObject = JSONUtil.deserialize(filters);
+ }
+ return filterObject;
+ }
+}
Property changes on: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/json/AbstractJSONPaginedAction.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/json/GetEntities.java (from rev 30, trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/GetEntities.java)
===================================================================
--- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/json/GetEntities.java (rev 0)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/json/GetEntities.java 2011-11-09 19:41:58 UTC (rev 32)
@@ -0,0 +1,116 @@
+/*
+ * #%L
+ * EchoBase :: UI
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 Ifremer, Codelutin
+ * %%
+ * 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 fr.ifremer.echobase.ui.actions.json;
+
+import fr.ifremer.echobase.services.DbEditorService;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.util.Map;
+
+/**
+ * To obtain the data for the given request.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.1
+ */
+public class GetEntities extends AbstractJSONPaginedAction {
+
+ private static final long serialVersionUID = 1L;
+
+ /** Logger. */
+ private static final Log log = LogFactory.getLog(GetEntities.class);
+
+ /** Name of the table to load. */
+ protected String tableName;
+
+ /** Datas of the given table. */
+ protected Map<?, ?>[] datas;
+
+ public GetEntities() {
+ super("tableDatas_");
+ }
+
+ public Map<?, ?>[] getDatas() {
+ return datas;
+ }
+
+ @Override
+ public Integer getRows() {
+ return pager.getPageSize();
+ }
+
+ @Override
+ public Integer getPage() {
+ return pager.getPageNumber();
+ }
+
+ @Override
+ public Integer getTotal() {
+ return pager.getPageCount();
+ }
+
+ @Override
+ public Integer getRecords() {
+ return pager.getRecords();
+ }
+
+ public void setTableName(String tableName) {
+ this.tableName = tableName;
+ }
+
+ @Override
+ public String execute() throws Exception {
+
+ Boolean ascendantOrder = isSortAscendant();
+ String sortColumn = getSortColumn();
+ Object filterObject = getFilterObject();
+
+ if (log.isInfoEnabled()) {
+ log.info("filters = " + getFilters());
+ log.info("filterObject = " + filterObject);
+ log.info("sidx = " + sortColumn);
+ log.info("sord = " + ascendantOrder);
+ }
+
+ DbEditorService dbEditorService = newService(DbEditorService.class);
+
+ DbEditorService.ResultDatas resultDatas = dbEditorService.getDatas(
+ tableName,
+ pager,
+ sortColumn,
+ ascendantOrder
+ );
+
+ datas = resultDatas.getRows();
+
+ if (log.isInfoEnabled()) {
+ log.info("Total page = " + getTotal());
+ }
+
+ return SUCCESS;
+ }
+
+
+}
Property changes on: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/json/GetEntities.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/json/GetUsers.java (from rev 25, trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/json/GetUsersDatas.java)
===================================================================
--- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/json/GetUsers.java (rev 0)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/json/GetUsers.java 2011-11-09 19:41:58 UTC (rev 32)
@@ -0,0 +1,87 @@
+/*
+ * #%L
+ * EchoBase :: UI
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 Ifremer, Codelutin
+ * %%
+ * 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 fr.ifremer.echobase.ui.actions.json;
+
+import fr.ifremer.echobase.entities.EchoBaseUser;
+import fr.ifremer.echobase.entities.EchoBaseUserDTO;
+import fr.ifremer.echobase.services.UserService;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Obtains all users of the echobase internal database.
+ *
+ * @author sletellier <letellier(a)codelutin.com>
+ * @since 0.1
+ */
+public class GetUsers extends AbstractJSONPaginedAction {
+
+ private static final long serialVersionUID = 1L;
+
+ protected List<EchoBaseUserDTO> users;
+
+ public GetUsers() {
+ super("users_");
+ }
+
+ public List<EchoBaseUserDTO> getUsers() {
+ return users;
+ }
+
+ @Override
+ public Integer getRows() {
+ return pager.getPageSize();
+ }
+
+ @Override
+ public Integer getPage() {
+ return pager.getPageNumber();
+ }
+
+ @Override
+ public Integer getTotal() {
+ return pager.getPageCount();
+ }
+
+ @Override
+ public Integer getRecords() {
+ return pager.getRecords();
+ }
+
+ @Override
+ public String execute() throws Exception {
+
+ List<EchoBaseUser> allUsers =
+ newService(UserService.class).getUsers(pager);
+
+ users = new ArrayList<EchoBaseUserDTO>(allUsers.size());
+ for (EchoBaseUser user : allUsers) {
+ users.add(user.toDTO());
+ }
+
+ return SUCCESS;
+ }
+
+}
Property changes on: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/json/GetUsers.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Deleted: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/json/GetUsersDatas.java
===================================================================
--- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/json/GetUsersDatas.java 2011-11-09 19:41:12 UTC (rev 31)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/json/GetUsersDatas.java 2011-11-09 19:41:58 UTC (rev 32)
@@ -1,63 +0,0 @@
-/*
- * #%L
- * EchoBase :: UI
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2011 Ifremer, Codelutin
- * %%
- * 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 fr.ifremer.echobase.ui.actions.json;
-
-import fr.ifremer.echobase.entities.EchoBaseUser;
-import fr.ifremer.echobase.entities.EchoBaseUserDTO;
-import fr.ifremer.echobase.services.UserService;
-import fr.ifremer.echobase.ui.actions.EchoBaseActionSupport;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Obtains all users of the echobase internal database.
- *
- * @author sletellier <letellier(a)codelutin.com>
- * @since 0.1
- */
-public class GetUsersDatas extends EchoBaseActionSupport {
-
- private static final long serialVersionUID = 1L;
-
- protected List<EchoBaseUserDTO> users;
-
- public List<EchoBaseUserDTO> getUsers() {
- return users;
- }
-
- @Override
- public String execute() throws Exception {
-
- List<EchoBaseUser> allUsers = newService(UserService.class).getUsers();
-
- users = new ArrayList<EchoBaseUserDTO>(allUsers.size());
- for (EchoBaseUser user : allUsers) {
- users.add(user.toDTO());
- }
-
- return SUCCESS;
- }
-
-}
Modified: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/interceptors/CheckLogguedInterceptor.java
===================================================================
--- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/interceptors/CheckLogguedInterceptor.java 2011-11-09 19:41:12 UTC (rev 31)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/interceptors/CheckLogguedInterceptor.java 2011-11-09 19:41:58 UTC (rev 32)
@@ -26,6 +26,7 @@
import com.opensymphony.xwork2.ActionInvocation;
import fr.ifremer.echobase.ui.EchoBaseSession;
import fr.ifremer.echobase.ui.actions.EchoBaseActionSupport;
+import fr.ifremer.echobase.ui.actions.LoginAction;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -60,6 +61,29 @@
boolean userLoggued = echoBaseSession.getEchoBaseUser() != null;
if (!userLoggued) {
+
+ boolean autoLogin =
+ EchoBaseActionSupport.getEchoBaseApplicationContext().getConfiguration().getOptionAsBoolean("autoLogin");
+
+ if (autoLogin) {
+ // by-pass login
+
+ if (log.isInfoEnabled()) {
+ log.info("AutotLogin with admin/admin user");
+ }
+ LoginAction loginAction = new LoginAction();
+ loginAction.setSession(invocation.getInvocationContext().getSession());
+ loginAction.setEmail("admin");
+ loginAction.setPassword("admin");
+ try {
+ loginAction.doLogin();
+ } catch (Exception eee) {
+ if (log.isErrorEnabled()) {
+ log.error("Could not auto-login", eee);
+ }
+ }
+ return true;
+ }
if (log.isInfoEnabled()) {
log.info("No user loggued!");
}
Deleted: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/interceptors/EchoBaseTransactionInterceptorImpl.java
===================================================================
--- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/interceptors/EchoBaseTransactionInterceptorImpl.java 2011-11-09 19:41:12 UTC (rev 31)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/interceptors/EchoBaseTransactionInterceptorImpl.java 2011-11-09 19:41:58 UTC (rev 32)
@@ -1,64 +0,0 @@
-/*
- * #%L
- * EchoBase :: UI
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2011 Ifremer, Codelutin
- * %%
- * 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 fr.ifremer.echobase.ui.interceptors;
-
-import com.google.common.base.Supplier;
-import fr.ifremer.echobase.ui.EchoBaseApplicationContext;
-import fr.ifremer.echobase.ui.actions.EchoBaseActionSupport;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.nuiton.topia.TopiaContext;
-import org.nuiton.topia.TopiaException;
-import org.nuiton.web.struts2.interceptor.OpenTopiaTransactionInterceptor;
-
-/**
- * Implementation of the {@link OpenTopiaTransactionInterceptor} giving how to
- * create a new topia transaction on a EchoBase database.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 0.1
- */
-public class EchoBaseTransactionInterceptorImpl extends OpenTopiaTransactionInterceptor {
-
- private static final long serialVersionUID = 1L;
-
- /** Logger. */
- private static final Log log =
- LogFactory.getLog(EchoBaseTransactionInterceptorImpl.class);
-
- @Override
- protected TopiaContext beginTransaction() throws TopiaException {
- EchoBaseApplicationContext applicationContext =
- EchoBaseActionSupport.getEchoBaseApplicationContext();
- Supplier<TopiaContext> rootContextSupplier =
- applicationContext.getRootContextSupplier();
-
- TopiaContext rootContext = rootContextSupplier.get();
- TopiaContext transaction = rootContext.beginTransaction();
- if (log.isDebugEnabled()) {
- log.debug("Starts a new echo transaction " + transaction);
- }
- return transaction;
- }
-}
Modified: trunk/echobase-ui/src/main/resources/config/struts-dbeditor.xml
===================================================================
--- trunk/echobase-ui/src/main/resources/config/struts-dbeditor.xml 2011-11-09 19:41:12 UTC (rev 31)
+++ trunk/echobase-ui/src/main/resources/config/struts-dbeditor.xml 2011-11-09 19:41:58 UTC (rev 32)
@@ -38,7 +38,7 @@
</action>
<action name="getTableDatas"
- class="fr.ifremer.echobase.ui.actions.dbeditor.GetEntities">
+ class="fr.ifremer.echobase.ui.actions.json.GetEntities">
<interceptor-ref name="basicStackLoggued"/>
<result type="json"/>
</action>
Modified: trunk/echobase-ui/src/main/resources/config/struts-json.xml
===================================================================
--- trunk/echobase-ui/src/main/resources/config/struts-json.xml 2011-11-09 19:41:12 UTC (rev 31)
+++ trunk/echobase-ui/src/main/resources/config/struts-json.xml 2011-11-09 19:41:58 UTC (rev 32)
@@ -32,7 +32,7 @@
<package name="json" extends="loggued" namespace="/json">
<action name="getUsers"
- class="fr.ifremer.echobase.ui.actions.json.GetUsersDatas">
+ class="fr.ifremer.echobase.ui.actions.json.GetUsers">
<interceptor-ref name="basicStackLoggued"/>
<interceptor-ref name="checkUserIsAdmin"/>
<result type="json"/>
Modified: trunk/echobase-ui/src/main/resources/config/struts-user.xml
===================================================================
--- trunk/echobase-ui/src/main/resources/config/struts-user.xml 2011-11-09 19:41:12 UTC (rev 31)
+++ trunk/echobase-ui/src/main/resources/config/struts-user.xml 2011-11-09 19:41:58 UTC (rev 32)
@@ -37,7 +37,7 @@
<result name="input">/WEB-INF/jsp/user/login.jsp</result>
<result name="error">/WEB-INF/jsp/user/login.jsp</result>
<result name="redirect" type="redirect">${redirectAction}</result>
- <interceptor-ref name="echoBaseParamsPrepareParamsStack"/>
+ <interceptor-ref name="paramsPrepareParamsStack"/>
</action>
<!-- logout action -->
Modified: trunk/echobase-ui/src/main/resources/struts.xml
===================================================================
--- trunk/echobase-ui/src/main/resources/struts.xml 2011-11-09 19:41:12 UTC (rev 31)
+++ trunk/echobase-ui/src/main/resources/struts.xml 2011-11-09 19:41:58 UTC (rev 32)
@@ -44,12 +44,12 @@
<constant name="struts.multipart.maxSize" value="209715200"/>
<constant name="struts.freemarker.templatesCache" value="true"/>
- <package name="default" extends="struts-default" abstract="true"
+ <package name="default" extends="json-default" abstract="true"
namespace="/">
- <result-types>
+ <!--result-types>
<result-type name="json" class="org.apache.struts2.json.JSONResult"/>
- </result-types>
+ </result-types-->
<interceptors>
@@ -57,10 +57,6 @@
<interceptor name="paramRemover"
class="com.opensymphony.xwork2.interceptor.ParameterRemoverInterceptor"/>
- <!-- to manage the echobase topia transaction inside an action -->
- <interceptor name="topiaTransaction"
- class="fr.ifremer.echobase.ui.interceptors.EchoBaseTransactionInterceptorImpl"/>
-
<!-- to clean some properties from the echobase session -->
<interceptor name="cleanEchoBaseSession"
class="fr.ifremer.echobase.ui.interceptors.CleanEchoBaseSessionInterceptor"/>
@@ -91,30 +87,18 @@
<interceptors>
- <!-- echobase basic authenticated stack -->
- <interceptor-stack name="echoBaseBasicStack">
- <interceptor-ref name="topiaTransaction"/>
- <interceptor-ref name="basicStack"/>
- </interceptor-stack>
-
- <!-- echobase stack with params-->
- <interceptor-stack name="echoBaseParamsPrepareParamsStack">
- <interceptor-ref name="topiaTransaction"/>
- <interceptor-ref name="paramsPrepareParamsStack"/>
- </interceptor-stack>
-
<!-- basic authenticated stack -->
<interceptor-stack name="basicStackLoggued">
<interceptor-ref name="i18n"/>
<interceptor-ref name="checkUserLoggued"/>
- <interceptor-ref name="echoBaseBasicStack"/>
+ <interceptor-ref name="basicStack"/>
</interceptor-stack>
<!-- authenticated stack with params-->
<interceptor-stack name="paramsPrepareParamsStackLoggued">
<interceptor-ref name="i18n"/>
<interceptor-ref name="checkUserLoggued"/>
- <interceptor-ref name="echoBaseParamsPrepareParamsStack"/>
+ <interceptor-ref name="paramsPrepareParamsStack"/>
</interceptor-stack>
</interceptors>
@@ -136,7 +120,6 @@
<param name="paramNames">request_locale</param>
</interceptor-ref>
<interceptor-ref name="checkUserLoggued"/>
- <interceptor-ref name="topiaTransaction"/>
</action>
</package>
Modified: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/user/userList.jsp
===================================================================
--- trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/user/userList.jsp 2011-11-09 19:41:12 UTC (rev 31)
+++ trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/user/userList.jsp 2011-11-09 19:41:58 UTC (rev 32)
@@ -59,19 +59,15 @@
<sjg:grid id="users" caption="%{getText('echobase.title.users')}"
dataType="json" href="%{loadUrl}" gridModel="users"
- pager="true" pagerButtons="false" pagerInput="false"
- navigator="true"
- rownumbers="false"
- autowidth="true"
+ pager="true" pagerButtons="true" pagerInput="true"
+ navigator="true" rownumbers="false" autowidth="true"
onSelectRowTopics='users-rowSelect'
onCompleteTopics='users-cleanSelect'
- navigatorEdit="false"
- navigatorDelete="false"
- navigatorSearch="false"
- navigatorRefresh="false"
+ navigatorEdit="false" navigatorDelete="false"
+ navigatorSearch="false" navigatorRefresh="false"
navigatorAdd="false"
editinline="false" resizable="true"
- height="100"
+ rowList="10,15,20, 50" rowNum="10"
navigatorExtraButtons="{
add: { title : 'Ajouter', icon: 'ui-icon-plus', topic: 'users-rowAdd' },
update: { title : 'Mettre à jour', icon: 'ui-icon-pencil', topic: 'users-rowUpdate' },
Modified: trunk/echobase-ui/src/main/webapp/WEB-INF/web.xml
===================================================================
--- trunk/echobase-ui/src/main/webapp/WEB-INF/web.xml 2011-11-09 19:41:12 UTC (rev 31)
+++ trunk/echobase-ui/src/main/webapp/WEB-INF/web.xml 2011-11-09 19:41:58 UTC (rev 32)
@@ -30,8 +30,8 @@
<display-name>EchoBase</display-name>
<filter>
- <filter-name>topiaCloseTransaction</filter-name>
- <filter-class>org.nuiton.web.struts2.filter.CloseTopiaTransactionFilter</filter-class>
+ <filter-name>topiaTransaction</filter-name>
+ <filter-class>fr.ifremer.echobase.ui.EchoBaseTopiaTransactionFilter</filter-class>
</filter>
<filter>
@@ -54,7 +54,7 @@
</filter>
<filter-mapping>
- <filter-name>topiaCloseTransaction</filter-name>
+ <filter-name>topiaTransaction</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
1
0
Author: tchemit
Date: 2011-11-09 20:41:12 +0100 (Wed, 09 Nov 2011)
New Revision: 31
Url: http://forge.codelutin.com/repositories/revision/echobase/31
Log:
using nuiton-web (new topia filter)
Modified:
trunk/echobase-ui/pom.xml
trunk/pom.xml
Modified: trunk/echobase-ui/pom.xml
===================================================================
--- trunk/echobase-ui/pom.xml 2011-11-09 08:55:29 UTC (rev 30)
+++ trunk/echobase-ui/pom.xml 2011-11-09 19:41:12 UTC (rev 31)
@@ -42,6 +42,10 @@
<groupId>org.nuiton.web</groupId>
<artifactId>nuiton-struts2</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.nuiton.web</groupId>
+ <artifactId>nuiton-web</artifactId>
+ </dependency>
<dependency>
<groupId>org.nuiton</groupId>
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2011-11-09 08:55:29 UTC (rev 30)
+++ trunk/pom.xml 2011-11-09 19:41:12 UTC (rev 31)
@@ -110,7 +110,7 @@
<topiaVersion>2.6.3</topiaVersion>
<nuitonUtilsVersion>2.4-SNAPSHOT</nuitonUtilsVersion>
<nuitonI18nVersion>2.4.1</nuitonI18nVersion>
- <nuitonWebVersion>1.5</nuitonWebVersion>
+ <nuitonWebVersion>1.6-SNAPSHOT</nuitonWebVersion>
<msaccessImporterVersion>1.4.1</msaccessImporterVersion>
<struts2Version>2.2.3.1</struts2Version>
<jqueryPluginVersion>3.1.0</jqueryPluginVersion>
@@ -173,6 +173,13 @@
</dependency>
<dependency>
+ <groupId>org.nuiton.web</groupId>
+ <artifactId>nuiton-web</artifactId>
+ <version>${nuitonWebVersion}</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
<groupId>org.nuiton.i18n</groupId>
<artifactId>nuiton-i18n</artifactId>
<version>${nuitonI18nVersion}</version>
1
0
r30 - in trunk: echobase-services/src/main/java/fr/ifremer/echobase/services/models echobase-ui/src/main/java/fr/ifremer/echobase/ui echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor echobase-ui/src/main/resources/config echobase-ui/src/main/resources/i18n echobase-ui/src/main/webapp/WEB-INF/jsp/dbeditor
by tchemit@users.forge.codelutin.com 09 Nov '11
by tchemit@users.forge.codelutin.com 09 Nov '11
09 Nov '11
Author: tchemit
Date: 2011-11-09 09:55:29 +0100 (Wed, 09 Nov 2011)
New Revision: 30
Url: http://forge.codelutin.com/repositories/revision/echobase/30
Log:
db editor story
Added:
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/GetEntities.java
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/LoadEntities.java
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/SaveEntity.java
Removed:
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/GetTableDatas.java
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/LoadTablePage.java
Modified:
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/models/ImportModel.java
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/EchoBaseApplicationListener.java
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/ImportAction.java
trunk/echobase-ui/src/main/resources/config/struts-dbeditor.xml
trunk/echobase-ui/src/main/resources/config/struts-import.xml
trunk/echobase-ui/src/main/resources/i18n/echobase-ui_fr_FR.properties
trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/dbeditor/dbeditor.jsp
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/models/ImportModel.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/models/ImportModel.java 2011-11-09 08:49:36 UTC (rev 29)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/models/ImportModel.java 2011-11-09 08:55:29 UTC (rev 30)
@@ -25,34 +25,45 @@
import fr.ifremer.echobase.entities.Survey;
import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.builder.ToStringBuilder;
import java.io.File;
+import java.io.Serializable;
/**
* Object representing all import configuration
*
* @author sletellier <letellier(a)codelutin.com>
+ * @since 0.1
*/
-public class ImportModel {
+public class ImportModel implements Serializable {
+ private static final long serialVersionUID = 1L;
+
protected Survey surveySelected;
protected File accessImport;
+
protected String accessImportFileName;
protected File accousticImport;
+
protected String accousticImportFileName;
protected File pecherieImport;
+
protected String pecherieImportFileName;
protected File lectureAgeGenImport;
+
protected String lectureAgeGenImportFileName;
protected File eventsImport;
+
protected String eventsImportFileName;
protected File typeEchoSpeciesImport;
+
protected String typeEchoSpeciesImportFileName;
protected String comment;
@@ -65,7 +76,6 @@
this.surveySelected = surveySelected;
}
-
public String getComment() {
return comment;
}
@@ -182,40 +192,51 @@
pecherieImport != null ||
eventsImport != null ||
typeEchoSpeciesImport != null);
-
return result;
}
@Override
public String toString() {
- StringBuilder builder = new StringBuilder();
-
- // Add selected survey
- if (surveySelected != null) {
- addToBuilder(builder, "surveySelected", surveySelected.getName());
- }
-
- // Add all import files
- addToBuilder(builder, "accessImportFile", accessImportFileName);
- addToBuilder(builder, "accousticImportFile", accousticImportFileName);
- addToBuilder(builder, "pecherieImportFile", pecherieImportFileName);
- addToBuilder(builder, "lectureAgeGenImportFile", lectureAgeGenImportFileName);
- addToBuilder(builder, "eventsImportFile", eventsImportFileName);
- addToBuilder(builder, "pecherieImportFile", typeEchoSpeciesImportFileName);
-
+ ToStringBuilder builder = new ToStringBuilder(this);
+ builder.append("surveySelected", surveySelected.getName());
+ builder.append("accessImportFile", accessImportFileName);
+ builder.append("accousticImportFile", accousticImportFileName);
+ builder.append("pecherieImportFile", pecherieImportFileName);
+ builder.append("lectureAgeGenImportFile", lectureAgeGenImportFileName);
+ builder.append("eventsImportFile", eventsImportFileName);
+ builder.append("pecherieImportFile", typeEchoSpeciesImportFileName);
if (StringUtils.isNotEmpty(comment)) {
- addToBuilder(builder, "comment", comment);
+ builder.append("comment", comment);
}
- return builder.toString().trim();
+ return builder.toString();
+// StringBuilder builder = new StringBuilder();
+//
+// // Add selected survey
+// if (surveySelected != null) {
+// addToBuilder(builder, "surveySelected", surveySelected.getName());
+// }
+//
+// // Add all import files
+// addToBuilder(builder, "accessImportFile", accessImportFileName);
+// addToBuilder(builder, "accousticImportFile", accousticImportFileName);
+// addToBuilder(builder, "pecherieImportFile", pecherieImportFileName);
+// addToBuilder(builder, "lectureAgeGenImportFile", lectureAgeGenImportFileName);
+// addToBuilder(builder, "eventsImportFile", eventsImportFileName);
+// addToBuilder(builder, "pecherieImportFile", typeEchoSpeciesImportFileName);
+//
+// if (StringUtils.isNotEmpty(comment)) {
+// addToBuilder(builder, "comment", comment);
+// }
+// return builder.toString().trim();
}
- protected void addToBuilder(StringBuilder builder, String name, String value) {
- if (StringUtils.isNotEmpty(value)) {
- builder.append(" ");
- builder.append(name);
- builder.append("[");
- builder.append(value);
- builder.append("]");
- }
- }
+// protected void addToBuilder(StringBuilder builder, String name, String value) {
+// if (StringUtils.isNotEmpty(value)) {
+// builder.append(" ");
+// builder.append(name);
+// builder.append("[");
+// builder.append(value);
+// builder.append("]");
+// }
+// }
}
Modified: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/EchoBaseApplicationListener.java
===================================================================
--- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/EchoBaseApplicationListener.java 2011-11-09 08:49:36 UTC (rev 29)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/EchoBaseApplicationListener.java 2011-11-09 08:55:29 UTC (rev 30)
@@ -108,7 +108,7 @@
applicationContext.setRootContextSupplier(rootContextSupplier);
List<EchoBaseEntityEnum> entityEnums =
Lists.newArrayList(EchoBaseEntityEnum.values());
- entityEnums.remove(EchoBaseEntityEnum.EchoBaseUser);
+// entityEnums.remove(EchoBaseEntityEnum.EchoBaseUser);
DbMeta dbMeta = new DbMeta(entityEnums.toArray(new EchoBaseEntityEnum[entityEnums.size()]));
applicationContext.setDbMeta(dbMeta);
@@ -123,7 +123,8 @@
// init database (and create minimal admin user if required)
try {
boolean schemaExist = isSchemaCreated();
- if (!schemaExist) {
+ if (!schemaExist ||
+ configuration.getOptionAsBoolean("updateSchema")) {
updateSchema(configuration);
}
Modified: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/ImportAction.java
===================================================================
--- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/ImportAction.java 2011-11-09 08:49:36 UTC (rev 29)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/ImportAction.java 2011-11-09 08:55:29 UTC (rev 30)
@@ -1,7 +1,29 @@
+/*
+ * #%L
+ * EchoBase :: UI
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 Ifremer, Codelutin
+ * %%
+ * 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 fr.ifremer.echobase.ui.actions;
import com.google.common.collect.Maps;
-import com.opensymphony.xwork2.Preparable;
import fr.ifremer.echobase.entities.Survey;
import fr.ifremer.echobase.services.SurveyService;
import fr.ifremer.echobase.services.models.ImportModel;
@@ -19,6 +41,8 @@
*/
public class ImportAction extends EchoBaseActionSupport {
+ private static final long serialVersionUID = 1L;
+
protected static final Log log = LogFactory.getLog(ImportAction.class);
protected ImportModel importModel;
Property changes on: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/ImportAction.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/GetEntities.java (from rev 25, trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/GetTableDatas.java)
===================================================================
--- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/GetEntities.java (rev 0)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/GetEntities.java 2011-11-09 08:55:29 UTC (rev 30)
@@ -0,0 +1,220 @@
+/*
+ * #%L
+ * EchoBase :: UI
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 Ifremer, Codelutin
+ * %%
+ * 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 fr.ifremer.echobase.ui.actions.dbeditor;
+
+import fr.ifremer.echobase.services.DbEditorService;
+import fr.ifremer.echobase.ui.actions.EchoBaseActionSupport;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.struts2.json.JSONUtil;
+
+import java.util.Map;
+
+/**
+ * To obtain the data for the given request.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.1
+ */
+public class GetEntities extends EchoBaseActionSupport {
+
+ private static final long serialVersionUID = 1L;
+
+ /** Logger. */
+ private static final Log log = LogFactory.getLog(GetEntities.class);
+
+ private static final String SIDX_PREFIX = "tableDatas_";
+
+ /** Name of the table to load. */
+ protected String tableName;
+
+ /** Datas of the given table. */
+ protected Map<?,?>[] datas;
+
+ //get how many rows we want to have into the grid - rowNum attribute in the grid
+ protected Integer rows = 0;
+
+ //Get the requested page. By default grid sets this to 1.
+ protected Integer page = 0;
+
+ // sorting order - asc or desc
+ protected String sord;
+
+ // get index row - i.e. user click to sort.
+ protected String sidx;
+
+ // Search Field
+ protected String searchField;
+
+ // The Search String
+ protected String searchString;
+
+ // he Search Operation ['eq','ne','lt','le','gt','ge','bw','bn','in','ni','ew','en','cn','nc']
+ protected String searchOper;
+
+ protected String filters;
+
+ // Your Total Pages
+ protected Integer total = 0;
+
+ // All Record
+ protected Integer records = 0;
+
+ public Map<?,?>[] getDatas() {
+ return datas;
+ }
+
+ public void setTableName(String tableName) {
+ this.tableName = tableName;
+ }
+
+ @Override
+ public String execute() throws Exception {
+ DbEditorService dbEditorService = newService(DbEditorService.class);
+
+ int to = rows * page;
+ int from = to - rows;
+
+ Boolean ascendantOrder = null;
+
+ if (StringUtils.isNotEmpty(sidx)) {
+
+ // there is a sort to do
+ sidx = sidx.substring(SIDX_PREFIX.length());
+
+ ascendantOrder = "asc".equals(sord);
+ }
+
+ Object filterObject = null;
+
+
+ if (StringUtils.isNotEmpty(filters)) {
+ filterObject = JSONUtil.deserialize(filters);
+ }
+
+ if (log.isInfoEnabled()) {
+ log.info("searchField = " + searchField);
+ log.info("searchField = " + searchField);
+ log.info("searchString = " + searchString);
+ log.info("searchOper = " + searchOper);
+ log.info("filters = " + filters);
+ log.info("filterObject = " + filterObject);
+ log.info("sidx = " + sidx);
+ log.info("sord = " + sord);
+ }
+
+ DbEditorService.ResultDatas resultDatas =
+ dbEditorService.getDatas(tableName, from, to, sidx, ascendantOrder);
+
+ datas = resultDatas.getRows();
+
+ records = resultDatas.getCount();
+
+ //calculate the total pages for the query
+ total = (int) Math.ceil((double) records / (double) rows);
+
+ return SUCCESS;
+ }
+
+ public Integer getRows() {
+ return rows;
+ }
+
+ public void setRows(Integer rows) {
+ this.rows = rows;
+ }
+
+ public Integer getPage() {
+ return page;
+ }
+
+ public void setPage(Integer page) {
+ this.page = page;
+ }
+
+ public String getSord() {
+ return sord;
+ }
+
+ public void setSord(String sord) {
+ this.sord = sord;
+ }
+
+ public String getSidx() {
+ return sidx;
+ }
+
+ public void setSidx(String sidx) {
+ this.sidx = sidx;
+ }
+
+ public String getSearchField() {
+ return searchField;
+ }
+
+ public void setSearchField(String searchField) {
+ this.searchField = searchField;
+ }
+
+ public String getSearchString() {
+ return searchString;
+ }
+
+ public void setSearchString(String searchString) {
+ this.searchString = searchString;
+ }
+
+ public String getSearchOper() {
+ return searchOper;
+ }
+
+ public void setSearchOper(String searchOper) {
+ this.searchOper = searchOper;
+ }
+
+ public Integer getTotal() {
+ return total;
+ }
+
+ public void setTotal(Integer total) {
+ this.total = total;
+ }
+
+ public Integer getRecords() {
+ return records;
+ }
+
+ public void setRecords(Integer records) {
+ this.records = records;
+ }
+
+ public String getFilters() {
+ return filters;
+ }
+
+ public void setFilters(String filters) {
+ this.filters = filters;
+ }
+}
Property changes on: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/GetEntities.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Deleted: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/GetTableDatas.java
===================================================================
--- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/GetTableDatas.java 2011-11-09 08:49:36 UTC (rev 29)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/GetTableDatas.java 2011-11-09 08:55:29 UTC (rev 30)
@@ -1,63 +0,0 @@
-/*
- * #%L
- * EchoBase :: UI
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2011 Ifremer, Codelutin
- * %%
- * 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 fr.ifremer.echobase.ui.actions.dbeditor;
-
-import fr.ifremer.echobase.services.DbEditorService;
-import fr.ifremer.echobase.ui.actions.EchoBaseActionSupport;
-
-import java.util.Map;
-
-/**
- * To obtain the data for the given request.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 0.1
- */
-public class GetTableDatas extends EchoBaseActionSupport {
-
- private static final long serialVersionUID = 1L;
-
- /** Name of the table to load. */
- protected String tableName;
-
- /** Datas of the given table. */
- protected Map[] datas;
-
- public Map[] getDatas() {
- return datas;
- }
-
- public void setTableName(String tableName) {
- this.tableName = tableName;
- }
-
- @Override
- public String execute() throws Exception {
- DbEditorService dbEditorService = newService(DbEditorService.class);
- datas = dbEditorService.getDatas(tableName);
- return SUCCESS;
- }
-
-
-}
Copied: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/LoadEntities.java (from rev 25, trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/LoadTablePage.java)
===================================================================
--- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/LoadEntities.java (rev 0)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/LoadEntities.java 2011-11-09 08:55:29 UTC (rev 30)
@@ -0,0 +1,95 @@
+/*
+ * #%L
+ * EchoBase :: UI
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 Ifremer, Codelutin
+ * %%
+ * 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 fr.ifremer.echobase.ui.actions.dbeditor;
+
+import com.google.common.collect.Maps;
+import fr.ifremer.echobase.entities.meta.ColumnMeta;
+import fr.ifremer.echobase.entities.meta.DbMeta;
+import fr.ifremer.echobase.entities.meta.TableMeta;
+import fr.ifremer.echobase.services.DbEditorService;
+import fr.ifremer.echobase.ui.actions.EchoBaseActionSupport;
+import org.apache.commons.lang.StringUtils;
+
+import java.util.List;
+import java.util.Map;
+
+import static org.nuiton.i18n.I18n.l_;
+
+/**
+ * To load the db editor pages.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.1
+ */
+public class LoadEntities extends EchoBaseActionSupport {
+
+ private static final long serialVersionUID = 1L;
+
+ /** Name of the table to load. */
+ protected String tableName;
+
+ /** All tables availables */
+ protected Map<String, String> tableNames;
+
+ /** Metas of the table */
+ protected TableMeta tableMeta;
+
+ public String getTableName() {
+ return tableName;
+ }
+
+ public Map<String, String> getTableNames() {
+ return tableNames;
+ }
+
+ public List<ColumnMeta> getColumnMetas() {
+ return tableMeta.getColumns();
+ }
+
+ public void setTableName(String tableName) {
+ this.tableName = tableName;
+ }
+
+ @Override
+ public String input() throws Exception {
+ tableNames = Maps.newTreeMap();
+ DbMeta dbMeta = getEchoBaseApplicationContext().getDbMeta();
+ for (TableMeta tableMeta : dbMeta) {
+ String name = tableMeta.getName();
+ String i18nKey = tableMeta.getI18nKey();
+ tableNames.put(name, l_(getLocale(), i18nKey));
+ }
+ if (StringUtils.isEmpty(tableName)) {
+
+ // no table selected
+ addActionMessage(_("echobase.info.no.table.selected"));
+ } else {
+
+ // load table metas
+ DbEditorService dbEditorService = newService(DbEditorService.class);
+ tableMeta = dbEditorService.getTableMetas(tableName);
+ }
+ return INPUT;
+ }
+}
Property changes on: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/LoadEntities.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Deleted: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/LoadTablePage.java
===================================================================
--- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/LoadTablePage.java 2011-11-09 08:49:36 UTC (rev 29)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/LoadTablePage.java 2011-11-09 08:55:29 UTC (rev 30)
@@ -1,96 +0,0 @@
-/*
- * #%L
- * EchoBase :: UI
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2011 Ifremer, Codelutin
- * %%
- * 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 fr.ifremer.echobase.ui.actions.dbeditor;
-
-import com.google.common.collect.Maps;
-import fr.ifremer.echobase.entities.meta.ColumnMeta;
-import fr.ifremer.echobase.entities.meta.DbMeta;
-import fr.ifremer.echobase.entities.meta.TableMeta;
-import fr.ifremer.echobase.services.DbEditorService;
-import fr.ifremer.echobase.ui.actions.EchoBaseActionSupport;
-import org.apache.commons.lang.StringUtils;
-
-import java.util.List;
-import java.util.Map;
-
-import static org.nuiton.i18n.I18n._;
-import static org.nuiton.i18n.I18n.l_;
-
-/**
- * To load the db editor page.s
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 0.1
- */
-public class LoadTablePage extends EchoBaseActionSupport {
-
- private static final long serialVersionUID = 1L;
-
- /** Name of the table to load. */
- protected String tableName;
-
- /** All tables availables */
- protected Map<String, String> tableNames;
-
- /** Metas of the table */
- protected TableMeta tableMeta;
-
- public String getTableName() {
- return tableName;
- }
-
- public Map<String, String> getTableNames() {
- return tableNames;
- }
-
- public List<ColumnMeta> getColumnMetas() {
- return tableMeta.getColumns();
- }
-
- public void setTableName(String tableName) {
- this.tableName = tableName;
- }
-
- @Override
- public String input() throws Exception {
- tableNames = Maps.newTreeMap();
- DbMeta dbMeta = getEchoBaseApplicationContext().getDbMeta();
- for (TableMeta tableMeta : dbMeta) {
- String name = tableMeta.getName();
- String i18nKey = tableMeta.getI18nKey();
- tableNames.put(name, l_(getLocale(), i18nKey));
- }
- if (StringUtils.isEmpty(tableName)) {
-
- // no table selected
- addActionMessage(_("echobase.info.no.table.selected"));
- } else {
-
- // load table metas
- DbEditorService dbEditorService = newService(DbEditorService.class);
- tableMeta = dbEditorService.getTableMetas(tableName);
- }
- return INPUT;
- }
-}
Added: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/SaveEntity.java
===================================================================
--- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/SaveEntity.java (rev 0)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/SaveEntity.java 2011-11-09 08:55:29 UTC (rev 30)
@@ -0,0 +1,117 @@
+/*
+ * #%L
+ * EchoBase :: UI
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 Ifremer, Codelutin
+ * %%
+ * 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 fr.ifremer.echobase.ui.actions.dbeditor;
+
+import com.google.common.collect.Maps;
+import fr.ifremer.echobase.entities.meta.TableMeta;
+import fr.ifremer.echobase.services.DbEditorService;
+import fr.ifremer.echobase.ui.actions.EchoBaseActionSupport;
+import org.apache.commons.lang.StringUtils;
+import org.apache.struts2.interceptor.ParameterAware;
+import org.nuiton.util.beans.PropertyDiff;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Save the edition of a row of a table.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.1
+ */
+public class SaveEntity extends EchoBaseActionSupport implements ParameterAware {
+
+ private static final long serialVersionUID = 1L;
+
+ /** Name of the table to load. */
+ protected String tableName;
+
+ /** id of entity to save. */
+ protected String id;
+
+ /** Metas of the table */
+ protected TableMeta tableMeta;
+
+ protected Map<String, String[]> params;
+
+ protected transient DbEditorService dbEditorService;
+
+ public void setTableName(String tableName) {
+ this.tableName = tableName;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ @Override
+ public String execute() throws Exception {
+
+ DbEditorService dbEditorService = newService(DbEditorService.class);
+ TableMeta tableMeta = dbEditorService.getTableMetas(tableName);
+ Map<String, String> properties = Maps.newHashMap();
+ List<String> columnNames = tableMeta.getColumnNames();
+ for (String columnName : columnNames) {
+ if (params.containsKey(columnName)) {
+
+ // there is a such property to edit
+ String[] values = params.get(columnName);
+
+ if (values.length > 0) {
+
+ // take only the first value
+ String propertyValue = values[0];
+ if (StringUtils.isNotEmpty(propertyValue)) {
+
+ // only keep properties with no empty value
+ properties.put(columnName, propertyValue);
+ }
+ }
+ }
+ }
+
+ PropertyDiff[] diffs =
+ dbEditorService.saveEntity(tableMeta,
+ id,
+ properties,
+ getEchoBaseSession().getEchoBaseUser());
+
+ for (PropertyDiff diff : diffs) {
+ addActionMessage(_("echobase.message.modified.property",
+ diff.getSourceProperty(),
+ diff.getSourceValue(),
+ diff.getTargetValue())
+ );
+ }
+ return NONE;
+ }
+
+ @Override
+ public void setParameters(Map<String, String[]> parameters) {
+ params = Maps.newHashMap();
+ params.putAll(parameters);
+ }
+
+}
+
Property changes on: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/SaveEntity.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/echobase-ui/src/main/resources/config/struts-dbeditor.xml
===================================================================
--- trunk/echobase-ui/src/main/resources/config/struts-dbeditor.xml 2011-11-09 08:49:36 UTC (rev 29)
+++ trunk/echobase-ui/src/main/resources/config/struts-dbeditor.xml 2011-11-09 08:55:29 UTC (rev 30)
@@ -32,17 +32,22 @@
<package name="dbeditor" extends="loggued" namespace="/dbeditor">
<action name="dbeditor" method="input"
- class="fr.ifremer.echobase.ui.actions.dbeditor.LoadTablePage">
+ class="fr.ifremer.echobase.ui.actions.dbeditor.LoadEntities">
<interceptor-ref name="basicStackLoggued"/>
<result name="input">/WEB-INF/jsp/dbeditor/dbeditor.jsp</result>
</action>
-
+
<action name="getTableDatas"
- class="fr.ifremer.echobase.ui.actions.dbeditor.GetTableDatas">
+ class="fr.ifremer.echobase.ui.actions.dbeditor.GetEntities">
<interceptor-ref name="basicStackLoggued"/>
<result type="json"/>
</action>
+ <action name="editTableData"
+ class="fr.ifremer.echobase.ui.actions.dbeditor.SaveEntity">
+ <interceptor-ref name="basicStackLoggued"/>
+ </action>
+
</package>
</struts>
Modified: trunk/echobase-ui/src/main/resources/config/struts-import.xml
===================================================================
--- trunk/echobase-ui/src/main/resources/config/struts-import.xml 2011-11-09 08:49:36 UTC (rev 29)
+++ trunk/echobase-ui/src/main/resources/config/struts-import.xml 2011-11-09 08:55:29 UTC (rev 30)
@@ -1,5 +1,29 @@
<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+ #%L
+ EchoBase :: UI
+
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2011 Ifremer, Codelutin
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+ #L%
+ -->
+
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.1.7.dtd">
Property changes on: trunk/echobase-ui/src/main/resources/config/struts-import.xml
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/echobase-ui/src/main/resources/i18n/echobase-ui_fr_FR.properties
===================================================================
--- trunk/echobase-ui/src/main/resources/i18n/echobase-ui_fr_FR.properties 2011-11-09 08:49:36 UTC (rev 29)
+++ trunk/echobase-ui/src/main/resources/i18n/echobase-ui_fr_FR.properties 2011-11-09 08:55:29 UTC (rev 30)
@@ -43,8 +43,10 @@
echobase.menu.import=Imports
echobase.menu.logs=Logs
echobase.menu.users=Utilisateurs
+echobase.message.modified.property=
echobase.msg.warnImportInProgress=Merci de ne pas fermer la fenêtre pour pouvoir acceder au résultats de l'import.
echobase.survey.selectHeader=Selectionnez une campagne
+echobase.title.dbEditor=Modification de la base
echobase.title.export=Export
echobase.title.import=Imports
echobase.title.importProgress=Import en cours
Modified: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/dbeditor/dbeditor.jsp
===================================================================
--- trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/dbeditor/dbeditor.jsp 2011-11-09 08:49:36 UTC (rev 29)
+++ trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/dbeditor/dbeditor.jsp 2011-11-09 08:55:29 UTC (rev 30)
@@ -36,7 +36,7 @@
$('[name="tableName"]').change(function(event) {
- var url = "${reloadUrl}?" + $.param({ tableName:this.value});
+ var url = "${reloadUrl}?" + $.param({tableName:this.value});
window.location = url;
});
});
@@ -46,7 +46,6 @@
<s:select key="tableName"
label='%{getText("echobase.common.tableName")}'
list="tableNames" headerKey="" headerValue=""/>
-
</div>
<br/>
@@ -56,25 +55,35 @@
<s:param name="tableName" value="%{tableName}"/>
</s:url>
+ <s:url id="editUrl" action="editTableData" namespace="/dbeditor"
+ escapeAmp="false">
+ <s:param name="tableName" value="%{tableName}"/>
+ </s:url>
+
<sjg:grid id="tableDatas"
caption="%{getText('echobase.common.tableDatas', tableNames[tableName])}"
dataType="json" href="%{loadUrl}" gridModel="datas"
- pager="true" pagerButtons="false" pagerInput="false"
+ pager="true" pagerButtons="true" pagerInput="true"
navigator="true" autowidth="true" rownumbers="false"
navigatorEdit="true"
navigatorDelete="false"
navigatorSearch="true"
navigatorRefresh="true"
navigatorAdd="false"
- resizable="true" editinline="false">
+ editurl="%{editUrl}"
+ rowList="10,15,20, 50"
+ rowNum="10"
+ resizable="true" editinline="false"
+ navigatorSearchOptions="{multipleGroup:false,showQuery:true,multipleSearch:true,sopt:['eq','ne','cn','nc','bw','bn','ew','en','lt','le','gt','ge','nu','nn','in','ni']}"
+ >
- <sjg:gridColumn name="id" title="id" hidden="true"/>
+ <sjg:gridColumn name="id" title="id" hidden="true" editable="true"/>
<s:iterator value="columnMetas" var="meta" status="status">
- <sjg:gridColumn name="%{#meta.name}" title="%{getText(#meta.i18nKey)}"
- edittype="%{#meta.columnType}"
- sortable="false" editable="true"/>
+ <sjg:gridColumn name="%{#meta.name}"
+ title="%{getText(#meta.i18nKey)}"
+ sortable="true" editable="true" />
</s:iterator>
1
0