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
- 1864 discussions
19 Nov '11
Author: tchemit
Date: 2011-11-19 15:10:49 +0100 (Sat, 19 Nov 2011)
New Revision: 96
Url: http://forge.codelutin.com/repositories/revision/echobase/96
Log:
can reuse the select row topic without any event + fix topic name
Modified:
trunk/echobase-ui/src/main/webapp/js/gridHelper.js
Modified: trunk/echobase-ui/src/main/webapp/js/gridHelper.js
===================================================================
--- trunk/echobase-ui/src/main/webapp/js/gridHelper.js 2011-11-18 20:57:14 UTC (rev 95)
+++ trunk/echobase-ui/src/main/webapp/js/gridHelper.js 2011-11-19 14:10:49 UTC (rev 96)
@@ -27,11 +27,14 @@
{
addRowSelectTopic: function(gridId, callback) {
$.subscribe(gridId + '-rowSelect', function(event) {
- var gridId = event.data.id;
- var opts = jQuery.struts2_jquery[gridId] = {};
- var id = event.originalEvent.id;
- if (id) {
- opts['selectedRow'] = id;
+ if (event.originalEvent) {
+ var gridId = event.data.id;
+ var opts = jQuery.struts2_jquery[gridId] = {};
+
+ var id = event.originalEvent.id;
+ if (id) {
+ opts['selectedRow'] = id;
+ }
}
var callback = event.data.callback;
if (callback) {
@@ -41,7 +44,7 @@
},
addClearSelectTopic: function (gridId, callback) {
- $.subscribe(gridId + '-cleanSelect', function(event) {
+ $.subscribe(gridId + '-clearSelect', function(event) {
var gridId = event.data.id;
jQuery.struts2_jquery[gridId] = {};
var callback = event.data.callback;
1
0
r95 - in trunk/echobase-entities/src/main: resources/i18n xmi
by tchemit@users.forge.codelutin.com 18 Nov '11
by tchemit@users.forge.codelutin.com 18 Nov '11
18 Nov '11
Author: tchemit
Date: 2011-11-18 21:57:14 +0100 (Fri, 18 Nov 2011)
New Revision: 95
Url: http://forge.codelutin.com/repositories/revision/echobase/95
Log:
fix model
Modified:
trunk/echobase-entities/src/main/resources/i18n/echobase-entities_fr_FR.properties
trunk/echobase-entities/src/main/xmi/echobase.zargo
Modified: trunk/echobase-entities/src/main/resources/i18n/echobase-entities_fr_FR.properties
===================================================================
--- trunk/echobase-entities/src/main/resources/i18n/echobase-entities_fr_FR.properties 2011-11-18 11:29:38 UTC (rev 94)
+++ trunk/echobase-entities/src/main/resources/i18n/echobase-entities_fr_FR.properties 2011-11-18 20:57:14 UTC (rev 95)
@@ -4,6 +4,7 @@
echobase.common.acquisitionSoftwareVersion=
echobase.common.addOffset=
echobase.common.admin=Administrateur
+echobase.common.age=
echobase.common.ageClass=ageClass
echobase.common.altCallsign=
echobase.common.areaOfOperation=areaOfOperation
@@ -36,7 +37,9 @@
echobase.common.classCode=
echobase.common.classGroupId=
echobase.common.classMeaning=
+echobase.common.codeMemo=
echobase.common.comment=
+echobase.common.count=
echobase.common.data=data
echobase.common.dataAcquisition=dataAcquisition
echobase.common.dataCentre=
@@ -64,7 +67,13 @@
echobase.common.echoBaseUserDTO=
echobase.common.echosounderSoundSpeed=
echobase.common.email=Courriel
+echobase.common.endDate=
echobase.common.endPort=
+echobase.common.endTimeFillageEngin=
+echobase.common.engine=
+echobase.common.engineCaracteristic=
+echobase.common.engineParameter=
+echobase.common.engineType=
echobase.common.entityId=Identifiant de l'entité
echobase.common.entityModificationLog=Journal des modifications
echobase.common.entityModificationLogDTO=
@@ -84,17 +93,30 @@
echobase.common.history=
echobase.common.iMO=
echobase.common.id=Identifiant
+echobase.common.impacte=
+echobase.common.individu=
+echobase.common.individualMeasureParameter=
+echobase.common.individualMeasureParameterValue=
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.latitudeEndFillageEngin=
+echobase.common.latitudeStartFillageEngin=
+echobase.common.length=
echobase.common.lengthClass=lengthClass
+echobase.common.libelle=
echobase.common.licence=
echobase.common.linestring=
echobase.common.loggedDataDatatype=
echobase.common.loggedDataFormat=
echobase.common.longName=
+echobase.common.longitudeEndFillageEngin=
+echobase.common.longitudeStartFillageEngin=
+echobase.common.measureStep=
+echobase.common.measureType=
+echobase.common.measureUnit=
echobase.common.metadata=metadata
echobase.common.metadataClass=metadataClass
echobase.common.mission=mission
@@ -104,6 +126,11 @@
echobase.common.modificationText=Modification
echobase.common.name=Nom
echobase.common.notes=
+echobase.common.operation=
+echobase.common.operationEngineParameterValue=
+echobase.common.operationParameter=
+echobase.common.operationParameterValue=
+echobase.common.operationType=
echobase.common.operator=
echobase.common.organisationLevelAcknowledgements=
echobase.common.organisationReferences=
@@ -127,14 +154,22 @@
echobase.common.region=region
echobase.common.regionName=
echobase.common.relatedActivity=
+echobase.common.sample=
+echobase.common.sampleCSJ=
+echobase.common.sampleLength=
echobase.common.scaleFactor=
+echobase.common.scientistName=
+echobase.common.size=
echobase.common.soundSpeedCalculations=
echobase.common.sounderConstant=
echobase.common.source=
+echobase.common.species=
echobase.common.speciesClass=speciesClass
echobase.common.sqlQuery=Requête SQL
echobase.common.standardName=
+echobase.common.startDate=
echobase.common.startPort=
+echobase.common.startTimeFillageEngin=
echobase.common.station=station
echobase.common.surface=
echobase.common.timeCoverageEnd=
@@ -183,6 +218,8 @@
echobase.common.user=Utilisateur
echobase.common.validMax=
echobase.common.validMin=
+echobase.common.value=
+echobase.common.vernacullaireName=
echobase.common.vessel=Navire
echobase.common.vesselCode=
echobase.common.vesselEnginePower=
@@ -197,4 +234,5 @@
echobase.common.voyageEndDate=
echobase.common.voyageName=
echobase.common.voyageStartDate=
+echobase.common.weight=
echobase.config.data.directory.description=Chemin de l'application
Modified: trunk/echobase-entities/src/main/xmi/echobase.zargo
===================================================================
(Binary files differ)
1
0
r94 - in trunk: . echobase-services/src/main/java/fr/ifremer/echobase/services echobase-ui/src/main/webapp/WEB-INF/jsp/dbeditor
by sletellier@users.forge.codelutin.com 18 Nov '11
by sletellier@users.forge.codelutin.com 18 Nov '11
18 Nov '11
Author: sletellier
Date: 2011-11-18 12:29:38 +0100 (Fri, 18 Nov 2011)
New Revision: 94
Url: http://forge.codelutin.com/repositories/revision/echobase/94
Log:
- Use ToCsv method of StringUtil : http://nuiton.org/issues/1811
Modified:
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/DbEditorService.java
trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/dbeditor/dbeditor.jsp
trunk/pom.xml
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/DbEditorService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/DbEditorService.java 2011-11-18 09:32:42 UTC (rev 93)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/DbEditorService.java 2011-11-18 11:29:38 UTC (rev 94)
@@ -45,6 +45,7 @@
import org.nuiton.topia.persistence.TopiaDAO;
import org.nuiton.topia.persistence.TopiaEntity;
import org.nuiton.topia.persistence.util.EntityOperator;
+import org.nuiton.util.StringUtil;
import org.nuiton.util.beans.BeanMonitor;
import org.nuiton.util.beans.PropertyDiff;
@@ -73,6 +74,7 @@
public static final String SCV_EXT = ".csv";
public static final String EXPORT_FILE_FORMAT_DATE = "yyyyMMddHHmmss";
public static final String BASE_EDITOR_FORMAT_DATE = "dd/MM/yyyy HH:mm:ss";
+ public static final String CSV_SEPARATOR = ";";
protected DecoratorService decoratorService;
protected SimpleDateFormat dateFormat;
@@ -124,6 +126,7 @@
return getDatas(tableName, pager, sidx, ascendantOrder, true);
}
+
public Map<?, ?>[] getDatas(String tableName,
Pager pager,
String sidx,
@@ -392,14 +395,14 @@
try {
bf = new BufferedReader(new FileReader(importFile));
String csvHeader = bf.readLine();
- String[] properties = csvHeader.split(";");
+ String[] properties = csvHeader.split(CSV_SEPARATOR);
String line = bf.readLine();
while (line != null) {
Map<String, String> valuesMap = Maps.newLinkedHashMap();
- String[] values = line.split(";");
+ String[] values = line.split(CSV_SEPARATOR);
String id = values[0];
for (int i=1;i<values.length;i++) {
@@ -439,15 +442,21 @@
// Build csv
boolean headerCompleted = false;
+
+ // To escape value if csv special char is found
+ StringUtil.ToString csvConvertor = new StringUtil.ToCSV(CSV_SEPARATOR);
for (Map<?, ?> data : datas) {
+
+ // Write header
if (!headerCompleted) {
- String keys = StringUtils.join(data.keySet(), ";");
+ String keys = StringUtil.join(data.keySet(), csvConvertor, CSV_SEPARATOR, false);
csvContent.append(keys);
csvContent.append("\n");
headerCompleted = true;
}
- String values = StringUtils.join(data.values(), ";");
+ // Write content
+ String values = StringUtil.join(data.values(), csvConvertor, CSV_SEPARATOR, false);
csvContent.append(values);
csvContent.append("\n");
}
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-18 09:32:42 UTC (rev 93)
+++ trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/dbeditor/dbeditor.jsp 2011-11-18 11:29:38 UTC (rev 94)
@@ -41,6 +41,7 @@
combos.each(function(obj) {
this.name = this.id;
});
+
var pickers = $('input.hasDatepicker');
pickers.each(function(obj) {
this.name = this.id;
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2011-11-18 09:32:42 UTC (rev 93)
+++ trunk/pom.xml 2011-11-18 11:29:38 UTC (rev 94)
@@ -109,7 +109,7 @@
<eugenePluginVersion>2.4.1</eugenePluginVersion>
<topiaVersion>2.6.4</topiaVersion>
- <nuitonUtilsVersion>2.3.1</nuitonUtilsVersion>
+ <nuitonUtilsVersion>2.4-SNAPSHOT</nuitonUtilsVersion>
<nuitonI18nVersion>2.4.1</nuitonI18nVersion>
<nuitonWebVersion>1.6</nuitonWebVersion>
<msaccessImporterVersion>1.4.1</msaccessImporterVersion>
1
0
r93 - in trunk: echobase-services/src/main/java/fr/ifremer/echobase/services echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor echobase-ui/src/main/resources/config echobase-ui/src/main/webapp/WEB-INF/includes
by sletellier@users.forge.codelutin.com 18 Nov '11
by sletellier@users.forge.codelutin.com 18 Nov '11
18 Nov '11
Author: sletellier
Date: 2011-11-18 10:32:42 +0100 (Fri, 18 Nov 2011)
New Revision: 93
Url: http://forge.codelutin.com/repositories/revision/echobase/93
Log:
- Replace "failled" to "failed"
- Fix footer copyright
- Improve import error message
- Using @InputConfig to call input method on validation error
Modified:
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/DbEditorService.java
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/ImportTable.java
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/LoadEntities.java
trunk/echobase-ui/src/main/resources/config/struts-dbeditor.xml
trunk/echobase-ui/src/main/webapp/WEB-INF/includes/footer.jsp
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/DbEditorService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/DbEditorService.java 2011-11-17 16:53:37 UTC (rev 92)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/DbEditorService.java 2011-11-18 09:32:42 UTC (rev 93)
@@ -373,7 +373,7 @@
property = topiaId;
}
- // Convert date to timestamp
+ // Format date
if (columnMeta.isDate() && property != null) {
Date date = (Date) property;
property = getDateFormat().format(date);
@@ -416,14 +416,14 @@
// Commit
getTransaction().commitTransaction();
} catch (Exception eee) {
- log.error("Failled to read import file " + importFile.getName(), eee);
+ log.error("Failed to read import file " + importFile.getName(), eee);
throw new EchoBaseTechnicalException(eee);
} finally {
if (bf != null) {
try {
bf.close();
} catch (IOException eee) {
- log.error("Failled to close import file " + importFile.getName(), eee);
+ log.error("Failed to close import file " + importFile.getName(), eee);
throw new EchoBaseTechnicalException(eee);
}
}
@@ -466,14 +466,14 @@
writer = new FileWriter(file, true);
writer.write(csvContent.toString());
} catch (IOException eee) {
- log.error("Failled to write modif export file", eee);
+ log.error("Failed to write modif export file", eee);
throw new EchoBaseTechnicalException(eee);
} finally {
if (writer != null) {
try {
writer.close();
} catch (IOException eee) {
- log.error("Failled to close modif export file", eee);
+ log.error("Failed to close modif export file", eee);
throw new EchoBaseTechnicalException(eee);
}
}
Modified: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/ImportTable.java
===================================================================
--- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/ImportTable.java 2011-11-17 16:53:37 UTC (rev 92)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/ImportTable.java 2011-11-18 09:32:42 UTC (rev 93)
@@ -23,7 +23,9 @@
*/
package fr.ifremer.echobase.ui.actions.dbeditor;
+import com.google.common.base.Throwables;
import com.google.common.collect.Lists;
+import com.opensymphony.xwork2.interceptor.annotations.InputConfig;
import fr.ifremer.echobase.services.DbEditorService;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -36,6 +38,7 @@
* To import datas from import file.
*
* FIXME 20111117 sletellier : extends {@link LoadEntities} find a better way to redirect to dbeditor page on validation error
+ * UPDATE 20111118 sletellier : with {@link @InputConfig} probleme is solve ? dbeditor root page is prepared only on validation error...
*
* @author sletellier <letellier(a)codelutin.com>
* @since 0.1
@@ -88,14 +91,24 @@
this.propertyDiffs = propertyDiffs;
}
- public String doImportModif() throws Exception {
+ @Override
+ @InputConfig(methodName = "input") // to call inpu method on validation error to initialize dbeditor page
+ public String execute() throws Exception {
DbEditorService dbEditorService = newService(DbEditorService.class);
- propertyDiffs = dbEditorService.importDatas(tableName,
- modifImport,
- getEchoBaseSession().getEchoBaseUser());
+ try {
+ propertyDiffs = dbEditorService.importDatas(tableName,
+ modifImport,
+ getEchoBaseSession().getEchoBaseUser());
+ } catch (Exception eee) {
+ String message = "Failed to import datas : ";
+ log.error(message, eee);
+ addActionError(message + Throwables.getRootCause(eee).getMessage());
+
+ return ERROR;
+ }
for (PropertyDiff[] diffs : propertyDiffs) {
for (PropertyDiff diff : diffs) {
String msg = _("echobase.message.modified.property",
Modified: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/LoadEntities.java
===================================================================
--- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/LoadEntities.java 2011-11-17 16:53:37 UTC (rev 92)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/LoadEntities.java 2011-11-18 09:32:42 UTC (rev 93)
@@ -43,7 +43,7 @@
* @author tchemit <chemit(a)codelutin.com>
* @since 0.1
*/
-public class LoadEntities extends EchoBaseActionSupport implements Preparable {
+public class LoadEntities extends EchoBaseActionSupport {
private static final long serialVersionUID = 1L;
@@ -73,7 +73,7 @@
}
@Override
- public void prepare() throws Exception {
+ public String input() throws Exception {
tableNames = Maps.newTreeMap();
DbMeta dbMeta = getEchoBaseApplicationContext().getDbMeta();
for (TableMeta tableMeta : dbMeta) {
@@ -91,6 +91,7 @@
DbEditorService dbEditorService = newService(DbEditorService.class);
tableMeta = dbEditorService.getTableMetas(tableName);
}
+ return INPUT;
}
public String getEditType(ColumnMeta meta) {
Modified: trunk/echobase-ui/src/main/resources/config/struts-dbeditor.xml
===================================================================
--- trunk/echobase-ui/src/main/resources/config/struts-dbeditor.xml 2011-11-17 16:53:37 UTC (rev 92)
+++ trunk/echobase-ui/src/main/resources/config/struts-dbeditor.xml 2011-11-18 09:32:42 UTC (rev 93)
@@ -41,10 +41,10 @@
</result-types>
<!-- load db editor main page -->
- <action name="dbeditor"
+ <action name="dbeditor" method="input"
class="fr.ifremer.echobase.ui.actions.dbeditor.LoadEntities">
<interceptor-ref name="paramsPrepareParamsStackLoggued"/>
- <result>/WEB-INF/jsp/dbeditor/dbeditor.jsp</result>
+ <result name="input">/WEB-INF/jsp/dbeditor/dbeditor.jsp</result>
</action>
<!-- get foreign entities as a select box -->
@@ -72,7 +72,7 @@
</action>
<!-- save the modified entity (no result as a grid json edit action)-->
- <action name="doImport" method="doImportModif" class="fr.ifremer.echobase.ui.actions.dbeditor.ImportTable">
+ <action name="doImport" class="fr.ifremer.echobase.ui.actions.dbeditor.ImportTable">
<interceptor-ref name="paramsPrepareParamsStackLoggued"/>
<result>/WEB-INF/jsp/dbeditor/modifImportResult.jsp</result>
<result name="input">/WEB-INF/jsp/dbeditor/dbeditor.jsp</result>
Modified: trunk/echobase-ui/src/main/webapp/WEB-INF/includes/footer.jsp
===================================================================
--- trunk/echobase-ui/src/main/webapp/WEB-INF/includes/footer.jsp 2011-11-17 16:53:37 UTC (rev 92)
+++ trunk/echobase-ui/src/main/webapp/WEB-INF/includes/footer.jsp 2011-11-18 09:32:42 UTC (rev 93)
@@ -53,7 +53,7 @@
</li>
<li>
Copyright 2011
- <a href="http://www.ifremer.fr">Echobase</a>
+ <a href="http://www.ifremer.fr">Ifremer</a>
<a href="http://www.codelutin.com" title="Code Lutin" target="_blank">Code
Lutin</a>
</li>
1
0
r92 - in trunk: echobase-entities/src/main/java/fr/ifremer/echobase/entities/meta 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/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 17:53:37 +0100 (Thu, 17 Nov 2011)
New Revision: 92
Url: http://forge.codelutin.com/repositories/revision/echobase/92
Log:
- Allow modify time (using jquery timepicker)
Modified:
trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/meta/ColumnMeta.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/LoadEntities.java
trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/dbeditor/dbeditor.jsp
Modified: trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/meta/ColumnMeta.java
===================================================================
--- trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/meta/ColumnMeta.java 2011-11-17 13:55:15 UTC (rev 91)
+++ trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/meta/ColumnMeta.java 2011-11-17 16:53:37 UTC (rev 92)
@@ -91,6 +91,14 @@
return TopiaEntity.class.isAssignableFrom(type);
}
+ public boolean isDate() {
+ return Date.class.equals(type);
+ }
+
+ public boolean isBoolean() {
+ return boolean.class.equals(type);
+ }
+
public Column getHibernateColumn() {
return hibernateColumn;
}
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/DbEditorService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/DbEditorService.java 2011-11-17 13:55:15 UTC (rev 91)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/DbEditorService.java 2011-11-17 16:53:37 UTC (rev 92)
@@ -69,10 +69,13 @@
/** 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";
+ public static final String EXPORT_FILE_PREFIX = "modifExport-";
+ public static final String SCV_EXT = ".csv";
+ public static final String EXPORT_FILE_FORMAT_DATE = "yyyyMMddHHmmss";
+ public static final String BASE_EDITOR_FORMAT_DATE = "dd/MM/yyyy HH:mm:ss";
protected DecoratorService decoratorService;
+ protected SimpleDateFormat dateFormat;
protected DecoratorService getDecoratorService() {
if (decoratorService == null) {
@@ -81,6 +84,13 @@
return decoratorService;
}
+ public SimpleDateFormat getDateFormat() {
+ if (dateFormat == null) {
+ dateFormat = new SimpleDateFormat(BASE_EDITOR_FORMAT_DATE);
+ }
+ return dateFormat;
+ }
+
public List<TopiaEntity> getForeignDatas(String entityType) {
Preconditions.checkNotNull(entityType);
EchoBaseEntityEnum entityEnum = EchoBaseEntityEnum.valueOf(entityType);
@@ -245,7 +255,7 @@
value = daoFK.findByTopiaId(propertyValue);
} else if (Date.class.equals(columnMeta.getType())) {
- value = new SimpleDateFormat("dd/MM/yyyy").parse(propertyValue);
+ value = getDateFormat().parse(propertyValue);
} else {
value = propertyValue;
}
@@ -363,9 +373,10 @@
property = topiaId;
}
- // FIXME : tempory hack for export
- if (property != null && Date.class.equals(columnMeta.getType())) {
- property = new SimpleDateFormat("dd/MM/yyyy").format((Date)property);
+ // Convert date to timestamp
+ if (columnMeta.isDate() && property != null) {
+ Date date = (Date) property;
+ property = getDateFormat().format(date);
}
row.put(propertyName, property);
}
@@ -442,7 +453,7 @@
}
// Write export file
- SimpleDateFormat format = new SimpleDateFormat("yyMMddHHmm");
+ SimpleDateFormat format = new SimpleDateFormat(EXPORT_FILE_FORMAT_DATE);
String now = format.format(new Date());
// Write in tmp dir
Modified: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/LoadEntities.java
===================================================================
--- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/LoadEntities.java 2011-11-17 13:55:15 UTC (rev 91)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/LoadEntities.java 2011-11-17 16:53:37 UTC (rev 92)
@@ -31,9 +31,7 @@
import fr.ifremer.echobase.services.DbEditorService;
import fr.ifremer.echobase.ui.actions.EchoBaseActionSupport;
import org.apache.commons.lang3.StringUtils;
-import org.nuiton.topia.persistence.TopiaEntity;
-import java.util.Date;
import java.util.List;
import java.util.Map;
@@ -96,24 +94,20 @@
}
public String getEditType(ColumnMeta meta) {
- Class<?> type = meta.getType();
String editType="text";
- if (boolean.class.equals(type)) {
+ if (meta.isBoolean()) {
editType = "checkbox";
- } else if (TopiaEntity.class.isAssignableFrom(type)) {
+ } else if (meta.isDate()) {
editType = "select";
}
return editType;
}
public String getFormatter(ColumnMeta meta) {
- Class<?> type = meta.getType();
String editType="'string'";
- if (boolean.class.equals(type)) {
+ if (meta.isBoolean()) {
editType = "'checkbox'";
- } else if (Date.class.isAssignableFrom(type)) {
- editType = "'date'";
- } else if (TopiaEntity.class.isAssignableFrom(type)) {
+ } else if (meta.isFK()) {
editType = "'formatEntityLabel'";
}
return editType;
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-17 13:55:15 UTC (rev 91)
+++ trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/dbeditor/dbeditor.jsp 2011-11-17 16:53:37 UTC (rev 92)
@@ -91,8 +91,7 @@
if ($(editor).hasClass("hasDatepicker")) {
// Update date
- var inst = $.datepicker._getInst(editor);
- $.datepicker._setDate(inst, new Date(value));
+ updateDate(value, editor);
} else {
// get type for checkbox
@@ -127,6 +126,32 @@
var columnName = options.colModel.name + "_lib";
return rowObject[columnName];
}
+
+ function updateDate(value, editor) {
+
+ // parse date formated like : dd/MM/yyyy HH:mm:ss
+ var dateString = value.substring(0, 10);
+ var dateSplited = dateString.split("/");
+
+ var hourString = value.substring(11, 19);
+ var hourSplited = hourString.split(":");
+
+ var options_timepicker = {};
+ options_timepicker.day = dateSplited[0];
+ options_timepicker.month = dateSplited[1];
+ options_timepicker.year = dateSplited[2];
+ options_timepicker.hour = hourSplited[0];
+ options_timepicker.minute = hourSplited[1];
+ options_timepicker.second = hourSplited[2];
+ options_timepicker.showOn = "both";
+ options_timepicker.buttonImage = "/echobase/struts/js/calendar.gif";
+ options_timepicker.timepicker = true;
+ options_timepicker.jqueryaction = "datepicker";
+ options_timepicker.id = editor.id;
+ options_timepicker.name = editor.id;
+
+ jQuery.struts2_jquery.bind(editor, options_timepicker);
+ }
</script>
<div class="inline">
@@ -258,9 +283,15 @@
label="%{getText(#meta.i18nKey)}" value="%{false}"/>
</s:elseif>
<s:elseif test='#meta.columnType == "date"'>
+ <%--<sj:datepicker id="%{#meta.name}"--%>
+ <%--name="%{#meta.name}"--%>
+ <%--label="%{getText(#meta.i18nKey)}"/>--%>
<sj:datepicker id="%{#meta.name}"
name="%{#meta.name}"
- label="%{getText(#meta.i18nKey)}"/>
+ label="%{getText(#meta.i18nKey)}"
+ timepicker="true"
+ timepickerShowSecond="true"
+ timepickerFormat="hh:mm:ss"/>
</s:elseif>
</s:else>
<br/>
1
0
r91 - in trunk: echobase-entities/src/main/java/fr/ifremer/echobase echobase-services/src/main/java/fr/ifremer/echobase/services echobase-ui/src/main/resources/i18n echobase-ui/src/main/webapp/WEB-INF/includes 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 14:55:15 +0100 (Thu, 17 Nov 2011)
New Revision: 91
Url: http://forge.codelutin.com/repositories/revision/echobase/91
Log:
Dont keep export file, use tmp dir instead
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/resources/i18n/echobase-ui_fr_FR.properties
trunk/echobase-ui/src/main/webapp/WEB-INF/includes/metas.jsp
trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/dbeditor/modifImportResult.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-17 12:42:01 UTC (rev 90)
+++ trunk/echobase-entities/src/main/java/fr/ifremer/echobase/EchoBaseConfiguration.java 2011-11-17 13:55:15 UTC (rev 91)
@@ -111,12 +111,6 @@
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);
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-17 12:42:01 UTC (rev 90)
+++ trunk/echobase-entities/src/main/java/fr/ifremer/echobase/EchoBaseConfigurationOption.java 2011-11-17 13:55:15 UTC (rev 91)
@@ -53,9 +53,6 @@
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-17 12:42:01 UTC (rev 90)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/DbEditorService.java 2011-11-17 13:55:15 UTC (rev 91)
@@ -26,7 +26,6 @@
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;
@@ -37,6 +36,7 @@
import fr.ifremer.echobase.entities.meta.DbMeta;
import fr.ifremer.echobase.entities.meta.TableMeta;
import org.apache.commons.beanutils.BeanUtils;
+import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -442,13 +442,13 @@
}
// 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);
+ // Write in tmp dir
+ File tempDirectory = FileUtils.getTempDirectory();
+ File file = new File(tempDirectory, EXPORT_FILE_PREFIX + now + SCV_EXT);
+ file.deleteOnExit();
FileWriter writer = null;
try {
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-17 12:42:01 UTC (rev 90)
+++ trunk/echobase-ui/src/main/resources/i18n/echobase-ui_fr_FR.properties 2011-11-17 13:55:15 UTC (rev 91)
@@ -35,7 +35,7 @@
echobase.common.user=Utilisateur
echobase.common.voyage=Voyage
echobase.common.voyagesToSelect=Voyage à exporter
-echobase.dbEditor.propertyDiffsResult=Nombres d'entrées importés \:
+echobase.dbEditor.propertyDiffsResult=Nombres d'entrées modifiés \: %s
echobase.dbeditor.create=Création de '%s'
echobase.dbeditor.edit=Edition de '%s'
echobase.dbeditor.export=Exporter
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-17 12:42:01 UTC (rev 90)
+++ trunk/echobase-ui/src/main/webapp/WEB-INF/includes/metas.jsp 2011-11-17 13:55:15 UTC (rev 91)
@@ -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" loadAtOnce="true" compressed="false" jquerytheme="cupertino"/>
+ <sj:head jqueryui="true" jquerytheme="cupertino"/>
</head>
Modified: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/dbeditor/modifImportResult.jsp
===================================================================
--- trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/dbeditor/modifImportResult.jsp 2011-11-17 12:42:01 UTC (rev 90)
+++ trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/dbeditor/modifImportResult.jsp 2011-11-17 13:55:15 UTC (rev 91)
@@ -25,7 +25,11 @@
<%@ 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>
+<h2>
+ <s:text name="echobase.dbEditor.propertyDiffsResult">
+ <s:param value="%{propertyDiffs.size}"/>
+ </s:text>
+</h2>
<s:a namespace="/dbeditor" action="dbeditor">
<s:param name="tableName" value="%{tableName}"/>
<s:text name="echobase.common.return"/>
1
0
r90 - in trunk/echobase-ui/src/main: java/fr/ifremer/echobase/ui/actions/dbeditor resources/fr/ifremer/echobase/ui/actions/dbeditor resources/i18n 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:42:01 +0100 (Thu, 17 Nov 2011)
New Revision: 90
Url: http://forge.codelutin.com/repositories/revision/echobase/90
Log:
- Update missing headers
- Add return link
Modified:
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/GetEntity.java
trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/dbeditor/ImportTable-doImport-validation.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/WEB-INF/jsp/dbeditor/modifImportResult.jsp
Modified: 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 2011-11-17 12:33:03 UTC (rev 89)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/GetEntity.java 2011-11-17 12:42:01 UTC (rev 90)
@@ -1,3 +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%
+ */
package fr.ifremer.echobase.ui.actions.dbeditor;
import fr.ifremer.echobase.services.DbEditorService;
Modified: 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 2011-11-17 12:33:03 UTC (rev 89)
+++ trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/dbeditor/ImportTable-doImport-validation.xml 2011-11-17 12:42:01 UTC (rev 90)
@@ -1,3 +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%
+ -->
<!DOCTYPE validators PUBLIC
"-//OpenSymphony Group//XWork Validator 1.0.2//EN"
"http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
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-17 12:33:03 UTC (rev 89)
+++ trunk/echobase-ui/src/main/resources/i18n/echobase-ui_fr_FR.properties 2011-11-17 12:42:01 UTC (rev 90)
@@ -29,12 +29,15 @@
echobase.common.query.name=Nom
echobase.common.request.result=Résultat de la requête sql
echobase.common.reset=Annuler
+echobase.common.return=Retour
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.create=Création de '%s'
+echobase.dbeditor.edit=Edition de '%s'
echobase.dbeditor.export=Exporter
echobase.dbeditor.import=Importer
echobase.embeddedApplication.configuration=Configuration de l'application embarquée
@@ -77,7 +80,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=Propriété '%s', ancienne valeur : %s, nouvelle valeur : %s",
+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
@@ -103,5 +106,3 @@
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/webapp/WEB-INF/jsp/dbeditor/dbeditor.jsp
===================================================================
--- trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/dbeditor/dbeditor.jsp 2011-11-17 12:33:03 UTC (rev 89)
+++ trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/dbeditor/dbeditor.jsp 2011-11-17 12:42:01 UTC (rev 90)
@@ -1,25 +1,24 @@
<%--
#%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%
+ 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" %>
Modified: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/dbeditor/modifImportResult.jsp
===================================================================
--- trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/dbeditor/modifImportResult.jsp 2011-11-17 12:33:03 UTC (rev 89)
+++ trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/dbeditor/modifImportResult.jsp 2011-11-17 12:42:01 UTC (rev 90)
@@ -1,3 +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%
+ --%>
<%@ page language="java" contentType="text/html" pageEncoding="utf-8" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<title><s:text name="echobase.title.dbEditor"/></title>
@@ -3,2 +26,6 @@
<h2><s:text name="echobase.dbEditor.propertyDiffsResult"/><s:property value="#{propertyDiffs.size}"/></h2>
+<s:a namespace="/dbeditor" action="dbeditor">
+ <s:param name="tableName" value="%{tableName}"/>
+ <s:text name="echobase.common.return"/>
+</s:a>
1
0
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