r93 - in trunk: echobase-services/src/main/java/fr/ifremer/echobase/services echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor echobase-ui/src/main/resources/config echobase-ui/src/main/webapp/WEB-INF/includes
Author: sletellier Date: 2011-11-18 10:32:42 +0100 (Fri, 18 Nov 2011) New Revision: 93 Url: http://forge.codelutin.com/repositories/revision/echobase/93 Log: - Replace "failled" to "failed" - Fix footer copyright - Improve import error message - Using @InputConfig to call input method on validation error Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/DbEditorService.java trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/ImportTable.java trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/LoadEntities.java trunk/echobase-ui/src/main/resources/config/struts-dbeditor.xml trunk/echobase-ui/src/main/webapp/WEB-INF/includes/footer.jsp 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-17 16:53:37 UTC (rev 92) +++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/DbEditorService.java 2011-11-18 09:32:42 UTC (rev 93) @@ -373,7 +373,7 @@ property = topiaId; } - // Convert date to timestamp + // Format date if (columnMeta.isDate() && property != null) { Date date = (Date) property; property = getDateFormat().format(date); @@ -416,14 +416,14 @@ // Commit getTransaction().commitTransaction(); } catch (Exception eee) { - log.error("Failled to read import file " + importFile.getName(), eee); + log.error("Failed to read import file " + importFile.getName(), eee); throw new EchoBaseTechnicalException(eee); } finally { if (bf != null) { try { bf.close(); } catch (IOException eee) { - log.error("Failled to close import file " + importFile.getName(), eee); + log.error("Failed to close import file " + importFile.getName(), eee); throw new EchoBaseTechnicalException(eee); } } @@ -466,14 +466,14 @@ writer = new FileWriter(file, true); writer.write(csvContent.toString()); } catch (IOException eee) { - log.error("Failled to write modif export file", eee); + log.error("Failed to write modif export file", eee); throw new EchoBaseTechnicalException(eee); } finally { if (writer != null) { try { writer.close(); } catch (IOException eee) { - log.error("Failled to close modif export file", eee); + log.error("Failed to close modif export file", eee); throw new EchoBaseTechnicalException(eee); } } Modified: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/ImportTable.java =================================================================== --- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/ImportTable.java 2011-11-17 16:53:37 UTC (rev 92) +++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/ImportTable.java 2011-11-18 09:32:42 UTC (rev 93) @@ -23,7 +23,9 @@ */ package fr.ifremer.echobase.ui.actions.dbeditor; +import com.google.common.base.Throwables; import com.google.common.collect.Lists; +import com.opensymphony.xwork2.interceptor.annotations.InputConfig; import fr.ifremer.echobase.services.DbEditorService; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -36,6 +38,7 @@ * To import datas from import file. * * FIXME 20111117 sletellier : extends {@link LoadEntities} find a better way to redirect to dbeditor page on validation error + * UPDATE 20111118 sletellier : with {@link @InputConfig} probleme is solve ? dbeditor root page is prepared only on validation error... * * @author sletellier <letellier@codelutin.com> * @since 0.1 @@ -88,14 +91,24 @@ this.propertyDiffs = propertyDiffs; } - public String doImportModif() throws Exception { + @Override + @InputConfig(methodName = "input") // to call inpu method on validation error to initialize dbeditor page + public String execute() throws Exception { DbEditorService dbEditorService = newService(DbEditorService.class); - propertyDiffs = dbEditorService.importDatas(tableName, - modifImport, - getEchoBaseSession().getEchoBaseUser()); + try { + propertyDiffs = dbEditorService.importDatas(tableName, + modifImport, + getEchoBaseSession().getEchoBaseUser()); + } catch (Exception eee) { + String message = "Failed to import datas : "; + log.error(message, eee); + addActionError(message + Throwables.getRootCause(eee).getMessage()); + + return ERROR; + } for (PropertyDiff[] diffs : propertyDiffs) { for (PropertyDiff diff : diffs) { String msg = _("echobase.message.modified.property", 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-17 16:53:37 UTC (rev 92) +++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/LoadEntities.java 2011-11-18 09:32:42 UTC (rev 93) @@ -43,7 +43,7 @@ * @author tchemit <chemit@codelutin.com> * @since 0.1 */ -public class LoadEntities extends EchoBaseActionSupport implements Preparable { +public class LoadEntities extends EchoBaseActionSupport { private static final long serialVersionUID = 1L; @@ -73,7 +73,7 @@ } @Override - public void prepare() throws Exception { + public String input() throws Exception { tableNames = Maps.newTreeMap(); DbMeta dbMeta = getEchoBaseApplicationContext().getDbMeta(); for (TableMeta tableMeta : dbMeta) { @@ -91,6 +91,7 @@ DbEditorService dbEditorService = newService(DbEditorService.class); tableMeta = dbEditorService.getTableMetas(tableName); } + return INPUT; } public String getEditType(ColumnMeta meta) { Modified: trunk/echobase-ui/src/main/resources/config/struts-dbeditor.xml =================================================================== --- trunk/echobase-ui/src/main/resources/config/struts-dbeditor.xml 2011-11-17 16:53:37 UTC (rev 92) +++ trunk/echobase-ui/src/main/resources/config/struts-dbeditor.xml 2011-11-18 09:32:42 UTC (rev 93) @@ -41,10 +41,10 @@ </result-types> <!-- load db editor main page --> - <action name="dbeditor" + <action name="dbeditor" method="input" class="fr.ifremer.echobase.ui.actions.dbeditor.LoadEntities"> <interceptor-ref name="paramsPrepareParamsStackLoggued"/> - <result>/WEB-INF/jsp/dbeditor/dbeditor.jsp</result> + <result name="input">/WEB-INF/jsp/dbeditor/dbeditor.jsp</result> </action> <!-- get foreign entities as a select box --> @@ -72,7 +72,7 @@ </action> <!-- save the modified entity (no result as a grid json edit action)--> - <action name="doImport" method="doImportModif" class="fr.ifremer.echobase.ui.actions.dbeditor.ImportTable"> + <action name="doImport" class="fr.ifremer.echobase.ui.actions.dbeditor.ImportTable"> <interceptor-ref name="paramsPrepareParamsStackLoggued"/> <result>/WEB-INF/jsp/dbeditor/modifImportResult.jsp</result> <result name="input">/WEB-INF/jsp/dbeditor/dbeditor.jsp</result> Modified: trunk/echobase-ui/src/main/webapp/WEB-INF/includes/footer.jsp =================================================================== --- trunk/echobase-ui/src/main/webapp/WEB-INF/includes/footer.jsp 2011-11-17 16:53:37 UTC (rev 92) +++ trunk/echobase-ui/src/main/webapp/WEB-INF/includes/footer.jsp 2011-11-18 09:32:42 UTC (rev 93) @@ -53,7 +53,7 @@ </li> <li> Copyright 2011 - <a href="http://www.ifremer.fr">Echobase</a> + <a href="http://www.ifremer.fr">Ifremer</a> <a href="http://www.codelutin.com" title="Code Lutin" target="_blank">Code Lutin</a> </li>
participants (1)
-
sletellier@users.forge.codelutin.com