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
r89 - 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 echobase-ui/src/main/resources/config echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/dbeditor echobase-ui/src/main/resources/i18n echobase-ui/src/main/webapp/WEB-INF/jsp/dbeditor
by sletellier@users.forge.codelutin.com 17 Nov '11
by sletellier@users.forge.codelutin.com 17 Nov '11
17 Nov '11
Author: sletellier
Date: 2011-11-17 13:33:03 +0100 (Thu, 17 Nov 2011)
New Revision: 89
Url: http://forge.codelutin.com/repositories/revision/echobase/89
Log:
For DBeditor :
- Complete i18n file
- Refactor import action
- Add success import page
- Add redirect main page on save or import
- Change log message on creation
- Switch label between edition and creation
Added:
trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/dbeditor/
trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/dbeditor/ImportTable-doImport-validation.xml
trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/dbeditor/modifImportResult.jsp
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/java/fr/ifremer/echobase/ui/actions/dbeditor/SaveEntity.java
trunk/echobase-ui/src/main/resources/config/struts-dbeditor.xml
trunk/echobase-ui/src/main/resources/config/struts-user.xml
trunk/echobase-ui/src/main/resources/i18n/echobase-ui_fr_FR.properties
trunk/echobase-ui/src/main/resources/log4j.properties
trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/dbeditor/dbeditor.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-16 17:33:28 UTC (rev 88)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/DbEditorService.java 2011-11-17 12:33:03 UTC (rev 89)
@@ -224,7 +224,8 @@
TopiaEntity entityToSave;
// Find or create entity if no id
- if (StringUtils.isEmpty(id)) {
+ boolean create = StringUtils.isEmpty(id);
+ if (create) {
entityToSave = dao.create();
} else {
entityToSave = dao.findByTopiaId(id);
@@ -267,10 +268,15 @@
);
StringBuilder buffer;
- if (length == 1) {
- buffer = new StringBuilder("Une propriété a été modifiée :");
+
+ if (create) {
+ buffer = new StringBuilder("Une entité à été crée :");
} else {
- buffer = new StringBuilder(length + " propriétés ont été modifiées :");
+ if (length == 1) {
+ buffer = new StringBuilder("Une propriété a été modifiée :");
+ } else {
+ buffer = new StringBuilder(length + " propriétés ont été modifiées :");
+ }
}
for (int i = 0; i < length; i++) {
PropertyDiff diff = propertyDiffs[i];
@@ -293,11 +299,19 @@
}
}
- buffer.append(String.format("\n Propriété '%s', ancienne valeur : %s, nouvelle valeur : %s",
- propertyName,
- sourceValue,
- targetValue
- ));
+
+ if (create) {
+ buffer.append(String.format("\n Propriété '%s', valeur : %s",
+ propertyName,
+ targetValue
+ ));
+ } else {
+ buffer.append(String.format("\n Propriété '%s', ancienne valeur : %s, nouvelle valeur : %s",
+ propertyName,
+ sourceValue,
+ targetValue
+ ));
+ }
}
dao1.create(
EntityModificationLog.PROPERTY_ENTITY_TYPE, entityType.getSimpleName(),
@@ -361,9 +375,7 @@
public List<PropertyDiff[]> importDatas(String tableName,
File importFile,
EchoBaseUser user) {
-
- TableMeta tableMeta = getTableMetas(tableName);
-
+ TableMeta tableMetas = getTableMetas(tableName);
BufferedReader bf = null;
List<PropertyDiff[]> result = Lists.newArrayList();
try {
@@ -384,12 +396,14 @@
}
// Save entity
- PropertyDiff[] propertyDiffs = saveEntity(tableMeta, id, valuesMap, user, false);
+ PropertyDiff[] propertyDiffs = saveEntity(tableMetas, id, valuesMap, user, false);
result.add(propertyDiffs);
line = bf.readLine();
}
+ // Commit
+ getTransaction().commitTransaction();
} catch (Exception eee) {
log.error("Failled to read import file " + importFile.getName(), 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-16 17:33:28 UTC (rev 88)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/ImportTable.java 2011-11-17 12:33:03 UTC (rev 89)
@@ -23,8 +23,8 @@
*/
package fr.ifremer.echobase.ui.actions.dbeditor;
+import com.google.common.collect.Lists;
import fr.ifremer.echobase.services.DbEditorService;
-import fr.ifremer.echobase.ui.actions.EchoBaseActionSupport;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.nuiton.util.beans.PropertyDiff;
@@ -35,65 +35,66 @@
/**
* To import datas from import file.
*
+ * FIXME 20111117 sletellier : extends {@link LoadEntities} find a better way to redirect to dbeditor page on validation error
+ *
* @author sletellier <letellier(a)codelutin.com>
* @since 0.1
*/
-public class ImportTable extends EchoBaseActionSupport {
+public class ImportTable extends LoadEntities {
private static final long serialVersionUID = 1L;
/** Logger. */
private static final Log log = LogFactory.getLog(ImportTable.class);
- /** Name of the table to load. */
- protected String tableName;
+ protected File modifImport;
+ protected String modifImportContentType;
+ protected String modifImportFileName;
- protected File upfile;
- protected String upfileContentType;
- protected String upfileFileName;
+ protected List<PropertyDiff[]> propertyDiffs;
- public void setTableName(String tableName) {
- this.tableName = tableName;
+ public File getModifImport() {
+ return modifImport;
}
- public File getUpfile() {
- return upfile;
+ public void setModifImport(File modifImport) {
+ this.modifImport = modifImport;
}
- public void setUpfile(File upfile) {
- this.upfile = upfile;
+ public String getModifImportContentType() {
+ return modifImportContentType;
}
- public String getUpfileContentType() {
- return upfileContentType;
+ public void setModifImportContentType(String modifImportContentType) {
+ this.modifImportContentType = modifImportContentType;
}
- public void setUpfileContentType(String upfileContentType) {
- this.upfileContentType = upfileContentType;
+ public String getModifImportFileName() {
+ return modifImportFileName;
}
- public String getUpfileFileName() {
- return upfileFileName;
+ public void setModifImportFileName(String modifImportFileName) {
+ this.modifImportFileName = modifImportFileName;
}
- public void setUpfileFileName(String upfileFileName) {
- this.upfileFileName = upfileFileName;
+ public List<PropertyDiff[]> getPropertyDiffs() {
+ if (propertyDiffs == null) {
+ return Lists.newArrayList();
+ }
+ return propertyDiffs;
}
- @Override
- public String execute() throws Exception {
+ public void setPropertyDiffs(List<PropertyDiff[]> propertyDiffs) {
+ this.propertyDiffs = propertyDiffs;
+ }
- if (upfile == null || !upfile.exists()) {
- addActionError(_("echobase.error.fileNotFound"));
- return ERROR;
- }
+ public String doImportModif() throws Exception {
DbEditorService dbEditorService = newService(DbEditorService.class);
- List<PropertyDiff[]> propertyDiffs =
- dbEditorService.importDatas(tableName,
- upfile,
- getEchoBaseSession().getEchoBaseUser());
+ propertyDiffs = dbEditorService.importDatas(tableName,
+ modifImport,
+ getEchoBaseSession().getEchoBaseUser());
for (PropertyDiff[] diffs : propertyDiffs) {
for (PropertyDiff diff : diffs) {
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-16 17:33:28 UTC (rev 88)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/LoadEntities.java 2011-11-17 12:33:03 UTC (rev 89)
@@ -24,6 +24,7 @@
package fr.ifremer.echobase.ui.actions.dbeditor;
import com.google.common.collect.Maps;
+import com.opensymphony.xwork2.Preparable;
import fr.ifremer.echobase.entities.meta.ColumnMeta;
import fr.ifremer.echobase.entities.meta.DbMeta;
import fr.ifremer.echobase.entities.meta.TableMeta;
@@ -33,7 +34,6 @@
import org.nuiton.topia.persistence.TopiaEntity;
import java.util.Date;
-import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@@ -45,7 +45,7 @@
* @author tchemit <chemit(a)codelutin.com>
* @since 0.1
*/
-public class LoadEntities extends EchoBaseActionSupport {
+public class LoadEntities extends EchoBaseActionSupport implements Preparable {
private static final long serialVersionUID = 1L;
@@ -58,10 +58,6 @@
/** Metas of the table */
protected TableMeta tableMeta;
- public String getTableName() {
- return tableName;
- }
-
public Map<String, String> getTableNames() {
return tableNames;
}
@@ -74,8 +70,12 @@
this.tableName = tableName;
}
+ public String getTableName() {
+ return tableName;
+ }
+
@Override
- public String execute() throws Exception {
+ public void prepare() throws Exception {
tableNames = Maps.newTreeMap();
DbMeta dbMeta = getEchoBaseApplicationContext().getDbMeta();
for (TableMeta tableMeta : dbMeta) {
@@ -93,7 +93,6 @@
DbEditorService dbEditorService = newService(DbEditorService.class);
tableMeta = dbEditorService.getTableMetas(tableName);
}
- return SUCCESS;
}
public String getEditType(ColumnMeta meta) {
Modified: 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 2011-11-16 17:33:28 UTC (rev 88)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/SaveEntity.java 2011-11-17 12:33:03 UTC (rev 89)
@@ -59,6 +59,10 @@
this.tableName = tableName;
}
+ public String getTableName() {
+ return tableName;
+ }
+
public void setId(String id) {
this.id = id;
}
@@ -102,7 +106,7 @@
diff.getTargetValue())
);
}
- return NONE;
+ return SUCCESS;
}
@Override
Modified: trunk/echobase-ui/src/main/resources/config/struts-dbeditor.xml
===================================================================
--- trunk/echobase-ui/src/main/resources/config/struts-dbeditor.xml 2011-11-16 17:33:28 UTC (rev 88)
+++ trunk/echobase-ui/src/main/resources/config/struts-dbeditor.xml 2011-11-17 12:33:03 UTC (rev 89)
@@ -31,9 +31,19 @@
<package name="dbeditor" extends="loggued" namespace="/dbeditor">
+ <result-types>
+ <result-type name="redirectToDbEditor" class="org.apache.struts2.dispatcher.ServletActionRedirectResult">
+ <param name="namespace">/dbeditor</param>
+ <param name="actionName">dbeditor</param>
+ <param name="tableName">${tableName}</param>
+ <param name="supressEmptyParameters">true</param>
+ </result-type>
+ </result-types>
+
<!-- load db editor main page -->
<action name="dbeditor"
class="fr.ifremer.echobase.ui.actions.dbeditor.LoadEntities">
+ <interceptor-ref name="paramsPrepareParamsStackLoggued"/>
<result>/WEB-INF/jsp/dbeditor/dbeditor.jsp</result>
</action>
@@ -57,12 +67,16 @@
<!-- save the modified entity (no result as a grid json edit action)-->
<action name="editTableData"
- class="fr.ifremer.echobase.ui.actions.dbeditor.SaveEntity"/>
+ class="fr.ifremer.echobase.ui.actions.dbeditor.SaveEntity">
+ <result name="success" type="redirectToDbEditor"/>
+ </action>
<!-- save the modified entity (no result as a grid json edit action)-->
- <action name="doImport"
- class="fr.ifremer.echobase.ui.actions.dbeditor.ImportTable">
+ <action name="doImport" method="doImportModif" 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>
+ <result name="error">/WEB-INF/jsp/dbeditor/modifImportResult.jsp</result>
</action>
<!-- save the modified entity (no result as a grid json edit action)-->
Modified: trunk/echobase-ui/src/main/resources/config/struts-user.xml
===================================================================
--- trunk/echobase-ui/src/main/resources/config/struts-user.xml 2011-11-16 17:33:28 UTC (rev 88)
+++ trunk/echobase-ui/src/main/resources/config/struts-user.xml 2011-11-17 12:33:03 UTC (rev 89)
@@ -89,7 +89,7 @@
<!-- Get modification logs entries -->
<action name="getEntityModificationLogs" method="entityModificationLogs"
- class="fr.ifremer.echobase.ui.actions.dbeditor.ImportTable">
+ class="fr.ifremer.echobase.ui.actions.dbeditor.GetEntities">
<result type="json"/>
</action>
Added: trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/dbeditor/ImportTable-doImport-validation.xml
===================================================================
--- trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/dbeditor/ImportTable-doImport-validation.xml (rev 0)
+++ trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/dbeditor/ImportTable-doImport-validation.xml 2011-11-17 12:33:03 UTC (rev 89)
@@ -0,0 +1,14 @@
+<!DOCTYPE validators PUBLIC
+ "-//OpenSymphony Group//XWork Validator 1.0.2//EN"
+ "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
+<validators>
+
+ <field name="modifImport">
+
+ <field-validator type="required">
+ <message key="echobase.validation.dbeditor.modifImport.required"/>
+ </field-validator>
+
+ </field>
+
+</validators>
\ No newline at end of file
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-16 17:33:28 UTC (rev 88)
+++ trunk/echobase-ui/src/main/resources/i18n/echobase-ui_fr_FR.properties 2011-11-17 12:33:03 UTC (rev 89)
@@ -28,16 +28,19 @@
echobase.common.query.description=Description
echobase.common.query.name=Nom
echobase.common.request.result=Résultat de la requête sql
+echobase.common.reset=Annuler
echobase.common.sqlQueries=Requêtes enregistrées
echobase.common.tableName=Nom de la table
echobase.common.user=Utilisateur
echobase.common.voyage=Voyage
echobase.common.voyagesToSelect=Voyage à exporter
+echobase.dbEditor.propertyDiffsResult=Nombres d'entrées importés \:
echobase.dbeditor.export=Exporter
echobase.dbeditor.import=Importer
echobase.embeddedApplication.configuration=Configuration de l'application embarquée
echobase.error.bad.password=Mot de passe incorrrect
echobase.error.email.already.used=
+echobase.error.fileDontExist=
echobase.error.fileNotFound=
echobase.error.importArgument=
echobase.error.login.unknown=Utilisateur inconnu
@@ -74,7 +77,7 @@
echobase.menu.logs=Visualiser les modifications
echobase.menu.users=Gérer les utilisateurs
echobase.message.askAdministratorPassword=Demander à un administrateur le mot de passe pour l'utilisateur donné
-echobase.message.modified.property=
+echobase.message.modified.property=Propriété '%s', ancienne valeur : %s, nouvelle valeur : %s",
echobase.message.noEntrySelection=Aucune entrée sélectionnée
echobase.msg.warnImportInProgress=Merci de ne pas fermer la fenêtre pour pouvoir accéder aux résultats de l'import.
echobase.sqlQuery.configuration=Configuration de la requête
@@ -100,3 +103,5 @@
echobase.validation.login.password.requiredstring=Le mot de passe est obligatoire
echobase.validation.login.wrongLogin=Le login est déjà utilisé
echobase.voyage.selectHeader=Selectionnez un voyage
+echobase.dbeditor.create=Création de '%s'
+echobase.dbeditor.edit=Edition de '%s'
Modified: trunk/echobase-ui/src/main/resources/log4j.properties
===================================================================
--- trunk/echobase-ui/src/main/resources/log4j.properties 2011-11-16 17:33:28 UTC (rev 88)
+++ trunk/echobase-ui/src/main/resources/log4j.properties 2011-11-17 12:33:03 UTC (rev 89)
@@ -32,4 +32,4 @@
log4j.appender.A1.layout.ConversionPattern=%d %5p [%t] (%F:%L) %M - %m%n
# Toute l'application
-log4j.logger.fr.ifremer.echobase=INFO
+log4j.logger.fr.ifremer.echobase=INFO
\ No newline at end of file
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-16 17:33:28 UTC (rev 88)
+++ trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/dbeditor/dbeditor.jsp 2011-11-17 12:33:03 UTC (rev 89)
@@ -55,6 +55,9 @@
$.subscribe('rowselect', function(event) {
+ // Display edit label
+ toggleLabels(true);
+
// get selected id
var id = event.originalEvent.id;
@@ -108,6 +111,19 @@
});
});
+ function toggleLabels(edit) {
+ var editDiv = $(document.getElementById("editDiv"));
+ var createDiv = $(document.getElementById("createDiv"));
+
+ if (edit) {
+ createDiv.hide();
+ editDiv.show();
+ } else {
+ editDiv.hide();
+ createDiv.show();
+ }
+ }
+
function formatEntityLabel(cellvalue, options, rowObject) {
var columnName = options.colModel.name + "_lib";
return rowObject[columnName];
@@ -122,17 +138,17 @@
enctype="multipart/form-data" theme="simple" cssClass="floatLeft">
<s:hidden key="tableName"/>
- <s:file name="upfile"
+ <s:file name="modifImport"
required="true"
key="echobase.dbeditor.importFile"
disabled="%{tableSelected}"/>
- <s:submit key="echobase.dbeditor.import" disabled="%{tableSelected}"/>
+ <s:submit value="%{getText('echobase.dbeditor.import')}" disabled="%{tableSelected}"/>
</s:form>
<s:form id="exportForm" action="doExport" namespace="/dbeditor" theme="simple" cssClass="floatRight">
<s:hidden key="tableName"/>
- <s:submit key="echobase.dbeditor.export" disabled="%{tableSelected}"/>
+ <s:submit value="%{getText('echobase.dbeditor.export')}" disabled="%{tableSelected}"/>
</s:form>
</div>
<br class="clearBoth"/>
@@ -148,9 +164,10 @@
<s:param name="tableName" value="%{tableName}"/>
</s:url>
+ <s:set var="tableI18nName" value="%{getText('echobase.common.tableDatas', tableNames[tableName])}"/>
<sjg:grid id="datas" dataType="json" href="%{loadUrl}" gridModel="datas"
- caption="%{getText('echobase.common.tableDatas', tableNames[tableName])}"
+ caption="%{tableI18nName}"
pager="true" pagerButtons="true" pagerInput="true" navigator="true"
autowidth="true" rownumbers="false" viewrecords="true"
navigatorEdit="true" navigatorSearch="true"
@@ -198,10 +215,21 @@
<s:form id="editForm" action="editTableData" namespace="/dbeditor">
<fieldset>
<legend>
- <s:text name="echobase.common.user"/>
+ <div id="editDiv" style="display: none;">
+ <s:text name="echobase.dbeditor.edit">
+ <s:param value="%{tableI18nName}"/>
+ </s:text>
+ </div>
+ <div id="createDiv">
+ <s:text name="echobase.dbeditor.create">
+ <s:param value="%{tableI18nName}"/>
+ </s:text>
+ </div>
</legend>
- <s:hidden id="id" key="id"/>
<s:hidden key="tableName"/>
+
+ <%-- hidden field dont reset --%>
+ <s:textfield id="id" name="id" cssClass="hidden"/>
<s:iterator value="columnMetas" var="meta" status="status">
<s:url id="urlName"
action="getForeignEntities"
@@ -240,7 +268,7 @@
</s:iterator>
</fieldset>
<ul class="toolbar floatRight">
- <li><s:reset key="echobase.common.reset"/></li>
+ <li><s:reset key="echobase.common.reset" onclick="toggleLabels(false)"/></li>
<li><s:submit name="submit" key="echobase.action.save" theme="simple"/></li>
</ul>
</s:form>
Added: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/dbeditor/modifImportResult.jsp
===================================================================
--- trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/dbeditor/modifImportResult.jsp (rev 0)
+++ trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/dbeditor/modifImportResult.jsp 2011-11-17 12:33:03 UTC (rev 89)
@@ -0,0 +1,5 @@
+<%@ page language="java" contentType="text/html" pageEncoding="utf-8" %>
+<%@ taglib prefix="s" uri="/struts-tags" %>
+<title><s:text name="echobase.title.dbEditor"/></title>
+
+<h2><s:text name="echobase.dbEditor.propertyDiffsResult"/><s:property value="#{propertyDiffs.size}"/></h2>
1
0
r88 - in trunk: echobase-entities/src/main/java/fr/ifremer/echobase 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/resources/i18n echobase-ui/src/main/webapp/WEB-INF/jsp/dbeditor echobase-ui/src/main/webapp/css
by sletellier@users.forge.codelutin.com 16 Nov '11
by sletellier@users.forge.codelutin.com 16 Nov '11
16 Nov '11
Author: sletellier
Date: 2011-11-16 18:33:28 +0100 (Wed, 16 Nov 2011)
New Revision: 88
Url: http://forge.codelutin.com/repositories/revision/echobase/88
Log:
Fix import/export for modifications
Added:
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/ExportTable.java
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/ImportTable.java
Modified:
trunk/echobase-entities/src/main/java/fr/ifremer/echobase/EchoBaseConfiguration.java
trunk/echobase-entities/src/main/java/fr/ifremer/echobase/EchoBaseConfigurationOption.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/DbEditorService.java
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/GetEntities.java
trunk/echobase-ui/src/main/resources/config/struts-dbeditor.xml
trunk/echobase-ui/src/main/resources/config/struts-user.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
trunk/echobase-ui/src/main/webapp/css/screen.css
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-16 13:12:32 UTC (rev 87)
+++ trunk/echobase-entities/src/main/java/fr/ifremer/echobase/EchoBaseConfiguration.java 2011-11-16 17:33:28 UTC (rev 88)
@@ -111,6 +111,12 @@
return file;
}
+ public File getModifExportDirectory() {
+ File file = applicationConfig.getOptionAsFile(EchoBaseConfigurationOption.MODIF_EXPORT_DIRECTORY.key);
+ Preconditions.checkNotNull(file);
+ return file;
+ }
+
public Version getApplicationVersion() {
String versionStr =
applicationConfig.getOption(EchoBaseConfigurationOption.VERSION.key);
@@ -168,5 +174,4 @@
"Could not create directory " + directory, e);
}
}
-
}
Modified: trunk/echobase-entities/src/main/java/fr/ifremer/echobase/EchoBaseConfigurationOption.java
===================================================================
--- trunk/echobase-entities/src/main/java/fr/ifremer/echobase/EchoBaseConfigurationOption.java 2011-11-16 13:12:32 UTC (rev 87)
+++ trunk/echobase-entities/src/main/java/fr/ifremer/echobase/EchoBaseConfigurationOption.java 2011-11-16 17:33:28 UTC (rev 88)
@@ -53,6 +53,9 @@
WAR_DIRECTORY("war.directory",
"Répertoire où est stoqué le war",
"${data.directory}/war", File.class),
+ MODIF_EXPORT_DIRECTORY("motif.export.directory",
+ "Répertoire où sont stoqué les exports",
+ "${data.directory}/modifExport", File.class),
WAR_LOCATION("war.location",
"Chemin complêt d'accès au war",
"${war.directory}/echobase-ui-${project.version}.war",
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-16 13:12:32 UTC (rev 87)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/DbEditorService.java 2011-11-16 17:33:28 UTC (rev 88)
@@ -24,7 +24,9 @@
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.EchoBaseConfiguration;
import fr.ifremer.echobase.EchoBaseTechnicalException;
import fr.ifremer.echobase.entities.EchoBaseDAOHelper;
import fr.ifremer.echobase.entities.EchoBaseEntityEnum;
@@ -46,6 +48,11 @@
import org.nuiton.util.beans.BeanMonitor;
import org.nuiton.util.beans.PropertyDiff;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
@@ -62,6 +69,9 @@
/** Logger. */
private static final Log log = LogFactory.getLog(DbEditorService.class);
+ private static final String EXPORT_FILE_PREFIX = "modifExport-";
+ private static final String SCV_EXT = ".csv";
+
protected DecoratorService decoratorService;
protected DecoratorService getDecoratorService() {
@@ -92,12 +102,24 @@
return result;
}
+ public Map<?, ?>[] getAllDatas(String tableName, boolean addDecorated) {
+ return getDatas(tableName, null, null, null, addDecorated);
+ }
+
//TODO Use an object to filter datas
public Map<?, ?>[] getDatas(String tableName,
Pager pager,
String sidx,
Boolean ascendantOrder) {
+ return getDatas(tableName, pager, sidx, ascendantOrder, true);
+ }
+ public Map<?, ?>[] getDatas(String tableName,
+ Pager pager,
+ String sidx,
+ Boolean ascendantOrder,
+ boolean addDecorated) {
+
DbMeta dbMeta = getDbMeta();
TableMeta tableMeta = dbMeta.getTable(tableName);
EchoBaseEntityEnum entityEnum = tableMeta.getEntityEnum();
@@ -110,37 +132,48 @@
countQuery.addSelect("count(*)");
int count = dao.countByQuery(countQuery);
- pager.setRecords(count);
- pager.computeIndexesAndPageCount();
+ List<?> all;
+ int resultSize;
+ if (pager != null) {
+ pager.setRecords(count);
+ pager.computeIndexesAndPageCount();
- int from = pager.getStartIndex();
- int to = pager.getEndIndex();
+ int from = pager.getStartIndex();
+ int to = pager.getEndIndex();
- if (log.isDebugEnabled()) {
- log.debug("Count = " + count);
- log.debug("page = " + pager.getPageNumber());
- log.debug("pageSize = " + pager.getPageSize());
- log.debug("from = " + from);
- log.debug("to = " + to);
- log.debug("pageCount= " + pager.getPageCount());
- }
+ resultSize = to - from;
- TopiaQuery query = dao.createQuery("e");
- if (StringUtils.isNotEmpty(sidx)) {
- if (ascendantOrder) {
- query.addOrder(sidx);
- } else {
- query.addOrderDesc(sidx);
+ if (log.isDebugEnabled()) {
+ log.debug("Count = " + count);
+ log.debug("page = " + pager.getPageNumber());
+ log.debug("pageSize = " + pager.getPageSize());
+ log.debug("from = " + from);
+ log.debug("to = " + to);
+ log.debug("pageCount= " + pager.getPageCount());
}
+
+ TopiaQuery query = dao.createQuery("e");
+ if (StringUtils.isNotEmpty(sidx)) {
+ if (ascendantOrder) {
+ query.addOrder(sidx);
+ } else {
+ query.addOrderDesc(sidx);
+ }
+ }
+ query.setLimit(from, to - 1);
+ all = dao.findAllByQuery(query);
+ } else {
+
+ // Get all
+ all = dao.findAll();
+ resultSize = count;
}
- query.setLimit(from, to - 1);
- List<?> all = dao.findAllByQuery(query);
- Map<?, ?>[] rows = new Map[to - from];
+ Map<?, ?>[] rows = new Map[resultSize];
int i = 0;
for (Object o : all) {
TopiaEntity entity = (TopiaEntity) o;
- Map<String, Object> row = loadRow(tableMeta, entity);
+ Map<String, Object> row = loadRow(tableMeta, entity, addDecorated);
rows[i++] = row;
}
return rows;
@@ -159,7 +192,7 @@
try {
TopiaDAO dao = EchoBaseDAOHelper.getDAO(getTransaction(), contract);
TopiaEntity entity = dao.findByTopiaId(topiaId);
- return loadRow(tableMeta, entity);
+ return loadRow(tableMeta, entity, true);
} catch (TopiaException eee) {
throw new EchoBaseTechnicalException("Could not obtain data", eee);
}
@@ -170,6 +203,15 @@
Map<String, String> properties,
EchoBaseUser user) {
+ return saveEntity(tableMeta, id, properties, user, true);
+ }
+
+ public PropertyDiff[] saveEntity(TableMeta tableMeta,
+ String id,
+ Map<String, String> properties,
+ EchoBaseUser user,
+ boolean commit) {
+
Class<? extends TopiaEntity> entityType = tableMeta.getEntityType();
String[] columnNames = tableMeta.getColumnNamesAsArray();
BeanMonitor monitor = new BeanMonitor(columnNames);
@@ -202,9 +244,7 @@
value = daoFK.findByTopiaId(propertyValue);
} else if (Date.class.equals(columnMeta.getType())) {
-
- // Parse date
- value = SimpleDateFormat.getInstance().parse(propertyValue);
+ value = new SimpleDateFormat("dd/MM/yyyy").parse(propertyValue);
} else {
value = propertyValue;
}
@@ -267,7 +307,9 @@
EntityModificationLog.PROPERTY_MODIFICATION_TEXT, buffer.toString()
);
- getTransaction().commitTransaction();
+ if (commit) {
+ getTransaction().commitTransaction();
+ }
}
return propertyDiffs;
} catch (Exception eee) {
@@ -278,7 +320,8 @@
}
protected Map<String, Object> loadRow(TableMeta tableMeta,
- TopiaEntity entity) {
+ TopiaEntity entity,
+ boolean addDecorated) {
Map<String, Object> row = Maps.newLinkedHashMap();
EntityOperator<TopiaEntity> operator =
(EntityOperator<TopiaEntity>) tableMeta.getOperator();
@@ -293,18 +336,123 @@
// this is a foreign key, just keep the topiaid
String topiaId = ((TopiaEntity) property).getTopiaId();
- // decorate the entity
- String decorate = getDecoratorService().decorate(
- getLocale(), property, null);
+ if (addDecorated) {
+ // decorate the entity
+ String decorate = getDecoratorService().decorate(
+ getLocale(), property, null);
- // keep the decorate value
- row.put(propertyName + "_lib", decorate);
+ // keep the decorate value
+ row.put(propertyName + "_lib", decorate);
+ }
// use as the property his topiaid
property = topiaId;
}
+
+ // FIXME : tempory hack for export
+ if (property != null && Date.class.equals(columnMeta.getType())) {
+ property = new SimpleDateFormat("dd/MM/yyyy").format((Date)property);
+ }
row.put(propertyName, property);
}
return row;
}
+
+ public List<PropertyDiff[]> importDatas(String tableName,
+ File importFile,
+ EchoBaseUser user) {
+
+ TableMeta tableMeta = getTableMetas(tableName);
+
+ BufferedReader bf = null;
+ List<PropertyDiff[]> result = Lists.newArrayList();
+ try {
+ bf = new BufferedReader(new FileReader(importFile));
+ String csvHeader = bf.readLine();
+ String[] properties = csvHeader.split(";");
+
+ String line = bf.readLine();
+ while (line != null) {
+
+ Map<String, String> valuesMap = Maps.newLinkedHashMap();
+
+ String[] values = line.split(";");
+
+ String id = values[0];
+ for (int i=1;i<values.length;i++) {
+ valuesMap.put(properties[i], values[i]);
+ }
+
+ // Save entity
+ PropertyDiff[] propertyDiffs = saveEntity(tableMeta, id, valuesMap, user, false);
+ result.add(propertyDiffs);
+
+ line = bf.readLine();
+ }
+
+ } catch (Exception eee) {
+ log.error("Failled 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);
+ throw new EchoBaseTechnicalException(eee);
+ }
+ }
+ }
+ return result;
+ }
+
+ public File exportDatas(String tableName) {
+
+ Map<?, ?>[] datas = getAllDatas(tableName, false);
+
+ StringBuilder csvContent = new StringBuilder();
+
+ // Build csv
+ boolean headerCompleted = false;
+ for (Map<?, ?> data : datas) {
+ if (!headerCompleted) {
+ String keys = StringUtils.join(data.keySet(), ";");
+ csvContent.append(keys);
+ csvContent.append("\n");
+ headerCompleted = true;
+ }
+
+ String values = StringUtils.join(data.values(), ";");
+ csvContent.append(values);
+ csvContent.append("\n");
+ }
+
+ // Write export file
+ EchoBaseConfiguration configuration = getConfiguration();
+ File modifExportDirectory = configuration.getModifExportDirectory();
+
+ SimpleDateFormat format = new SimpleDateFormat("yyMMddHHmm");
+ String now = format.format(new Date());
+
+ File file = new File(modifExportDirectory, EXPORT_FILE_PREFIX + now + SCV_EXT);
+
+ FileWriter writer = null;
+ try {
+ writer = new FileWriter(file, true);
+ writer.write(csvContent.toString());
+ } catch (IOException eee) {
+ log.error("Failled 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);
+ throw new EchoBaseTechnicalException(eee);
+ }
+ }
+ }
+ return file;
+ }
}
Added: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/ExportTable.java
===================================================================
--- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/ExportTable.java (rev 0)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/ExportTable.java 2011-11-16 17:33:28 UTC (rev 88)
@@ -0,0 +1,91 @@
+/*
+ * #%L
+ * EchoBase :: UI
+ *
+ * $Id: GetEntities.java 51 2011-11-13 16:20:45Z tchemit $
+ * $HeadURL: http://svn.forge.codelutin.com/svn/echobase/trunk/echobase-ui/src/main/java… $
+ * %%
+ * 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.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
+
+/**
+ * To export datas for the given request.
+ *
+ * @author sletellier <letellier(a)codelutin.com>
+ * @since 0.1
+ */
+public class ExportTable extends EchoBaseActionSupport {
+
+ private static final long serialVersionUID = 1L;
+
+ /** Logger. */
+ private static final Log log = LogFactory.getLog(ImportTable.class);
+
+ /** Name of the table to load. */
+ protected String tableName;
+
+ /** Default file name to create. */
+ protected String fileName;
+ protected InputStream inputStream;
+ protected long contentLength;
+ protected String contentType;
+
+ public void setTableName(String tableName) {
+ this.tableName = tableName;
+ }
+
+ public InputStream getInputStream() {
+ return inputStream;
+ }
+
+ public long getContentLength() {
+ return contentLength;
+ }
+
+ public String getContentType() {
+ return contentType;
+ }
+
+ public String getFileName() {
+ return fileName;
+ }
+
+ @Override
+ public String execute() throws Exception {
+
+ DbEditorService dbEditorService = newService(DbEditorService.class);
+
+ File file = dbEditorService.exportDatas(tableName);
+
+ contentType = "text/csv";
+ fileName = file.getName();
+ contentLength = file.length();
+ inputStream = new FileInputStream(file);
+
+ return SUCCESS;
+ }
+}
Modified: 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-16 13:12:32 UTC (rev 87)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/GetEntities.java 2011-11-16 17:33:28 UTC (rev 88)
@@ -42,7 +42,7 @@
private static final long serialVersionUID = 1L;
/** Logger. */
- private static final Log log = LogFactory.getLog(GetEntities.class);
+ private static final Log log = LogFactory.getLog(ImportTable.class);
/** Name of the table to load. */
protected String tableName;
Added: 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 (rev 0)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/ImportTable.java 2011-11-16 17:33:28 UTC (rev 88)
@@ -0,0 +1,113 @@
+/*
+ * #%L
+ * EchoBase :: UI
+ *
+ * $Id: GetEntities.java 51 2011-11-13 16:20:45Z tchemit $
+ * $HeadURL: http://svn.forge.codelutin.com/svn/echobase/trunk/echobase-ui/src/main/java… $
+ * %%
+ * 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.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.util.beans.PropertyDiff;
+
+import java.io.File;
+import java.util.List;
+
+/**
+ * To import datas from import file.
+ *
+ * @author sletellier <letellier(a)codelutin.com>
+ * @since 0.1
+ */
+public class ImportTable extends EchoBaseActionSupport {
+
+ private static final long serialVersionUID = 1L;
+
+ /** Logger. */
+ private static final Log log = LogFactory.getLog(ImportTable.class);
+
+ /** Name of the table to load. */
+ protected String tableName;
+
+ protected File upfile;
+ protected String upfileContentType;
+ protected String upfileFileName;
+
+ public void setTableName(String tableName) {
+ this.tableName = tableName;
+ }
+
+ public File getUpfile() {
+ return upfile;
+ }
+
+ public void setUpfile(File upfile) {
+ this.upfile = upfile;
+ }
+
+ public String getUpfileContentType() {
+ return upfileContentType;
+ }
+
+ public void setUpfileContentType(String upfileContentType) {
+ this.upfileContentType = upfileContentType;
+ }
+
+ public String getUpfileFileName() {
+ return upfileFileName;
+ }
+
+ public void setUpfileFileName(String upfileFileName) {
+ this.upfileFileName = upfileFileName;
+ }
+
+ @Override
+ public String execute() throws Exception {
+
+ if (upfile == null || !upfile.exists()) {
+ addActionError(_("echobase.error.fileNotFound"));
+ return ERROR;
+ }
+
+ DbEditorService dbEditorService = newService(DbEditorService.class);
+
+ List<PropertyDiff[]> propertyDiffs =
+ dbEditorService.importDatas(tableName,
+ upfile,
+ getEchoBaseSession().getEchoBaseUser());
+
+ for (PropertyDiff[] diffs : propertyDiffs) {
+ for (PropertyDiff diff : diffs) {
+ String msg = _("echobase.message.modified.property",
+ diff.getSourceProperty(),
+ diff.getSourceValue(),
+ diff.getTargetValue());
+
+ log.info(msg);
+
+ addActionMessage(msg);
+ }
+ }
+
+ return SUCCESS;
+ }
+}
Modified: trunk/echobase-ui/src/main/resources/config/struts-dbeditor.xml
===================================================================
--- trunk/echobase-ui/src/main/resources/config/struts-dbeditor.xml 2011-11-16 13:12:32 UTC (rev 87)
+++ trunk/echobase-ui/src/main/resources/config/struts-dbeditor.xml 2011-11-16 17:33:28 UTC (rev 88)
@@ -57,10 +57,25 @@
<!-- save the modified entity (no result as a grid json edit action)-->
<action name="editTableData"
- class="fr.ifremer.echobase.ui.actions.dbeditor.SaveEntity">
- <result type="redirectAction">/dbeditor</result>
+ class="fr.ifremer.echobase.ui.actions.dbeditor.SaveEntity"/>
+
+ <!-- save the modified entity (no result as a grid json edit action)-->
+ <action name="doImport"
+ class="fr.ifremer.echobase.ui.actions.dbeditor.ImportTable">
+ <interceptor-ref name="paramsPrepareParamsStackLoggued"/>
</action>
+ <!-- save the modified entity (no result as a grid json edit action)-->
+ <action name="doExport"
+ class="fr.ifremer.echobase.ui.actions.dbeditor.ExportTable">
+ <interceptor-ref name="paramsPrepareParamsStackLoggued"/>
+ <result type="stream">
+ <param name="contentType">${contentType}</param>
+ <param name="contentLength">${contentLength}</param>
+ <param name="contentDisposition">filename="${fileName}"</param>
+ </result>
+ </action>
+
</package>
</struts>
Modified: trunk/echobase-ui/src/main/resources/config/struts-user.xml
===================================================================
--- trunk/echobase-ui/src/main/resources/config/struts-user.xml 2011-11-16 13:12:32 UTC (rev 87)
+++ trunk/echobase-ui/src/main/resources/config/struts-user.xml 2011-11-16 17:33:28 UTC (rev 88)
@@ -89,7 +89,7 @@
<!-- Get modification logs entries -->
<action name="getEntityModificationLogs" method="entityModificationLogs"
- class="fr.ifremer.echobase.ui.actions.dbeditor.GetEntities">
+ class="fr.ifremer.echobase.ui.actions.dbeditor.ImportTable">
<result type="json"/>
</action>
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-16 13:12:32 UTC (rev 87)
+++ trunk/echobase-ui/src/main/resources/i18n/echobase-ui_fr_FR.properties 2011-11-16 17:33:28 UTC (rev 88)
@@ -33,9 +33,12 @@
echobase.common.user=Utilisateur
echobase.common.voyage=Voyage
echobase.common.voyagesToSelect=Voyage à exporter
+echobase.dbeditor.export=Exporter
+echobase.dbeditor.import=Importer
echobase.embeddedApplication.configuration=Configuration de l'application embarquée
echobase.error.bad.password=Mot de passe incorrrect
echobase.error.email.already.used=
+echobase.error.fileNotFound=
echobase.error.importArgument=
echobase.error.login.unknown=Utilisateur inconnu
echobase.error.required.email=L'email est obligatoire
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-16 13:12:32 UTC (rev 87)
+++ trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/dbeditor/dbeditor.jsp 2011-11-16 17:33:28 UTC (rev 88)
@@ -29,10 +29,10 @@
<s:url id="reloadUrl" action="dbeditor" namespace="/dbeditor"/>
<s:url id="getTableData" action="getTableData" namespace="/dbeditor"/>
+<s:set name="tableSelected" value="%{tableName == null}"/>
+
<title><s:text name="echobase.title.dbEditor"/></title>
-<%--<script type="text/javascript" src="/echobase/struts/js/base/jquery.ui.datepicker.min.js"></script>--%>
-<script type="text/javascript" src="/echobase/struts/js/base/jquery.ui.datepicker.js"></script>
<script type="text/javascript">
jQuery(document).ready(function () {
@@ -114,9 +114,26 @@
}
</script>
-<div>
+<div class="inline">
<s:select key="tableName" label='%{getText("echobase.common.tableName")}'
list="tableNames" headerKey="" headerValue=""/>
+
+ <s:form id="importForm" action="doImport" namespace="/dbeditor" method="post"
+ enctype="multipart/form-data" theme="simple" cssClass="floatLeft">
+
+ <s:hidden key="tableName"/>
+ <s:file name="upfile"
+ required="true"
+ key="echobase.dbeditor.importFile"
+ disabled="%{tableSelected}"/>
+ <s:submit key="echobase.dbeditor.import" disabled="%{tableSelected}"/>
+ </s:form>
+
+ <s:form id="exportForm" action="doExport" namespace="/dbeditor" theme="simple" cssClass="floatRight">
+
+ <s:hidden key="tableName"/>
+ <s:submit key="echobase.dbeditor.export" disabled="%{tableSelected}"/>
+ </s:form>
</div>
<br class="clearBoth"/>
@@ -167,7 +184,7 @@
title="%{getText(#meta.i18nKey)}"
edittype='%{getEditType(#meta)}'
formatter='%{getFormatter(#meta)}'
- formatoptions="{newformat : 'd/m/Y H:i:s'}"
+ formatoptions="{newformat : 'd/m/Y'}"
sortable="true" editable="true"/>
</s:else>
@@ -186,8 +203,6 @@
<s:hidden id="id" key="id"/>
<s:hidden key="tableName"/>
<s:iterator value="columnMetas" var="meta" status="status">
- <%-- TODO sletellier 20111115 : try to refactor with table url --%>
- <s:set name="urlName">getForeignEntitiesUrl_<s:property value="%{#meta.typeSimpleName}"/></s:set>
<s:url id="urlName"
action="getForeignEntities"
namespace="/dbeditor"
@@ -218,9 +233,6 @@
<s:elseif test='#meta.columnType == "date"'>
<sj:datepicker id="%{#meta.name}"
name="%{#meta.name}"
- timepicker="true"
- timepickerShowSecond="true"
- timepickerFormat="hh:mm:ss"
label="%{getText(#meta.i18nKey)}"/>
</s:elseif>
</s:else>
@@ -229,7 +241,7 @@
</fieldset>
<ul class="toolbar floatRight">
<li><s:reset key="echobase.common.reset"/></li>
- <li><s:submit key="echobase.action.save" theme="simple"/></li>
+ <li><s:submit name="submit" key="echobase.action.save" theme="simple"/></li>
</ul>
</s:form>
Modified: trunk/echobase-ui/src/main/webapp/css/screen.css
===================================================================
--- trunk/echobase-ui/src/main/webapp/css/screen.css 2011-11-16 13:12:32 UTC (rev 87)
+++ trunk/echobase-ui/src/main/webapp/css/screen.css 2011-11-16 17:33:28 UTC (rev 88)
@@ -25,6 +25,10 @@
font-family: sans-serif;
}
+.inline {
+ display:inline;
+}
+
.fontsize11 {
font-size: 11px;
}
1
0
r87 - 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/webapp/WEB-INF/includes echobase-ui/src/main/webapp/WEB-INF/jsp/dbeditor echobase-ui/src/main/webapp/css
by sletellier@users.forge.codelutin.com 16 Nov '11
by sletellier@users.forge.codelutin.com 16 Nov '11
16 Nov '11
Author: sletellier
Date: 2011-11-16 14:12:32 +0100 (Wed, 16 Nov 2011)
New Revision: 87
Url: http://forge.codelutin.com/repositories/revision/echobase/87
Log:
- Allow to update date in dbeditor
- Allow to create entity in dbeditore
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/LoadEntities.java
trunk/echobase-ui/src/main/webapp/WEB-INF/includes/metas.jsp
trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/dbeditor/dbeditor.jsp
trunk/echobase-ui/src/main/webapp/css/screen.css
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-15 17:40:35 UTC (rev 86)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/DbEditorService.java 2011-11-16 13:12:32 UTC (rev 87)
@@ -46,6 +46,7 @@
import org.nuiton.util.beans.BeanMonitor;
import org.nuiton.util.beans.PropertyDiff;
+import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Map;
@@ -178,7 +179,14 @@
getTransaction(),
entityType);
- TopiaEntity entityToSave = dao.findByTopiaId(id);
+ TopiaEntity entityToSave;
+
+ // Find or create entity if no id
+ if (StringUtils.isEmpty(id)) {
+ entityToSave = dao.create();
+ } else {
+ entityToSave = dao.findByTopiaId(id);
+ }
monitor.setBean(entityToSave);
for (Map.Entry<String, String> entry : properties.entrySet()) {
String propertyName = entry.getKey();
@@ -192,6 +200,11 @@
getTransaction(),
(Class<? extends TopiaEntity>) columnMeta.getType());
value = daoFK.findByTopiaId(propertyValue);
+
+ } else if (Date.class.equals(columnMeta.getType())) {
+
+ // Parse date
+ value = SimpleDateFormat.getInstance().parse(propertyValue);
} else {
value = propertyValue;
}
@@ -230,10 +243,14 @@
if (tableMeta.getColumns(propertyName).isFK()) {
// replace by the decorate value
- sourceValue = getDecoratorService().decorate(
- getLocale(), sourceValue, null);
- targetValue = getDecoratorService().decorate(
- getLocale(), targetValue, null);
+ if (sourceValue != null) {
+ sourceValue = getDecoratorService().decorate(
+ getLocale(), sourceValue, null);
+ }
+ if (targetValue != null) {
+ targetValue = getDecoratorService().decorate(
+ getLocale(), targetValue, null);
+ }
}
buffer.append(String.format("\n Propriété '%s', ancienne valeur : %s, nouvelle valeur : %s",
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-15 17:40:35 UTC (rev 86)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/LoadEntities.java 2011-11-16 13:12:32 UTC (rev 87)
@@ -32,6 +32,7 @@
import org.apache.commons.lang3.StringUtils;
import org.nuiton.topia.persistence.TopiaEntity;
+import java.util.Date;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@@ -111,7 +112,9 @@
String editType="'string'";
if (boolean.class.equals(type)) {
editType = "'checkbox'";
- } else if (TopiaEntity.class.isAssignableFrom(type)) {
+ } else if (Date.class.isAssignableFrom(type)) {
+ editType = "'date'";
+ } else if (TopiaEntity.class.isAssignableFrom(type)) {
editType = "'formatEntityLabel'";
}
return editType;
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-15 17:40:35 UTC (rev 86)
+++ trunk/echobase-ui/src/main/webapp/WEB-INF/includes/metas.jsp 2011-11-16 13:12:32 UTC (rev 87)
@@ -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="cupertino"/>
+ <sj:head jqueryui="true" loadAtOnce="true" compressed="false" jquerytheme="cupertino"/>
</head>
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-15 17:40:35 UTC (rev 86)
+++ trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/dbeditor/dbeditor.jsp 2011-11-16 13:12:32 UTC (rev 87)
@@ -1,26 +1,26 @@
<%--
- #%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%
- --%>
+#%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%
+--%>
<%@page contentType="text/html" pageEncoding="UTF-8" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%@ taglib prefix="sj" uri="/struts-jquery-tags" %>
@@ -31,10 +31,22 @@
<title><s:text name="echobase.title.dbEditor"/></title>
+<%--<script type="text/javascript" src="/echobase/struts/js/base/jquery.ui.datepicker.min.js"></script>--%>
+<script type="text/javascript" src="/echobase/struts/js/base/jquery.ui.datepicker.js"></script>
<script type="text/javascript">
jQuery(document).ready(function () {
+ // Hack to make name=id on sj tags
+ var combos = $('select[name=""]');
+ combos.each(function(obj) {
+ this.name = this.id;
+ });
+ var pickers = $('input.hasDatepicker');
+ pickers.each(function(obj) {
+ this.name = this.id;
+ });
+
$('[name="tableName"]').change(function(event) {
var url = "${reloadUrl}?" + $.param({tableName:this.value});
window.location = url;
@@ -74,12 +86,21 @@
// if editor found
if (editor) {
- // get type for checkbox
- var editorType = editor.type;
- if (editorType == "checkbox") {
- editor.checked = value;
+ if ($(editor).hasClass("hasDatepicker")) {
+
+ // Update date
+ var inst = $.datepicker._getInst(editor);
+ $.datepicker._setDate(inst, new Date(value));
} else {
- editor.value = value;
+
+ // get type for checkbox
+ var editorType = editor.type;
+
+ if (editorType == "checkbox") {
+ editor.checked = value;
+ } else {
+ editor.value = value;
+ }
}
}
}
@@ -97,7 +118,7 @@
<s:select key="tableName" label='%{getText("echobase.common.tableName")}'
list="tableNames" headerKey="" headerValue=""/>
</div>
-<br/>
+<br class="clearBoth"/>
<s:if test="tableName!=null and tableName != ''">
<s:url id="loadUrl" action="getTableDatas" namespace="/dbeditor"
@@ -146,6 +167,7 @@
title="%{getText(#meta.i18nKey)}"
edittype='%{getEditType(#meta)}'
formatter='%{getFormatter(#meta)}'
+ formatoptions="{newformat : 'd/m/Y H:i:s'}"
sortable="true" editable="true"/>
</s:else>
@@ -154,12 +176,14 @@
</sjg:grid>
+ <br class="clearBoth"/>
+
<s:form id="editForm" action="editTableData" namespace="/dbeditor">
<fieldset>
<legend>
<s:text name="echobase.common.user"/>
</legend>
- <s:hidden key="id"/>
+ <s:hidden id="id" key="id"/>
<s:hidden key="tableName"/>
<s:iterator value="columnMetas" var="meta" status="status">
<%-- TODO sletellier 20111115 : try to refactor with table url --%>
@@ -170,9 +194,7 @@
escapeAmp="false">
<s:param name="entityType" value="%{#meta.typeSimpleName}"/>
</s:url>
- <%-- TODO sletellier 20111115 : foreign key --%>
<s:if test="#meta.fK">
- <%--Foreign : <s:property value="%{#meta.name}"/>--%>
<sj:select id="%{#meta.name}"
label="%{getText(#meta.i18nKey)}"
href="%{urlName}"
@@ -183,16 +205,22 @@
<s:else>
<s:if test='#meta.columnType == "string"'>
<s:textfield id="%{#meta.name}"
+ name="%{#meta.name}"
label="%{getText(#meta.i18nKey)}"
disabled="%{#meta.fK}"
value=""/>
</s:if>
<s:elseif test='#meta.columnType == "boolean"'>
<s:checkbox id="%{#meta.name}"
+ name="%{#meta.name}"
label="%{getText(#meta.i18nKey)}" value="%{false}"/>
</s:elseif>
<s:elseif test='#meta.columnType == "date"'>
<sj:datepicker id="%{#meta.name}"
+ name="%{#meta.name}"
+ timepicker="true"
+ timepickerShowSecond="true"
+ timepickerFormat="hh:mm:ss"
label="%{getText(#meta.i18nKey)}"/>
</s:elseif>
</s:else>
Modified: trunk/echobase-ui/src/main/webapp/css/screen.css
===================================================================
--- trunk/echobase-ui/src/main/webapp/css/screen.css 2011-11-15 17:40:35 UTC (rev 86)
+++ trunk/echobase-ui/src/main/webapp/css/screen.css 2011-11-16 13:12:32 UTC (rev 87)
@@ -42,6 +42,10 @@
width: 99%;
}
+.clearBoth {
+ clear: both;
+}
+
#footer {
/*margin-top: 120px;*/
clear: both;
1
0
r86 - 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/jsp/dbeditor
by sletellier@users.forge.codelutin.com 15 Nov '11
by sletellier@users.forge.codelutin.com 15 Nov '11
15 Nov '11
Author: sletellier
Date: 2011-11-15 18:40:35 +0100 (Tue, 15 Nov 2011)
New Revision: 86
Url: http://forge.codelutin.com/repositories/revision/echobase/86
Log:
Fix editing in dbeditor without grid
Added:
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/GetEntity.java
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/LoadEntities.java
trunk/echobase-ui/src/main/resources/config/struts-dbeditor.xml
trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/dbeditor/dbeditor.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-15 09:38:05 UTC (rev 85)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/DbEditorService.java 2011-11-15 17:40:35 UTC (rev 86)
@@ -148,6 +148,22 @@
}
}
+ public Map<?, ?> getData(String tableName,
+ String topiaId) {
+
+ DbMeta dbMeta = getDbMeta();
+ TableMeta tableMeta = dbMeta.getTable(tableName);
+ EchoBaseEntityEnum entityEnum = tableMeta.getEntityEnum();
+ Class<? extends TopiaEntity> contract = entityEnum.getContract();
+ try {
+ TopiaDAO dao = EchoBaseDAOHelper.getDAO(getTransaction(), contract);
+ TopiaEntity entity = dao.findByTopiaId(topiaId);
+ return loadRow(tableMeta, entity);
+ } catch (TopiaException eee) {
+ throw new EchoBaseTechnicalException("Could not obtain data", eee);
+ }
+ }
+
public PropertyDiff[] saveEntity(TableMeta tableMeta,
String id,
Map<String, String> properties,
Added: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/GetEntity.java
===================================================================
--- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/GetEntity.java (rev 0)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/GetEntity.java 2011-11-15 17:40:35 UTC (rev 86)
@@ -0,0 +1,46 @@
+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 entity.
+ *
+ * @author sletellier <letellier(a)codelutin.com>
+ * @since 0.1
+ */
+public class GetEntity extends EchoBaseActionSupport {
+
+ /** Name of the table to load. */
+ protected String tableName;
+
+ /** Id of entity to load. */
+ protected String id;
+
+ /** Datas of the given table. */
+ protected Map<?, ?> datas;
+
+ public void setTableName(String tableName) {
+ this.tableName = tableName;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public Map<?, ?> getDatas() {
+ return datas;
+ }
+
+ @Override
+ public String execute() throws Exception {
+
+ DbEditorService dbEditorService = newService(DbEditorService.class);
+
+ datas = dbEditorService.getData(tableName, id);
+
+ return SUCCESS;
+ }
+}
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-15 09:38:05 UTC (rev 85)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/LoadEntities.java 2011-11-15 17:40:35 UTC (rev 86)
@@ -32,6 +32,7 @@
import org.apache.commons.lang3.StringUtils;
import org.nuiton.topia.persistence.TopiaEntity;
+import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
Modified: trunk/echobase-ui/src/main/resources/config/struts-dbeditor.xml
===================================================================
--- trunk/echobase-ui/src/main/resources/config/struts-dbeditor.xml 2011-11-15 09:38:05 UTC (rev 85)
+++ trunk/echobase-ui/src/main/resources/config/struts-dbeditor.xml 2011-11-15 17:40:35 UTC (rev 86)
@@ -40,7 +40,7 @@
<!-- get foreign entities as a select box -->
<action name="getForeignEntities"
class="fr.ifremer.echobase.ui.actions.dbeditor.GetForeignEntities">
- <result>/WEB-INF/jsp/dbeditor/foreignEntities.jsp</result>
+ <result type="json"/>
</action>
<!-- Get datas of the selected table -->
@@ -49,9 +49,16 @@
<result type="json"/>
</action>
+ <!-- Get datas of the selected table -->
+ <action name="getTableData"
+ class="fr.ifremer.echobase.ui.actions.dbeditor.GetEntity">
+ <result type="json"/>
+ </action>
+
<!-- save the modified entity (no result as a grid json edit action)-->
<action name="editTableData"
class="fr.ifremer.echobase.ui.actions.dbeditor.SaveEntity">
+ <result type="redirectAction">/dbeditor</result>
</action>
</package>
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-15 09:38:05 UTC (rev 85)
+++ trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/dbeditor/dbeditor.jsp 2011-11-15 17:40:35 UTC (rev 86)
@@ -27,6 +27,7 @@
<%@ taglib prefix="sjg" uri="/struts-jquery-grid-tags" %>
<s:url id="reloadUrl" action="dbeditor" namespace="/dbeditor"/>
+<s:url id="getTableData" action="getTableData" namespace="/dbeditor"/>
<title><s:text name="echobase.title.dbEditor"/></title>
@@ -40,6 +41,52 @@
});
});
+ $.subscribe('rowselect', function(event) {
+
+ // get selected id
+ var id = event.originalEvent.id;
+
+ // get table name
+ var tableName = "${tableName}";
+
+ // get entity value from json
+ jQuery.getJSON("${getTableData}",
+ {
+ "tableName":tableName,
+ "id":id
+ },
+ function (result) {
+
+ // for all json result
+ // get data as pair : [property, value]
+ for (var data in Iterator(result.datas)) {
+ if (data) {
+
+ // get property
+ var propertyName = data[0];
+
+ // get value
+ var value = data[1];
+
+ // get concerned editor
+ var editor = document.getElementById(propertyName);
+
+ // if editor found
+ if (editor) {
+
+ // get type for checkbox
+ var editorType = editor.type;
+ if (editorType == "checkbox") {
+ editor.checked = value;
+ } else {
+ editor.value = value;
+ }
+ }
+ }
+ }
+ });
+ });
+
function formatEntityLabel(cellvalue, options, rowObject) {
var columnName = options.colModel.name + "_lib";
return rowObject[columnName];
@@ -71,6 +118,7 @@
navigatorEdit="true" navigatorSearch="true"
navigatorDelete="false" navigatorAdd="false" resizable="true"
editurl="%{editUrl}" rowList="10,15,20, 50" rowNum="10"
+ onSelectRowTopics="rowselect"
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"/>
@@ -106,5 +154,56 @@
</sjg:grid>
+ <s:form id="editForm" action="editTableData" namespace="/dbeditor">
+ <fieldset>
+ <legend>
+ <s:text name="echobase.common.user"/>
+ </legend>
+ <s:hidden key="id"/>
+ <s:hidden key="tableName"/>
+ <s:iterator value="columnMetas" var="meta" status="status">
+ <%-- TODO sletellier 20111115 : try to refactor with table url --%>
+ <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>
+ <%-- TODO sletellier 20111115 : foreign key --%>
+ <s:if test="#meta.fK">
+ <%--Foreign : <s:property value="%{#meta.name}"/>--%>
+ <sj:select id="%{#meta.name}"
+ label="%{getText(#meta.i18nKey)}"
+ href="%{urlName}"
+ list="entities"
+ listenTopics="rowselect"
+ emptyOption="true"/>
+ </s:if>
+ <s:else>
+ <s:if test='#meta.columnType == "string"'>
+ <s:textfield id="%{#meta.name}"
+ label="%{getText(#meta.i18nKey)}"
+ disabled="%{#meta.fK}"
+ value=""/>
+ </s:if>
+ <s:elseif test='#meta.columnType == "boolean"'>
+ <s:checkbox id="%{#meta.name}"
+ label="%{getText(#meta.i18nKey)}" value="%{false}"/>
+ </s:elseif>
+ <s:elseif test='#meta.columnType == "date"'>
+ <sj:datepicker id="%{#meta.name}"
+ label="%{getText(#meta.i18nKey)}"/>
+ </s:elseif>
+ </s:else>
+ <br/>
+ </s:iterator>
+ </fieldset>
+ <ul class="toolbar floatRight">
+ <li><s:reset key="echobase.common.reset"/></li>
+ <li><s:submit key="echobase.action.save" theme="simple"/></li>
+ </ul>
+ </s:form>
+
</s:if>
1
0
r85 - in trunk: echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions src/doc
by tchemit@users.forge.codelutin.com 15 Nov '11
by tchemit@users.forge.codelutin.com 15 Nov '11
15 Nov '11
Author: tchemit
Date: 2011-11-15 10:38:05 +0100 (Tue, 15 Nov 2011)
New Revision: 85
Url: http://forge.codelutin.com/repositories/revision/echobase/85
Log:
make freemind model bianrysrc/doc/EchoBAse_structure_V3.mm
Modified:
trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/ImportAction-doImport-validation.xml
trunk/src/doc/EchoBAse_structure_V3.mm
Property changes on: trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/ImportAction-doImport-validation.xml
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Property changes on: trunk/src/doc/EchoBAse_structure_V3.mm
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
1
0
Author: tchemit
Date: 2011-11-15 10:37:20 +0100 (Tue, 15 Nov 2011)
New Revision: 84
Url: http://forge.codelutin.com/repositories/revision/echobase/84
Log:
add CR
Added:
trunk/src/doc/reunions/reunion-2011-11-15.txt
Added: trunk/src/doc/reunions/reunion-2011-11-15.txt
===================================================================
--- trunk/src/doc/reunions/reunion-2011-11-15.txt (rev 0)
+++ trunk/src/doc/reunions/reunion-2011-11-15.txt 2011-11-15 09:37:20 UTC (rev 84)
@@ -0,0 +1,83 @@
+projet echobase
+---------------
+
+Lundi 15-11-2011 (Ifremer)
+
+Présents : Matthieu, Vincent, Benjamin, Tony
+
+Planning
+--------
+
+- détail du modèle accoustique
+- discussion sur le modèle capture
+- Release 0.1
+
+Détail sur le modèle accoustique
+--------------------------------
+
+On a fait un gros point sur le modèle partie accoustique.
+
+- ajout des référentiels suivants :
+
+ - CellType
+ - DataMetadataName
+ - CategoryMeaning
+ - CategoryType
+ - CellMEthod
+
+- discussion autour de la modélisation des *Class* que l'on renomme en *Category*
+- suppression de l'entité du référentiel *Region* qui sera au final remplacée
+ lors d'un import historique par une Data du bon type.
+
+Détail sur le modèle Capture
+----------------------------
+
+- discussion pour passer le modèle en anglais, Vincent a validé même si au
+ départ cela le génait. Cela permettra une plus grande cohérence sur
+ l'application.
+
+- On doit étudier le modèle fourni, mais il va nous falloir des précisions
+ je pense car on a un peu du mal à comprendre les sens des associations.
+
+- Quelques informations en vrac :
+
+ - ajouter un référentiel TypeStratification
+ - le secteur est-il dans la mission ?
+ - Les espces ont un lien avec le secteur pour valider
+
+Démo 0.1
+--------
+
+- petit tour d'horizon de la version 0.1
+- il faut revoir le style qui est un peu cassé :(
+- Ecran *Import*
+
+ - Ajouter une configuration de campagne (Entité Voyage)
+ - On abandonne les imports access (initialement prévu pour la partie capture)
+ - renommer Fichier Pêcherie en Captures
+
+- Ecran *Modifier les données*
+
+ - Il faut mettre la fonctionnalité d'import-export via fichier csv mais sans
+ gérer aucune jointure (on utilisera uniquement les identifiatns technique
+ (*topiaId*).
+
+Actions
+-------
+
+- Vincent doit nous fournir les informations du modèle capture.
+- Mathieu doit nous fournir une procédure d'import
+- Tony doit fournir la dernière version du modèle heuristique.
+- Inviter Franck Coppin à s'abonner aux mailing-lists.
+- Mettre en place un style *minimaliste* mais sympa.
+
+Réunion
+-------
+
+- Lundi 28 movembre à 10h00 à l'Ifremer (retours sur les modèles + démo 0.2).
+
+
+
+
+
+
Property changes on: trunk/src/doc/reunions/reunion-2011-11-15.txt
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
1
0
r83 - trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions
by sletellier@users.forge.codelutin.com 15 Nov '11
by sletellier@users.forge.codelutin.com 15 Nov '11
15 Nov '11
Author: sletellier
Date: 2011-11-15 10:27:59 +0100 (Tue, 15 Nov 2011)
New Revision: 83
Url: http://forge.codelutin.com/repositories/revision/echobase/83
Log:
- Retrieve import validation file
Modified:
trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/ImportAction-doImport-validation.xml
Modified: trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/ImportAction-doImport-validation.xml
===================================================================
--- trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/ImportAction-doImport-validation.xml 2011-11-15 08:40:07 UTC (rev 82)
+++ trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/ImportAction-doImport-validation.xml 2011-11-15 09:27:59 UTC (rev 83)
@@ -26,31 +26,11 @@
"http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
<validators>
- <field name="query.name">
-
- <field-validator type="requiredstring">
- <message key="echobase.validation.export.name.requiredstring"/>
+ <field name="importModel.accessImport">
+ <field-validator type="expression">
+ <param name="expression">(importModel.accessImport == null ^ importModel.selectedVoyage == null) == 1</param>
+ <message key="echobase.validation.import.selectedVoyageOrAccessImport.required"/>
</field-validator>
</field>
- <field name="query.description">
-
- <field-validator type="requiredstring">
- <message key="echobase.validation.export.description.requiredstring"/>
- </field-validator>
- </field>
-
- <field name="query.sqlQuery">
-
- <field-validator type="requiredstring">
- <message key="echobase.validation.export.sqlQuery.requiredstring"/>
- </field-validator>
- <field-validator type="regex">
- <!-- TODO sletellier 2011/11/14 : Find a better regex exression to define sql query -->
- <param name="expression">^\s*select\s+.+\s+from\s+.+$</param>
- <param name="caseSensitive">false</param>
- <message key="echobase.validation.export.sqlQuery.wrongformat"/>
- </field-validator>
- </field>
-
</validators>
\ No newline at end of file
1
0
r82 - in trunk: echobase-entities/src/main/resources/i18n echobase-entities/src/main/xmi echobase-services/src/main/java/fr/ifremer/echobase/services echobase-services/src/main/java/fr/ifremer/echobase/services/models echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/export src/doc
by tchemit@users.forge.codelutin.com 15 Nov '11
by tchemit@users.forge.codelutin.com 15 Nov '11
15 Nov '11
Author: tchemit
Date: 2011-11-15 09:40:07 +0100 (Tue, 15 Nov 2011)
New Revision: 82
Url: http://forge.codelutin.com/repositories/revision/echobase/82
Log:
update models
Modified:
trunk/echobase-entities/src/main/resources/i18n/echobase-entities_fr_FR.properties
trunk/echobase-entities/src/main/xmi/echobase.zargo
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/DecoratorService.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EmbeddedApplicationService.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/VoyageService.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/models/ImportModel.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/export/CreateEmbeddedApplication.java
trunk/src/doc/EchoBAse_structure_V3.mm
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-14 16:38:34 UTC (rev 81)
+++ trunk/echobase-entities/src/main/resources/i18n/echobase-entities_fr_FR.properties 2011-11-15 08:40:07 UTC (rev 82)
@@ -22,7 +22,13 @@
echobase.common.calibrationProcessingMethod=
echobase.common.calibrationReport=
echobase.common.callsign=
+echobase.common.category=
+echobase.common.categoryMeaning=
+echobase.common.categoryRef=
+echobase.common.categoryType=
+echobase.common.categoryValue=
echobase.common.cell=cell
+echobase.common.cellMethod=
echobase.common.cellMethods=
echobase.common.cellName=
echobase.common.cellType=
@@ -36,6 +42,7 @@
echobase.common.dataCentre=
echobase.common.dataCentreEmail=
echobase.common.dataMetadata=
+echobase.common.dataMetadataName=
echobase.common.dataName=
echobase.common.dataProcessing=dataProcessing
echobase.common.dataQuality=dataQuality
@@ -48,6 +55,7 @@
echobase.common.depthStratum=depthStratum
echobase.common.depthStratumId=
echobase.common.depthStratumMeaning=
+echobase.common.depthStratumType=
echobase.common.description=Description
echobase.common.digitThreshold=
echobase.common.distributionStatement=
@@ -78,6 +86,7 @@
echobase.common.id=Identifiant
echobase.common.institution=
echobase.common.keywords=
+echobase.common.label=
echobase.common.lastModifiedDate=Date de dernière modification
echobase.common.lastModifiedUser=Utilisateur de dernière modification
echobase.common.lengthClass=lengthClass
@@ -169,6 +178,7 @@
echobase.common.transitEndTime=
echobase.common.transitStartLocality=
echobase.common.transitStartTime=
+echobase.common.transitVessel=
echobase.common.units=
echobase.common.user=Utilisateur
echobase.common.validMax=
Modified: trunk/echobase-entities/src/main/xmi/echobase.zargo
===================================================================
(Binary files differ)
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-14 16:38:34 UTC (rev 81)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/DecoratorService.java 2011-11-15 08:40:07 UTC (rev 82)
@@ -28,7 +28,7 @@
import com.google.common.collect.Maps;
import fr.ifremer.echobase.entities.EchoBaseUser;
import fr.ifremer.echobase.entities.ExportQuery;
-import fr.ifremer.echobase.entities.Voyage;
+import fr.ifremer.echobase.entities.data.Voyage;
import org.apache.commons.collections.CollectionUtils;
import org.nuiton.topia.persistence.TopiaEntity;
import org.nuiton.util.decorator.Decorator;
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EmbeddedApplicationService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EmbeddedApplicationService.java 2011-11-14 16:38:34 UTC (rev 81)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EmbeddedApplicationService.java 2011-11-15 08:40:07 UTC (rev 82)
@@ -29,7 +29,7 @@
import fr.ifremer.echobase.EchoBaseTopiaRootContextSupplierFactory;
import fr.ifremer.echobase.entities.EchoBaseUser;
import fr.ifremer.echobase.entities.ExportQuery;
-import fr.ifremer.echobase.entities.Voyage;
+import fr.ifremer.echobase.entities.data.Voyage;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import org.apache.commons.logging.Log;
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/VoyageService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/VoyageService.java 2011-11-14 16:38:34 UTC (rev 81)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/VoyageService.java 2011-11-15 08:40:07 UTC (rev 82)
@@ -25,8 +25,8 @@
import fr.ifremer.echobase.EchoBaseTechnicalException;
import fr.ifremer.echobase.entities.EchoBaseDAOHelper;
-import fr.ifremer.echobase.entities.Voyage;
-import fr.ifremer.echobase.entities.VoyageDAO;
+import fr.ifremer.echobase.entities.data.Voyage;
+import fr.ifremer.echobase.entities.data.VoyageDAO;
import org.nuiton.topia.TopiaException;
import java.util.List;
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-14 16:38:34 UTC (rev 81)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/models/ImportModel.java 2011-11-15 08:40:07 UTC (rev 82)
@@ -23,7 +23,7 @@
*/
package fr.ifremer.echobase.services.models;
-import fr.ifremer.echobase.entities.Voyage;
+import fr.ifremer.echobase.entities.data.Voyage;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.builder.ToStringBuilder;
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-14 16:38:34 UTC (rev 81)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/ImportAction.java 2011-11-15 08:40:07 UTC (rev 82)
@@ -24,7 +24,7 @@
package fr.ifremer.echobase.ui.actions;
import com.opensymphony.xwork2.Preparable;
-import fr.ifremer.echobase.entities.Voyage;
+import fr.ifremer.echobase.entities.data.Voyage;
import fr.ifremer.echobase.services.VoyageService;
import fr.ifremer.echobase.services.models.ImportModel;
import org.apache.commons.logging.Log;
Modified: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/export/CreateEmbeddedApplication.java
===================================================================
--- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/export/CreateEmbeddedApplication.java 2011-11-14 16:38:34 UTC (rev 81)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/export/CreateEmbeddedApplication.java 2011-11-15 08:40:07 UTC (rev 82)
@@ -24,7 +24,7 @@
package fr.ifremer.echobase.ui.actions.export;
import fr.ifremer.echobase.EchoBaseConfiguration;
-import fr.ifremer.echobase.entities.Voyage;
+import fr.ifremer.echobase.entities.data.Voyage;
import fr.ifremer.echobase.services.VoyageService;
import fr.ifremer.echobase.ui.actions.EchoBaseActionSupport;
import org.nuiton.util.Version;
Modified: trunk/src/doc/EchoBAse_structure_V3.mm
===================================================================
--- trunk/src/doc/EchoBAse_structure_V3.mm 2011-11-14 16:38:34 UTC (rev 81)
+++ trunk/src/doc/EchoBAse_structure_V3.mm 2011-11-15 08:40:07 UTC (rev 82)
@@ -32,7 +32,7 @@
</node>
<node CREATED="1320672768627" ID="Freemind_Link_1234421627" MODIFIED="1320685375595" TEXT="One-to-many link to" VSHIFT="-111">
<font ITALIC="true" NAME="SansSerif" SIZE="12"/>
-<node CREATED="1320414374515" ID="_" MODIFIED="1320685406626" TEXT="Voyage">
+<node CREATED="1320414374515" ID="_" MODIFIED="1321279147118" TEXT="Voyage">
<font BOLD="true" NAME="SansSerif" SIZE="12"/>
<node CREATED="1320762754281" ID="Freemind_Link_876869769" MODIFIED="1320764179800" TEXT="MissionID">
<font BOLD="true" ITALIC="true" NAME="SansSerif" SIZE="12"/>
@@ -68,14 +68,14 @@
<font BOLD="true" ITALIC="true" NAME="SansSerif" SIZE="12"/>
<node CREATED="1320680989887" ID="Freemind_Link_435190659" MODIFIED="1320685813293" TEXT="One-to-many link">
<font ITALIC="true" NAME="SansSerif" SIZE="12"/>
-<node CREATED="1320673346795" FOLDED="true" ID="Freemind_Link_1110771553" MODIFIED="1321267793459" TEXT="AcousticInstrument">
+<node CREATED="1320673346795" FOLDED="true" ID="Freemind_Link_1110771553" MODIFIED="1321279169442" TEXT="AcousticInstrument">
<font BOLD="true" NAME="SansSerif" SIZE="12"/>
<node CREATED="1320687033637" ID="Freemind_Link_443830258" MODIFIED="1320764239015" TEXT="TransectID">
<font BOLD="true" ITALIC="true" NAME="SansSerif" SIZE="12"/>
</node>
<node CREATED="1320686503938" ID="Freemind_Link_238706726" MODIFIED="1320764243011" TEXT="AcousticInstrumentID">
<font BOLD="true" ITALIC="true" NAME="SansSerif" SIZE="12"/>
-<node CREATED="1320745727927" ID="Freemind_Link_1071765877" MODIFIED="1321262359489" TEXT="Many-to-one link">
+<node CREATED="1320745727927" FOLDED="true" ID="Freemind_Link_1071765877" MODIFIED="1321279165592" TEXT="Many-to-one link">
<font ITALIC="true" NAME="SansSerif" SIZE="12"/>
<node CREATED="1320745784879" ID="Freemind_Link_286667586" MODIFIED="1321262374168" TEXT="AcousticInstrumentsList">
<font BOLD="true" NAME="SansSerif" SIZE="12"/>
@@ -345,8 +345,8 @@
<node CREATED="1320687449754" MODIFIED="1320687449754" TEXT="ProcessingSoftwareVersion"/>
<node CREATED="1320687449754" MODIFIED="1320687449754" TEXT="TransceiverProcessingSacorrection"/>
<node CREATED="1320687449754" MODIFIED="1320687449754" TEXT="TransceiverProcessingAbsorption"/>
-<node CREATED="1320687449754" MODIFIED="1320687449754" TEXT="TransceiverProcessingAbsorptionDescription"/>
-<node CREATED="1320687449754" MODIFIED="1320687449754" TEXT="TransducerProcessingPsi"/>
+<node CREATED="1320687449754" ID="ID_818807184" MODIFIED="1320687449754" TEXT="TransceiverProcessingAbsorptionDescription"/>
+<node CREATED="1320687449754" ID="ID_1634165222" MODIFIED="1320687449754" TEXT="TransducerProcessingPsi"/>
<node CREATED="1320687449754" MODIFIED="1320687449754" TEXT="TransducerProcessingBeamAngleAthwartship"/>
<node CREATED="1320687449754" MODIFIED="1320687449754" TEXT="TransducerProcessingBeamAngleAlongship"/>
<node CREATED="1320687449754" ID="Freemind_Link_245146210" MODIFIED="1320687449754" TEXT="AcousticDensityUnit"/>
1
0
r81 - in trunk: echobase-services/src/main/java/fr/ifremer/echobase/services/models echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions echobase-ui/src/main/resources/config echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions echobase-ui/src/main/resources/i18n echobase-ui/src/main/webapp/WEB-INF/jsp/import
by sletellier@users.forge.codelutin.com 14 Nov '11
by sletellier@users.forge.codelutin.com 14 Nov '11
14 Nov '11
Author: sletellier
Date: 2011-11-14 17:38:34 +0100 (Mon, 14 Nov 2011)
New Revision: 81
Url: http://forge.codelutin.com/repositories/revision/echobase/81
Log:
- Add content type in import model
- Add validation message traduction
- Fix import validation
Added:
trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/ImportAction-doImport-validation.xml
Removed:
trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/ImportAction-importForm-validation.xml
Modified:
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/models/ImportModel.java
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/ImportAction.java
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/import/import.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-14 15:09:26 UTC (rev 80)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/models/ImportModel.java 2011-11-14 16:38:34 UTC (rev 81)
@@ -43,28 +43,28 @@
protected Voyage selectedVoyage;
protected File accessImport;
-
protected String accessImportFileName;
+ protected String accessImportContentType;
protected File accousticImport;
-
protected String accousticImportFileName;
+ protected String accousticImportContentType;
protected File pecherieImport;
-
protected String pecherieImportFileName;
+ protected String pecherieImportContentType;
protected File lectureAgeGenImport;
-
protected String lectureAgeGenImportFileName;
+ protected String lectureAgeGenImportContentType;
protected File eventsImport;
-
protected String eventsImportFileName;
+ protected String eventsImportContentType;
protected File typeEchoSpeciesImport;
-
protected String typeEchoSpeciesImportFileName;
+ protected String typeEchoSpeciesImportContentType;
protected String comment;
@@ -104,6 +104,14 @@
this.accessImportFileName = accessImportFileName;
}
+ public String getAccessImportContentType() {
+ return accessImportContentType;
+ }
+
+ public void setAccessImportContentType(String accessImportContentType) {
+ this.accessImportContentType = accessImportContentType;
+ }
+
public File getAccousticImport() {
return accousticImport;
}
@@ -120,6 +128,14 @@
this.accousticImportFileName = accousticImportFileName;
}
+ public String getAccousticImportContentType() {
+ return accousticImportContentType;
+ }
+
+ public void setAccousticImportContentType(String accousticImportContentType) {
+ this.accousticImportContentType = accousticImportContentType;
+ }
+
public File getPecherieImport() {
return pecherieImport;
}
@@ -136,6 +152,14 @@
this.pecherieImportFileName = pecherieImportFileName;
}
+ public String getPecherieImportContentType() {
+ return pecherieImportContentType;
+ }
+
+ public void setPecherieImportContentType(String pecherieImportContentType) {
+ this.pecherieImportContentType = pecherieImportContentType;
+ }
+
public File getLectureAgeGenImport() {
return lectureAgeGenImport;
}
@@ -152,6 +176,14 @@
this.lectureAgeGenImportFileName = lectureAgeGenImportFileName;
}
+ public String getLectureAgeGenImportContentType() {
+ return lectureAgeGenImportContentType;
+ }
+
+ public void setLectureAgeGenImportContentType(String lectureAgeGenImportContentType) {
+ this.lectureAgeGenImportContentType = lectureAgeGenImportContentType;
+ }
+
public File getEventsImport() {
return eventsImport;
}
@@ -168,6 +200,14 @@
this.eventsImportFileName = eventsImportFileName;
}
+ public String getEventsImportContentType() {
+ return eventsImportContentType;
+ }
+
+ public void setEventsImportContentType(String eventsImportContentType) {
+ this.eventsImportContentType = eventsImportContentType;
+ }
+
public File getTypeEchoSpeciesImport() {
return typeEchoSpeciesImport;
}
@@ -184,6 +224,14 @@
this.typeEchoSpeciesImportFileName = typeEchoSpeciesImportFileName;
}
+ public String getTypeEchoSpeciesImportContentType() {
+ return typeEchoSpeciesImportContentType;
+ }
+
+ public void setTypeEchoSpeciesImportContentType(String typeEchoSpeciesImportContentType) {
+ this.typeEchoSpeciesImportContentType = typeEchoSpeciesImportContentType;
+ }
+
public boolean validate() {
// access file or survey is selected, not both
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-14 15:09:26 UTC (rev 80)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/ImportAction.java 2011-11-14 16:38:34 UTC (rev 81)
@@ -23,6 +23,7 @@
*/
package fr.ifremer.echobase.ui.actions;
+import com.opensymphony.xwork2.Preparable;
import fr.ifremer.echobase.entities.Voyage;
import fr.ifremer.echobase.services.VoyageService;
import fr.ifremer.echobase.services.models.ImportModel;
@@ -38,7 +39,7 @@
* @author sletellier <letellier(a)codelutin.com>
* @since 0.1
*/
-public class ImportAction extends EchoBaseActionSupport {
+public class ImportAction extends EchoBaseActionSupport implements Preparable {
private static final long serialVersionUID = 1L;
@@ -71,18 +72,15 @@
}
@Override
- public String input() throws Exception {
-
+ public void prepare() throws Exception {
VoyageService service = newService(VoyageService.class);
List<Voyage> allVoyages = service.getVoyages();
voyages = sortAndDecorate(allVoyages, null);
-
- return INPUT;
}
@Override
public String execute() throws Exception {
- log.info("Will import : " + importModel.toString());
+ log.info("Will import : " + getImportModel().toString());
return SUCCESS;
}
Modified: trunk/echobase-ui/src/main/resources/config/struts-import.xml
===================================================================
--- trunk/echobase-ui/src/main/resources/config/struts-import.xml 2011-11-14 15:09:26 UTC (rev 80)
+++ trunk/echobase-ui/src/main/resources/config/struts-import.xml 2011-11-14 16:38:34 UTC (rev 81)
@@ -36,13 +36,13 @@
<action name="import" class="fr.ifremer.echobase.ui.actions.ImportAction"
method="input">
<result name="input">/WEB-INF/jsp/import/import.jsp</result>
- <result type="redirectAction">doImport</result>
</action>
<!-- Display import page -->
<action name="doImport" class="fr.ifremer.echobase.ui.actions.ImportAction">
<interceptor-ref name="paramsPrepareParamsStackLoggued"/>
- <result name="wait">/WEB-INF/jsp/import/importProgress.jsp</result>
+ <!--<result name="wait">/WEB-INF/jsp/import/importProgress.jsp</result>-->
+ <result name="input">/WEB-INF/jsp/import/import.jsp</result>
<result>/WEB-INF/jsp/import/importProgress.jsp</result>
</action>
Copied: trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/ImportAction-doImport-validation.xml (from rev 78, trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/ImportAction-importForm-validation.xml)
===================================================================
--- trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/ImportAction-doImport-validation.xml (rev 0)
+++ trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/ImportAction-doImport-validation.xml 2011-11-14 16:38:34 UTC (rev 81)
@@ -0,0 +1,56 @@
+<!--
+ #%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 validators PUBLIC
+ "-//OpenSymphony Group//XWork Validator 1.0.2//EN"
+ "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
+<validators>
+
+ <field name="query.name">
+
+ <field-validator type="requiredstring">
+ <message key="echobase.validation.export.name.requiredstring"/>
+ </field-validator>
+ </field>
+
+ <field name="query.description">
+
+ <field-validator type="requiredstring">
+ <message key="echobase.validation.export.description.requiredstring"/>
+ </field-validator>
+ </field>
+
+ <field name="query.sqlQuery">
+
+ <field-validator type="requiredstring">
+ <message key="echobase.validation.export.sqlQuery.requiredstring"/>
+ </field-validator>
+ <field-validator type="regex">
+ <!-- TODO sletellier 2011/11/14 : Find a better regex exression to define sql query -->
+ <param name="expression">^\s*select\s+.+\s+from\s+.+$</param>
+ <param name="caseSensitive">false</param>
+ <message key="echobase.validation.export.sqlQuery.wrongformat"/>
+ </field-validator>
+ </field>
+
+</validators>
\ No newline at end of file
Deleted: trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/ImportAction-importForm-validation.xml
===================================================================
--- trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/ImportAction-importForm-validation.xml 2011-11-14 15:09:26 UTC (rev 80)
+++ trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/ImportAction-importForm-validation.xml 2011-11-14 16:38:34 UTC (rev 81)
@@ -1,45 +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%
- -->
-<!DOCTYPE validators PUBLIC
- "-//OpenSymphony Group//XWork Validator 1.0.2//EN"
- "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
-<validators>
-
- <field name="importModel.selectedVoyage">
-
- <field-validator type="fieldexpression">
- <param name="expression">importModel.accessImport == null</param>
- <message key="echobase.validation.import.selectedVoyageOrAccessImport.required"/>
- </field-validator>
- </field>
-
- <field name="importModel.accessImport">
-
- <field-validator type="fieldexpression">
- <param name="expression">importModel.selectedVoyage == null</param>
- <message key="echobase.validation.import.selectedVoyageOrAccessImport.required"/>
- </field-validator>
- </field>
-
-</validators>
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-14 15:09:26 UTC (rev 80)
+++ trunk/echobase-ui/src/main/resources/i18n/echobase-ui_fr_FR.properties 2011-11-14 16:38:34 UTC (rev 81)
@@ -89,4 +89,11 @@
echobase.title.modification.detail=Détail de la modification
echobase.title.users=Adminitration des utilisateurs
echobase.user.gridTitle=Liste des utilisateurs
+echobase.validation.export.description.requiredstring=La description de l'export est obligatoire
+echobase.validation.export.name.requiredstring=Le nom de l'export est obligatoire
+echobase.validation.export.sqlQuery.requiredstring=La requête de l'export est obligatoire
+echobase.validation.export.sqlQuery.wrongformat=La requêtes n'est pas valide
+echobase.validation.import.selectedVoyageOrAccessImport.required=Merci de selectionner un voyage ou un import access
+echobase.validation.login.password.requiredstring=Le mot de passe est obligatoire
+echobase.validation.login.wrongLogin=Le login est déjà utilisé
echobase.voyage.selectHeader=Selectionnez un voyage
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-14 15:09:26 UTC (rev 80)
+++ trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/import/import.jsp 2011-11-14 16:38:34 UTC (rev 81)
@@ -26,7 +26,7 @@
<title><s:text name="echobase.title.import"/></title>
-<s:form id="importForm" action="import" namespace="/import" method="POST"
+<s:form id="importForm" action="doImport" namespace="/import" method="POST"
enctype="multipart/form-data">
<fieldset>
1
0
14 Nov '11
Author: tchemit
Date: 2011-11-14 16:09:26 +0100 (Mon, 14 Nov 2011)
New Revision: 80
Url: http://forge.codelutin.com/repositories/revision/echobase/80
Log:
- make export sql validation works
- add svn properties
- add missing entity stereotype on model
- add configuration constants
Added:
trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/export/ManageExportQuery-saveExportQuery-validation.xml
Removed:
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/export/ExportSql.java
trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/export/ManageExportQuery-doSaveQuery-validation.xml
Modified:
trunk/echobase-entities/src/main/java/fr/ifremer/echobase/EchoBaseConfiguration.java
trunk/echobase-entities/src/main/resources/i18n/echobase-entities_fr_FR.properties
trunk/echobase-entities/src/main/xmi/echobase.zargo
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/UserService.java
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/EchoBaseApplicationListener.java
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/export/ExportSqlResult.java
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/export/ManageExportQuery.java
trunk/echobase-ui/src/main/resources/config/struts-export.xml
trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/ImportAction-importForm-validation.xml
trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/user/ManageUser-validation.xml
trunk/echobase-ui/src/main/resources/log4j.properties
trunk/echobase-ui/src/main/resources/template/css_xhtml/checkbox.ftl
trunk/echobase-ui/src/main/resources/template/css_xhtml/controlheader-core.ftl
trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/export/exportSql.jsp
trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/export/exportSqlResult.jsp
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-14 13:55:41 UTC (rev 79)
+++ trunk/echobase-entities/src/main/java/fr/ifremer/echobase/EchoBaseConfiguration.java 2011-11-14 15:09:26 UTC (rev 80)
@@ -51,6 +51,10 @@
protected static final Log log =
LogFactory.getLog(EchoBaseConfiguration.class);
+ public static final String OPTION_CREATE_ADMINS = "createAdmins";
+
+ public static final String OPTION_UPDATE_SCHEMA = "updateSchema";
+
/** Delegate application config object containing configuration. */
protected ApplicationConfig applicationConfig;
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-14 13:55:41 UTC (rev 79)
+++ trunk/echobase-entities/src/main/resources/i18n/echobase-entities_fr_FR.properties 2011-11-14 15:09:26 UTC (rev 80)
@@ -162,6 +162,7 @@
echobase.common.transducerSerial=
echobase.common.transect=transect
echobase.common.transectAbstract=
+echobase.common.transectAcousticInstrument=
echobase.common.transit=transit
echobase.common.transitDescription=
echobase.common.transitEndLocatlity=
@@ -179,6 +180,7 @@
echobase.common.vesselName=
echobase.common.vesselNoiseDesign=
echobase.common.vesselTonnage=
+echobase.common.vesselTransit=
echobase.common.vesselType=
echobase.common.voyage=Campagne
echobase.common.voyageDescription=
Modified: trunk/echobase-entities/src/main/xmi/echobase.zargo
===================================================================
(Binary files differ)
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-14 13:55:41 UTC (rev 79)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/UserService.java 2011-11-14 15:09:26 UTC (rev 80)
@@ -24,6 +24,7 @@
package fr.ifremer.echobase.services;
import com.google.common.base.Preconditions;
+import fr.ifremer.echobase.EchoBaseConfiguration;
import fr.ifremer.echobase.EchoBaseTechnicalException;
import fr.ifremer.echobase.entities.EchoBaseDAOHelper;
import fr.ifremer.echobase.entities.EchoBaseUser;
@@ -144,7 +145,7 @@
userDTO.setAdmin(true);
createOrUpdate(userDTO);
- if (getConfiguration().getOptionAsBoolean("createAdmins")) {
+ if (getConfiguration().getOptionAsBoolean(EchoBaseConfiguration.OPTION_CREATE_ADMINS)) {
for (int i = 0; i < 1000; i++) {
userDTO = new EchoBaseUserDTOImpl();
userDTO.setEmail(DEFAULT_ADMIN_EMAIL + i);
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-14 13:55:41 UTC (rev 79)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/EchoBaseApplicationListener.java 2011-11-14 15:09:26 UTC (rev 80)
@@ -122,7 +122,7 @@
try {
boolean schemaExist = isSchemaCreated();
if (!schemaExist ||
- configuration.getOptionAsBoolean("updateSchema")) {
+ configuration.getOptionAsBoolean(EchoBaseConfiguration.OPTION_UPDATE_SCHEMA)) {
updateSchema(configuration);
}
Deleted: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/export/ExportSql.java
===================================================================
--- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/export/ExportSql.java 2011-11-14 13:55:41 UTC (rev 79)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/export/ExportSql.java 2011-11-14 15:09:26 UTC (rev 80)
@@ -1,92 +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.export;
-
-import fr.ifremer.echobase.entities.ExportQuery;
-import fr.ifremer.echobase.entities.ExportQueryImpl;
-import fr.ifremer.echobase.services.ExportSqlService;
-import fr.ifremer.echobase.ui.actions.EchoBaseActionSupport;
-import org.apache.commons.lang3.StringUtils;
-
-import java.util.Collection;
-import java.util.Map;
-
-/**
- * Load export sql main page.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 0.1
- */
-public class ExportSql extends EchoBaseActionSupport {
-
- private static final long serialVersionUID = 1L;
-
- /** All available queries from database. */
- protected Map<String, String> queries;
-
- /** Selected query loaded from database if his id is not empty. */
- protected ExportQuery query;
-
- public ExportQuery getQuery() {
- if (query == null) {
- query = new ExportQueryImpl();
- }
- return query;
- }
-
- public Map<String, String> getQueries() {
- return queries;
- }
-
- public Map<String, String> getTableNames() {
- return queries;
- }
-
- @Override
- public String execute() throws Exception {
- ExportSqlService service = newService(ExportSqlService.class);
-
- Collection<ExportQuery> sqlQueries = service.getQueries();
- queries = sortAndDecorate(sqlQueries, null);
-
- if (sqlQueries.isEmpty()) {
- // no query saved
- addActionMessage(_("echobase.info.no.sqlQuery.saved"));
- }
-
- String selectedQueryId = getQuery().getTopiaId();
-
- if (StringUtils.isEmpty(selectedQueryId)) {
-
- // no query selected
- addActionMessage(_("echobase.info.no.sqlQuery.selected"));
- } else {
-
- // load query from database
- query = service.getQueryById(selectedQueryId);
- }
- return SUCCESS;
- }
-
-}
Modified: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/export/ExportSqlResult.java
===================================================================
--- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/export/ExportSqlResult.java 2011-11-14 13:55:41 UTC (rev 79)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/export/ExportSqlResult.java 2011-11-14 15:09:26 UTC (rev 80)
@@ -23,6 +23,7 @@
*/
package fr.ifremer.echobase.ui.actions.export;
+import fr.ifremer.echobase.EchoBaseTechnicalException;
import fr.ifremer.echobase.services.ExportSqlService;
import fr.ifremer.echobase.ui.actions.EchoBaseActionSupport;
@@ -66,8 +67,14 @@
// obtain columNames from the request
ExportSqlService service = newService(ExportSqlService.class);
- columnNames = service.getColumnNames(sql);
+ try {
+ columnNames = service.getColumnNames(sql);
+ } catch (EchoBaseTechnicalException e) {
+ //TODO add a real nice message
+ addActionError(e.getMessage());
+ }
+
// create default file name
fileName = "export.csv";
Modified: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/export/ManageExportQuery.java
===================================================================
--- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/export/ManageExportQuery.java 2011-11-14 13:55:41 UTC (rev 79)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/export/ManageExportQuery.java 2011-11-14 15:09:26 UTC (rev 80)
@@ -23,22 +23,30 @@
*/
package fr.ifremer.echobase.ui.actions.export;
+import com.opensymphony.xwork2.Preparable;
import fr.ifremer.echobase.entities.ExportQuery;
import fr.ifremer.echobase.entities.ExportQueryImpl;
import fr.ifremer.echobase.services.ExportSqlService;
import fr.ifremer.echobase.ui.actions.EchoBaseActionSupport;
+import org.apache.commons.lang3.StringUtils;
+import java.util.Collection;
+import java.util.Map;
+
/**
* To manage {@link ExportQuery}.
*
* @author tchemit <chemit(a)codelutin.com>
* @since 0.1
*/
-public class ManageExportQuery extends EchoBaseActionSupport {
+public class ManageExportQuery extends EchoBaseActionSupport implements Preparable {
private static final long serialVersionUID = 1L;
- /** Selected query */
+ /** All available queries from database. */
+ protected Map<String, String> queries;
+
+ /** Selected query loaded from database if his id is not empty. */
protected ExportQuery query;
public ExportQuery getQuery() {
@@ -48,6 +56,14 @@
return query;
}
+ public Map<String, String> getQueries() {
+ return queries;
+ }
+
+ public Map<String, String> getTableNames() {
+ return queries;
+ }
+
public String saveQuery() throws Exception {
//TODO : do validation
@@ -79,4 +95,29 @@
query = null;
return SUCCESS;
}
+
+ @Override
+ public void prepare() throws Exception {
+ ExportSqlService service = newService(ExportSqlService.class);
+
+ Collection<ExportQuery> sqlQueries = service.getQueries();
+ queries = sortAndDecorate(sqlQueries, null);
+
+ if (sqlQueries.isEmpty()) {
+ // no query saved
+ addActionMessage(_("echobase.info.no.sqlQuery.saved"));
+ }
+
+ String selectedQueryId = getQuery().getTopiaId();
+
+ if (StringUtils.isEmpty(selectedQueryId)) {
+
+ // no query selected
+ addActionMessage(_("echobase.info.no.sqlQuery.selected"));
+ } else {
+
+ // load query from database
+ query = service.getQueryById(selectedQueryId);
+ }
+ }
}
\ No newline at end of file
Modified: trunk/echobase-ui/src/main/resources/config/struts-export.xml
===================================================================
--- trunk/echobase-ui/src/main/resources/config/struts-export.xml 2011-11-14 13:55:41 UTC (rev 79)
+++ trunk/echobase-ui/src/main/resources/config/struts-export.xml 2011-11-14 15:09:26 UTC (rev 80)
@@ -38,12 +38,14 @@
<param name="namespace">export</param>
<param name="query.topiaId">${query.topiaId}</param>
</result-type>
+
</result-types>
<!-- Display export sql main page -->
- <action name="exportSql"
- class="fr.ifremer.echobase.ui.actions.export.ExportSql">
- <result>/WEB-INF/jsp/export/exportSql.jsp</result>
+ <action name="exportSql" method="input"
+ class="fr.ifremer.echobase.ui.actions.export.ManageExportQuery">
+ <interceptor-ref name="paramsPrepareParamsStackLoggued"/>
+ <result name="input">/WEB-INF/jsp/export/exportSql.jsp</result>
</action>
<!-- Display the result of the sql query execution -->
@@ -67,24 +69,31 @@
<!-- Clone the sql query -->
<action name="cloneExportQuery" method="cloneQuery"
class="fr.ifremer.echobase.ui.actions.export.ManageExportQuery">
+ <interceptor-ref name="paramsPrepareParamsStackLoggued"/>
+ <result name="input">/WEB-INF/jsp/export/exportSql.jsp</result>
<result type="redirectExportSql"/>
</action>
<!-- Save the sql query -->
<action name="saveExportQuery" method="saveQuery"
class="fr.ifremer.echobase.ui.actions.export.ManageExportQuery">
+ <interceptor-ref name="paramsPrepareParamsStackLoggued"/>
+ <result name="input">/WEB-INF/jsp/export/exportSql.jsp</result>
<result type="redirectExportSql"/>
</action>
<!-- Delete the sql query -->
<action name="deleteExportQuery" method="deleteQuery"
class="fr.ifremer.echobase.ui.actions.export.ManageExportQuery">
+ <interceptor-ref name="paramsPrepareParamsStackLoggued"/>
+ <result name="input">/WEB-INF/jsp/export/exportSql.jsp</result>
<result type="redirectExportSql"/>
</action>
<!-- Download the sql query csv file -->
<action name="downloadExportSqlResult"
class="fr.ifremer.echobase.ui.actions.export.DownloadExportSqlResult">
+ <interceptor-ref name="paramsPrepareParamsStackLoggued"/>
<result type="stream">
<param name="contentType">${contentType}</param>
<param name="contentLength">${contentLength}</param>
@@ -95,6 +104,7 @@
<!-- Download the embedded application zip file -->
<action name="downloadEmbeddedApplication"
class="fr.ifremer.echobase.ui.actions.export.DownloadEmbeddedApplication">
+ <interceptor-ref name="paramsPrepareParamsStackLoggued"/>
<result type="stream">
<param name="contentType">${contentType}</param>
<param name="contentLength">${contentLength}</param>
Property changes on: trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/ImportAction-importForm-validation.xml
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Deleted: trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/export/ManageExportQuery-doSaveQuery-validation.xml
===================================================================
--- trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/export/ManageExportQuery-doSaveQuery-validation.xml 2011-11-14 13:55:41 UTC (rev 79)
+++ trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/export/ManageExportQuery-doSaveQuery-validation.xml 2011-11-14 15:09:26 UTC (rev 80)
@@ -1,56 +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%
- -->
-<!DOCTYPE validators PUBLIC
- "-//OpenSymphony Group//XWork Validator 1.0.2//EN"
- "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
-<validators>
-
- <field name="query.name">
-
- <field-validator type="requiredstring">
- <message key="echobase.validation.export.name.requiredstring"/>
- </field-validator>
- </field>
-
- <field name="query.description">
-
- <field-validator type="requiredstring">
- <message key="echobase.validation.export.description.requiredstring"/>
- </field-validator>
- </field>
-
- <field name="query.sqlQuery">
-
- <field-validator type="requiredstring">
- <message key="echobase.validation.export.sqlQuery.requiredstring"/>
- </field-validator>
- <field-validator type="regex">
- <!-- TODO sletellier 2011/11/14 : Find a better regex exression to define sql query -->
- <param name="expression">^\s*select\s+.+\s+from\s+.+$</param>
- <param name="caseSensitive">false</param>
- <message key="echobase.validation.export.sqlQuery.wrongformat"/>
- </field-validator>
- </field>
-
-</validators>
\ No newline at end of file
Copied: trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/export/ManageExportQuery-saveExportQuery-validation.xml (from rev 78, trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/export/ManageExportQuery-doSaveQuery-validation.xml)
===================================================================
--- trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/export/ManageExportQuery-saveExportQuery-validation.xml (rev 0)
+++ trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/export/ManageExportQuery-saveExportQuery-validation.xml 2011-11-14 15:09:26 UTC (rev 80)
@@ -0,0 +1,56 @@
+<!--
+ #%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 validators PUBLIC
+ "-//OpenSymphony Group//XWork Validator 1.0.2//EN"
+ "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
+<validators>
+
+ <field name="query.name">
+
+ <field-validator type="requiredstring">
+ <message key="echobase.validation.export.name.requiredstring"/>
+ </field-validator>
+ </field>
+
+ <field name="query.description">
+
+ <field-validator type="requiredstring">
+ <message key="echobase.validation.export.description.requiredstring"/>
+ </field-validator>
+ </field>
+
+ <field name="query.sqlQuery">
+
+ <field-validator type="requiredstring">
+ <message key="echobase.validation.export.sqlQuery.requiredstring"/>
+ </field-validator>
+ <field-validator type="regex">
+ <!-- TODO sletellier 2011/11/14 : Find a better regex exression to define sql query -->
+ <param name="expression">^\s*select\s+.+\s+from\s+.+$</param>
+ <param name="caseSensitive">false</param>
+ <message key="echobase.validation.export.sqlQuery.wrongformat"/>
+ </field-validator>
+ </field>
+
+</validators>
\ No newline at end of file
Property changes on: trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/export/ManageExportQuery-saveExportQuery-validation.xml
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Property changes on: trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/user/ManageUser-validation.xml
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/echobase-ui/src/main/resources/log4j.properties
===================================================================
--- trunk/echobase-ui/src/main/resources/log4j.properties 2011-11-14 13:55:41 UTC (rev 79)
+++ trunk/echobase-ui/src/main/resources/log4j.properties 2011-11-14 15:09:26 UTC (rev 80)
@@ -22,7 +22,7 @@
# #L%
###
# Default to info level output; this is very handy if you eventually use Hibernate as well.
-log4j.rootCategory=info, A1
+log4j.rootCategory=WARN, A1
# A1 is set to be a ConsoleAppender.
log4j.appender.A1=org.apache.log4j.ConsoleAppender
@@ -33,6 +33,3 @@
# Toute l'application
log4j.logger.fr.ifremer.echobase=INFO
-
-log4j.logger.com.opensymphony.xwork2.validator.ValidationInterceptor=DEBUG
-log4j.logger.org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor=DEBUG
\ No newline at end of file
Property changes on: trunk/echobase-ui/src/main/resources/log4j.properties
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Property changes on: trunk/echobase-ui/src/main/resources/template/css_xhtml/checkbox.ftl
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Property changes on: trunk/echobase-ui/src/main/resources/template/css_xhtml/controlheader-core.ftl
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/export/exportSql.jsp
===================================================================
--- trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/export/exportSql.jsp 2011-11-14 13:55:41 UTC (rev 79)
+++ trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/export/exportSql.jsp 2011-11-14 15:09:26 UTC (rev 80)
@@ -27,6 +27,7 @@
<s:url id="reloadUrl" action='exportSql' namespace='/export'/>
<s:url id="exportSqlResultUrl" action="exportSqlResult" namespace="/export"/>
+<s:set var="noError" value="!hasErrors()"/>
<script type="text/javascript">
function reloadQuery() {
@@ -57,7 +58,7 @@
});
var queryId = $('[name="query.topiaId"]').val();
- if (queryId) {
+ if (queryId && ${noError}) {
// auto launch query
loadGridData();
}
Modified: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/export/exportSqlResult.jsp
===================================================================
--- trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/export/exportSqlResult.jsp 2011-11-14 13:55:41 UTC (rev 79)
+++ trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/export/exportSqlResult.jsp 2011-11-14 15:09:26 UTC (rev 80)
@@ -26,39 +26,47 @@
<%@ taglib prefix="sj" uri="/struts-jquery-tags" %>
<%@ taglib prefix="sjg" uri="/struts-jquery-grid-tags" %>
-<s:url id="loadUrl" action="getExportSqlResult" namespace="/export"
- escapeAmp="false">
- <s:param name="sql" value="%{sql}"/>
-</s:url>
+<s:if test="hasActionErrors()">
+ <div class="info_error">
+ <s:actionerror/>
+ </div>
+</s:if>
+<s:else>
+ <s:url id="loadUrl" action="getExportSqlResult" namespace="/export"
+ escapeAmp="false">
+ <s:param name="sql" value="%{sql}"/>
+ </s:url>
-<s:form action="downloadExportSqlResult" namespace="/export">
+ <s:form action="downloadExportSqlResult" namespace="/export">
- <fieldset>
- <legend><s:text name="echobase.sqlQuery.result"/></legend>
+ <fieldset>
+ <legend><s:text name="echobase.sqlQuery.result"/></legend>
- <s:hidden key="sql" label=""/>
- <s:textfield key="fileName" required="true" size="100"
- label="%{getText('echobase.common.exportFileName')}"/>
- <s:submit key="echobase.action.exportSqlData" align="left"/>
- <br/>
-<sjg:grid id="rows" caption="%{getText('echobase.common.request.result')}"
- dataType="json" href="%{loadUrl}" gridModel="datas"
- pager="true" pagerButtons="true" pagerInput="true"
- navigator="true" autowidth="true" rownumbers="false"
- navigatorEdit="false" navigatorDelete="false"
- navigatorSearch="false" navigatorRefresh="false"
- navigatorAdd="false" rowList="10,15,20,50" rowNum="10"
- viewrecords="true">
+ <s:hidden key="sql" label=""/>
+ <s:textfield key="fileName" required="true" size="100"
+ label="%{getText('echobase.common.exportFileName')}"/>
+ <s:submit key="echobase.action.exportSqlData" align="left"/>
+ <br/>
+ <sjg:grid id="rows" caption="%{getText('echobase.common.request.result')}"
+ dataType="json" href="%{loadUrl}" gridModel="datas"
+ pager="true" pagerButtons="true" pagerInput="true"
+ navigator="true" autowidth="true" rownumbers="false"
+ navigatorEdit="false" navigatorDelete="false"
+ navigatorSearch="false" navigatorRefresh="false"
+ navigatorAdd="false" rowList="10,15,20,50" rowNum="10"
+ viewrecords="true">
- <s:iterator value="columnNames" var="name" status="status">
+ <s:iterator value="columnNames" var="name" status="status">
- <sjg:gridColumn name="%{#name}" title="%{#name}" sortable="false"/>
+ <sjg:gridColumn name="%{#name}" title="%{#name}" sortable="false"/>
- </s:iterator>
+ </s:iterator>
-</sjg:grid>
- </fieldset>
-</s:form>
+ </sjg:grid>
+ </fieldset>
+ </s:form>
+</s:else>
+
1
0