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
- 1820 discussions
r112 - in trunk: . src/doc/model src/site/resources src/site/rst
by tchemit@users.forge.codelutin.com 23 Nov '11
by tchemit@users.forge.codelutin.com 23 Nov '11
23 Nov '11
Author: tchemit
Date: 2011-11-23 19:02:27 +0100 (Wed, 23 Nov 2011)
New Revision: 112
Url: http://forge.codelutin.com/repositories/revision/echobase/112
Log:
update pom + add svn properties
Modified:
trunk/pom.xml
trunk/src/doc/model/EchoBase_structure_V5.mm
trunk/src/site/resources/echobase.properties
trunk/src/site/rst/install.rst
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2011-11-23 18:01:02 UTC (rev 111)
+++ trunk/pom.xml 2011-11-23 18:02:27 UTC (rev 112)
@@ -171,6 +171,12 @@
</dependency>
<dependency>
+ <groupId>org.nuiton</groupId>
+ <artifactId>nuiton-csv</artifactId>
+ <version>${nuitonUtilsVersion}</version>
+ </dependency>
+
+ <dependency>
<groupId>org.nuiton.web</groupId>
<artifactId>nuiton-struts2</artifactId>
<version>${nuitonWebVersion}</version>
Property changes on: trunk/src/doc/model/EchoBase_structure_V5.mm
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/src/site/resources/echobase.properties
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Property changes on: trunk/src/site/rst/install.rst
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
1
0
r111 - in trunk/echobase-ui: . src/main/java/fr/ifremer/echobase/ui/actions/dbeditor src/main/resources/config src/main/resources/i18n src/main/webapp/WEB-INF src/main/webapp/WEB-INF/jsp/dbeditor
by tchemit@users.forge.codelutin.com 23 Nov '11
by tchemit@users.forge.codelutin.com 23 Nov '11
23 Nov '11
Author: tchemit
Date: 2011-11-23 19:01:02 +0100 (Wed, 23 Nov 2011)
New Revision: 111
Url: http://forge.codelutin.com/repositories/revision/echobase/111
Log:
finish dbeditor (import-export is ok now) + use the final csv api
Added:
trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/dbeditor/csvImportResult.jsp
Removed:
trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/dbeditor/modifImportResult.jsp
Modified:
trunk/echobase-ui/pom.xml
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/AbstractLoadPage.java
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/GetEntities.java
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/GetForeignEntities.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/i18n/echobase-ui_fr_FR.properties
trunk/echobase-ui/src/main/webapp/WEB-INF/decorators.xml
trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/dbeditor/dbeditor.jsp
Modified: trunk/echobase-ui/pom.xml
===================================================================
--- trunk/echobase-ui/pom.xml 2011-11-23 17:51:57 UTC (rev 110)
+++ trunk/echobase-ui/pom.xml 2011-11-23 18:01:02 UTC (rev 111)
@@ -286,7 +286,27 @@
</configuration>
</plugin>
- <plugin>
+ </plugins>
+ </pluginManagement>
+ </build>
+
+ <profiles>
+
+ <profile>
+ <id>do-release</id>
+ <activation>
+ <property>
+ <name>performRelease</name>
+ <value>true</value>
+ </property>
+ </activation>
+ <properties>
+ <env>prod</env>
+ </properties>
+
+ <build>
+ <plugins>
+ <plugin>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<archive>
@@ -311,23 +331,8 @@
</overlays>
</configuration>
</plugin>
- </plugins>
- </pluginManagement>
- </build>
-
- <profiles>
-
- <profile>
- <id>do-release</id>
- <activation>
- <property>
- <name>performRelease</name>
- <value>true</value>
- </property>
- </activation>
- <properties>
- <env>prod</env>
- </properties>
+ </plugins>
+ </build>
</profile>
<profile>
Modified: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/AbstractLoadPage.java
===================================================================
--- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/AbstractLoadPage.java 2011-11-23 17:51:57 UTC (rev 110)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/AbstractLoadPage.java 2011-11-23 18:01:02 UTC (rev 111)
@@ -24,18 +24,16 @@
package fr.ifremer.echobase.ui.actions.dbeditor;
import com.google.common.collect.Maps;
+import fr.ifremer.echobase.entities.EchoBaseEntityEnum;
import fr.ifremer.echobase.entities.meta.ColumnMeta;
import fr.ifremer.echobase.entities.meta.DbMeta;
import fr.ifremer.echobase.entities.meta.TableMeta;
import fr.ifremer.echobase.services.DbEditorService;
import fr.ifremer.echobase.ui.actions.EchoBaseActionSupport;
-import org.apache.commons.lang3.StringUtils;
import java.util.List;
import java.util.Map;
-import static org.nuiton.i18n.I18n.l_;
-
/**
* A abstract action which can load the table names and a selected table
* meta datas.
@@ -47,40 +45,40 @@
private static final long serialVersionUID = 1L;
- /** Name of the table to load. */
- protected String tableName;
+ /** Type of entity to load. */
+ protected EchoBaseEntityEnum entityType;
- /** All tables availables */
- protected Map<String, String> tableNames;
+ /** All entities availables. */
+ protected Map<String, String> entityTypes;
- /** Metas of the table */
+ /** Metas of the table. */
protected TableMeta tableMeta;
- public Map<String, String> getTableNames() {
- return tableNames;
+ public Map<String, String> getEntityTypes() {
+ return entityTypes;
}
public List<ColumnMeta> getColumnMetas() {
return tableMeta.getColumns();
}
- public void setTableName(String tableName) {
- this.tableName = tableName;
+ public void setEntityType(EchoBaseEntityEnum entityType) {
+ this.entityType = entityType;
}
- public String getTableName() {
- return tableName;
+ public EchoBaseEntityEnum getEntityType() {
+ return entityType;
}
public void load() throws Exception {
- tableNames = Maps.newTreeMap();
+ entityTypes = Maps.newTreeMap();
DbMeta dbMeta = getEchoBaseApplicationContext().getDbMeta();
for (TableMeta tableMeta : dbMeta) {
String name = tableMeta.getName();
String i18nKey = tableMeta.getI18nKey();
- tableNames.put(name, l_(getLocale(), i18nKey));
+ entityTypes.put(name, _(i18nKey));
}
- if (StringUtils.isEmpty(tableName)) {
+ if (entityType == null) {
// no table selected
addActionMessage(_("echobase.info.no.table.selected"));
@@ -88,7 +86,7 @@
// load table metas
DbEditorService dbEditorService = newService(DbEditorService.class);
- tableMeta = dbEditorService.getTableMetas(tableName);
+ tableMeta = dbEditorService.getTableMetas(entityType);
}
}
Modified: 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 2011-11-23 17:51:57 UTC (rev 110)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/ExportTable.java 2011-11-23 18:01:02 UTC (rev 111)
@@ -23,13 +23,13 @@
*/
package fr.ifremer.echobase.ui.actions.dbeditor;
+import fr.ifremer.echobase.entities.EchoBaseEntityEnum;
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.ByteArrayInputStream;
import java.io.InputStream;
/**
@@ -45,14 +45,14 @@
/** Logger. */
private static final Log log = LogFactory.getLog(ImportTable.class);
- /** Name of the table to load. */
- protected String tableName;
+ /** Type of entity to export. */
+ protected EchoBaseEntityEnum entityType;
/** Default file name to create. */
protected String exportFileName;
/** Stream of the file to export. */
- protected InputStream inputStream;
+ protected transient InputStream inputStream;
/** Length of the file to export. */
protected long contentLength;
@@ -60,8 +60,8 @@
/** Type of the file to export. */
protected String contentType;
- public void setTableName(String tableName) {
- this.tableName = tableName;
+ public void setEntityType(EchoBaseEntityEnum entityType) {
+ this.entityType = entityType;
}
public void setExportFileName(String exportFileName) {
@@ -87,14 +87,16 @@
@Override
public String execute() throws Exception {
- DbEditorService dbEditorService = newService(DbEditorService.class);
+ DbEditorService service = newService(DbEditorService.class);
- File file = dbEditorService.exportDatas(tableName);
+ String content = service.exportDatas(entityType);
+ if (log.isDebugEnabled()) {
+ log.debug("file to export " + content);
+ }
+ contentLength = content.length();
contentType = "text/csv";
- contentLength = file.length();
- inputStream = new FileInputStream(file);
-
+ inputStream = new ByteArrayInputStream(content.getBytes());
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-23 17:51:57 UTC (rev 110)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/GetEntities.java 2011-11-23 18:01:02 UTC (rev 111)
@@ -23,7 +23,7 @@
*/
package fr.ifremer.echobase.ui.actions.dbeditor;
-import fr.ifremer.echobase.entities.EntityModificationLogImpl;
+import fr.ifremer.echobase.entities.EchoBaseEntityEnum;
import fr.ifremer.echobase.services.DbEditorService;
import fr.ifremer.echobase.ui.actions.AbstractJSONPaginedAction;
import org.apache.commons.logging.Log;
@@ -44,8 +44,8 @@
/** Logger. */
private static final Log log = LogFactory.getLog(ImportTable.class);
- /** Name of the table to load. */
- protected String tableName;
+ /** Type of entity to load. */
+ protected EchoBaseEntityEnum entityType;
/** Datas of the given table. */
protected Map<?, ?>[] datas;
@@ -54,6 +54,10 @@
super("datas_");
}
+ public void setEntityType(EchoBaseEntityEnum entityType) {
+ this.entityType = entityType;
+ }
+
public Map<?, ?>[] getDatas() {
return datas;
}
@@ -78,10 +82,6 @@
return pager.getRecords();
}
- public void setTableName(String tableName) {
- this.tableName = tableName;
- }
-
@Override
public String execute() throws Exception {
@@ -96,10 +96,10 @@
log.debug("sord = " + ascendantOrder);
}
- DbEditorService dbEditorService = newService(DbEditorService.class);
+ DbEditorService service = newService(DbEditorService.class);
- datas = dbEditorService.getDatas(
- tableName,
+ datas = service.getDatas(
+ entityType,
pager,
sortColumn,
ascendantOrder
@@ -114,7 +114,7 @@
public String entityModificationLogs() throws Exception {
- tableName = EntityModificationLogImpl.class.getName();
+ entityType = EchoBaseEntityEnum.EntityModificationLog;
execute();
return SUCCESS;
}
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-23 17:51:57 UTC (rev 110)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/GetEntity.java 2011-11-23 18:01:02 UTC (rev 111)
@@ -24,6 +24,7 @@
package fr.ifremer.echobase.ui.actions.dbeditor;
import com.google.common.collect.Maps;
+import fr.ifremer.echobase.entities.EchoBaseEntityEnum;
import fr.ifremer.echobase.entities.meta.ColumnMeta;
import fr.ifremer.echobase.entities.meta.TableMeta;
import fr.ifremer.echobase.services.DbEditorService;
@@ -42,8 +43,8 @@
private static final long serialVersionUID = 1L;
- /** Name of the table to load. */
- protected String tableName;
+ /** Type of entity to load. */
+ protected EchoBaseEntityEnum entityType;
/** Id of entity to load. */
protected String id;
@@ -54,8 +55,8 @@
/** Universe of columns metat datas of the selected entity type. */
protected Map<String, ColumnMeta> metas;
- public void setTableName(String tableName) {
- this.tableName = tableName;
+ public void setEntityType(EchoBaseEntityEnum entityType) {
+ this.entityType = entityType;
}
public void setId(String id) {
@@ -73,11 +74,12 @@
@Override
public String execute() throws Exception {
- DbEditorService dbEditorService = newService(DbEditorService.class);
+ DbEditorService service = newService(DbEditorService.class);
- datas = dbEditorService.getData(tableName, id);
+ TableMeta table = serviceContext.getDbMeta().getTable(entityType);
+
+ datas = service.getData(table, id);
- TableMeta table = serviceContext.getDbMeta().getTable(tableName);
List<ColumnMeta> columnMetas = table.getColumns();
metas = Maps.newHashMap();
for (ColumnMeta columnMeta : columnMetas) {
Modified: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/GetForeignEntities.java
===================================================================
--- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/GetForeignEntities.java 2011-11-23 17:51:57 UTC (rev 110)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/GetForeignEntities.java 2011-11-23 18:01:02 UTC (rev 111)
@@ -23,6 +23,7 @@
*/
package fr.ifremer.echobase.ui.actions.dbeditor;
+import fr.ifremer.echobase.entities.EchoBaseEntityEnum;
import fr.ifremer.echobase.services.DbEditorService;
import fr.ifremer.echobase.ui.actions.EchoBaseActionSupport;
import org.nuiton.topia.persistence.TopiaEntity;
@@ -40,11 +41,13 @@
private static final long serialVersionUID = 1L;
+ /** Type of entity to load. */
+ protected EchoBaseEntityEnum entityType;
+
+ /** Entities loaded (key are id, values are decoration of entity). */
protected Map<String, String> entities;
- protected String entityType;
-
- public void setEntityType(String entityType) {
+ public void setEntityType(EchoBaseEntityEnum entityType) {
this.entityType = entityType;
}
@@ -56,7 +59,8 @@
public String execute() throws Exception {
DbEditorService service = newService(DbEditorService.class);
- List<TopiaEntity> foreignEntities = service.getForeignDatas(entityType);
+ List<? extends TopiaEntity> foreignEntities =
+ service.getForeignDatas(entityType.getContract());
entities = sortAndDecorate(foreignEntities, null);
return SUCCESS;
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-23 17:51:57 UTC (rev 110)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/ImportTable.java 2011-11-23 18:01:02 UTC (rev 111)
@@ -24,15 +24,13 @@
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.CsvImportResult;
import fr.ifremer.echobase.services.DbEditorService;
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.
@@ -53,15 +51,22 @@
/** WTF ? */
protected File importFile;
+ /** Flag to authorize to create an entity if not found in db. */
+ protected boolean createIfNotFound = true;
+
/** WTF ? */
protected String importFileContentType;
/** WTF ? */
protected String importFileFileName;
- /** WTF ? */
- protected List<PropertyDiff[]> propertyDiffs;
+ /** CSV import result */
+ private CsvImportResult result;
+ public CsvImportResult getResult() {
+ return result;
+ }
+
public File getImportFile() {
return importFile;
}
@@ -86,16 +91,14 @@
this.importFileFileName = importFileFileName;
}
- public List<PropertyDiff[]> getPropertyDiffs() {
- if (propertyDiffs == null) {
- return Lists.newArrayList();
- }
- return propertyDiffs;
+
+ public boolean isCreateIfNotFound() {
+ return createIfNotFound;
}
-// public void setPropertyDiffs(List<PropertyDiff[]> propertyDiffs) {
-// this.propertyDiffs = propertyDiffs;
-// }
+ public void setCreateIfNotFound(boolean createIfNotFound) {
+ this.createIfNotFound = createIfNotFound;
+ }
@Override
public String input() throws Exception {
@@ -111,9 +114,11 @@
DbEditorService dbEditorService = newService(DbEditorService.class);
try {
- propertyDiffs = dbEditorService.importDatas(tableName,
- importFile,
- getEchoBaseSession().getEchoBaseUser());
+ result = dbEditorService.importDatas(getEntityType(),
+ importFileFileName,
+ importFile,
+ createIfNotFound,
+ getEchoBaseSession().getEchoBaseUser());
} catch (Exception eee) {
String message = "Failed to import datas : ";
@@ -122,19 +127,7 @@
return ERROR;
}
- 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/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-23 17:51:57 UTC (rev 110)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/LoadEntities.java 2011-11-23 18:01:02 UTC (rev 111)
@@ -35,6 +35,7 @@
private static final long serialVersionUID = 1L;
+ /** Default name of the export file. */
protected String exportFileName;
public String getExportFileName() {
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-23 17:51:57 UTC (rev 110)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/SaveEntity.java 2011-11-23 18:01:02 UTC (rev 111)
@@ -24,12 +24,12 @@
package fr.ifremer.echobase.ui.actions.dbeditor;
import com.google.common.collect.Maps;
+import fr.ifremer.echobase.entities.EchoBaseEntityEnum;
import fr.ifremer.echobase.entities.meta.TableMeta;
import fr.ifremer.echobase.services.DbEditorService;
import fr.ifremer.echobase.ui.actions.EchoBaseActionSupport;
import org.apache.commons.lang3.StringUtils;
import org.apache.struts2.interceptor.ParameterAware;
-import org.nuiton.util.beans.PropertyDiff;
import java.util.List;
import java.util.Map;
@@ -44,8 +44,8 @@
private static final long serialVersionUID = 1L;
- /** Name of the table to load. */
- protected String tableName;
+ /** Type of entity to save. */
+ protected EchoBaseEntityEnum entityType;
/** id of entity to save. */
protected String id;
@@ -55,14 +55,10 @@
protected Map<String, String[]> params;
- public void setTableName(String tableName) {
- this.tableName = tableName;
+ public void setEntityType(EchoBaseEntityEnum entityType) {
+ this.entityType = entityType;
}
- public String getTableName() {
- return tableName;
- }
-
public void setId(String id) {
this.id = id;
}
@@ -70,8 +66,8 @@
@Override
public String execute() throws Exception {
- DbEditorService dbEditorService = newService(DbEditorService.class);
- TableMeta tableMeta = dbEditorService.getTableMetas(tableName);
+ DbEditorService service = newService(DbEditorService.class);
+ TableMeta tableMeta = service.getTableMetas(entityType);
Map<String, String> properties = Maps.newHashMap();
List<String> columnNames = tableMeta.getColumnNames();
for (String columnName : columnNames) {
@@ -93,19 +89,12 @@
}
}
- PropertyDiff[] diffs =
- dbEditorService.saveEntity(tableMeta,
- id,
- properties,
- getEchoBaseSession().getEchoBaseUser());
+ service.saveEntity(tableMeta,
+ id,
+ properties,
+ getEchoBaseSession().getEchoBaseUser());
- for (PropertyDiff diff : diffs) {
- addActionMessage(_("echobase.message.modified.property",
- diff.getSourceProperty(),
- diff.getSourceValue(),
- diff.getTargetValue())
- );
- }
+
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-23 17:51:57 UTC (rev 110)
+++ trunk/echobase-ui/src/main/resources/config/struts-dbeditor.xml 2011-11-23 18:01:02 UTC (rev 111)
@@ -75,9 +75,8 @@
<!-- Import some entities from a csv file -->
<action name="doImport" class="fr.ifremer.echobase.ui.actions.dbeditor.ImportTable">
<interceptor-ref name="paramsPrepareParamsStackLoggued"/>
- <result>/WEB-INF/jsp/dbeditor/modifImportResult.jsp</result>
+ <result>/WEB-INF/jsp/dbeditor/csvImportResult.jsp</result>
<result name="input">/WEB-INF/jsp/dbeditor/dbeditor.jsp</result>
- <result name="error">/WEB-INF/jsp/dbeditor/modifImportResult.jsp</result>
</action>
<!-- Export a selected entity type to a csv 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-23 17:51:57 UTC (rev 110)
+++ trunk/echobase-ui/src/main/resources/i18n/echobase-ui_fr_FR.properties 2011-11-23 18:01:02 UTC (rev 111)
@@ -21,6 +21,7 @@
echobase.common.admin=Administrateur
echobase.common.comment=Commentaire
echobase.common.email=Email
+echobase.common.entityType=Type d'entité
echobase.common.jdbcLogin=Login de connexion
echobase.common.jdbcPassword=Mot de passe
echobase.common.jdbcUrl=Url de connexion
@@ -47,10 +48,11 @@
echobase.header.request.result=Résultat de la requête sql
echobase.header.user.gridTitle=Liste des utilisateurs
echobase.header.voyageSelect=Selectionnez un voyage
-echobase.info.dbeditor.propertyDiffsResult=Nombres d'entrées modifiés \: %s
+echobase.info.dbeditor.propertyDiffsResult=Résultat d'import de données
echobase.info.no.sqlQuery.saved=Aucune requête d'export sql enregistré
echobase.info.no.sqlQuery.selected=Aucune requête d'export sql sélectionnée
echobase.info.no.table.selected=Aucune table sélectionnée
+echobase.label.createIfNotFound=Créer les entités non trouvées en base
echobase.label.embeddedApplicationFileName=Nom de l'archive à télécharger
echobase.label.embeddedWarFileName=Nom du war à utiliser
echobase.label.exportFileName=Nom du fichier d'export
@@ -66,11 +68,12 @@
echobase.label.locale.english=Anglais
echobase.label.locale.french=Français
echobase.label.login=Connexion
+echobase.label.numberOfCreatedEntities=Nombre d'entitiés créées
+echobase.label.numberOfUpdatedEntities=Nombre d'entitiés mises à jour
echobase.label.query.description=Description
echobase.label.query.name=Nom
echobase.label.query.sql=SQL
echobase.label.sqlQueries=Requêtes enregistrées
-echobase.label.tableName=Nom de la table
echobase.label.user.login=Utilisateur \: %s
echobase.label.voyageToSelect=Voyage à exporter
echobase.legend.dbeditor.edit=Edition de '%s'
Modified: trunk/echobase-ui/src/main/webapp/WEB-INF/decorators.xml
===================================================================
--- trunk/echobase-ui/src/main/webapp/WEB-INF/decorators.xml 2011-11-23 17:51:57 UTC (rev 110)
+++ trunk/echobase-ui/src/main/webapp/WEB-INF/decorators.xml 2011-11-23 18:01:02 UTC (rev 111)
@@ -30,6 +30,7 @@
<pattern>/user/login*</pattern>
<pattern>/index*</pattern>
<pattern>/dbeditor/getForeignEntities*</pattern>
+ <pattern>/dbeditor/doExport*</pattern>
<pattern>/export/exportSqlResult*</pattern>
</excludes>
Copied: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/dbeditor/csvImportResult.jsp (from rev 107, trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/dbeditor/modifImportResult.jsp)
===================================================================
--- trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/dbeditor/csvImportResult.jsp (rev 0)
+++ trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/dbeditor/csvImportResult.jsp 2011-11-23 18:01:02 UTC (rev 111)
@@ -0,0 +1,49 @@
+<%--
+ #%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>
+
+<h2>
+ <s:text name="echobase.info.dbeditor.propertyDiffsResult"/>
+</h2>
+
+<fieldset>
+ <s:label key="result.entityType"
+ label="%{getText('echobase.common.entityType')}"/>
+
+ <s:label key="result.importFileName"
+ label="%{getText('echobase.label.importFile')}"/>
+
+ <s:label key="result.numberCreated"
+ label="%{getText('echobase.label.numberOfCreatedEntities')}"/>
+
+ <s:label key="result.numberUpdated"
+ label="%{getText('echobase.label.numberOfUpdatedEntities')}"/>
+</fieldset>
+
+<s:a namespace="/dbeditor" action="dbeditor">
+ <s:param name="entityType" value="%{result.entityType}"/>
+ <s:text name="echobase.action.return"/>
+</s:a>
Property changes on: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/dbeditor/csvImportResult.jsp
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
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-23 17:51:57 UTC (rev 110)
+++ trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/dbeditor/dbeditor.jsp 2011-11-23 18:01:02 UTC (rev 111)
@@ -31,7 +31,7 @@
<s:url id="reloadUrl" action="dbeditor" namespace="/dbeditor"/>
<s:url id="getTableData" action="getTableData" namespace="/dbeditor"/>
-<s:set name="tableSelected" value="%{tableName != null && tableName != ''}"/>
+<s:set name="tableSelected" value="%{entityType != null}"/>
<title><s:text name="echobase.title.dbEditor"/></title>
@@ -51,8 +51,8 @@
});
// on table name change, let's reload reload this page
- $('[name="tableName"]').change(function(event) {
- var url = "${reloadUrl}?" + $.param({tableName:this.value});
+ $('[name="entityType"]').change(function(event) {
+ var url = "${reloadUrl}?" + $.param({entityType:this.value});
window.location = url;
});
@@ -78,11 +78,11 @@
var id = jQuery.struts2_jquery['datas']['selectedRow'];
// get table name
- var tableName = "${tableName}";
+ var entityType = "${entityType}";
// get entity value from json
jQuery.getJSON("${getTableData}",
- { "tableName":tableName, "id":id }, function (result) {
+ { "entityType":entityType, "id":id }, function (result) {
// get metadatas from the response
var metas = result.metas;
@@ -182,8 +182,8 @@
}
</script>
-<s:select key="tableName" label='%{getText("echobase.label.tableName")}'
- list="tableNames" headerKey="" headerValue=""/>
+<s:select key="entityType" label='%{getText("echobase.common.entityType")}'
+ list="entityTypes" headerKey="" headerValue=""/>
<br class="clearBoth"/>
@@ -199,16 +199,19 @@
<s:form id="importForm" namespace="/dbeditor" method="post"
enctype="multipart/form-data">
- <s:hidden key="tableName" label=''/>
+ <s:hidden key="entityType" label=''/>
<s:file key="importFile" required="true"
label="%{getText('echobase.label.importFile')}"/>
+
+ <s:checkbox key='createIfNotFound' value='true'
+ label='%{getText("echobase.label.createIfNotFound")}'/>
<br/>
<s:submit key="echobase.action.importTable" action="doImport"
align="right"/>
</s:form>
<s:form id="exportForm" namespace="/dbeditor" method="post">
- <s:hidden key="tableName" label=''/>
+ <s:hidden key="entityType" label=''/>
<s:textfield key="exportFileName" required="true" size="100"
label="%{getText('echobase.label.exportFileName')}"/>
@@ -225,11 +228,11 @@
<s:if test="tableSelected">
<s:url id="loadUrl" action="getTableDatas" namespace="/dbeditor"
escapeAmp="false">
- <s:param name="tableName" value="%{tableName}"/>
+ <s:param name="entityType" value="%{entityType}"/>
</s:url>
<s:set var="tableI18nName"
- value="%{getText('echobase.common.tableDatas', tableNames[tableName])}"/>
+ value="%{getText('echobase.common.tableDatas', entityTypes[entityType])}"/>
<sjg:grid id="datas" dataType="json" href="%{loadUrl}" gridModel="datas"
caption="%{tableI18nName}"
@@ -284,9 +287,9 @@
</s:text>
</legend>
- <s:hidden key="tableName" label=''/>
+ <s:hidden key="entityType" label=''/>
- <s:hidden id="id" name="id"/>
+ <s:hidden key="id" label=''/>
<s:iterator value="columnMetas" var="meta" status="status">
<s:if test="#meta.fK">
Deleted: 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-23 17:51:57 UTC (rev 110)
+++ trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/dbeditor/modifImportResult.jsp 2011-11-23 18:01:02 UTC (rev 111)
@@ -1,36 +0,0 @@
-<%--
- #%L
- EchoBase :: UI
-
- $Id$
- $HeadURL$
- %%
- Copyright (C) 2011 Ifremer, Codelutin
- %%
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
- #L%
- --%>
-<%@ 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.info.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.action.return"/>
-</s:a>
1
0
r110 - in trunk/echobase-services: . src/main/java/fr/ifremer/echobase/services
by tchemit@users.forge.codelutin.com 23 Nov '11
by tchemit@users.forge.codelutin.com 23 Nov '11
23 Nov '11
Author: tchemit
Date: 2011-11-23 18:51:57 +0100 (Wed, 23 Nov 2011)
New Revision: 110
Url: http://forge.codelutin.com/repositories/revision/echobase/110
Log:
using csv model for all dbeditor commands
Added:
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/CsvImportResult.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/CsvModelUtil.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/DbEditorCsvModel.java
Modified:
trunk/echobase-services/pom.xml
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/AbstractEchoBaseService.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/DbEditorService.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ExportSqlService.java
Modified: trunk/echobase-services/pom.xml
===================================================================
--- trunk/echobase-services/pom.xml 2011-11-23 17:50:27 UTC (rev 109)
+++ trunk/echobase-services/pom.xml 2011-11-23 17:51:57 UTC (rev 110)
@@ -38,6 +38,11 @@
<artifactId>nuiton-utils</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.nuiton</groupId>
+ <artifactId>nuiton-csv</artifactId>
+ </dependency>
+
<!--dependency>
<groupId>org.nuiton.i18n</groupId>
<artifactId>nuiton-i18n</artifactId>
@@ -55,10 +60,10 @@
<artifactId>xwork-core</artifactId>
</dependency-->
- <dependency>
+ <!--dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
- </dependency>
+ </dependency-->
<dependency>
<groupId>commons-logging</groupId>
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/AbstractEchoBaseService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/AbstractEchoBaseService.java 2011-11-23 17:50:27 UTC (rev 109)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/AbstractEchoBaseService.java 2011-11-23 17:51:57 UTC (rev 110)
@@ -24,9 +24,17 @@
package fr.ifremer.echobase.services;
import fr.ifremer.echobase.EchoBaseConfiguration;
+import fr.ifremer.echobase.EchoBaseTechnicalException;
+import fr.ifremer.echobase.entities.EchoBaseDAOHelper;
+import fr.ifremer.echobase.entities.EchoBaseEntityEnum;
import fr.ifremer.echobase.entities.meta.DbMeta;
+import org.apache.commons.lang3.time.DateUtils;
import org.nuiton.topia.TopiaContext;
+import org.nuiton.topia.TopiaException;
+import org.nuiton.topia.persistence.TopiaDAO;
+import org.nuiton.topia.persistence.TopiaEntity;
+import java.util.Date;
import java.util.Locale;
/**
@@ -63,5 +71,31 @@
return e;
}
+ protected <E extends TopiaEntity> TopiaDAO<E> getDAO(EchoBaseEntityEnum entityEnum) throws TopiaException {
+ TopiaDAO<E> dao = getDAO((Class<E>) entityEnum.getContract());
+ return dao;
+ }
+ protected <E extends TopiaEntity> TopiaDAO<E> getDAO(Class<E> entityType) throws TopiaException {
+ TopiaDAO<E> dao = EchoBaseDAOHelper.<E, TopiaDAO<E>>getDAO(
+ getTransaction(),
+ entityType);
+
+ return dao;
+ }
+
+ protected void commitTransaction(String errorMessage) {
+ try {
+ getTransaction().commitTransaction();
+ } catch (TopiaException eee) {
+ throw new EchoBaseTechnicalException(errorMessage, eee);
+ }
+ }
+
+ protected Date newDate() {
+ Date result = new Date();
+ DateUtils.setMilliseconds(result,0);
+ return result;
+ }
+
}
Added: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/CsvImportResult.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/CsvImportResult.java (rev 0)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/CsvImportResult.java 2011-11-23 17:51:57 UTC (rev 110)
@@ -0,0 +1,98 @@
+/*
+ * #%L
+ * EchoBase :: Services
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 Ifremer, Codelutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+package fr.ifremer.echobase.services;
+
+import fr.ifremer.echobase.entities.EchoBaseEntityEnum;
+
+import java.io.Serializable;
+
+/**
+ * A simple csv result bean just to keep the number of created or
+ * updated entities.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.2
+ */
+public class CsvImportResult implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ /** type of entity to import csv datas. */
+ protected EchoBaseEntityEnum entityType;
+
+ /** Name of the csv file to import. */
+ protected String importFileName;
+
+ /** Count of created entities. */
+
+ protected int numberCreated;
+
+ /** Count of updated entities. */
+ protected int numberUpdated;
+
+ /** Flag to authorize to create entities not found in db. */
+ protected boolean createIfNotFound;
+
+
+ public EchoBaseEntityEnum getEntityType() {
+ return entityType;
+ }
+
+
+ public String getImportFileName() {
+ return importFileName;
+ }
+
+ public int getNumberCreated() {
+ return numberCreated;
+ }
+
+ public int getNumberUpdated() {
+ return numberUpdated;
+ }
+
+ public boolean isCreateIfNotFound() {
+ return createIfNotFound;
+ }
+
+ public void incrementsNumberCreated() {
+ numberCreated++;
+ }
+
+ public void incrementsNumberUpdated() {
+ numberUpdated++;
+ }
+
+ public void setEntityType(EchoBaseEntityEnum entityType) {
+ this.entityType = entityType;
+ }
+
+ public void setImportFileName(String importFileName) {
+ this.importFileName = importFileName;
+ }
+
+ public void setCreateIfNotFound(boolean createIfNotFound) {
+ this.createIfNotFound = createIfNotFound;
+ }
+}
Property changes on: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/CsvImportResult.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/CsvModelUtil.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/CsvModelUtil.java (rev 0)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/CsvModelUtil.java 2011-11-23 17:51:57 UTC (rev 110)
@@ -0,0 +1,134 @@
+/*
+ * #%L
+ * EchoBase :: Services
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 Ifremer, Codelutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+package fr.ifremer.echobase.services;
+
+import com.google.common.base.Function;
+import com.google.common.collect.Maps;
+import fr.ifremer.echobase.EchoBaseTechnicalException;
+import org.apache.commons.lang3.StringUtils;
+import org.nuiton.topia.persistence.TopiaEntity;
+import org.nuiton.util.csv.Common;
+import org.nuiton.util.csv.ValueFormatter;
+import org.nuiton.util.csv.ValueParserFormatter;
+
+import java.text.ParseException;
+import java.util.Collection;
+import java.util.Locale;
+import java.util.Map;
+
+/**
+ * Usefull class to build csv import-export models.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.2
+ */
+public class CsvModelUtil extends Common {
+
+ public static <E extends TopiaEntity> ForeignKeyValue<E> newForeignKeyValue(Class<E> type) {
+ return new ForeignKeyValue<E>(type);
+ }
+
+ public static <E extends TopiaEntity> ForeignKeyValue<E> newForeignKeyValue(Class<E> type, Collection<E> entitites) {
+ return new ForeignKeyValue<E>(type, entitites);
+ }
+
+ public static <E extends TopiaEntity> ForeignKeyDecoratedValue<E> newForeignKeyDecoratedValue(Class<E> entityType, DecoratorService decoratorService, Locale locale) {
+ return new ForeignKeyDecoratedValue<E>(entityType, decoratorService, locale);
+ }
+
+ public static class ForeignKeyValue<E extends TopiaEntity> implements ValueParserFormatter<E> {
+
+ protected final Class<E> entityType;
+
+ protected final Map<String, E> universe;
+
+ public ForeignKeyValue(Class<E> entityType, Collection<E> entitites) {
+ this.entityType = entityType;
+ universe = Maps.uniqueIndex(entitites, new Function<E, String>() {
+ @Override
+ public String apply(E input) {
+ return input.getTopiaId();
+ }
+ });
+ }
+
+ public ForeignKeyValue(Class<E> entityType) {
+ this.entityType = entityType;
+ universe = Maps.newHashMap();
+ }
+
+ @Override
+ public E parse(String value) throws ParseException {
+ E result = null;
+ if (StringUtils.isNotBlank(value)) {
+
+ // get entity from universe
+ result = universe.get(value);
+
+ if (result == null) {
+
+ // can not find entity this is a big problem for us...
+ throw new EchoBaseTechnicalException(
+ "Could not find entity with name " + value);
+ }
+ }
+ return result;
+ }
+
+ @Override
+ public String format(E e) {
+ String value = "";
+ if (e != null) {
+ value = e.getTopiaId();
+ }
+ return value;
+ }
+ }
+
+ public static class ForeignKeyDecoratedValue<E extends TopiaEntity> implements ValueFormatter<E> {
+
+ protected final Class<E> entityType;
+
+ protected final DecoratorService decoratorService;
+
+ protected final Locale locale;
+
+ public ForeignKeyDecoratedValue(Class<E> entityType, DecoratorService decoratorService, Locale locale) {
+ this.entityType = entityType;
+ this.decoratorService = decoratorService;
+ this.locale = locale;
+
+ }
+
+ @Override
+ public String format(E e) {
+ String value = "";
+ if (e != null) {
+
+ value = decoratorService.decorate(locale, e, null);
+ }
+ return value;
+ }
+ }
+}
Property changes on: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/CsvModelUtil.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/DbEditorCsvModel.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/DbEditorCsvModel.java (rev 0)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/DbEditorCsvModel.java 2011-11-23 17:51:57 UTC (rev 110)
@@ -0,0 +1,159 @@
+/*
+ * #%L
+ * EchoBase :: Services
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 Ifremer, Codelutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+package fr.ifremer.echobase.services;
+
+import fr.ifremer.echobase.entities.meta.TableMeta;
+import org.nuiton.topia.persistence.TopiaEntity;
+import org.nuiton.util.csv.ExportableColumn;
+import org.nuiton.util.csv.ImportExportModel;
+import org.nuiton.util.csv.ImportableColumn;
+import org.nuiton.util.csv.ModelBuilder;
+
+import java.util.Collection;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * Import/Export csv model.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.2
+ */
+public class DbEditorCsvModel<E extends TopiaEntity> implements ImportExportModel<E> {
+
+ protected final char separator;
+
+ protected final TableMeta tableMeta;
+
+ protected ModelBuilder<E> modelBuilder;
+
+ public DbEditorCsvModel(char separator, TableMeta tableMeta) {
+ this.separator = separator;
+ this.tableMeta = tableMeta;
+ modelBuilder = new ModelBuilder<E>();
+ }
+
+ @Override
+ public char getSeparator() {
+ return separator;
+ }
+
+ @Override
+ public Collection<ExportableColumn<E, Object>> getColumnsForExport() {
+ return (Collection)
+ modelBuilder.getColumnsForExport();
+ }
+
+ @Override
+ public Collection<ImportableColumn<E, Object>> getColumnsForImport() {
+ return (Collection)
+ modelBuilder.getColumnsForImport();
+ }
+
+ @Override
+ public void pushCsvHeaderNames(List<String> headerNames) {
+ }
+
+ @Override
+ public E newEmptyInstance() {
+ return (E) tableMeta.newEntity();
+ }
+
+ public void addForeignKeyForExport(String propertyName,
+ Class<TopiaEntity> entityType) {
+
+ modelBuilder.newColumnForExport(
+ propertyName,
+ propertyName,
+ CsvModelUtil.newForeignKeyValue(entityType)
+ );
+ }
+
+ public void addForeignKeyForImport(String propertyName,
+ Class<TopiaEntity> entityType,
+ Collection<TopiaEntity> universe) {
+
+ modelBuilder.newMandatoryColumn(
+ propertyName,
+ propertyName,
+ CsvModelUtil.newForeignKeyValue(entityType, universe)
+ );
+ }
+
+ public <E extends TopiaEntity> void addDefaultColumn(String propertyName,
+ Class<?> type) {
+
+ if (Date.class.equals(type)) {
+ modelBuilder.newColumnForImportExport(
+ propertyName,
+ propertyName,
+ CsvModelUtil.DAY_TIME_SECOND
+ );
+ } else if (float.class.equals(type)) {
+ modelBuilder.newColumnForImportExport(
+ propertyName,
+ propertyName,
+ CsvModelUtil.PRIMITIVE_FLOAT
+ );
+ } else if (Float.class.equals(type)) {
+ modelBuilder.newColumnForImportExport(
+ propertyName,
+ propertyName,
+ CsvModelUtil.FLOAT
+ );
+ } else if (int.class.equals(type)) {
+ modelBuilder.newColumnForImportExport(
+ propertyName,
+ propertyName,
+ CsvModelUtil.PRIMITIVE_INTEGER
+ );
+ } else if (Integer.class.equals(type)) {
+ modelBuilder.newColumnForImportExport(
+ propertyName,
+ propertyName,
+ CsvModelUtil.INTEGER
+ );
+ } else if (boolean.class.equals(type)) {
+ modelBuilder.newColumnForImportExport(
+ propertyName,
+ propertyName,
+ CsvModelUtil.PRIMITIVE_BOOLEAN
+ );
+ } else if (Boolean.class.equals(type)) {
+ modelBuilder.newColumnForImportExport(
+ propertyName,
+ propertyName,
+ CsvModelUtil.BOOLEAN
+ );
+ } else {
+
+ // string
+ modelBuilder.newColumnForImportExport(
+ propertyName,
+ propertyName
+ );
+ }
+ }
+
+}
Property changes on: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/DbEditorCsvModel.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/DbEditorService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/DbEditorService.java 2011-11-23 17:50:27 UTC (rev 109)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/DbEditorService.java 2011-11-23 17:51:57 UTC (rev 110)
@@ -24,19 +24,15 @@
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.EchoBaseTechnicalException;
-import fr.ifremer.echobase.entities.EchoBaseDAOHelper;
import fr.ifremer.echobase.entities.EchoBaseEntityEnum;
import fr.ifremer.echobase.entities.EchoBaseUser;
import fr.ifremer.echobase.entities.EntityModificationLog;
-import fr.ifremer.echobase.entities.EntityModificationLogDAO;
import fr.ifremer.echobase.entities.meta.ColumnMeta;
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.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -44,18 +40,19 @@
import org.nuiton.topia.framework.TopiaQuery;
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;
+import org.nuiton.util.csv.Export;
+import org.nuiton.util.csv.ExportableColumn;
+import org.nuiton.util.csv.Import;
+import org.nuiton.util.csv.ImportableColumn;
+import org.nuiton.util.csv.ModelBuilder;
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.Collection;
+import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -70,14 +67,9 @@
/** Logger. */
private static final Log log = LogFactory.getLog(DbEditorService.class);
- 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";
- public static final String CSV_SEPARATOR = ";";
+ public static final char CSV_CHAR_SEPARATOR = ';';
protected DecoratorService decoratorService;
- protected SimpleDateFormat dateFormat;
protected DecoratorService getDecoratorService() {
if (decoratorService == null) {
@@ -86,67 +78,50 @@
return decoratorService;
}
- public SimpleDateFormat getDateFormat() {
- if (dateFormat == null) {
- dateFormat = new SimpleDateFormat(BASE_EDITOR_FORMAT_DATE);
- }
- return dateFormat;
- }
-
- public List<TopiaEntity> getForeignDatas(String entityType) {
+ public <E extends TopiaEntity> List<E> getForeignDatas(Class<E> entityType) {
Preconditions.checkNotNull(entityType);
- EchoBaseEntityEnum entityEnum = EchoBaseEntityEnum.valueOf(entityType);
- Preconditions.checkNotNull(entityEnum);
- Class<? extends TopiaEntity> contract = entityEnum.getContract();
try {
- TopiaDAO dao = EchoBaseDAOHelper.getDAO(getTransaction(), contract);
+ TopiaDAO<E> dao = getDAO(entityType);
- List result = dao.findAll();
+ List<E> result = dao.findAll();
return result;
} catch (TopiaException eee) {
throw new EchoBaseTechnicalException("Could not obtain data", eee);
}
}
- public TableMeta getTableMetas(String tableName) {
+ public TableMeta getTableMetas(EchoBaseEntityEnum tableName) {
DbMeta dbMeta = getDbMeta();
TableMeta result = dbMeta.getTable(tableName);
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,
+ public Map<?, ?>[] getDatas(EchoBaseEntityEnum entityType,
Pager pager,
String sidx,
Boolean ascendantOrder) {
- return getDatas(tableName, pager, sidx, ascendantOrder, true);
+ return getDatas(entityType, 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);
+ public <E extends TopiaEntity> List<E> getEntities(TableMeta tableMeta,
+ Pager pager,
+ String sidx,
+ Boolean ascendantOrder) {
+
+ List<E> result;
EchoBaseEntityEnum entityEnum = tableMeta.getEntityEnum();
Class<? extends TopiaEntity> contract = entityEnum.getContract();
try {
- TopiaDAO dao = EchoBaseDAOHelper.getDAO(getTransaction(), contract);
+ TopiaDAO dao = getDAO(contract);
// first query to count datas
TopiaQuery countQuery = dao.createQuery("e");
countQuery.addSelect("count(*)");
int count = dao.countByQuery(countQuery);
- List<?> all;
- int resultSize;
if (pager != null) {
pager.setRecords(count);
pager.computeIndexesAndPageCount();
@@ -154,8 +129,6 @@
int from = pager.getStartIndex();
int to = pager.getEndIndex();
- resultSize = to - from;
-
if (log.isDebugEnabled()) {
log.debug("Count = " + count);
log.debug("page = " + pager.getPageNumber());
@@ -174,319 +147,445 @@
}
}
query.setLimit(from, to - 1);
- all = dao.findAllByQuery(query);
+ result = dao.findAllByQuery(query);
} else {
// Get all
- all = dao.findAll();
- resultSize = count;
+ result = dao.findAll();
}
- Map<?, ?>[] rows = new Map[resultSize];
-
- int i = 0;
- for (Object o : all) {
- TopiaEntity entity = (TopiaEntity) o;
- Map<String, Object> row = loadRow(tableMeta, entity, addDecorated);
- rows[i++] = row;
- }
- return rows;
+ return result;
} catch (TopiaException eee) {
throw new EchoBaseTechnicalException("Could not obtain data", eee);
}
}
- public Map<?, ?> getData(String tableName,
- String topiaId) {
+ public Map<?, ?>[] getDatas(EchoBaseEntityEnum entityType,
+ Pager pager,
+ String sidx,
+ Boolean ascendantOrder,
+ boolean addDecorated) {
- DbMeta dbMeta = getDbMeta();
- TableMeta tableMeta = dbMeta.getTable(tableName);
+ TableMeta tableMeta = getTableMetas(entityType);
+
+ List<TopiaEntity> entities = getEntities(tableMeta,
+ pager,
+ sidx,
+ ascendantOrder
+ );
+
+ Map<?, ?>[] rows = new Map[entities.size()];
+
+ DbEditorCsvModel<TopiaEntity> model =
+ buildForLoad(tableMeta, addDecorated);
+
+ int i = 0;
+ for (Object o : entities) {
+ TopiaEntity entity = (TopiaEntity) o;
+ Map<String, Object> row = loadRow(entity, model);
+ rows[i++] = row;
+ }
+ return rows;
+ }
+
+ public Map<?, ?> getData(TableMeta tableMeta, String topiaId) {
+
EchoBaseEntityEnum entityEnum = tableMeta.getEntityEnum();
- Class<? extends TopiaEntity> contract = entityEnum.getContract();
try {
- TopiaDAO dao = EchoBaseDAOHelper.getDAO(getTransaction(), contract);
+ TopiaDAO<?> dao = getDAO(entityEnum.getContract());
TopiaEntity entity = dao.findByTopiaId(topiaId);
- return loadRow(tableMeta, entity, true);
+ DbEditorCsvModel<TopiaEntity> model = buildForLoad(tableMeta, true);
+ return loadRow(entity, model);
} catch (TopiaException eee) {
throw new EchoBaseTechnicalException("Could not obtain data", eee);
}
}
- public PropertyDiff[] saveEntity(TableMeta tableMeta,
- String id,
- Map<String, String> properties,
- EchoBaseUser user) {
+ public void saveEntity(TableMeta tableMeta,
+ String id,
+ Map<String, String> properties,
+ EchoBaseUser user) {
- return saveEntity(tableMeta, id, properties, user, true);
+ // transform properties entity
+ DbEditorCsvModel<TopiaEntity> model = buildForSave(tableMeta);
+
+ TopiaEntity entity = model.newEmptyInstance();
+ entity.setTopiaId(id);
+
+ for (ImportableColumn<TopiaEntity, Object> column : model.getColumnsForImport()) {
+ String propertyName = column.getHeaderName();
+ String stringValue = properties.get(propertyName);
+ Object o;
+ try {
+ o = column.parseValue(stringValue);
+ } catch (Exception e) {
+ throw new EchoBaseTechnicalException("Could not parse property [" + propertyName + "] with value " + stringValue);
+ }
+ try {
+ column.setValue(entity, o);
+ } catch (Exception e) {
+ throw new EchoBaseTechnicalException("Could not set property [" + propertyName + "] with value " + stringValue + " to entity " + entity);
+ }
+ }
+
+ saveEntity(
+ tableMeta,
+ "Modification utilisateur",
+ entity,
+ user,
+ false,
+ null
+ );
+ commitTransaction("Could not commit transaction");
}
- public PropertyDiff[] saveEntity(TableMeta tableMeta,
- String id,
- Map<String, String> properties,
- EchoBaseUser user,
- boolean commit) {
+ public CsvImportResult importDatas(EchoBaseEntityEnum entityType,
+ String importFileName,
+ File importFile,
+ boolean createIfNotFound,
+ EchoBaseUser user) {
+ TableMeta tableMeta = getTableMetas(entityType);
+ DbEditorCsvModel<TopiaEntity> csvModel = buildForImport(tableMeta);
+ String messagePrefix = "Import du fichier " + importFileName;
- Class<? extends TopiaEntity> entityType = tableMeta.getEntityType();
+ CsvImportResult result = new CsvImportResult();
+ result.setImportFileName(importFileName);
+ result.setEntityType(entityType);
+ BufferedReader bf = null;
+ try {
+
+ bf = new BufferedReader(new FileReader(importFile));
+
+ Import<TopiaEntity> importer = Import.newImport(csvModel, bf);
+
+ Iterator<TopiaEntity> iterator = importer.startImport();
+
+ try {
+ while (iterator.hasNext()) {
+ TopiaEntity entity = iterator.next();
+ saveEntity(tableMeta,
+ messagePrefix,
+ entity,
+ user,
+ createIfNotFound,
+ result
+ );
+ }
+ } finally {
+
+ importer.stopImport();
+ }
+
+ commitTransaction("Could not commit transaction");
+ } catch (EchoBaseTechnicalException eee) {
+ throw eee;
+ } catch (Exception eee) {
+ log.error("Failed to read import file " + importFile.getName(), eee);
+ throw new EchoBaseTechnicalException(eee);
+ } finally {
+ IOUtils.closeQuietly(bf);
+ }
+
+ return result;
+ }
+
+ public String exportDatas(EchoBaseEntityEnum entityType) {
+
+ TableMeta tableMeta = getTableMetas(entityType);
+
+ List<TopiaEntity> datas = getEntities(tableMeta, null, null, null);
+
+ DbEditorCsvModel<TopiaEntity> model = buildForExport(tableMeta);
+
+ Export<TopiaEntity> export = Export.newExport(model, datas);
+
+ try {
+ return export.startExportAsString();
+ } catch (Exception eee) {
+ throw new EchoBaseTechnicalException("Can not export datas", eee);
+ }
+ }
+
+ protected void saveEntity(TableMeta tableMeta,
+ String messagePrefix,
+ TopiaEntity entity,
+ EchoBaseUser user,
+ boolean createIfNotFound,
+ CsvImportResult result) {
+
String[] columnNames = tableMeta.getColumnNamesAsArray();
- BeanMonitor monitor = new BeanMonitor(columnNames);
+ BeanMonitor monitor = null;
+ String id = entity.getTopiaId();
+
try {
- TopiaDAO dao = EchoBaseDAOHelper.getDAO(
- getTransaction(),
- entityType);
+ TopiaDAO<TopiaEntity> dao = getDAO(tableMeta.getEntityEnum());
TopiaEntity entityToSave;
// Find or create entity if no id
boolean create = StringUtils.isEmpty(id);
if (create) {
+
entityToSave = dao.create();
+ result.incrementsNumberCreated();
} else {
+
entityToSave = dao.findByTopiaId(id);
- }
- monitor.setBean(entityToSave);
- for (Map.Entry<String, String> entry : properties.entrySet()) {
- String propertyName = entry.getKey();
- String propertyValue = entry.getValue();
- Object value;
- ColumnMeta columnMeta = tableMeta.getColumns(propertyName);
- if (columnMeta.isFK()) {
+ if (entityToSave == null) {
- // let's find the entity
- TopiaDAO daoFK = EchoBaseDAOHelper.getDAO(
- getTransaction(),
- (Class<? extends TopiaEntity>) columnMeta.getType());
- value = daoFK.findByTopiaId(propertyValue);
+ if (!createIfNotFound) {
- } else if (Date.class.equals(columnMeta.getType())) {
- value = getDateFormat().parse(propertyValue);
- } else {
- value = propertyValue;
+ // this is an error
+ throw new EchoBaseTechnicalException("Could not found entity with id " + id);
+ } else {
+ entityToSave = dao.create(TopiaEntity.TOPIA_ID, id);
+
+ }
}
- BeanUtils.setProperty(entityToSave,
- propertyName,
- value);
+ // monitor the existing bean
+ monitor = new BeanMonitor(columnNames);
+ monitor.setBean(entityToSave);
+
+ result.incrementsNumberUpdated();
}
- PropertyDiff[] propertyDiffs = monitor.getPropertyDiffs();
+ tableMeta.copy(entity, entityToSave);
- int length = propertyDiffs.length;
+ PropertyDiff[] propertyDiffs = monitor == null ? null :
+ monitor.getPropertyDiffs();
- if (length > 0) {
+ createEntityModificationLog(
+ tableMeta,
+ messagePrefix,
+ entityToSave,
+ user,
+ propertyDiffs
+ );
+ } catch (Exception eee) {
+ throw new EchoBaseTechnicalException("Could not update entity", eee);
+ } finally {
+ if (monitor != null) {
+ monitor.setBean(null);
+ }
+ }
+ }
- // something was modified on the entity
+ protected void createEntityModificationLog(
+ TableMeta tableMeta,
+ String messagePrefix,
+ TopiaEntity entity,
+ EchoBaseUser user,
+ PropertyDiff[] propertyDiffs) throws TopiaException {
- EntityModificationLogDAO dao1 =
- EchoBaseDAOHelper.getEntityModificationLogDAO(
- getTransaction()
- );
+ StringBuilder buffer;
- StringBuilder buffer;
+ String topiaId = entity.getTopiaId();
- if (create) {
- buffer = new StringBuilder("Une entité à été crée :");
- } else {
- 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];
+ boolean create = propertyDiffs == null;
- Object sourceValue = diff.getSourceValue();
- Object targetValue = diff.getTargetValue();
+ buffer = new StringBuilder(messagePrefix + "\n");
+ if (create) {
+ buffer.append("Une entité à été crée d'identifiant ").append(topiaId);
+ } else {
- String propertyName = diff.getSourceProperty();
+ int length = propertyDiffs.length;
- if (tableMeta.getColumns(propertyName).isFK()) {
+ if (length == 1) {
+ buffer.append("Une propriété a été modifiée :");
+ } else {
+ buffer.append(length).append(" propriétés ont été modifiées :");
+ }
+ for (int i = 0; i < length; i++) {
+ PropertyDiff diff = propertyDiffs[i];
- // replace by the decorate value
- if (sourceValue != null) {
- sourceValue = getDecoratorService().decorate(
- getLocale(), sourceValue, null);
- }
- if (targetValue != null) {
- targetValue = getDecoratorService().decorate(
- getLocale(), targetValue, null);
- }
+ Object sourceValue = diff.getSourceValue();
+ Object targetValue = diff.getTargetValue();
- }
+ String propertyName = diff.getSourceProperty();
- 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
- ));
+ if (tableMeta.getColumns(propertyName).isFK()) {
+
+ // replace by the decorate value
+ 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",
+ propertyName,
+ sourceValue,
+ targetValue
+ ));
}
- dao1.create(
- EntityModificationLog.PROPERTY_ENTITY_TYPE, entityType.getSimpleName(),
- EntityModificationLog.PROPERTY_ENTITY_ID, id,
- EntityModificationLog.PROPERTY_USER, user,
- EntityModificationLog.PROPERTY_MODIFICATION_DATE, new Date(),
- EntityModificationLog.PROPERTY_MODIFICATION_TEXT, buffer.toString()
- );
-
- if (commit) {
- getTransaction().commitTransaction();
- }
}
- return propertyDiffs;
- } catch (Exception eee) {
- throw new EchoBaseTechnicalException("Could not update entity", eee);
- } finally {
- monitor.setBean(null);
}
+
+ TopiaDAO<EntityModificationLog> dao =
+ getDAO(EntityModificationLog.class);
+
+ dao.create(
+ EntityModificationLog.PROPERTY_ENTITY_TYPE, tableMeta.getEntityEnum().name(),
+ EntityModificationLog.PROPERTY_ENTITY_ID, topiaId,
+ EntityModificationLog.PROPERTY_USER, user,
+ EntityModificationLog.PROPERTY_MODIFICATION_DATE, newDate(),
+ EntityModificationLog.PROPERTY_MODIFICATION_TEXT, buffer.toString()
+ );
}
- protected Map<String, Object> loadRow(TableMeta tableMeta,
- TopiaEntity entity,
- boolean addDecorated) {
+ protected <E extends TopiaEntity> Map<String, Object> loadRow(
+ E entity,
+ DbEditorCsvModel<E> loadModel) {
+
Map<String, Object> row = Maps.newLinkedHashMap();
- EntityOperator<TopiaEntity> operator =
- (EntityOperator<TopiaEntity>) tableMeta.getOperator();
- row.put("id", entity.getTopiaId());
- for (ColumnMeta columnMeta : tableMeta) {
- String propertyName = columnMeta.getName();
- // get property value
- Object property = operator.get(propertyName, entity);
- if (columnMeta.isFK() && property != null) {
+ Collection<ExportableColumn<E, Object>> columns =
+ loadModel.getColumnsForExport();
- // this is a foreign key, just keep the topiaid
- String topiaId = ((TopiaEntity) property).getTopiaId();
+ for (ExportableColumn<E, Object> column : columns) {
+ String propertyName = column.getHeaderName();
+ Object value;
+ try {
+ value = column.getValue(entity);
+ } catch (Exception eee) {
+ throw new EchoBaseTechnicalException(
+ "Could not obtain property [" + propertyName +
+ "] value ", eee);
+ }
+ String formatedValue = column.formatValue(value);
+ row.put(propertyName, formatedValue);
- if (addDecorated) {
- // decorate the entity
- String decorate = getDecoratorService().decorate(
- getLocale(), property, null);
+ }
+ return row;
+ }
- // keep the decorate value
- row.put(propertyName + "_lib", decorate);
- }
+ protected <E extends TopiaEntity> DbEditorCsvModel<E> buildForImport(TableMeta tableMetas) {
- // use as the property his topiaid
- property = topiaId;
- }
+ DbEditorCsvModel<E> model = new DbEditorCsvModel<E>(CSV_CHAR_SEPARATOR,
+ tableMetas);
- // Format date
- if (columnMeta.isDate() && property != null) {
- Date date = (Date) property;
- property = getDateFormat().format(date);
+ ModelBuilder<E> modelBuilder = model.modelBuilder;
+
+ modelBuilder.newColumnForImportExport(
+ TopiaEntity.TOPIA_ID,
+ TopiaEntity.TOPIA_ID
+ );
+
+ for (ColumnMeta columnMeta : model.tableMeta) {
+ String propertyName = columnMeta.getName();
+ Class<?> type = columnMeta.getType();
+ if (columnMeta.isFK()) {
+
+ Class<TopiaEntity> entityType = (Class<TopiaEntity>) type;
+ Collection<TopiaEntity> universe = getForeignDatas(entityType);
+ model.addForeignKeyForImport(propertyName, entityType, universe);
+ } else {
+ model.addDefaultColumn(propertyName, type);
}
- row.put(propertyName, property);
}
- return row;
+ return model;
}
- public List<PropertyDiff[]> importDatas(String tableName,
- File importFile,
- EchoBaseUser user) {
- TableMeta tableMetas = 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(CSV_SEPARATOR);
+ protected <E extends TopiaEntity> DbEditorCsvModel<E> buildForSave(TableMeta tableMetas) {
- String line = bf.readLine();
- while (line != null) {
+ DbEditorCsvModel<E> model = new DbEditorCsvModel<E>(CSV_CHAR_SEPARATOR,
+ tableMetas);
- Map<String, String> valuesMap = Maps.newLinkedHashMap();
+ ModelBuilder<E> modelBuilder = model.modelBuilder;
- String[] values = line.split(CSV_SEPARATOR);
+ modelBuilder.newColumnForExport(
+ TopiaEntity.TOPIA_ID,
+ TopiaEntity.TOPIA_ID
+ );
- String id = values[0];
- for (int i=1;i<values.length;i++) {
- valuesMap.put(properties[i], values[i]);
- }
+ for (ColumnMeta columnMeta : model.tableMeta) {
+ String propertyName = columnMeta.getName();
+ Class<?> type = columnMeta.getType();
+ if (columnMeta.isFK()) {
- // Save entity
- PropertyDiff[] propertyDiffs = saveEntity(tableMetas, id, valuesMap, user, false);
- result.add(propertyDiffs);
+ Class<TopiaEntity> entityType = (Class<TopiaEntity>) type;
- line = bf.readLine();
- }
+ Collection<TopiaEntity> universe = getForeignDatas(entityType);
- // Commit
- getTransaction().commitTransaction();
- } catch (Exception 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("Failed to close import file " + importFile.getName(), eee);
- throw new EchoBaseTechnicalException(eee);
- }
+ // translate foreign key to his id
+ model.addForeignKeyForImport(propertyName, entityType, universe);
+
+ } else {
+ model.addDefaultColumn(propertyName, type);
}
}
- return result;
+ return model;
}
- public File exportDatas(String tableName) {
+ protected <E extends TopiaEntity> DbEditorCsvModel<E> buildForExport(TableMeta tableMetas) {
- Map<?, ?>[] datas = getAllDatas(tableName, false);
+ DbEditorCsvModel<E> model = new DbEditorCsvModel<E>(CSV_CHAR_SEPARATOR,
+ tableMetas);
- StringBuilder csvContent = new StringBuilder();
+ ModelBuilder<E> modelBuilder = model.modelBuilder;
- // Build csv
- boolean headerCompleted = false;
+ modelBuilder.newColumnForImportExport(
+ TopiaEntity.TOPIA_ID,
+ TopiaEntity.TOPIA_ID
+ );
- // To escape value if csv special char is found
- StringUtil.ToString csvConvertor = new StringUtil.ToCSV(CSV_SEPARATOR);
- for (Map<?, ?> data : datas) {
+ for (ColumnMeta columnMeta : model.tableMeta) {
+ String propertyName = columnMeta.getName();
+ Class<?> type = columnMeta.getType();
+ if (columnMeta.isFK()) {
- // Write header
- if (!headerCompleted) {
- String keys = StringUtil.join(data.keySet(), csvConvertor, CSV_SEPARATOR, false);
- csvContent.append(keys);
- csvContent.append("\n");
- headerCompleted = true;
+ Class<TopiaEntity> entityType = (Class<TopiaEntity>) type;
+ model.addForeignKeyForExport(propertyName, entityType);
+ } else {
+ model.addDefaultColumn(propertyName, type);
}
-
- // Write content
- String values = StringUtil.join(data.values(), csvConvertor, CSV_SEPARATOR, false);
- csvContent.append(values);
- csvContent.append("\n");
}
+ return model;
+ }
- // Write export file
- SimpleDateFormat format = new SimpleDateFormat(EXPORT_FILE_FORMAT_DATE);
- String now = format.format(new Date());
+ protected <E extends TopiaEntity> DbEditorCsvModel<E> buildForLoad(TableMeta tableMetas,
+ boolean addDecorated) {
- // Write in tmp dir
- File tempDirectory = FileUtils.getTempDirectory();
- File file = new File(tempDirectory, EXPORT_FILE_PREFIX + now + SCV_EXT);
- file.deleteOnExit();
+ DbEditorCsvModel<E> model = new DbEditorCsvModel<E>(CSV_CHAR_SEPARATOR,
+ tableMetas);
- FileWriter writer = null;
- try {
- writer = new FileWriter(file, true);
- writer.write(csvContent.toString());
- } catch (IOException 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("Failed to close modif export file", eee);
- throw new EchoBaseTechnicalException(eee);
+ ModelBuilder<E> modelBuilder = model.modelBuilder;
+
+ modelBuilder.newColumnForImportExport(
+ "id",
+ TopiaEntity.TOPIA_ID
+ );
+
+ for (ColumnMeta columnMeta : model.tableMeta) {
+ String propertyName = columnMeta.getName();
+ Class<?> type = columnMeta.getType();
+ if (columnMeta.isFK()) {
+
+ Class<TopiaEntity> entityType = (Class<TopiaEntity>) type;
+
+ // translate foreign key to his id
+ model.addForeignKeyForExport(propertyName, entityType);
+
+ if (addDecorated) {
+
+ // translate foreign key to his decorated value
+ modelBuilder.newColumnForExport(
+ propertyName + "_lib",
+ propertyName,
+ CsvModelUtil.newForeignKeyDecoratedValue(
+ entityType,
+ getDecoratorService(),
+ getLocale())
+ );
}
+
+ } else {
+ model.addDefaultColumn(propertyName, type);
}
}
- return file;
+ return model;
}
+
}
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ExportSqlService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ExportSqlService.java 2011-11-23 17:50:27 UTC (rev 109)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ExportSqlService.java 2011-11-23 17:51:57 UTC (rev 110)
@@ -40,7 +40,6 @@
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
-import java.util.Date;
import java.util.List;
import java.util.Map;
@@ -90,7 +89,7 @@
entityToSave.setName(exportQuery.getName());
entityToSave.setDescription(exportQuery.getDescription());
entityToSave.setSqlQuery(exportQuery.getSqlQuery());
- entityToSave.setLastModifiedDate(new Date());
+ entityToSave.setLastModifiedDate(newDate());
entityToSave.setLastModifiedUser(user);
dao.update(entityToSave);
@@ -156,8 +155,7 @@
}
StringBuilder buffer = new StringBuilder();
int rowCount = rows.length;
- buffer.append("#Created at ").append(new Date()).append(" by user ").append(echoBaseUser.getEmail());
- buffer.append("\n#").append(StringUtils.join(columnNames, ";"));
+ buffer.append(StringUtils.join(columnNames, ";"));
for (int i = 0; i < rowCount; i++) {
Map<String, Object> row = rows[i];
buffer.append('\n').append(StringUtils.join(row.values(), ";"));
1
0
r109 - trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/meta
by tchemit@users.forge.codelutin.com 23 Nov '11
by tchemit@users.forge.codelutin.com 23 Nov '11
23 Nov '11
Author: tchemit
Date: 2011-11-23 18:50:27 +0100 (Wed, 23 Nov 2011)
New Revision: 109
Url: http://forge.codelutin.com/repositories/revision/echobase/109
Log:
use entityEnum instead of name
Modified:
trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/meta/DbMeta.java
trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/meta/TableMeta.java
Modified: trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/meta/DbMeta.java
===================================================================
--- trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/meta/DbMeta.java 2011-11-23 10:34:23 UTC (rev 108)
+++ trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/meta/DbMeta.java 2011-11-23 17:50:27 UTC (rev 109)
@@ -66,18 +66,6 @@
return tables;
}
- public TableMeta getTable(String tableName) {
- Preconditions.checkNotNull(tableName);
- TableMeta result = null;
- for (TableMeta tableMeta : getTables()) {
- if (tableName.equals(tableMeta.getName())) {
- result = tableMeta;
- break;
- }
- }
- return result;
- }
-
public TableMeta getTable(EchoBaseEntityEnum tableName) {
Preconditions.checkNotNull(tableName);
TableMeta result = null;
Modified: trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/meta/TableMeta.java
===================================================================
--- trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/meta/TableMeta.java 2011-11-23 10:34:23 UTC (rev 108)
+++ trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/meta/TableMeta.java 2011-11-23 17:50:27 UTC (rev 109)
@@ -29,6 +29,7 @@
import fr.ifremer.echobase.entities.EchoBaseEntityEnum;
import org.nuiton.topia.persistence.TopiaEntity;
import org.nuiton.topia.persistence.util.EntityOperator;
+import org.nuiton.util.ObjectUtil;
import org.nuiton.util.beans.Binder;
import org.nuiton.util.beans.BinderModelBuilder;
@@ -47,8 +48,6 @@
private static final long serialVersionUID = 1L;
- protected final String name;
-
protected final String i18nKey;
protected final EntityOperator<?> operator;
@@ -62,7 +61,6 @@
public TableMeta(EchoBaseEntityEnum entityEnum) {
Preconditions.checkNotNull(entityEnum);
this.entityEnum = entityEnum;
- name = entityEnum.getImplementationFQN();
Class<? extends TopiaEntity> contract = entityEnum.getContract();
i18nKey = "echobase.common." +
Introspector.decapitalize(contract.getSimpleName());
@@ -70,7 +68,7 @@
}
public String getName() {
- return name;
+ return entityEnum.name();
}
public EchoBaseEntityEnum getEntityEnum() {
@@ -140,6 +138,10 @@
return getColumns().iterator();
}
+ public TopiaEntity newEntity() {
+ return ObjectUtil.newInstance(entityEnum.getImplementation());
+ }
+
protected static <E extends TopiaEntity> Binder<E, E> newbinder(TableMeta meta) {
BinderModelBuilder<E, E> binderModelBuilder =
(BinderModelBuilder<E, E>) BinderModelBuilder.newEmptyBuilder(meta.getEntityType());
1
0
r108 - trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/meta
by tchemit@users.forge.codelutin.com 23 Nov '11
by tchemit@users.forge.codelutin.com 23 Nov '11
23 Nov '11
Author: tchemit
Date: 2011-11-23 11:34:23 +0100 (Wed, 23 Nov 2011)
New Revision: 108
Url: http://forge.codelutin.com/repositories/revision/echobase/108
Log:
add binder facility inside the TableMeta object
Modified:
trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/meta/TableMeta.java
Modified: trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/meta/TableMeta.java
===================================================================
--- trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/meta/TableMeta.java 2011-11-22 11:33:08 UTC (rev 107)
+++ trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/meta/TableMeta.java 2011-11-23 10:34:23 UTC (rev 108)
@@ -29,6 +29,8 @@
import fr.ifremer.echobase.entities.EchoBaseEntityEnum;
import org.nuiton.topia.persistence.TopiaEntity;
import org.nuiton.topia.persistence.util.EntityOperator;
+import org.nuiton.util.beans.Binder;
+import org.nuiton.util.beans.BinderModelBuilder;
import java.beans.Introspector;
import java.io.Serializable;
@@ -55,6 +57,8 @@
protected List<ColumnMeta> columns;
+ protected Binder<TopiaEntity, TopiaEntity> binder;
+
public TableMeta(EchoBaseEntityEnum entityEnum) {
Preconditions.checkNotNull(entityEnum);
this.entityEnum = entityEnum;
@@ -127,8 +131,31 @@
return columns;
}
+ public void copy(TopiaEntity source, TopiaEntity target) {
+ getBinder().copy(source, target);
+ }
+
@Override
public Iterator<ColumnMeta> iterator() {
return getColumns().iterator();
}
+
+ protected static <E extends TopiaEntity> Binder<E, E> newbinder(TableMeta meta) {
+ BinderModelBuilder<E, E> binderModelBuilder =
+ (BinderModelBuilder<E, E>) BinderModelBuilder.newEmptyBuilder(meta.getEntityType());
+ for (ColumnMeta columnMeta : meta) {
+ binderModelBuilder.addSimpleProperties(
+ columnMeta.getName()
+ );
+ }
+ Binder<E, E> binder = binderModelBuilder.toBinder();
+ return binder;
+ }
+
+ protected Binder<TopiaEntity, TopiaEntity> getBinder() {
+ if (binder == null) {
+ binder = newbinder(this);
+ }
+ return binder;
+ }
}
1
0
r107 - in trunk/echobase-services/src/main: java/fr/ifremer/echobase/services resources resources/embedded
by sletellier@users.forge.codelutin.com 22 Nov '11
by sletellier@users.forge.codelutin.com 22 Nov '11
22 Nov '11
Author: sletellier
Date: 2011-11-22 12:33:08 +0100 (Tue, 22 Nov 2011)
New Revision: 107
Url: http://forge.codelutin.com/repositories/revision/echobase/107
Log:
Move embedded configuration to embedded directory
Added:
trunk/echobase-services/src/main/resources/embedded/
trunk/echobase-services/src/main/resources/embedded/echobase-embedded.properties
Removed:
trunk/echobase-services/src/main/resources/echobase-embedded.properties
Modified:
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EmbeddedApplicationService.java
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EmbeddedApplicationService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EmbeddedApplicationService.java 2011-11-22 11:32:34 UTC (rev 106)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EmbeddedApplicationService.java 2011-11-22 11:33:08 UTC (rev 107)
@@ -114,7 +114,7 @@
log.info("Copy configuration to " + configurationfile);
}
InputStream configInputStream =
- getClass().getResourceAsStream("/echobase-embedded.properties");
+ getClass().getResourceAsStream("/embedded/echobase-embedded.properties");
OutputStream configOutputStream = new FileOutputStream(configurationfile);
try {
IOUtils.copy(configInputStream, configOutputStream);
Deleted: trunk/echobase-services/src/main/resources/echobase-embedded.properties
===================================================================
--- trunk/echobase-services/src/main/resources/echobase-embedded.properties 2011-11-22 11:32:34 UTC (rev 106)
+++ trunk/echobase-services/src/main/resources/echobase-embedded.properties 2011-11-22 11:33:08 UTC (rev 107)
@@ -1,29 +0,0 @@
-###
-# #%L
-# EchoBase :: Services
-#
-# $Id$
-# $HeadURL$
-# %%
-# Copyright (C) 2011 Ifremer, Codelutin
-# %%
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-# #L%
-###
-
-hibernate.dialect=org.hibernate.dialect.H2Dialect
-hibernate.connection.username=sa
-hibernate.connection.password=sa
-hibernate.connection.driver_class=org.h2.Driver
-hibernate.connection.url=jdbc:h2:file:./db/echobase
Copied: trunk/echobase-services/src/main/resources/embedded/echobase-embedded.properties (from rev 104, trunk/echobase-services/src/main/resources/echobase-embedded.properties)
===================================================================
--- trunk/echobase-services/src/main/resources/embedded/echobase-embedded.properties (rev 0)
+++ trunk/echobase-services/src/main/resources/embedded/echobase-embedded.properties 2011-11-22 11:33:08 UTC (rev 107)
@@ -0,0 +1,29 @@
+###
+# #%L
+# EchoBase :: Services
+#
+# $Id$
+# $HeadURL$
+# %%
+# Copyright (C) 2011 Ifremer, Codelutin
+# %%
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+# #L%
+###
+
+hibernate.dialect=org.hibernate.dialect.H2Dialect
+hibernate.connection.username=sa
+hibernate.connection.password=sa
+hibernate.connection.driver_class=org.h2.Driver
+hibernate.connection.url=jdbc:h2:file:./db/echobase
Property changes on: trunk/echobase-services/src/main/resources/embedded/echobase-embedded.properties
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
1
0
22 Nov '11
Author: sletellier
Date: 2011-11-22 12:32:34 +0100 (Tue, 22 Nov 2011)
New Revision: 106
Url: http://forge.codelutin.com/repositories/revision/echobase/106
Log:
- Update server install documentation
Added:
trunk/src/site/resources/
trunk/src/site/resources/echobase.properties
trunk/src/site/rst/install.rst
trunk/src/site/rst/todo.rst
Removed:
trunk/src/site/rst/Todo.rst
Modified:
trunk/src/site/rst/index.rst
trunk/src/site/site_fr.xml
Added: trunk/src/site/resources/echobase.properties
===================================================================
--- trunk/src/site/resources/echobase.properties (rev 0)
+++ trunk/src/site/resources/echobase.properties 2011-11-22 11:32:34 UTC (rev 106)
@@ -0,0 +1,28 @@
+###
+# #%L
+# EchoBase
+#
+# $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%
+###
+hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
+hibernate.connection.driver_class=org.postgresql.Driver
+hibernate.connection.url=jdbc:postgresql://localhost/echobase
+hibernate.connection.username=echobase
+hibernate.connection.password=echobase
Deleted: trunk/src/site/rst/Todo.rst
===================================================================
--- trunk/src/site/rst/Todo.rst 2011-11-22 09:46:56 UTC (rev 105)
+++ trunk/src/site/rst/Todo.rst 2011-11-22 11:32:34 UTC (rev 106)
@@ -1,23 +0,0 @@
-.. -
-.. * #%L
-.. * EchoBase
-.. *
-.. * $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%
-.. -
Modified: trunk/src/site/rst/index.rst
===================================================================
--- trunk/src/site/rst/index.rst 2011-11-22 09:46:56 UTC (rev 105)
+++ trunk/src/site/rst/index.rst 2011-11-22 11:32:34 UTC (rev 106)
@@ -21,11 +21,11 @@
.. * along with this program. If not, see <http://www.gnu.org/licenses/>.
.. * #L%
.. -
-==
-Baracouda
-==
+========
+Echobase
+========
-:Author: Tony Chemit <chemit(a)codelutin.com>
+:Authors: Tony Chemit <chemit(a)codelutin.com>, Letellier Sylvain <letellier(a)codelutin.com>
.. contents:: Table des matières
:depth: 2
@@ -34,7 +34,6 @@
:start: 1
:depth: 2
-
Présentation
------------
@@ -43,4 +42,4 @@
Les documents
-------------
-TODO
\ No newline at end of file
+TODO
Added: trunk/src/site/rst/install.rst
===================================================================
--- trunk/src/site/rst/install.rst (rev 0)
+++ trunk/src/site/rst/install.rst 2011-11-22 11:32:34 UTC (rev 106)
@@ -0,0 +1,74 @@
+.. -
+.. * #%L
+.. * EchoBase
+.. *
+.. * $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
+========
+
+:Authors: Tony Chemit <chemit(a)codelutin.com>, Letellier Sylvain <letellier(a)codelutin.com>
+
+.. contents:: Table des matières
+ :depth: 2
+
+.. sectnum::
+ :start: 1
+ :depth: 2
+
+Première utilisation
+--------------------
+
+Un utilisateur par défaut est crée si la base est vide (première utilisation)::
+
+ login : admin
+ mot de passe : admin
+
+Pour des raison de sécurité, il est conseillé de créer un nouvelle admin via l'interface de gestion des utilisateurs.
+
+Configuration d'Echobase
+------------------------
+
+Il faut éditer le fichier
+
+Voici les configurations par défaut::
+
+ data.directory=/var/local/echobase # Repertoire de l'application
+ war.directory=${data.directory}/war # Répertoire où est stoqué le war
+ war.location=${war.directory}/echobase-ui-${project.version}.war # Chemin complêt d'accès au war
+
+Vous pouvez surcharger toute les propriétés ci-dessus, dans la plupart des cas, seul la modification de data.directory est nécessaire.
+Pour ce faire, il suffit de créer le fichier /etc/echobase.properties et d'y ajouter la ligne ci-dessus modifiée.
+
+Installation Postgres
+---------------------
+
+Création de l'utilisateur Postgres::
+
+ createuser -P echobase
+
+Création de la base de donnée "echobase"::
+
+ createdb -E utf8 echobase -O echobase
+
+Il faut positionner le fichier de configuration echobase.properties_ dans /etc et remplacer le mot de passe (hibernate.connection.password) par celui rentré lors de la création de l'utilisateur Postgres.
+
+.. _echobase.properties: echobase.properties
\ No newline at end of file
Copied: trunk/src/site/rst/todo.rst (from rev 104, trunk/src/site/rst/Todo.rst)
===================================================================
--- trunk/src/site/rst/todo.rst (rev 0)
+++ trunk/src/site/rst/todo.rst 2011-11-22 11:32:34 UTC (rev 106)
@@ -0,0 +1,40 @@
+.. -
+.. * #%L
+.. * EchoBase
+.. *
+.. * $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
+========
+
+:Authors: Tony Chemit <chemit(a)codelutin.com>, Letellier Sylvain <letellier(a)codelutin.com>
+
+.. contents:: Table des matières
+ :depth: 2
+
+.. sectnum::
+ :start: 1
+ :depth: 2
+
+TODO
+====
+
+- Completer la documentation
\ No newline at end of file
Property changes on: trunk/src/site/rst/todo.rst
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/src/site/site_fr.xml
===================================================================
--- trunk/src/site/site_fr.xml 2011-11-22 09:46:56 UTC (rev 105)
+++ trunk/src/site/site_fr.xml 2011-11-22 11:32:34 UTC (rev 106)
@@ -23,8 +23,6 @@
#L%
-->
-
-
<project name="${project.name}">
<poweredBy>
@@ -56,17 +54,19 @@
<breadcrumbs>
<item name="${project.name}"
- href="http://maven-site.forge.codelutin.com/baracouda/index.html"/>
+ href="http://maven-site.forge.codelutin.com/echobase/index.html"/>
</breadcrumbs>
<menu name="Utilisateur">
<item name="Accueil" href="index.html"/>
<item name="Installation" href="install.html"/>
<item name="Téléchargement"
- href="http://forge.codelutin.com/projects/baracouda/files"/>
+ href="http://forge.codelutin.com/projects/echobase/files"/>
<item name="Roadmap"
- href="http://forge.codelutin.com/projects/baracouda/roadmap"/>
- <item name="Historique des versions" href="changes-report.html"/>
+ href="http://forge.codelutin.com/projects/echobase/roadmap"/>
+
+ <!-- TODO -->
+ <!--<item name="Historique des versions" href="changes-report.html"/>-->
</menu>
<!--menu name="Modélisation">
1
0
r105 - in trunk/echobase-ui/src/main: resources/i18n webapp/WEB-INF/jsp/dbeditor
by sletellier@users.forge.codelutin.com 22 Nov '11
by sletellier@users.forge.codelutin.com 22 Nov '11
22 Nov '11
Author: sletellier
Date: 2011-11-22 10:46:56 +0100 (Tue, 22 Nov 2011)
New Revision: 105
Url: http://forge.codelutin.com/repositories/revision/echobase/105
Log:
Fix time edition
Modified:
trunk/echobase-ui/src/main/resources/i18n/echobase-ui_fr_FR.properties
trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/dbeditor/dbeditor.jsp
Modified: trunk/echobase-ui/src/main/resources/i18n/echobase-ui_fr_FR.properties
===================================================================
--- trunk/echobase-ui/src/main/resources/i18n/echobase-ui_fr_FR.properties 2011-11-21 16:12:09 UTC (rev 104)
+++ trunk/echobase-ui/src/main/resources/i18n/echobase-ui_fr_FR.properties 2011-11-22 09:46:56 UTC (rev 105)
@@ -1,6 +1,5 @@
echobase.action.applySqlQuery=Appliquer la requête
echobase.action.backToUserList=Retour à la liste des utilisateurs
-echobase.action.reset=Annuler
echobase.action.cloneSqlQuery=Cloner la requête
echobase.action.create=Créer
echobase.action.createEmbeddedApplication=Créer l'application
@@ -15,6 +14,7 @@
echobase.action.login=Connection
echobase.action.logout=Déconnexion
echobase.action.reloadSqlQuery=Recharger
+echobase.action.reset=Annuler
echobase.action.return=Retour
echobase.action.save=Sauvegarder
echobase.action.saveSqlQuery=Enregistrer la requête
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-21 16:12:09 UTC (rev 104)
+++ trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/dbeditor/dbeditor.jsp 2011-11-22 09:46:56 UTC (rev 105)
@@ -146,27 +146,39 @@
function updateDate(value, editor) {
// parse date formated like : dd/MM/yyyy HH:mm:ss
+ var date = parseDate(value);
+
+ // get timePicker instance
+ var inst = $.datepicker._getInst(editor[0]);
+
+ // set date
+ $.datepicker._setDate(inst, date);
+
+ // set time
+ $.datepicker._setTime(inst, date);
+ }
+
+ function parseDate(value) {
+
+ // 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;
+ var day = parseInt(dateSplited[0]);
- jQuery.struts2_jquery.bind(editor, options_timepicker);
+ // FIXME sletellier 20111122 : currently, one month more are displayed....
+ var month = parseInt(dateSplited[1]) - 1;
+ var year = parseInt(dateSplited[2]);
+ var hour = parseInt(hourSplited[0]);
+ var minute = parseInt(hourSplited[1]);
+ var second = parseInt(hourSplited[2]);
+
+ // update date
+ // TODO sletellier 20111122 : edit milliseconds ?
+ return new Date(year, month, day, hour, minute, second, 0);
}
</script>
@@ -307,6 +319,8 @@
<sj:datepicker id="%{#meta.name}"
name="%{#meta.name}"
label="%{getText(#meta.i18nKey)}"
+ value="%{new java.util.Date()}"
+ displayFormat="dd/mm/yy"
timepicker="true"
timepickerShowSecond="true"
timepickerFormat="hh:mm:ss"/>
1
0
r104 - in trunk: echobase-entities/src/main/java/fr/ifremer/echobase echobase-ui/src/main/java/fr/ifremer/echobase/ui/interceptors echobase-ui/src/main/resources/i18n echobase-ui/src/main/webapp/WEB-INF/jsp echobase-ui/src/main/webapp/WEB-INF/jsp/dbeditor echobase-ui/src/main/webapp/WEB-INF/jsp/export echobase-ui/src/main/webapp/WEB-INF/jsp/import echobase-ui/src/main/webapp/WEB-INF/jsp/user
by sletellier@users.forge.codelutin.com 21 Nov '11
by sletellier@users.forge.codelutin.com 21 Nov '11
21 Nov '11
Author: sletellier
Date: 2011-11-21 17:12:09 +0100 (Mon, 21 Nov 2011)
New Revision: 104
Url: http://forge.codelutin.com/repositories/revision/echobase/104
Log:
- Clean all traduction
- Add autoLogin constant in Config
Modified:
trunk/echobase-entities/src/main/java/fr/ifremer/echobase/EchoBaseConfiguration.java
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/interceptors/CheckLogguedInterceptor.java
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
trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/export/createEmbeddedApplication.jsp
trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/export/exportSql.jsp
trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/export/exportSqlResult.jsp
trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/home.jsp
trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/import/import.jsp
trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/import/importProgress.jsp
trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/user/userList.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-21 16:05:50 UTC (rev 103)
+++ trunk/echobase-entities/src/main/java/fr/ifremer/echobase/EchoBaseConfiguration.java 2011-11-21 16:12:09 UTC (rev 104)
@@ -55,6 +55,8 @@
public static final String OPTION_UPDATE_SCHEMA = "updateSchema";
+ public static final String OPTION_AUTO_LOGIN = "autoLogin";
+
/** Delegate application config object containing configuration. */
protected ApplicationConfig applicationConfig;
Modified: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/interceptors/CheckLogguedInterceptor.java
===================================================================
--- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/interceptors/CheckLogguedInterceptor.java 2011-11-21 16:05:50 UTC (rev 103)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/interceptors/CheckLogguedInterceptor.java 2011-11-21 16:12:09 UTC (rev 104)
@@ -24,6 +24,7 @@
package fr.ifremer.echobase.ui.interceptors;
import com.opensymphony.xwork2.ActionInvocation;
+import fr.ifremer.echobase.EchoBaseConfiguration;
import fr.ifremer.echobase.ui.EchoBaseSession;
import fr.ifremer.echobase.ui.actions.EchoBaseActionSupport;
import fr.ifremer.echobase.ui.actions.user.LoginAction;
@@ -63,7 +64,9 @@
if (!userLoggued) {
boolean autoLogin =
- EchoBaseActionSupport.getEchoBaseApplicationContext().getConfiguration().getOptionAsBoolean("autoLogin");
+ EchoBaseActionSupport.getEchoBaseApplicationContext()
+ .getConfiguration()
+ .getOptionAsBoolean(EchoBaseConfiguration.OPTION_AUTO_LOGIN);
if (autoLogin) {
// by-pass login
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-21 16:05:50 UTC (rev 103)
+++ trunk/echobase-ui/src/main/resources/i18n/echobase-ui_fr_FR.properties 2011-11-21 16:12:09 UTC (rev 104)
@@ -1,5 +1,6 @@
echobase.action.applySqlQuery=Appliquer la requête
echobase.action.backToUserList=Retour à la liste des utilisateurs
+echobase.action.reset=Annuler
echobase.action.cloneSqlQuery=Cloner la requête
echobase.action.create=Créer
echobase.action.createEmbeddedApplication=Créer l'application
@@ -14,65 +15,69 @@
echobase.action.login=Connection
echobase.action.logout=Déconnexion
echobase.action.reloadSqlQuery=Recharger
+echobase.action.return=Retour
echobase.action.save=Sauvegarder
echobase.action.saveSqlQuery=Enregistrer la requête
echobase.common.admin=Administrateur
echobase.common.comment=Commentaire
echobase.common.email=Email
-echobase.common.embeddedApplicationFileName=Nom de l'archive à télécharger
-echobase.common.embeddedWarFileName=Nom du war à utiliser
-echobase.common.exportFileName=Nom du fichier d'export
-echobase.common.import=Import configuration
-echobase.common.importFile=Fichier à importer
echobase.common.jdbcLogin=Login de connexion
echobase.common.jdbcPassword=Mot de passe
echobase.common.jdbcUrl=Url de connexion
echobase.common.password=Mot de passe
-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.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 modifiés \: %s
-echobase.dbeditor.edit=Edition de '%s'
-echobase.embeddedApplication.configuration=Configuration de l'application embarquée
echobase.error.bad.password=Mot de passe incorrrect
echobase.error.email.already.used=
+echobase.error.export.description.requiredstring=La description de l'export est obligatoire
+echobase.error.export.name.requiredstring=Le nom de l'export est obligatoire
+echobase.error.export.sqlQuery.requiredstring=La requête de l'export est obligatoire
+echobase.error.export.sqlQuery.wrongformat=La requêtes n'est pas valide
echobase.error.fileDontExist=
echobase.error.fileNotFound=
+echobase.error.import.selectedVoyageOrAccessImport.required=Merci de selectionner un voyage ou un import access
echobase.error.importArgument=
echobase.error.importFile.required=Fichier d'import obligatoire
+echobase.error.login.password.requiredstring=Le mot de passe est obligatoire
echobase.error.login.unknown=Utilisateur inconnu
+echobase.error.login.wrongLogin=Le login est déjà utilisé
echobase.error.required.email=L'email est obligatoire
echobase.error.required.password=Le mot de passe est obligatoire
echobase.error.warlocation.notFound=L'application n'a pas été trouvé à l'emplacement suivant %s
-echobase.export.queryDescription=Description
-echobase.export.queryName=Nom
-echobase.export.querySql=SQL
-echobase.importFile.access=Base access
-echobase.importFile.accoustique=Fichier accoustique
-echobase.importFile.events=Fichier evenements
-echobase.importFile.lectureAgeGen=Fichier lecture age
-echobase.importFile.pecherie=Fichier pecherie
-echobase.importFile.typeEchoSpecies=Fichier espèces
+echobase.header.request.result=Résultat de la requête sql
+echobase.header.user.gridTitle=Liste des utilisateurs
+echobase.header.voyageSelect=Selectionnez un voyage
+echobase.info.dbeditor.propertyDiffsResult=Nombres d'entrées modifiés \: %s
echobase.info.no.sqlQuery.saved=Aucune requête d'export sql enregistré
echobase.info.no.sqlQuery.selected=Aucune requête d'export sql sélectionnée
echobase.info.no.table.selected=Aucune table sélectionnée
-echobase.label.admin.user.create=Création d'un utilisateur
-echobase.label.admin.user.delete=Suppression d'un utilisateur
-echobase.label.admin.user.edit=Edition d'un utilisateur
+echobase.label.embeddedApplicationFileName=Nom de l'archive à télécharger
+echobase.label.embeddedWarFileName=Nom du war à utiliser
+echobase.label.exportFileName=Nom du fichier d'export
+echobase.label.import.access=Base access
+echobase.label.import.accoustique=Fichier accoustique
+echobase.label.import.events=Fichier evenements
+echobase.label.import.lectureAgeGen=Fichier lecture age
+echobase.label.import.pecherie=Fichier pecherie
+echobase.label.import.typeEchoSpecies=Fichier espèces
+echobase.label.importFile=Fichier à importer
echobase.label.info.changePassword=Changement du mot de passe
echobase.label.language=Language
echobase.label.locale.english=Anglais
echobase.label.locale.french=Français
echobase.label.login=Connexion
+echobase.label.query.description=Description
+echobase.label.query.name=Nom
+echobase.label.query.sql=SQL
+echobase.label.sqlQueries=Requêtes enregistrées
+echobase.label.tableName=Nom de la table
echobase.label.user.login=Utilisateur \: %s
-echobase.label.welcome=Bienvenue dans EchoBase
+echobase.label.voyageToSelect=Voyage à exporter
+echobase.legend.dbeditor.edit=Edition de '%s'
+echobase.legend.embeddedApplication.configuration=Configuration de l'application embarquée
+echobase.legend.import=Import configuration
+echobase.legend.sqlQuery.configuration=Configuration de la requête
+echobase.legend.sqlQuery.result=Résultats de la requête
echobase.menu.connectToDbInformations=Se connecter à la base
echobase.menu.createEmbeddedApplication=Créer une application embarquée
echobase.menu.dbeditor=Modifier les données
@@ -84,9 +89,10 @@
echobase.message.modified.property=Propriété '%s', ancienne valeur \: %s, nouvelle valeur \: %s
echobase.message.no.row.selected=Aucune donnée sélectionnée
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
-echobase.sqlQuery.result=Résultats de la requête
+echobase.message.warnImportInProgress=Merci de ne pas fermer la fenêtre pour pouvoir accéder aux résultats de l'import.
+echobase.title.admin.user.create=Création d'un utilisateur
+echobase.title.admin.user.delete=Suppression d'un utilisateur
+echobase.title.admin.user.edit=Edition d'un utilisateur
echobase.title.connectToDbInformations=Se connecter à la base de données
echobase.title.connectionToDb.detail=Détail de la connection à la base de données
echobase.title.createEmbeddedApplication=Création de l'application embarquée
@@ -101,12 +107,4 @@
echobase.title.login=Connexion
echobase.title.modification.detail=Détail de la modification
echobase.title.users=Adminitration des utilisateurs
-echobase.user.gridTitle=Liste des utilisateurs
-echobase.validation.export.description.requiredstring=La description de l'export est obligatoire
-echobase.validation.export.name.requiredstring=Le nom de l'export est obligatoire
-echobase.validation.export.sqlQuery.requiredstring=La requête de l'export est obligatoire
-echobase.validation.export.sqlQuery.wrongformat=La requêtes n'est pas valide
-echobase.validation.import.selectedVoyageOrAccessImport.required=Merci de selectionner un voyage ou un import access
-echobase.validation.login.password.requiredstring=Le mot de passe est obligatoire
-echobase.validation.login.wrongLogin=Le login est déjà utilisé
-echobase.voyage.selectHeader=Selectionnez un voyage
+echobase.title.welcome=Bienvenue dans EchoBase
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-21 16:05:50 UTC (rev 103)
+++ trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/dbeditor/dbeditor.jsp 2011-11-21 16:12:09 UTC (rev 104)
@@ -170,7 +170,7 @@
}
</script>
-<s:select key="tableName" label='%{getText("echobase.common.tableName")}'
+<s:select key="tableName" label='%{getText("echobase.label.tableName")}'
list="tableNames" headerKey="" headerValue=""/>
<br class="clearBoth"/>
@@ -189,7 +189,7 @@
<s:hidden key="tableName" label=''/>
<s:file key="importFile" required="true"
- label="%{getText('echobase.common.importFile')}"/>
+ label="%{getText('echobase.label.importFile')}"/>
<br/>
<s:submit key="echobase.action.importTable" action="doImport"
align="right"/>
@@ -198,7 +198,7 @@
<s:form id="exportForm" namespace="/dbeditor" method="post">
<s:hidden key="tableName" label=''/>
<s:textfield key="exportFileName" required="true" size="100"
- label="%{getText('echobase.common.exportFileName')}"/>
+ label="%{getText('echobase.label.exportFileName')}"/>
<br/>
<s:submit key="echobase.action.exportTable" action="doExport"
@@ -257,7 +257,7 @@
<fieldset id="noRowSelected">
<legend>
- <s:text name="echobase.dbeditor.edit">
+ <s:text name="echobase.legend.dbeditor.edit">
<s:param value="%{tableI18nName}"/>
</s:text>
</legend>
@@ -267,7 +267,7 @@
<s:form id="editForm" namespace="/dbeditor">
<fieldset>
<legend>
- <s:text name="echobase.dbeditor.edit">
+ <s:text name="echobase.legend.dbeditor.edit">
<s:param value="%{tableI18nName}"/>
</s:text>
</legend>
@@ -316,7 +316,7 @@
</s:iterator>
</fieldset>
<ul class="toolbar floatRight">
- <li><s:submit name='resetAction' key="echobase.common.reset"
+ <li><s:submit name='resetAction' key="echobase.action.reset"
theme="simple" onclick="return false;"/>
</li>
<li><s:submit name="submitAction" key="echobase.action.save"
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-21 16:05:50 UTC (rev 103)
+++ trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/dbeditor/modifImportResult.jsp 2011-11-21 16:12:09 UTC (rev 104)
@@ -26,11 +26,11 @@
<title><s:text name="echobase.title.dbEditor"/></title>
<h2>
- <s:text name="echobase.dbEditor.propertyDiffsResult">
+ <s:text name="echobase.info.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"/>
+ <s:text name="echobase.action.return"/>
</s:a>
Modified: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/export/createEmbeddedApplication.jsp
===================================================================
--- trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/export/createEmbeddedApplication.jsp 2011-11-21 16:05:50 UTC (rev 103)
+++ trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/export/createEmbeddedApplication.jsp 2011-11-21 16:12:09 UTC (rev 104)
@@ -32,16 +32,16 @@
<br/>
<fieldset>
- <legend><s:text name="echobase.embeddedApplication.configuration"/></legend>
+ <legend><s:text name="echobase.legend.embeddedApplication.configuration"/></legend>
<s:checkboxlist list="voyages" key="voyageIds"
- label="%{getText('echobase.common.voyagesToSelect')}"/>
+ label="%{getText('echobase.label.voyageToSelect')}"/>
<s:textfield key="fileName" required="true" size="100"
- label="%{getText('echobase.common.embeddedApplicationFileName')} (*)"/>
+ label="%{getText('echobase.label.embeddedApplicationFileName')} (*)"/>
<s:label value="%{warFileName}" readonly="true"
- label="%{getText('echobase.common.embeddedWarFileName')}"/>
+ label="%{getText('echobase.label.embeddedWarFileName')}"/>
<s:if test="!hasActionErrors()">
Modified: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/export/exportSql.jsp
===================================================================
--- trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/export/exportSql.jsp 2011-11-21 16:05:50 UTC (rev 103)
+++ trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/export/exportSql.jsp 2011-11-21 16:12:09 UTC (rev 104)
@@ -74,22 +74,22 @@
<s:form id="exportQueryForm" namespace="/export">
- <s:select key="query.topiaId" label="%{getText('echobase.common.sqlQueries')}"
+ <s:select key="query.topiaId" label="%{getText('echobase.label.sqlQueries')}"
list="queries" headerKey="" headerValue=""/>
<br/>
<fieldset>
- <legend><s:text name="echobase.sqlQuery.configuration"/></legend>
+ <legend><s:text name="echobase.legend.sqlQuery.configuration"/></legend>
<s:textarea key="query.name" required="true" cols="160" rows="1"
- label="%{getText('echobase.common.query.name')}"/>
+ label="%{getText('echobase.label.query.name')}"/>
<s:textarea key="query.description" required="true" cols="160" rows="2"
- label="%{getText('echobase.common.query.description')}"/>
+ label="%{getText('echobase.label.query.description')}"/>
<s:textarea key="query.sqlQuery" required="true" cols="160" rows="4"
- label="%{getText('echobase.common.sqlQuery')}"/>
+ label="%{getText('echobase.label.query.sql')}"/>
<s:if test="queryExists">
Modified: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/export/exportSqlResult.jsp
===================================================================
--- trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/export/exportSqlResult.jsp 2011-11-21 16:05:50 UTC (rev 103)
+++ trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/export/exportSqlResult.jsp 2011-11-21 16:12:09 UTC (rev 104)
@@ -40,14 +40,14 @@
<s:form action="downloadExportSqlResult" namespace="/export">
<fieldset>
- <legend><s:text name="echobase.sqlQuery.result"/></legend>
+ <legend><s:text name="echobase.legend.sqlQuery.result"/></legend>
<s:hidden key="sql" label=""/>
<s:textfield key="fileName" required="true" size="100"
- label="%{getText('echobase.common.exportFileName')}"/>
+ label="%{getText('echobase.label.exportFileName')}"/>
<s:submit key="echobase.action.exportSqlData" align="left"/>
<br/>
- <sjg:grid id="rows" caption="%{getText('echobase.common.request.result')}"
+ <sjg:grid id="rows" caption="%{getText('echobase.header.request.result')}"
dataType="json" href="%{loadUrl}" gridModel="datas"
pager="true" pagerButtons="true" pagerInput="true"
navigator="true" autowidth="true" rownumbers="false"
Modified: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/home.jsp
===================================================================
--- trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/home.jsp 2011-11-21 16:05:50 UTC (rev 103)
+++ trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/home.jsp 2011-11-21 16:12:09 UTC (rev 104)
@@ -23,6 +23,6 @@
--%>
<%@ page language="java" contentType="text/html" pageEncoding="utf-8" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
-<title><s:text name="echobase.label.welcome"/></title>
+<title><s:text name="echobase.title.welcome"/></title>
-<h2><s:text name="echobase.label.welcome"/></h2>
+<h2><s:text name="echobase.title.welcome"/></h2>
Modified: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/import/import.jsp
===================================================================
--- trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/import/import.jsp 2011-11-21 16:05:50 UTC (rev 103)
+++ trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/import/import.jsp 2011-11-21 16:12:09 UTC (rev 104)
@@ -31,25 +31,27 @@
<fieldset>
<legend>
- <s:text name="echobase.common.import"/>
+ <s:text name="echobase.legend.import"/>
</legend>
<s:select key="selectedVoyageId"
label='%{getText("echobase.common.voyage")}'
list="voyages"
emptyOption="true"
headerKey="-1"
- headerValue='%{getText("echobase.voyage.selectHeader")}' />
+ headerValue='%{getText("echobase.header.voyageSelect")}' />
- <s:file name="importModel.accessImport" key="echobase.importFile.access"/>
+ <s:file name="importModel.accessImport"
+ key="echobase.label.import.access"/>
<s:file name="importModel.accousticImport"
- key="echobase.importFile.accoustique"/>
+ key="echobase.label.import.accoustique"/>
<s:file name="importModel.pecherieImport"
- key="echobase.importFile.pecherie"/>
+ key="echobase.label.import.pecherie"/>
<s:file name="importModel.lectureAgeGenImport"
- key="echobase.importFile.lectureAgeGen"/>
- <s:file name="importModel.eventsImport" key="echobase.importFile.events"/>
+ key="echobase.label.import.lectureAgeGen"/>
+ <s:file name="importModel.eventsImport"
+ key="echobase.label.import.events"/>
<s:file name="importModel.typeEchoSpeciesImport"
- key="echobase.importFile.typeEchoSpecies"/>
+ key="echobase.label.import.typeEchoSpecies"/>
<s:textarea name="importModel.comment" rows="4" cols="50" key="echobase.common.comment"/>
Modified: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/import/importProgress.jsp
===================================================================
--- trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/import/importProgress.jsp 2011-11-21 16:05:50 UTC (rev 103)
+++ trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/import/importProgress.jsp 2011-11-21 16:12:09 UTC (rev 104)
@@ -30,4 +30,4 @@
<sj:progressbar value="%{EchoBaseActionContext.progression}"/>
<%-- TODO letellier 20111104 : Add warn icon --%>
-<p><s:text name="echobase.msg.warnImportInProgress"/></p>
\ No newline at end of file
+<p><s:text name="echobase.message.warnImportInProgress"/></p>
\ No newline at end of file
Modified: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/user/userList.jsp
===================================================================
--- trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/user/userList.jsp 2011-11-21 16:05:50 UTC (rev 103)
+++ trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/user/userList.jsp 2011-11-21 16:12:09 UTC (rev 104)
@@ -57,7 +57,7 @@
<h2><s:text name="echobase.title.users"/></h2>
<br/>
-<sjg:grid id="users" caption="%{getText('echobase.title.users')}"
+<sjg:grid id="users" caption="%{getText('echobase.header.user.gridTitle')}"
dataType="json" href="%{loadUrl}" gridModel="users"
pager="true" pagerButtons="true" pagerInput="true"
navigator="true" rownumbers="false" autowidth="true"
1
0
r103 - trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor
by tchemit@users.forge.codelutin.com 21 Nov '11
by tchemit@users.forge.codelutin.com 21 Nov '11
21 Nov '11
Author: tchemit
Date: 2011-11-21 17:05:50 +0100 (Mon, 21 Nov 2011)
New Revision: 103
Url: http://forge.codelutin.com/repositories/revision/echobase/103
Log:
fix NPE
Modified:
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/LoadEntities.java
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-21 15:40:40 UTC (rev 102)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/LoadEntities.java 2011-11-21 16:05:50 UTC (rev 103)
@@ -45,7 +45,9 @@
public String input() throws Exception {
load();
- exportFileName = "export-" + tableMeta.getEntityType().getSimpleName() + ".csv";
+ if (tableMeta != null) {
+ exportFileName = "export-" + tableMeta.getEntityType().getSimpleName() + ".csv";
+ }
return INPUT;
}
1
0