Echobase-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
November 2011
- 3 participants
- 137 discussions
Author: tchemit
Date: 2011-11-09 09:49:36 +0100 (Wed, 09 Nov 2011)
New Revision: 29
Url: http://forge.codelutin.com/repositories/revision/echobase/29
Log:
add json in compile scope
Modified:
trunk/echobase-ui/pom.xml
Modified: trunk/echobase-ui/pom.xml
===================================================================
--- trunk/echobase-ui/pom.xml 2011-11-09 07:31:29 UTC (rev 28)
+++ trunk/echobase-ui/pom.xml 2011-11-09 08:49:36 UTC (rev 29)
@@ -76,7 +76,7 @@
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-json-plugin</artifactId>
- <scope>runtime</scope>
+ <scope>compile</scope>
</dependency>
<dependency>
1
0
r28 - in trunk/echobase-services/src/main/java/fr/ifremer/echobase/services: . models
by tchemit@users.forge.codelutin.com 09 Nov '11
by tchemit@users.forge.codelutin.com 09 Nov '11
09 Nov '11
Author: tchemit
Date: 2011-11-09 08:31:29 +0100 (Wed, 09 Nov 2011)
New Revision: 28
Url: http://forge.codelutin.com/repositories/revision/echobase/28
Log:
contiue Dbeditor service + headers
Modified:
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/SurveyService.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/models/ImportModel.java
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/AbstractEchoBaseService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/AbstractEchoBaseService.java 2011-11-09 07:29:52 UTC (rev 27)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/AbstractEchoBaseService.java 2011-11-09 07:31:29 UTC (rev 28)
@@ -52,4 +52,6 @@
protected DbMeta getDbMeta() {
return serviceContext.getDbMeta();
}
+
+
}
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/DbEditorService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/DbEditorService.java 2011-11-09 07:29:52 UTC (rev 27)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/DbEditorService.java 2011-11-09 07:31:29 UTC (rev 28)
@@ -27,15 +27,23 @@
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.lang.StringUtils;
import org.nuiton.topia.TopiaException;
+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.beans.BeanMonitor;
+import org.nuiton.util.beans.PropertyDiff;
-import java.util.Iterator;
+import java.util.Date;
import java.util.List;
import java.util.Map;
@@ -47,6 +55,31 @@
*/
public class DbEditorService extends AbstractEchoBaseService {
+ public static class ResultDatas {
+
+ /** Total count. */
+ int count;
+
+ /** Loaded datas (for the given asked page). */
+ Map[] rows;
+
+ public int getCount() {
+ return count;
+ }
+
+ public void setCount(int count) {
+ this.count = count;
+ }
+
+ public Map[] getRows() {
+ return rows;
+ }
+
+ public void setRows(Map[] rows) {
+ this.rows = rows;
+ }
+ }
+
public TableMeta getTableMetas(String tableName) {
DbMeta dbMeta = getDbMeta();
TableMeta result = dbMeta.getTable(tableName);
@@ -54,32 +87,124 @@
}
//TODO Use an object to filter datas and do pagination
- public Map[] getDatas(String tableName) {
+ public ResultDatas getDatas(String tableName,
+ int from,
+ int to,
+ String sidx,
+ Boolean ascendantOrder) {
+
DbMeta dbMeta = getDbMeta();
TableMeta tableMeta = dbMeta.getTable(tableName);
EchoBaseEntityEnum entityEnum = tableMeta.getEntityEnum();
Class<? extends TopiaEntity> contract = entityEnum.getContract();
try {
TopiaDAO dao = EchoBaseDAOHelper.getDAO(getTransaction(), contract);
- List<?> all = dao.findAll();
- Map[] result = new Map[all.size()];
- Iterator<?> dataItr = all.iterator();
- int i = 0;
- while (dataItr.hasNext()) {
- TopiaEntity entity = (TopiaEntity) dataItr.next();
+ ResultDatas result = new ResultDatas();
+ TopiaQuery query = dao.createQuery("e");
+ if (StringUtils.isNotEmpty(sidx)) {
+ if (ascendantOrder) {
+ query.addOrder(sidx);
+ } else {
+ query.addOrderDesc(sidx);
+ }
+ }
+ List<?> all = dao.findAllByQuery(query);
+ int count = all.size();
+ if (count < to) {
+ to = count;
+ }
+ Map[] rows = new Map[to - from];
+
+ int j = 0;
+ for (int i = from; i < to; i++) {
+ TopiaEntity entity = (TopiaEntity) all.get(i);
Map<String, Object> row = loadRow(tableMeta, entity);
- result[i++] = row;
+ rows[j++] = row;
}
+
+ result.setCount(all.size());
+ result.setRows(rows);
return result;
} catch (TopiaException eee) {
throw new EchoBaseTechnicalException("Could not obtain data", eee);
}
}
+ public PropertyDiff[] saveEntity(TableMeta tableMeta,
+ String id,
+ Map<String, String> properties,
+ EchoBaseUser user) {
+
+ Class<? extends TopiaEntity> entityType = tableMeta.getEntityType();
+ String[] columnNames = tableMeta.getColumnNamesAsArray();
+ BeanMonitor monitor = new BeanMonitor(columnNames);
+
+ try {
+ TopiaDAO dao = EchoBaseDAOHelper.getDAO(
+ getTransaction(),
+ entityType);
+
+ TopiaEntity entityToSave = dao.findByTopiaId(id);
+ monitor.setBean(entityToSave);
+ for (Map.Entry<String, String> entry : properties.entrySet()) {
+ String propertyName = entry.getKey();
+ String propertyValue = entry.getValue();
+ BeanUtils.setProperty(entityToSave,
+ propertyName,
+ propertyValue);
+ }
+
+ PropertyDiff[] propertyDiffs = monitor.getPropertyDiffs();
+
+ int length = propertyDiffs.length;
+
+ if (length > 0) {
+
+ // something was modified on the entity
+
+ EntityModificationLogDAO dao1 =
+ EchoBaseDAOHelper.getEntityModificationLogDAO(
+ getTransaction()
+ );
+
+ StringBuilder buffer;
+ 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];
+ buffer.append(String.format("\n Propriété '%s', ancienne valeur : %s, nouvelle valeur : %s",
+ diff.getSourceProperty(),
+ diff.getSourceValue(),
+ diff.getTargetValue()
+ ));
+ }
+ 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()
+ );
+
+ getTransaction().commitTransaction();
+ }
+ return propertyDiffs;
+ } catch (Exception eee) {
+ throw new EchoBaseTechnicalException("Could not update entity", eee);
+ } finally {
+ monitor.setBean(null);
+ }
+
+ }
+
protected Map<String, Object> loadRow(TableMeta tableMeta, TopiaEntity entity) {
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();
Object property =
@@ -88,5 +213,4 @@
}
return row;
}
-
}
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/SurveyService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/SurveyService.java 2011-11-09 07:29:52 UTC (rev 27)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/SurveyService.java 2011-11-09 07:31:29 UTC (rev 28)
@@ -1,3 +1,26 @@
+/*
+ * #%L
+ * EchoBase :: Services
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 Ifremer, Codelutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
package fr.ifremer.echobase.services;
import fr.ifremer.echobase.EchoBaseTechnicalException;
Property changes on: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/SurveyService.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/models/ImportModel.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/models/ImportModel.java 2011-11-09 07:29:52 UTC (rev 27)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/models/ImportModel.java 2011-11-09 07:31:29 UTC (rev 28)
@@ -1,3 +1,26 @@
+/*
+ * #%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.models;
import fr.ifremer.echobase.entities.Survey;
Property changes on: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/models/ImportModel.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
1
0
r27 - in trunk/echobase-entities/src/main: java/fr/ifremer/echobase java/fr/ifremer/echobase/entities java/fr/ifremer/echobase/entities/meta resources/i18n xmi
by tchemit@users.forge.codelutin.com 09 Nov '11
by tchemit@users.forge.codelutin.com 09 Nov '11
09 Nov '11
Author: tchemit
Date: 2011-11-09 08:29:52 +0100 (Wed, 09 Nov 2011)
New Revision: 27
Url: http://forge.codelutin.com/repositories/revision/echobase/27
Log:
add entity EntityModificationLog + improve configuration and db meta
Added:
trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/EntityModificationLogImpl.java
Modified:
trunk/echobase-entities/src/main/java/fr/ifremer/echobase/EchoBaseConfiguration.java
trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/meta/TableMeta.java
trunk/echobase-entities/src/main/resources/i18n/echobase-entities_fr_FR.properties
trunk/echobase-entities/src/main/xmi/echobase.zargo
Modified: trunk/echobase-entities/src/main/java/fr/ifremer/echobase/EchoBaseConfiguration.java
===================================================================
--- trunk/echobase-entities/src/main/java/fr/ifremer/echobase/EchoBaseConfiguration.java 2011-11-09 07:26:15 UTC (rev 26)
+++ trunk/echobase-entities/src/main/java/fr/ifremer/echobase/EchoBaseConfiguration.java 2011-11-09 07:29:52 UTC (rev 27)
@@ -126,6 +126,11 @@
return driverClass.getSimpleName().toLowerCase().contains("h2");
}
+ public boolean getOptionAsBoolean(String propertyName) {
+ Boolean result = applicationConfig.getOptionAsBoolean(propertyName);
+ return result!=null && result;
+ }
+
/**
* Creates a directory given the configuration given key.
*
Added: trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/EntityModificationLogImpl.java
===================================================================
--- trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/EntityModificationLogImpl.java (rev 0)
+++ trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/EntityModificationLogImpl.java 2011-11-09 07:29:52 UTC (rev 27)
@@ -0,0 +1,46 @@
+/*
+ * #%L
+ * EchoBase :: Entities
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 Ifremer, Codelutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+package fr.ifremer.echobase.entities;
+
+/**
+ * Default implementation of {@link EntityModificationLog}.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.1
+ */
+public class EntityModificationLogImpl extends EntityModificationLogAbstract {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public EntityModificationLogDTO toDTO() {
+ EntityModificationLogDTO result = new EntityModificationLogDTOImpl();
+ result.setEntityType(getEntityType());
+ result.setEntityId(getEntityId());
+ result.setModificationDate(getModificationDate());
+ result.setModificationText(getModificationText());
+ result.setUser(getUser().toDTO());
+ return result;
+ }
+}
Property changes on: trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/EntityModificationLogImpl.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
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-09 07:26:15 UTC (rev 26)
+++ trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/meta/TableMeta.java 2011-11-09 07:29:52 UTC (rev 27)
@@ -73,6 +73,10 @@
return entityEnum;
}
+ public Class<? extends TopiaEntity> getEntityType() {
+ return entityEnum.getContract();
+ }
+
public String getI18nKey() {
return i18nKey;
}
@@ -93,6 +97,11 @@
return result;
}
+ public String[] getColumnNamesAsArray() {
+ List<String> columnNames = getColumnNames();
+ return columnNames.toArray(new String[columnNames.size()]);
+ }
+
public List<String> getColumnNames() {
List<String> result = Lists.newLinkedList();
for (ColumnMeta columnMeta : getColumns()) {
Modified: trunk/echobase-entities/src/main/resources/i18n/echobase-entities_fr_FR.properties
===================================================================
--- trunk/echobase-entities/src/main/resources/i18n/echobase-entities_fr_FR.properties 2011-11-09 07:26:15 UTC (rev 26)
+++ trunk/echobase-entities/src/main/resources/i18n/echobase-entities_fr_FR.properties 2011-11-09 07:29:52 UTC (rev 27)
@@ -3,13 +3,20 @@
echobase.common.echoBaseUser=Utilisateur
echobase.common.echoBaseUserDTO=
echobase.common.email=Courriel
+echobase.common.entityId=Identifiant de l'entité
+echobase.common.entityModificationLog=Journal des modifications
+echobase.common.entityModificationLogDTO=
+echobase.common.entityType=Type de l'entité
echobase.common.exportQuery=Requête d'export
echobase.common.exportQueryDTO=
echobase.common.id=Identifiant
echobase.common.lastModifiedDate=Date de dernière modification
echobase.common.lastModifiedUser=Utilisateur de dernière modification
+echobase.common.modificationDate=Date de modification
+echobase.common.modificationText=Modification
echobase.common.name=Nom
echobase.common.password=Mot de passe
echobase.common.sqlQuery=Requête SQL
-echobase.common.survey=
+echobase.common.survey=Campagne
+echobase.common.user=Utilisateur
echobase.config.data.directory.description=Chemin de l'application
Modified: trunk/echobase-entities/src/main/xmi/echobase.zargo
===================================================================
(Binary files differ)
1
0
Author: tchemit
Date: 2011-11-09 08:26:15 +0100 (Wed, 09 Nov 2011)
New Revision: 26
Url: http://forge.codelutin.com/repositories/revision/echobase/26
Log:
use last snapshot of nuiton-utils
Modified:
trunk/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2011-11-08 17:51:54 UTC (rev 25)
+++ trunk/pom.xml 2011-11-09 07:26:15 UTC (rev 26)
@@ -108,7 +108,7 @@
<eugenePluginVersion>2.4.1</eugenePluginVersion>
<topiaVersion>2.6.3</topiaVersion>
- <nuitonUtilsVersion>2.3</nuitonUtilsVersion>
+ <nuitonUtilsVersion>2.4-SNAPSHOT</nuitonUtilsVersion>
<nuitonI18nVersion>2.4.1</nuitonI18nVersion>
<nuitonWebVersion>1.5</nuitonWebVersion>
<msaccessImporterVersion>1.4.1</msaccessImporterVersion>
1
0
08 Nov '11
Author: sletellier
Date: 2011-11-08 18:51:54 +0100 (Tue, 08 Nov 2011)
New Revision: 25
Url: http://forge.codelutin.com/repositories/revision/echobase/25
Log:
- Add survey entity
- Add import pages
- Creating import model in service
- Creating survey service
Added:
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/SurveyService.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/models/
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/models/ImportModel.java
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/ImportAction.java
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/json/GetUsersDatas.java
trunk/echobase-ui/src/main/resources/config/struts-import.xml
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/import/importResult.jsp
Removed:
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/json/GetUsersAction.java
trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/import/ImportProgress.jsp
trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/import/ImportResult.jsp
trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/import/imports.jsp
Modified:
trunk/echobase-entities/src/license/THIRD-PARTY.properties
trunk/echobase-entities/src/main/resources/i18n/echobase-entities_fr_FR.properties
trunk/echobase-entities/src/main/xmi/echobase.zargo
trunk/echobase-ui/src/main/resources/config/struts-json.xml
trunk/echobase-ui/src/main/resources/config/struts-user.xml
trunk/echobase-ui/src/main/resources/i18n/echobase-ui_fr_FR.properties
trunk/echobase-ui/src/main/resources/struts.xml
trunk/echobase-ui/src/main/webapp/WEB-INF/decorators/layout-default.jsp
trunk/echobase-ui/src/main/webapp/WEB-INF/includes/menu.jsp
trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/dbeditor/dbeditor.jsp
trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/export/exportQueryForm.jsp
Modified: trunk/echobase-entities/src/license/THIRD-PARTY.properties
===================================================================
--- trunk/echobase-entities/src/license/THIRD-PARTY.properties 2011-11-08 14:08:22 UTC (rev 24)
+++ trunk/echobase-entities/src/license/THIRD-PARTY.properties 2011-11-08 17:51:54 UTC (rev 25)
@@ -5,7 +5,6 @@
# - BSD style
# - COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0
# - Common Public License Version 1.0
-# - General Public License (GPL)
# - Indiana University Extreme! Lab Software License, vesion 1.1.1
# - Lesser General Public License (LGPL) v 3.0
# - Lesser General Public License (LPGL)
@@ -19,9 +18,8 @@
# Please fill the missing licenses for dependencies :
#
#
-#Thu Nov 03 15:02:42 CET 2011
+#Tue Nov 08 16:07:35 CET 2011
antlr--antlr--2.7.6=BSD License
commons-primitives--commons-primitives--1.0=The Apache Software License, Version 2.0
dom4j--dom4j--1.6.1=BSD License
javax.transaction--jta--1.1=COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0
-echobase.title.dbEditor=Editeur de données
Modified: trunk/echobase-entities/src/main/resources/i18n/echobase-entities_fr_FR.properties
===================================================================
--- trunk/echobase-entities/src/main/resources/i18n/echobase-entities_fr_FR.properties 2011-11-08 14:08:22 UTC (rev 24)
+++ trunk/echobase-entities/src/main/resources/i18n/echobase-entities_fr_FR.properties 2011-11-08 17:51:54 UTC (rev 25)
@@ -11,4 +11,5 @@
echobase.common.name=Nom
echobase.common.password=Mot de passe
echobase.common.sqlQuery=Requête SQL
+echobase.common.survey=
echobase.config.data.directory.description=Chemin de l'application
Modified: trunk/echobase-entities/src/main/xmi/echobase.zargo
===================================================================
(Binary files differ)
Added: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/SurveyService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/SurveyService.java (rev 0)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/SurveyService.java 2011-11-08 17:51:54 UTC (rev 25)
@@ -0,0 +1,39 @@
+package fr.ifremer.echobase.services;
+
+import fr.ifremer.echobase.EchoBaseTechnicalException;
+import fr.ifremer.echobase.entities.EchoBaseDAOHelper;
+import fr.ifremer.echobase.entities.Survey;
+import fr.ifremer.echobase.entities.SurveyDAO;
+import org.nuiton.topia.TopiaException;
+
+import java.util.List;
+
+/**
+ * Service to manage all concerning survey
+ *
+ * @author sletellier <letellier(a)codelutin.com>
+ */
+public class SurveyService extends AbstractEchoBaseService {
+
+ public List<Survey> getSurveys() {
+ try {
+ List<Survey> surveys = getDAO().findAll();
+ return surveys;
+ } catch (TopiaException eee) {
+ throw new EchoBaseTechnicalException(eee);
+ }
+ }
+
+ public Survey getSurveyById(String topiaId) {
+ try {
+ Survey survey = getDAO().findByTopiaId(topiaId);
+ return survey;
+ } catch (TopiaException eee) {
+ throw new EchoBaseTechnicalException(eee);
+ }
+ }
+
+ protected SurveyDAO getDAO() throws TopiaException {
+ return EchoBaseDAOHelper.getSurveyDAO(getTransaction());
+ }
+}
Added: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/models/ImportModel.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/models/ImportModel.java (rev 0)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/models/ImportModel.java 2011-11-08 17:51:54 UTC (rev 25)
@@ -0,0 +1,198 @@
+package fr.ifremer.echobase.services.models;
+
+import fr.ifremer.echobase.entities.Survey;
+import org.apache.commons.lang.StringUtils;
+
+import java.io.File;
+
+/**
+ * Object representing all import configuration
+ *
+ * @author sletellier <letellier(a)codelutin.com>
+ */
+public class ImportModel {
+
+ protected Survey surveySelected;
+
+ protected File accessImport;
+ protected String accessImportFileName;
+
+ protected File accousticImport;
+ protected String accousticImportFileName;
+
+ protected File pecherieImport;
+ protected String pecherieImportFileName;
+
+ protected File lectureAgeGenImport;
+ protected String lectureAgeGenImportFileName;
+
+ protected File eventsImport;
+ protected String eventsImportFileName;
+
+ protected File typeEchoSpeciesImport;
+ protected String typeEchoSpeciesImportFileName;
+
+ protected String comment;
+
+ public Survey getSurveySelected() {
+ return surveySelected;
+ }
+
+ public void setSurveySelected(Survey surveySelected) {
+ this.surveySelected = surveySelected;
+ }
+
+
+ public String getComment() {
+ return comment;
+ }
+
+ public void setComment(String comment) {
+ this.comment = comment;
+ }
+
+ public File getAccessImport() {
+ return accessImport;
+ }
+
+ public void setAccessImport(File accessImport) {
+ this.accessImport = accessImport;
+ }
+
+ public String getAccessImportFileName() {
+ return accessImportFileName;
+ }
+
+ public void setAccessImportFileName(String accessImportFileName) {
+ this.accessImportFileName = accessImportFileName;
+ }
+
+ public File getAccousticImport() {
+ return accousticImport;
+ }
+
+ public void setAccousticImport(File accousticImport) {
+ this.accousticImport = accousticImport;
+ }
+
+ public String getAccousticImportFileName() {
+ return accousticImportFileName;
+ }
+
+ public void setAccousticImportFileName(String accousticImportFileName) {
+ this.accousticImportFileName = accousticImportFileName;
+ }
+
+ public File getPecherieImport() {
+ return pecherieImport;
+ }
+
+ public void setPecherieImport(File pecherieImport) {
+ this.pecherieImport = pecherieImport;
+ }
+
+ public String getPecherieImportFileName() {
+ return pecherieImportFileName;
+ }
+
+ public void setPecherieImportFileName(String pecherieImportFileName) {
+ this.pecherieImportFileName = pecherieImportFileName;
+ }
+
+ public File getLectureAgeGenImport() {
+ return lectureAgeGenImport;
+ }
+
+ public void setLectureAgeGenImport(File lectureAgeGenImport) {
+ this.lectureAgeGenImport = lectureAgeGenImport;
+ }
+
+ public String getLectureAgeGenImportFileName() {
+ return lectureAgeGenImportFileName;
+ }
+
+ public void setLectureAgeGenImportFileName(String lectureAgeGenImportFileName) {
+ this.lectureAgeGenImportFileName = lectureAgeGenImportFileName;
+ }
+
+ public File getEventsImport() {
+ return eventsImport;
+ }
+
+ public void setEventsImport(File eventsImport) {
+ this.eventsImport = eventsImport;
+ }
+
+ public String getEventsImportFileName() {
+ return eventsImportFileName;
+ }
+
+ public void setEventsImportFileName(String eventsImportFileName) {
+ this.eventsImportFileName = eventsImportFileName;
+ }
+
+ public File getTypeEchoSpeciesImport() {
+ return typeEchoSpeciesImport;
+ }
+
+ public void setTypeEchoSpeciesImport(File typeEchoSpeciesImport) {
+ this.typeEchoSpeciesImport = typeEchoSpeciesImport;
+ }
+
+ public String getTypeEchoSpeciesImportFileName() {
+ return typeEchoSpeciesImportFileName;
+ }
+
+ public void setTypeEchoSpeciesImportFileName(String typeEchoSpeciesImportFileName) {
+ this.typeEchoSpeciesImportFileName = typeEchoSpeciesImportFileName;
+ }
+
+ public boolean validate() {
+
+ // access file or survey is selected, not both
+ boolean result = surveySelected == null ^ accessImport == null;
+
+ // Less one of other import
+ result = result && (accessImport != null ||
+ accousticImport != null ||
+ lectureAgeGenImport != null ||
+ pecherieImport != null ||
+ eventsImport != null ||
+ typeEchoSpeciesImport != null);
+
+ return result;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder builder = new StringBuilder();
+
+ // Add selected survey
+ if (surveySelected != null) {
+ addToBuilder(builder, "surveySelected", surveySelected.getName());
+ }
+
+ // Add all import files
+ addToBuilder(builder, "accessImportFile", accessImportFileName);
+ addToBuilder(builder, "accousticImportFile", accousticImportFileName);
+ addToBuilder(builder, "pecherieImportFile", pecherieImportFileName);
+ addToBuilder(builder, "lectureAgeGenImportFile", lectureAgeGenImportFileName);
+ addToBuilder(builder, "eventsImportFile", eventsImportFileName);
+ addToBuilder(builder, "pecherieImportFile", typeEchoSpeciesImportFileName);
+
+ if (StringUtils.isNotEmpty(comment)) {
+ addToBuilder(builder, "comment", comment);
+ }
+ return builder.toString().trim();
+ }
+
+ protected void addToBuilder(StringBuilder builder, String name, String value) {
+ if (StringUtils.isNotEmpty(value)) {
+ builder.append(" ");
+ builder.append(name);
+ builder.append("[");
+ builder.append(value);
+ builder.append("]");
+ }
+ }
+}
Added: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/ImportAction.java
===================================================================
--- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/ImportAction.java (rev 0)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/ImportAction.java 2011-11-08 17:51:54 UTC (rev 25)
@@ -0,0 +1,82 @@
+package fr.ifremer.echobase.ui.actions;
+
+import com.google.common.collect.Maps;
+import com.opensymphony.xwork2.Preparable;
+import fr.ifremer.echobase.entities.Survey;
+import fr.ifremer.echobase.services.SurveyService;
+import fr.ifremer.echobase.services.models.ImportModel;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Action to manage imports
+ *
+ * @author sletellier <letellier(a)codelutin.com>
+ * @since 0.1
+ */
+public class ImportAction extends EchoBaseActionSupport {
+
+ protected static final Log log = LogFactory.getLog(ImportAction.class);
+
+ protected ImportModel importModel;
+
+ protected Map<String, String> surveys;
+
+ public ImportModel getImportModel() {
+ if (importModel == null) {
+ importModel = new ImportModel();
+ }
+ return importModel;
+ }
+
+ public void setImportModel(ImportModel importModel) {
+ this.importModel = importModel;
+ }
+
+ public String getSelectedSurvey() {
+ Survey surveySelected = getImportModel().getSurveySelected();
+ if (surveySelected == null) {
+ return null;
+ }
+ return surveySelected.getTopiaId();
+ }
+
+ public void setSelectedSurvey(String selectedSurveyId) {
+ Survey selectedSurvey = newService(SurveyService.class).getSurveyById(selectedSurveyId);
+ getImportModel().setSurveySelected(selectedSurvey);
+ }
+
+ public Map<String, String> getSurveys() {
+ return surveys;
+ }
+
+ @Override
+ public String input() throws Exception {
+
+ SurveyService service = newService(SurveyService.class);
+ List<Survey> allSurveys = service.getSurveys();
+
+ surveys = Maps.newHashMap();
+ for (Survey survey : allSurveys) {
+ surveys.put(survey.getTopiaId(), survey.getName());
+ }
+
+ return INPUT;
+ }
+
+ @Override
+ public String execute() throws Exception {
+ log.info("Will import : " + importModel.toString());
+ return SUCCESS;
+ }
+
+ @Override
+ public void validate() {
+ if (!importModel.validate()) {
+ addActionError(getText("echobase.error.importArgument"));
+ }
+ }
+}
Deleted: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/json/GetUsersAction.java
===================================================================
--- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/json/GetUsersAction.java 2011-11-08 14:08:22 UTC (rev 24)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/json/GetUsersAction.java 2011-11-08 17:51:54 UTC (rev 25)
@@ -1,73 +0,0 @@
-/*
- * #%L
- * EchoBase :: UI
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2011 Ifremer, Codelutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- * #L%
- */
-package fr.ifremer.echobase.ui.actions.json;
-
-import fr.ifremer.echobase.entities.EchoBaseUser;
-import fr.ifremer.echobase.entities.EchoBaseUserDTO;
-import fr.ifremer.echobase.services.UserService;
-import fr.ifremer.echobase.ui.actions.EchoBaseActionSupport;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Obtains all users of the echobase internal database.
- *
- * @author sletellier <letellier(a)codelutin.com>
- * @since 0.1
- */
-public class GetUsersAction extends EchoBaseActionSupport {
-
- private static final long serialVersionUID = 1L;
-
-// protected transient UserService service;
-
- protected List<EchoBaseUserDTO> users;
-
- public List<EchoBaseUserDTO> getUsers() {
- return users;
- }
-
-// protected UserService getUserService() {
-// if (service == null) {
-// service = newService(UserService.class);
-// }
-// return service;
-// }
-
- @Override
- public String execute() throws Exception {
-
-// List<EchoBaseUser> allUsers = getUserService().getUsers();
- List<EchoBaseUser> allUsers = newService(UserService.class).getUsers();
-
- users = new ArrayList<EchoBaseUserDTO>(allUsers.size());
- for (EchoBaseUser user : allUsers) {
- users.add(user.toDTO());
- }
-
- return SUCCESS;
- }
-
-}
Copied: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/json/GetUsersDatas.java (from rev 24, trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/json/GetUsersAction.java)
===================================================================
--- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/json/GetUsersDatas.java (rev 0)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/json/GetUsersDatas.java 2011-11-08 17:51:54 UTC (rev 25)
@@ -0,0 +1,63 @@
+/*
+ * #%L
+ * EchoBase :: UI
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 Ifremer, Codelutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+package fr.ifremer.echobase.ui.actions.json;
+
+import fr.ifremer.echobase.entities.EchoBaseUser;
+import fr.ifremer.echobase.entities.EchoBaseUserDTO;
+import fr.ifremer.echobase.services.UserService;
+import fr.ifremer.echobase.ui.actions.EchoBaseActionSupport;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Obtains all users of the echobase internal database.
+ *
+ * @author sletellier <letellier(a)codelutin.com>
+ * @since 0.1
+ */
+public class GetUsersDatas extends EchoBaseActionSupport {
+
+ private static final long serialVersionUID = 1L;
+
+ protected List<EchoBaseUserDTO> users;
+
+ public List<EchoBaseUserDTO> getUsers() {
+ return users;
+ }
+
+ @Override
+ public String execute() throws Exception {
+
+ List<EchoBaseUser> allUsers = newService(UserService.class).getUsers();
+
+ users = new ArrayList<EchoBaseUserDTO>(allUsers.size());
+ for (EchoBaseUser user : allUsers) {
+ users.add(user.toDTO());
+ }
+
+ return SUCCESS;
+ }
+
+}
Property changes on: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/json/GetUsersDatas.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/echobase-ui/src/main/resources/config/struts-import.xml
===================================================================
--- trunk/echobase-ui/src/main/resources/config/struts-import.xml (rev 0)
+++ trunk/echobase-ui/src/main/resources/config/struts-import.xml 2011-11-08 17:51:54 UTC (rev 25)
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<!DOCTYPE struts PUBLIC
+ "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
+ "http://struts.apache.org/dtds/struts-2.1.7.dtd">
+
+<struts>
+
+ <package name="import" extends="loggued" namespace="/import">
+
+ <!-- Display import page -->
+ <action name="import" class="fr.ifremer.echobase.ui.actions.ImportAction" method="input">
+ <interceptor-ref name="basicStackLoggued"/>
+ <result name="input">/WEB-INF/jsp/import/import.jsp</result>
+ <result name="success" type="redirectAction">doImport</result>
+ </action>
+
+ <!-- Display import page -->
+ <action name="doImport" class="fr.ifremer.echobase.ui.actions.ImportAction">
+ <interceptor-ref name="paramsPrepareParamsStackLoggued"/>
+ <result name="success">/WEB-INF/jsp/import/importProgress.jsp</result>
+ </action>
+
+ </package>
+
+</struts>
+
Modified: trunk/echobase-ui/src/main/resources/config/struts-json.xml
===================================================================
--- trunk/echobase-ui/src/main/resources/config/struts-json.xml 2011-11-08 14:08:22 UTC (rev 24)
+++ trunk/echobase-ui/src/main/resources/config/struts-json.xml 2011-11-08 17:51:54 UTC (rev 25)
@@ -23,7 +23,6 @@
#L%
-->
-
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.1.7.dtd">
@@ -33,7 +32,7 @@
<package name="json" extends="loggued" namespace="/json">
<action name="getUsers"
- class="fr.ifremer.echobase.ui.actions.json.GetUsersAction">
+ class="fr.ifremer.echobase.ui.actions.json.GetUsersDatas">
<interceptor-ref name="basicStackLoggued"/>
<interceptor-ref name="checkUserIsAdmin"/>
<result type="json"/>
Modified: trunk/echobase-ui/src/main/resources/config/struts-user.xml
===================================================================
--- trunk/echobase-ui/src/main/resources/config/struts-user.xml 2011-11-08 14:08:22 UTC (rev 24)
+++ trunk/echobase-ui/src/main/resources/config/struts-user.xml 2011-11-08 17:51:54 UTC (rev 25)
@@ -23,7 +23,6 @@
#L%
-->
-
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.1.7.dtd">
Modified: trunk/echobase-ui/src/main/resources/i18n/echobase-ui_fr_FR.properties
===================================================================
--- trunk/echobase-ui/src/main/resources/i18n/echobase-ui_fr_FR.properties 2011-11-08 14:08:22 UTC (rev 24)
+++ trunk/echobase-ui/src/main/resources/i18n/echobase-ui_fr_FR.properties 2011-11-08 17:51:54 UTC (rev 25)
@@ -1,14 +1,17 @@
echobase.action.create=Créer
echobase.action.delete=Suppression
+echobase.action.import=Importer
echobase.action.locale.english=Anglais
echobase.action.locale.french=Français
echobase.action.login=Connection
echobase.action.logout=Déconnection
echobase.action.save=Sauvegarder
echobase.common.admin=Administrateur
+echobase.common.comment=Commentaire
echobase.common.email=Email
+echobase.common.import=Import configuration
echobase.common.password=Mot de passe
-echobase.common.save=Sauvegarder
+echobase.common.survey=Campagne
echobase.common.tableName=Nom de la table
echobase.common.user=Utilisateur
echobase.error.bad.password=Mot de passe incorrrect
@@ -19,6 +22,12 @@
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.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
@@ -35,6 +44,7 @@
echobase.menu.logs=Logs
echobase.menu.users=Utilisateurs
echobase.msg.warnImportInProgress=Merci de ne pas fermer la fenêtre pour pouvoir acceder au résultats de l'import.
+echobase.survey.selectHeader=Selectionnez une campagne
echobase.title.export=Export
echobase.title.import=Imports
echobase.title.importProgress=Import en cours
Modified: trunk/echobase-ui/src/main/resources/struts.xml
===================================================================
--- trunk/echobase-ui/src/main/resources/struts.xml 2011-11-08 14:08:22 UTC (rev 24)
+++ trunk/echobase-ui/src/main/resources/struts.xml 2011-11-08 17:51:54 UTC (rev 25)
@@ -144,6 +144,7 @@
<include file="config/struts-dbeditor.xml"/>
<include file="config/struts-json.xml"/>
<include file="config/struts-user.xml"/>
+ <include file="config/struts-import.xml"/>
</struts>
Modified: trunk/echobase-ui/src/main/webapp/WEB-INF/decorators/layout-default.jsp
===================================================================
--- trunk/echobase-ui/src/main/webapp/WEB-INF/decorators/layout-default.jsp 2011-11-08 14:08:22 UTC (rev 24)
+++ trunk/echobase-ui/src/main/webapp/WEB-INF/decorators/layout-default.jsp 2011-11-08 17:51:54 UTC (rev 25)
@@ -41,7 +41,6 @@
<div id="body">
- <%-- TODO sletellier 20111104 : add this --%>
<s:if test="hasActionMessages()">
<div class="info_success">
<s:actionmessage/>
Modified: trunk/echobase-ui/src/main/webapp/WEB-INF/includes/menu.jsp
===================================================================
--- trunk/echobase-ui/src/main/webapp/WEB-INF/includes/menu.jsp 2011-11-08 14:08:22 UTC (rev 24)
+++ trunk/echobase-ui/src/main/webapp/WEB-INF/includes/menu.jsp 2011-11-08 17:51:54 UTC (rev 25)
@@ -25,13 +25,13 @@
<div class="cleanBoth">
<ul>
<li>
- <s:a action="import"><s:text name="echobase.menu.import"/></s:a>
+ <s:a action="import" namespace="/import"><s:text name="echobase.menu.import"/></s:a>
</li>
<li>
<s:a action="export"><s:text name="echobase.menu.export"/></s:a>
</li>
<li>
- <s:a action="export"><s:text name="echobase.menu.logs"/></s:a>
+ <s:a action="logs"><s:text name="echobase.menu.logs"/></s:a>
</li>
<s:if
test="%{userIsAdmin}">
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-08 14:08:22 UTC (rev 24)
+++ trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/dbeditor/dbeditor.jsp 2011-11-08 17:51:54 UTC (rev 25)
@@ -43,7 +43,7 @@
</script>
<div>
- <s:select key="tableName" href='%{getTableNamesUrl}'
+ <s:select key="tableName"
label='%{getText("echobase.common.tableName")}'
list="tableNames" headerKey="" headerValue=""/>
Modified: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/export/exportQueryForm.jsp
===================================================================
--- trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/export/exportQueryForm.jsp 2011-11-08 14:08:22 UTC (rev 24)
+++ trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/export/exportQueryForm.jsp 2011-11-08 17:51:54 UTC (rev 25)
@@ -49,7 +49,7 @@
<s:url id="saveExportQueryUrl" action="saveExportQuery" namespace="export"/>
<s:set id="saveExportQueryText">
- <s:text name="echobase.common.save"/>
+ <s:text name="echobase.action.save"/>
</s:set>
<sj:submit id="saveQuery"
Deleted: 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-08 14:08:22 UTC (rev 24)
+++ trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/import/ImportProgress.jsp 2011-11-08 17:51:54 UTC (rev 25)
@@ -1,33 +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 contentType="text/html" pageEncoding="UTF-8" %>
-<%@ taglib prefix="s" uri="/struts-tags" %>
-<%@ taglib prefix="sj" uri="/struts-jquery-tags" %>
-
-<title><s:text name="echobase.title.importProgress"/></title>
-
-<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
Deleted: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/import/ImportResult.jsp
===================================================================
--- trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/import/ImportResult.jsp 2011-11-08 14:08:22 UTC (rev 24)
+++ trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/import/ImportResult.jsp 2011-11-08 17:51:54 UTC (rev 25)
@@ -1,29 +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 contentType="text/html" pageEncoding="UTF-8" %>
-<%@ taglib prefix="s" uri="/struts-tags" %>
-
-<title><s:text name="echobase.title.importResult"/></title>
-
-<%-- TODO letellier 20111104 : Add import results --%>
\ No newline at end of file
Copied: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/import/import.jsp (from rev 24, trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/import/imports.jsp)
===================================================================
--- trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/import/import.jsp (rev 0)
+++ trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/import/import.jsp 2011-11-08 17:51:54 UTC (rev 25)
@@ -0,0 +1,56 @@
+<%--
+ #%L
+ EchoBase :: UI
+
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2011 Ifremer, Codelutin
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+ #L%
+ --%>
+<%@page contentType="text/html" pageEncoding="UTF-8" %>
+<%@ taglib prefix="s" uri="/struts-tags" %>
+
+<title><s:text name="echobase.title.import"/></title>
+
+<s:form id="importForm" action="import" namespace="/import" method="POST" enctype="multipart/form-data">
+
+ <fieldset>
+ <legend>
+ <s:text name="echobase.common.import"/>
+ </legend>
+ <s:select
+ key="selectedSurvey"
+ label='%{getText("echobase.common.survey")}'
+ list="surveys"
+ emptyOption="true"
+ headerKey="-1"
+ headerValue='%{getText("echobase.survey.selectHeader")}'
+ />
+
+ <s:file name="importModel.accessImport" key="echobase.importFile.access"/>
+ <s:file name="importModel.accousticImport" key="echobase.importFile.accoustique"/>
+ <s:file name="importModel.pecherieImport" key="echobase.importFile.pecherie"/>
+ <s:file name="importModel.lectureAgeGenImport" key="echobase.importFile.lectureAgeGen"/>
+ <s:file name="importModel.eventsImport" key="echobase.importFile.events"/>
+ <s:file name="importModel.typeEchoSpeciesImport" key="echobase.importFile.typeEchoSpecies"/>
+
+ <s:textarea name="importModel.comment" key="echobase.common.comment"/>
+
+ </fieldset>
+ <br/>
+ <s:submit id="addFilesSubmit" value='%{getText("echobase.action.import")}'/>
+</s:form>
\ No newline at end of file
Property changes on: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/import/import.jsp
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/import/importProgress.jsp (from rev 24, trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/import/ImportProgress.jsp)
===================================================================
--- trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/import/importProgress.jsp (rev 0)
+++ trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/import/importProgress.jsp 2011-11-08 17:51:54 UTC (rev 25)
@@ -0,0 +1,33 @@
+<%--
+ #%L
+ EchoBase :: UI
+
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2011 Ifremer, Codelutin
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+ #L%
+ --%>
+<%@page contentType="text/html" pageEncoding="UTF-8" %>
+<%@ taglib prefix="s" uri="/struts-tags" %>
+<%@ taglib prefix="sj" uri="/struts-jquery-tags" %>
+
+<title><s:text name="echobase.title.importProgress"/></title>
+
+<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
Property changes on: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/import/importProgress.jsp
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/import/importResult.jsp (from rev 24, trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/import/ImportResult.jsp)
===================================================================
--- trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/import/importResult.jsp (rev 0)
+++ trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/import/importResult.jsp 2011-11-08 17:51:54 UTC (rev 25)
@@ -0,0 +1,29 @@
+<%--
+ #%L
+ EchoBase :: UI
+
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2011 Ifremer, Codelutin
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+ #L%
+ --%>
+<%@page contentType="text/html" pageEncoding="UTF-8" %>
+<%@ taglib prefix="s" uri="/struts-tags" %>
+
+<title><s:text name="echobase.title.importResult"/></title>
+
+<%-- TODO letellier 20111104 : Add import results --%>
\ No newline at end of file
Property changes on: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/import/importResult.jsp
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Deleted: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/import/imports.jsp
===================================================================
--- trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/import/imports.jsp 2011-11-08 14:08:22 UTC (rev 24)
+++ trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/import/imports.jsp 2011-11-08 17:51:54 UTC (rev 25)
@@ -1,43 +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 contentType="text/html" pageEncoding="UTF-8" %>
-<%@ taglib prefix="s" uri="/struts-tags" %>
-
-<title><s:text name="echobase.title.import"/></title>
-
-<s:form id="importForm" action="importFiles" namespace="/import" method="POST" enctype="multipart/form-data">
-
- <%-- TODO letellier 20111104 : Allow to select existing campagne --%>
-
- <s:file name="accoustique" key="echobase.importFile.accoustique"/>
- <s:file name="pecherie" key="echobase.importFile.pecherie"/>
- <s:file name="lectureAgeGen" key="echobase.importFile.lectureAgeGen"/>
- <s:file name="events" key="echobase.importFile.events"/>
- <s:file name="typeEchoSpecies" key="echobase.importFile.typeEchoSpecies"/>
-
- <s:textarea name="comment" key="echobase.common.comment"/>
-
- <s:submit id="addFilesSubmit"
- value="%{saveText}"/>
-</s:form>
\ No newline at end of file
1
0
r24 - in trunk/echobase-ui/src/main: java/fr/ifremer/echobase/ui java/fr/ifremer/echobase/ui/actions java/fr/ifremer/echobase/ui/actions/dbeditor java/fr/ifremer/echobase/ui/actions/json resources/config resources/i18n webapp/WEB-INF/decorators webapp/WEB-INF/jsp/dbeditor webapp/WEB-INF/jsp/user
by tchemit@users.forge.codelutin.com 08 Nov '11
by tchemit@users.forge.codelutin.com 08 Nov '11
08 Nov '11
Author: tchemit
Date: 2011-11-08 15:08:22 +0100 (Tue, 08 Nov 2011)
New Revision: 24
Url: http://forge.codelutin.com/repositories/revision/echobase/24
Log:
add dbeditor
Removed:
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/DbEditorUtil.java
Modified:
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/EchoBaseApplicationContext.java
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/EchoBaseApplicationListener.java
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/EchoBaseActionSupport.java
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/EditActionEnum.java
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/GetTableDatas.java
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/LoadTablePage.java
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/json/GetUsersAction.java
trunk/echobase-ui/src/main/resources/config/struts-dbeditor.xml
trunk/echobase-ui/src/main/resources/config/struts-json.xml
trunk/echobase-ui/src/main/resources/i18n/echobase-ui_fr_FR.properties
trunk/echobase-ui/src/main/webapp/WEB-INF/decorators/layout-default.jsp
trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/dbeditor/dbeditor.jsp
trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/user/userForm.jsp
Modified: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/EchoBaseApplicationContext.java
===================================================================
--- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/EchoBaseApplicationContext.java 2011-11-08 14:07:37 UTC (rev 23)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/EchoBaseApplicationContext.java 2011-11-08 14:08:22 UTC (rev 24)
@@ -25,6 +25,7 @@
import com.google.common.base.Supplier;
import fr.ifremer.echobase.EchoBaseConfiguration;
+import fr.ifremer.echobase.entities.meta.DbMeta;
import org.nuiton.topia.TopiaContext;
/**
@@ -34,6 +35,7 @@
public class EchoBaseApplicationContext {
protected EchoBaseConfiguration configuration;
+ protected DbMeta dbMeta;
protected Supplier<TopiaContext> rootContextSupplier;
@@ -52,4 +54,12 @@
public void setRootContextSupplier(Supplier<TopiaContext> rootContextSupplier) {
this.rootContextSupplier = rootContextSupplier;
}
+
+ public DbMeta getDbMeta() {
+ return dbMeta;
+ }
+
+ public void setDbMeta(DbMeta dbMeta) {
+ this.dbMeta = dbMeta;
+ }
}
Modified: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/EchoBaseApplicationListener.java
===================================================================
--- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/EchoBaseApplicationListener.java 2011-11-08 14:07:37 UTC (rev 23)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/EchoBaseApplicationListener.java 2011-11-08 14:08:22 UTC (rev 24)
@@ -24,13 +24,16 @@
package fr.ifremer.echobase.ui;
import com.google.common.base.Supplier;
+import com.google.common.collect.Lists;
import fr.ifremer.echobase.EchoBaseConfiguration;
import fr.ifremer.echobase.EchoBaseTechnicalException;
import fr.ifremer.echobase.EchoBaseTopiaRootContextSupplierFactory;
+import fr.ifremer.echobase.entities.EchoBaseEntityEnum;
import fr.ifremer.echobase.entities.EchoBaseUser;
import fr.ifremer.echobase.entities.EchoBaseUserDTO;
import fr.ifremer.echobase.entities.EchoBaseUserDTOImpl;
import fr.ifremer.echobase.entities.EchoBaseUserImpl;
+import fr.ifremer.echobase.entities.meta.DbMeta;
import fr.ifremer.echobase.services.EchoBaseServiceContext;
import fr.ifremer.echobase.services.EchoBaseServiceContextImpl;
import fr.ifremer.echobase.services.EchoBaseServiceFactory;
@@ -103,7 +106,13 @@
new EchoBaseTopiaRootContextSupplierFactory();
rootContextSupplier = factory.newDatabaseFromConfig(configuration);
applicationContext.setRootContextSupplier(rootContextSupplier);
+ List<EchoBaseEntityEnum> entityEnums =
+ Lists.newArrayList(EchoBaseEntityEnum.values());
+ entityEnums.remove(EchoBaseEntityEnum.EchoBaseUser);
+ DbMeta dbMeta = new DbMeta(entityEnums.toArray(new EchoBaseEntityEnum[entityEnums.size()]));
+ applicationContext.setDbMeta(dbMeta);
+
// register our not locale dependant converter
Converter converter = ConverterUtil.getConverter(Float.class);
if (converter != null) {
@@ -119,7 +128,7 @@
updateSchema(configuration);
}
- createAdminUser(configuration);
+ createAdminUser(applicationContext);
} catch (TopiaException e) {
throw new EchoBaseTechnicalException("Could not init db", e);
}
@@ -179,22 +188,26 @@
}
/**
- * Creates the adminsitrator ({@code admin/admin}) on the internal
- * database.
+ * Creates the adminsitrator ({@code admin/admin}) on the database.
*
- * @param configuration EchoBase configuration
+ * @param applicationContext application context
* @throws TopiaException if could not create the user.
*/
- protected void createAdminUser(EchoBaseConfiguration configuration) throws TopiaException {
+ protected void createAdminUser(EchoBaseApplicationContext applicationContext) throws TopiaException {
+ EchoBaseConfiguration configuration =
+ applicationContext.getConfiguration();
+
EchoBaseServiceFactory serviceFactory =
new EchoBaseServiceFactory();
TopiaContext transaction = rootContextSupplier.get().beginTransaction();
try {
EchoBaseServiceContext serviceContext = new EchoBaseServiceContextImpl(
+ Locale.getDefault(),
transaction,
configuration,
+ applicationContext.getDbMeta(),
serviceFactory
);
@@ -217,13 +230,6 @@
userDTO.setAdmin(true);
service.createOrUpdate(userDTO);
- for (int i = 0; i < 1000; i++) {
-
- userDTO.setEmail("admin" + i);
- userDTO.setPassword("admin");
- userDTO.setAdmin(true);
- service.createOrUpdate(userDTO);
- }
}
} finally {
transaction.closeContext();
Modified: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/EchoBaseActionSupport.java
===================================================================
--- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/EchoBaseActionSupport.java 2011-11-08 14:07:37 UTC (rev 23)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/EchoBaseActionSupport.java 2011-11-08 14:08:22 UTC (rev 24)
@@ -122,11 +122,18 @@
/**
* Fabrique pour récupérer le ServiceContext tel qu'il devrait être fourni
* à la fabrication d'un service.
+ *
+ * @return service context
*/
protected EchoBaseServiceContext getServiceContext() {
if (serviceContext == null) {
serviceContext = new EchoBaseServiceContextImpl(
- getTransaction(), getConfiguration(), serviceFactory);
+ getLocale(),
+ getTransaction(),
+ getConfiguration(),
+ getEchoBaseApplicationContext().getDbMeta(),
+ serviceFactory
+ );
}
return serviceContext;
}
Property changes on: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/EditActionEnum.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Deleted: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/DbEditorUtil.java
===================================================================
--- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/DbEditorUtil.java 2011-11-08 14:07:37 UTC (rev 23)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/DbEditorUtil.java 2011-11-08 14:08:22 UTC (rev 24)
@@ -1,67 +0,0 @@
-package fr.ifremer.echobase.ui.actions.dbeditor;
-
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
-import fr.ifremer.echobase.entities.EchoBaseDAOHelper;
-import fr.ifremer.echobase.entities.EchoBaseUser;
-import fr.ifremer.echobase.entities.ExportQuery;
-import fr.ifremer.echobase.services.DbEditorService;
-import org.nuiton.topia.TopiaContext;
-import org.nuiton.topia.persistence.TopiaEntity;
-
-import java.beans.Introspector;
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
-
-import static org.nuiton.i18n.I18n._;
-
-/**
- * Helper for the db editor.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 0.1
- */
-public class DbEditorUtil {
-
- protected static Map<String, String> tableNames;
-
- public static Map<String, String> getTableNames() {
-
- if (tableNames == null) {
- tableNames = Maps.newTreeMap();
- Class<? extends TopiaEntity>[] contractClasses =
- EchoBaseDAOHelper.getContractClasses();
- for (Class<? extends TopiaEntity> contractClass : contractClasses) {
- tableNames.put(contractClass.getName(), _("echobase.common." + Introspector.decapitalize(contractClass.getSimpleName())));
- }
- }
- return tableNames;
- }
-
- public static List<DbEditorService.TableMeta> getTableMeta(String tableName, TopiaContext transaction) {
-
- List<DbEditorService.TableMeta> result = Lists.newLinkedList();
- if (EchoBaseUser.class.getName().equals(tableName)) {
-// result.add(newMeta(EchoBaseUser.TOPIA_ID, String.class));
- result.add(DbEditorService.newMeta(EchoBaseUser.PROPERTY_EMAIL, String.class));
- result.add(DbEditorService.newMeta(EchoBaseUser.PROPERTY_ADMIN, boolean.class));
- }
-
- if (ExportQuery.class.getName().equals(tableName)) {
-
-// result.add(newMeta(ExportQuery.TOPIA_ID, String.class));
- result.add(DbEditorService.newMeta(ExportQuery.PROPERTY_NAME, String.class));
- result.add(DbEditorService.newMeta(ExportQuery.PROPERTY_DESCRIPTION, String.class));
- result.add(DbEditorService.newMeta(ExportQuery.PROPERTY_SQL_QUERY, String.class));
- result.add(DbEditorService.newMeta(ExportQuery.PROPERTY_LAST_MODIFIED_DATE, Date.class));
- result.add(DbEditorService.newMeta(ExportQuery.PROPERTY_LAST_MODIFIED_USER, EchoBaseUser.class));
- }
- return result;
- }
-
- protected DbEditorUtil() {
- // helper classes, avoid constructor
- }
-
-}
Modified: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/GetTableDatas.java
===================================================================
--- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/GetTableDatas.java 2011-11-08 14:07:37 UTC (rev 23)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/GetTableDatas.java 2011-11-08 14:08:22 UTC (rev 24)
@@ -1,10 +1,32 @@
+/*
+ * #%L
+ * EchoBase :: UI
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 Ifremer, Codelutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
package fr.ifremer.echobase.ui.actions.dbeditor;
-import com.google.common.collect.Lists;
import fr.ifremer.echobase.services.DbEditorService;
import fr.ifremer.echobase.ui.actions.EchoBaseActionSupport;
-import java.util.List;
+import java.util.Map;
/**
* To obtain the data for the given request.
@@ -19,17 +41,21 @@
/** Name of the table to load. */
protected String tableName;
- /** Metas of the table */
- protected List<DbEditorService.TableMeta> tableMetas;
+ /** Datas of the given table. */
+ protected Map[] datas;
+ public Map[] getDatas() {
+ return datas;
+ }
+
public void setTableName(String tableName) {
this.tableName = tableName;
}
@Override
public String execute() throws Exception {
- tableMetas = Lists.newLinkedList();
- tableMetas.addAll(DbEditorUtil.getTableMeta(tableName));
+ DbEditorService dbEditorService = newService(DbEditorService.class);
+ datas = dbEditorService.getDatas(tableName);
return SUCCESS;
}
Property changes on: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/GetTableDatas.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/LoadTablePage.java
===================================================================
--- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/LoadTablePage.java 2011-11-08 14:07:37 UTC (rev 23)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/LoadTablePage.java 2011-11-08 14:08:22 UTC (rev 24)
@@ -1,23 +1,42 @@
+/*
+ * #%L
+ * EchoBase :: UI
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 Ifremer, Codelutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
package fr.ifremer.echobase.ui.actions.dbeditor;
-import com.google.common.base.Preconditions;
-import com.google.common.collect.Lists;
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.lang.StringUtils;
-import org.hibernate.cfg.Configuration;
-import org.hibernate.mapping.Column;
-import org.hibernate.mapping.PersistentClass;
-import org.hibernate.mapping.Table;
-import org.nuiton.topia.framework.TopiaContextImplementor;
-import org.nuiton.topia.persistence.TopiaEntity;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import static org.nuiton.i18n.I18n._;
+import static org.nuiton.i18n.I18n.l_;
+
/**
* To load the db editor page.s
*
@@ -35,7 +54,7 @@
protected Map<String, String> tableNames;
/** Metas of the table */
- protected List<DbEditorService.TableMeta> tableMetas;
+ protected TableMeta tableMeta;
public String getTableName() {
return tableName;
@@ -45,8 +64,8 @@
return tableNames;
}
- public List<DbEditorService.TableMeta> getTableMetas() {
- return tableMetas;
+ public List<ColumnMeta> getColumnMetas() {
+ return tableMeta.getColumns();
}
public void setTableName(String tableName) {
@@ -56,28 +75,21 @@
@Override
public String input() throws Exception {
tableNames = Maps.newTreeMap();
- tableNames.putAll(DbEditorUtil.getTableNames());
- if (StringUtils.isNotEmpty(tableName)) {
+ DbMeta dbMeta = getEchoBaseApplicationContext().getDbMeta();
+ for (TableMeta tableMeta : dbMeta) {
+ String name = tableMeta.getName();
+ String i18nKey = tableMeta.getI18nKey();
+ tableNames.put(name, l_(getLocale(), i18nKey));
+ }
+ if (StringUtils.isEmpty(tableName)) {
- // load also table metas
- EchoBaseEntityEnum entityEnum = EchoBaseEntityEnum.valueOf(tableName);
- Preconditions.checkNotNull(entityEnum);
- String implementationFQN = entityEnum.getImplementationFQN();
- TopiaContextImplementor tx = (TopiaContextImplementor) getTransaction();
- Configuration hibernateConfiguration = tx.getHibernateConfiguration();
- PersistentClass classMapping = hibernateConfiguration.getClassMapping(implementationFQN);
- Table table = classMapping.getTable();
- Iterator<?> columnIterator = table.getColumnIterator();
- while (columnIterator.hasNext()) {
- Column column = (Column) columnIterator.next();
- String name = column.getName();
- if (TopiaEntity.TOPIA_CREATE_DATE.equals(name)) {
+ // no table selected
+ addActionMessage(_("echobase.info.no.table.selected"));
+ } else {
- // skip it
- }
- }
- tableMetas = Lists.newLinkedList();
- tableMetas.addAll(DbEditorUtil.getTableMeta(tableName, getTransaction()));
+ // load table metas
+ DbEditorService dbEditorService = newService(DbEditorService.class);
+ tableMeta = dbEditorService.getTableMetas(tableName);
}
return INPUT;
}
Property changes on: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/LoadTablePage.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Property changes on: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/json/GetUsersAction.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/echobase-ui/src/main/resources/config/struts-dbeditor.xml
===================================================================
--- trunk/echobase-ui/src/main/resources/config/struts-dbeditor.xml 2011-11-08 14:07:37 UTC (rev 23)
+++ trunk/echobase-ui/src/main/resources/config/struts-dbeditor.xml 2011-11-08 14:08:22 UTC (rev 24)
@@ -1,4 +1,28 @@
<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+ #%L
+ EchoBase :: UI
+
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2011 Ifremer, Codelutin
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+ #L%
+ -->
+
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.1.7.dtd">
Property changes on: trunk/echobase-ui/src/main/resources/config/struts-dbeditor.xml
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Property changes on: trunk/echobase-ui/src/main/resources/config/struts-json.xml
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/echobase-ui/src/main/resources/i18n/echobase-ui_fr_FR.properties
===================================================================
--- trunk/echobase-ui/src/main/resources/i18n/echobase-ui_fr_FR.properties 2011-11-08 14:07:37 UTC (rev 23)
+++ trunk/echobase-ui/src/main/resources/i18n/echobase-ui_fr_FR.properties 2011-11-08 14:08:22 UTC (rev 24)
@@ -9,6 +9,7 @@
echobase.common.email=Email
echobase.common.password=Mot de passe
echobase.common.save=Sauvegarder
+echobase.common.tableName=Nom de la table
echobase.common.user=Utilisateur
echobase.error.bad.password=Mot de passe incorrrect
echobase.error.email.already.used=
@@ -18,6 +19,7 @@
echobase.export.queryDescription=Description
echobase.export.queryName=Nom
echobase.export.querySql=SQL
+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
Modified: trunk/echobase-ui/src/main/webapp/WEB-INF/decorators/layout-default.jsp
===================================================================
--- trunk/echobase-ui/src/main/webapp/WEB-INF/decorators/layout-default.jsp 2011-11-08 14:07:37 UTC (rev 23)
+++ trunk/echobase-ui/src/main/webapp/WEB-INF/decorators/layout-default.jsp 2011-11-08 14:08:22 UTC (rev 24)
@@ -41,18 +41,18 @@
<div id="body">
- <%-- TODO sletellier 20111104 : add this --%>
- <%--<s:if test="hasActionMessages()">--%>
- <%--<div class="info_success">--%>
- <%--<s:actionmessage/>--%>
- <%--</div>--%>
- <%--</s:if>--%>
+ <%-- TODO sletellier 20111104 : add this --%>
+ <s:if test="hasActionMessages()">
+ <div class="info_success">
+ <s:actionmessage/>
+ </div>
+ </s:if>
- <%--<s:if test="hasActionErrors()">--%>
- <%--<div class="info_error">--%>
- <%--<s:actionerror/>--%>
- <%--</div>--%>
- <%--</s:if>--%>
+ <s:if test="hasActionErrors()">
+ <div class="info_error">
+ <s:actionerror/>
+ </div>
+ </s:if>
<d:body/>
</div>
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-08 14:07:37 UTC (rev 23)
+++ trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/dbeditor/dbeditor.jsp 2011-11-08 14:08:22 UTC (rev 24)
@@ -2,8 +2,8 @@
#%L
EchoBase :: UI
- $Id: export.jsp 17 2011-11-07 10:57:50Z tchemit $
- $HeadURL: http://svn.forge.codelutin.com/svn/echobase/trunk/echobase-ui/src/main/weba… $
+ $Id$
+ $HeadURL$
%%
Copyright (C) 2011 Ifremer, Codelutin
%%
@@ -43,19 +43,14 @@
</script>
<div>
-<s:select key="tableName" href='%{getTableNamesUrl}'
- label='%{getText("echobase.common.tableName")}'
+ <s:select key="tableName" href='%{getTableNamesUrl}'
+ label='%{getText("echobase.common.tableName")}'
+ list="tableNames" headerKey="" headerValue=""/>
- list="tableNames" headerKey="" headerValue=""/>
-
- </div>
+</div>
<br/>
-<s:if test="tableName == ''">
- <p>Aucune table sélectionnée</p>
-</s:if>
-<s:else>
-
+<s:if test="tableName!=null and tableName != ''">
<s:url id="loadUrl" action="getTableDatas" namespace="/dbeditor"
escapeAmp="false">
<s:param name="tableName" value="%{tableName}"/>
@@ -63,7 +58,7 @@
<sjg:grid id="tableDatas"
caption="%{getText('echobase.common.tableDatas', tableNames[tableName])}"
- dataType="json" href="%{loadUrl}" gridModel="trips"
+ dataType="json" href="%{loadUrl}" gridModel="datas"
pager="true" pagerButtons="false" pagerInput="false"
navigator="true" autowidth="true" rownumbers="false"
navigatorEdit="true"
@@ -75,9 +70,9 @@
<sjg:gridColumn name="id" title="id" hidden="true"/>
- <s:iterator value="tableMetas" var="meta" status="status">
+ <s:iterator value="columnMetas" var="meta" status="status">
- <sjg:gridColumn name="%{#meta.name}" title="%{#meta.label}"
+ <sjg:gridColumn name="%{#meta.name}" title="%{getText(#meta.i18nKey)}"
edittype="%{#meta.columnType}"
sortable="false" editable="true"/>
@@ -85,5 +80,5 @@
</sjg:grid>
-</s:else>
+</s:if>
Property changes on: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/dbeditor/dbeditor.jsp
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Property changes on: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/user/userForm.jsp
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
1
0
r23 - trunk/echobase-services/src/main/java/fr/ifremer/echobase/services
by tchemit@users.forge.codelutin.com 08 Nov '11
by tchemit@users.forge.codelutin.com 08 Nov '11
08 Nov '11
Author: tchemit
Date: 2011-11-08 15:07:37 +0100 (Tue, 08 Nov 2011)
New Revision: 23
Url: http://forge.codelutin.com/repositories/revision/echobase/23
Log:
begin of the dbEditorService
Modified:
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/EchoBaseServiceContext.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EchoBaseServiceContextImpl.java
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-08 14:06:34 UTC (rev 22)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/AbstractEchoBaseService.java 2011-11-08 14:07:37 UTC (rev 23)
@@ -23,8 +23,11 @@
*/
package fr.ifremer.echobase.services;
+import fr.ifremer.echobase.entities.meta.DbMeta;
import org.nuiton.topia.TopiaContext;
+import java.util.Locale;
+
/**
* @author sletellier <letellier(a)codelutin.com>
* @since 0.1
@@ -38,7 +41,15 @@
this.serviceContext = serviceContext;
}
- public TopiaContext getTransaction() {
+ protected TopiaContext getTransaction() {
return serviceContext.getTransaction();
}
+
+ protected Locale getLocale() {
+ return serviceContext.getLocale();
+ }
+
+ protected DbMeta getDbMeta() {
+ return serviceContext.getDbMeta();
+ }
}
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-08 14:06:34 UTC (rev 22)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/DbEditorService.java 2011-11-08 14:07:37 UTC (rev 23)
@@ -23,16 +23,21 @@
*/
package fr.ifremer.echobase.services;
-import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
import fr.ifremer.echobase.EchoBaseTechnicalException;
-import org.apache.commons.beanutils.ResultSetDynaClass;
-import org.hibernate.mapping.Column;
+import fr.ifremer.echobase.entities.EchoBaseDAOHelper;
+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 org.nuiton.topia.TopiaException;
+import org.nuiton.topia.persistence.TopiaDAO;
import org.nuiton.topia.persistence.TopiaEntity;
+import org.nuiton.topia.persistence.util.EntityOperator;
-import java.io.Serializable;
-import java.sql.SQLException;
-import java.util.Date;
+import java.util.Iterator;
import java.util.List;
+import java.util.Map;
/**
* Service to edit the database.
@@ -42,75 +47,46 @@
*/
public class DbEditorService extends AbstractEchoBaseService {
- protected static TableMeta newMeta(String name, Class<?> type) {
- return new TableMeta(name, type);
- }
-
- public List<TableMeta> getMetas(String tableName) {
- List<TableMeta> result = Lists.newLinkedList();
+ public TableMeta getTableMetas(String tableName) {
+ DbMeta dbMeta = getDbMeta();
+ TableMeta result = dbMeta.getTable(tableName);
return result;
}
- public ResultSetDynaClass getDatas(String tableName) {
+ //TODO Use an object to filter datas and do pagination
+ public Map[] getDatas(String tableName) {
+ DbMeta dbMeta = getDbMeta();
+ TableMeta tableMeta = dbMeta.getTable(tableName);
+ EchoBaseEntityEnum entityEnum = tableMeta.getEntityEnum();
+ Class<? extends TopiaEntity> contract = entityEnum.getContract();
try {
- ResultSetDynaClass result = null;
- result = new ResultSetDynaClass(null);
+ TopiaDAO dao = EchoBaseDAOHelper.getDAO(getTransaction(), contract);
+ List<?> all = dao.findAll();
+ Map[] result = new Map[all.size()];
+ Iterator<?> dataItr = all.iterator();
+ int i = 0;
+ while (dataItr.hasNext()) {
+ TopiaEntity entity = (TopiaEntity) dataItr.next();
+ Map<String, Object> row = loadRow(tableMeta, entity);
+ result[i++] = row;
+ }
return result;
- } catch (SQLException eee) {
+ } catch (TopiaException eee) {
throw new EchoBaseTechnicalException("Could not obtain data", eee);
}
}
- public static class TableMeta implements Serializable {
-
- private static final long serialVersionUID = 1L;
-
- protected String name;
-
- protected String label;
-
- protected Column hibernateColumn;
-
- protected Class<?> type;
-
- public TableMeta(String name, Class<?> type) {
- this(name, name, type);
+ protected Map<String, Object> loadRow(TableMeta tableMeta, TopiaEntity entity) {
+ Map<String, Object> row = Maps.newLinkedHashMap();
+ EntityOperator<TopiaEntity> operator =
+ (EntityOperator<TopiaEntity>) tableMeta.getOperator();
+ for (ColumnMeta columnMeta : tableMeta) {
+ String propertyName = columnMeta.getName();
+ Object property =
+ operator.get(propertyName, entity);
+ row.put(propertyName, property);
}
-
- public TableMeta(String name, String label, Class<?> type) {
- this.name = name;
- this.label = label;
- this.type = type;
- }
-
- public String getName() {
- return name;
- }
-
- public String getLabel() {
- return label;
- }
-
- public Class<?> getType() {
- return type;
- }
-
- public String getColumnType() {
- String result = "string";
- if (boolean.class.equals(type)) {
- result = "boolean";
- } else if (Date.class.equals(type)) {
- result = "date";
- }
- return result;
- }
-
- public boolean isFK() {
- return TopiaEntity.class.isAssignableFrom(type);
- }
-
- public Column getHibernateColumn() {
- return hibernateColumn;
- }
+ return row;
}
+
}
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EchoBaseServiceContext.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EchoBaseServiceContext.java 2011-11-08 14:06:34 UTC (rev 22)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EchoBaseServiceContext.java 2011-11-08 14:07:37 UTC (rev 23)
@@ -25,8 +25,11 @@
package fr.ifremer.echobase.services;
import fr.ifremer.echobase.EchoBaseConfiguration;
+import fr.ifremer.echobase.entities.meta.DbMeta;
import org.nuiton.topia.TopiaContext;
+import java.util.Locale;
+
/**
* This contract represents objects you must provide when asking for a service.
* Objects provided may be injected in services returned by
@@ -39,8 +42,12 @@
TopiaContext getTransaction();
- <E extends EchoBaseService> E newService(Class<E> clazz);
+ Locale getLocale();
EchoBaseConfiguration getConfiguration();
+ DbMeta getDbMeta();
+
+ <E extends EchoBaseService> E newService(Class<E> clazz);
+
}
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EchoBaseServiceContextImpl.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EchoBaseServiceContextImpl.java 2011-11-08 14:06:34 UTC (rev 22)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EchoBaseServiceContextImpl.java 2011-11-08 14:07:37 UTC (rev 23)
@@ -25,13 +25,17 @@
import com.google.common.base.Preconditions;
import fr.ifremer.echobase.EchoBaseConfiguration;
+import fr.ifremer.echobase.entities.meta.DbMeta;
import org.nuiton.topia.TopiaContext;
-/** Instances of this class will be given to service factory.
+import java.util.Locale;
+
+/**
+ * Instances of this class will be given to service factory.
*
* @author tchemit <chemit(a)codelutin.com>
* @since 0.1
- **/
+ */
public class EchoBaseServiceContextImpl implements EchoBaseServiceContext {
protected TopiaContext transaction;
@@ -40,11 +44,19 @@
protected EchoBaseConfiguration configuration;
- public EchoBaseServiceContextImpl(TopiaContext transaction,
+ protected Locale locale;
+
+ protected DbMeta dbMeta;
+
+ public EchoBaseServiceContextImpl(Locale locale,
+ TopiaContext transaction,
EchoBaseConfiguration configuration,
+ DbMeta dbMeta,
EchoBaseServiceFactory serviceFactory) {
+ this.locale = locale;
this.transaction = transaction;
this.configuration = configuration;
+ this.dbMeta = dbMeta;
this.serviceFactory = serviceFactory;
}
@@ -55,6 +67,11 @@
}
@Override
+ public Locale getLocale() {
+ return locale;
+ }
+
+ @Override
public <E extends EchoBaseService> E newService(Class<E> clazz) {
return serviceFactory.newService(clazz, this);
}
@@ -64,6 +81,11 @@
return configuration;
}
+ @Override
+ public DbMeta getDbMeta() {
+ return dbMeta;
+ }
+
protected EchoBaseServiceFactory getServiceFactory() {
return serviceFactory;
}
1
0
r22 - in trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities: . meta
by tchemit@users.forge.codelutin.com 08 Nov '11
by tchemit@users.forge.codelutin.com 08 Nov '11
08 Nov '11
Author: tchemit
Date: 2011-11-08 15:06:34 +0100 (Tue, 08 Nov 2011)
New Revision: 22
Url: http://forge.codelutin.com/repositories/revision/echobase/22
Log:
add db metas api
Added:
trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/meta/
trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/meta/ColumnMeta.java
trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/meta/DbMeta.java
trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/meta/TableMeta.java
Added: trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/meta/ColumnMeta.java
===================================================================
--- trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/meta/ColumnMeta.java (rev 0)
+++ trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/meta/ColumnMeta.java 2011-11-08 14:06:34 UTC (rev 22)
@@ -0,0 +1,93 @@
+/*
+ * #%L
+ * EchoBase :: Entities
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 Ifremer, Codelutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+package fr.ifremer.echobase.entities.meta;
+
+import org.hibernate.mapping.Column;
+import org.nuiton.topia.persistence.TopiaEntity;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+* Define the meta data.
+*
+* @author tchemit <chemit(a)codelutin.com>
+* @since 0.1
+*/
+public class ColumnMeta implements Serializable {
+
+ protected static ColumnMeta newMeta(String name, String label, Class<?> type) {
+ return new ColumnMeta(name, label, type);
+ }
+
+ private static final long serialVersionUID = 1L;
+
+ protected String name;
+
+ protected String i18nKey;
+
+ protected Column hibernateColumn;
+
+ protected Class<?> type;
+
+ public ColumnMeta(String name, Class<?> type) {
+ this(name, name, type);
+ }
+
+ public ColumnMeta(String name, String i18nKey, Class<?> type) {
+ this.name = name;
+ this.i18nKey = i18nKey;
+ this.type = type;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getI18nKey() {
+ return i18nKey;
+ }
+
+ public Class<?> getType() {
+ return type;
+ }
+
+ public String getColumnType() {
+ String result = "string";
+ if (boolean.class.equals(type)) {
+ result = "boolean";
+ } else if (Date.class.equals(type)) {
+ result = "date";
+ }
+ return result;
+ }
+
+ public boolean isFK() {
+ return TopiaEntity.class.isAssignableFrom(type);
+ }
+
+ public Column getHibernateColumn() {
+ return hibernateColumn;
+ }
+}
Property changes on: trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/meta/ColumnMeta.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: 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 (rev 0)
+++ trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/meta/DbMeta.java 2011-11-08 14:06:34 UTC (rev 22)
@@ -0,0 +1,85 @@
+/*
+ * #%L
+ * EchoBase :: Entities
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 Ifremer, Codelutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+package fr.ifremer.echobase.entities.meta;
+
+
+import com.google.common.base.Preconditions;
+import com.google.common.collect.Lists;
+import fr.ifremer.echobase.entities.EchoBaseEntityEnum;
+
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * Define metas about a db.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.1
+ */
+public class DbMeta implements Iterable<TableMeta> {
+
+ protected List<TableMeta> tables;
+
+ protected final EchoBaseEntityEnum[] entityEnums;
+
+ public DbMeta(EchoBaseEntityEnum[] entityEnums) {
+ this.entityEnums = entityEnums;
+ }
+
+ public List<String> getTableNames() {
+ List<String> result = Lists.newArrayList();
+ for (TableMeta tableMeta : getTables()) {
+ result.add(tableMeta.getName());
+ }
+ return result;
+ }
+
+ public List<TableMeta> getTables() {
+ if (tables == null) {
+ tables = Lists.newArrayList();
+ for (EchoBaseEntityEnum entityEnum : entityEnums) {
+ TableMeta tableMeta = new TableMeta(entityEnum);
+ tables.add(tableMeta);
+ }
+ }
+ 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;
+ }
+
+ @Override
+ public Iterator<TableMeta> iterator() {
+ return getTables().iterator();
+ }
+}
Property changes on: trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/meta/DbMeta.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: 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 (rev 0)
+++ trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/meta/TableMeta.java 2011-11-08 14:06:34 UTC (rev 22)
@@ -0,0 +1,125 @@
+/*
+ * #%L
+ * EchoBase :: Entities
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 Ifremer, Codelutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+package fr.ifremer.echobase.entities.meta;
+
+import com.google.common.base.Preconditions;
+import com.google.common.collect.Lists;
+import fr.ifremer.echobase.entities.EchoBaseDAOHelper;
+import fr.ifremer.echobase.entities.EchoBaseEntityEnum;
+import org.nuiton.topia.persistence.TopiaEntity;
+import org.nuiton.topia.persistence.util.EntityOperator;
+
+import java.beans.Introspector;
+import java.io.Serializable;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * Define metas of a given db table.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.1
+ */
+public class TableMeta implements Serializable, Iterable<ColumnMeta> {
+
+ private static final long serialVersionUID = 1L;
+
+ protected final String name;
+
+ protected final String i18nKey;
+
+ protected final EntityOperator<?> operator;
+
+ protected final EchoBaseEntityEnum entityEnum;
+
+ protected List<ColumnMeta> columns;
+
+ 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());
+ operator = EchoBaseDAOHelper.getOperator(contract);
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public EchoBaseEntityEnum getEntityEnum() {
+ return entityEnum;
+ }
+
+ public String getI18nKey() {
+ return i18nKey;
+ }
+
+ public EntityOperator<?> getOperator() {
+ return operator;
+ }
+
+ public ColumnMeta getColumns(String columnName) {
+ Preconditions.checkNotNull(columnName);
+ ColumnMeta result = null;
+ for (ColumnMeta columnMeta : getColumns()) {
+ if (columnName.equals(columnMeta.getName())) {
+ result = columnMeta;
+ break;
+ }
+ }
+ return result;
+ }
+
+ public List<String> getColumnNames() {
+ List<String> result = Lists.newLinkedList();
+ for (ColumnMeta columnMeta : getColumns()) {
+ result.add(columnMeta.getName());
+ }
+ return result;
+ }
+
+ public List<ColumnMeta> getColumns() {
+ if (columns == null) {
+ columns = Lists.newLinkedList();
+ Class<? extends TopiaEntity> contract = entityEnum.getContract();
+ EntityOperator<? extends TopiaEntity> operator =
+ EchoBaseDAOHelper.getOperator(contract);
+ List<String> properties = operator.getProperties();
+ for (String property : properties) {
+ Class<?> propertyType = operator.getPropertyType(property);
+ String i18nKey = "echobase.common." + property;
+ ColumnMeta tableMeta = ColumnMeta.newMeta(property, i18nKey, propertyType);
+ columns.add(tableMeta);
+ }
+ }
+ return columns;
+ }
+
+ @Override
+ public Iterator<ColumnMeta> iterator() {
+ return getColumns().iterator();
+ }
+}
Property changes on: trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/meta/TableMeta.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
1
0
r21 - in trunk/echobase-ui/src/main: java/fr/ifremer/echobase/ui java/fr/ifremer/echobase/ui/actions java/fr/ifremer/echobase/ui/actions/dbeditor java/fr/ifremer/echobase/ui/actions/json java/fr/ifremer/echobase/ui/interceptors resources resources/config webapp/WEB-INF/jsp webapp/WEB-INF/jsp/dbeditor
by tchemit@users.forge.codelutin.com 08 Nov '11
by tchemit@users.forge.codelutin.com 08 Nov '11
08 Nov '11
Author: tchemit
Date: 2011-11-08 10:03:06 +0100 (Tue, 08 Nov 2011)
New Revision: 21
Url: http://forge.codelutin.com/repositories/revision/echobase/21
Log:
change chemit to tchemit + begin of dbeditor ui
Added:
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/DbEditorUtil.java
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/GetTableDatas.java
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/LoadTablePage.java
trunk/echobase-ui/src/main/resources/config/struts-dbeditor.xml
trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/dbeditor/
trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/dbeditor/dbeditor.jsp
Removed:
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/ApplicationListener.java
Modified:
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/EchoBaseApplicationContext.java
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/EchoBaseApplicationListener.java
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/EchoBaseSession.java
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/EchoBaseActionSupport.java
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/EditActionEnum.java
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/LoginAction.java
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/json/GetUsersAction.java
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/interceptors/CheckInUserSessionInterceptor.java
trunk/echobase-ui/src/main/resources/struts.xml
trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/home.jsp
Deleted: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/ApplicationListener.java
===================================================================
--- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/ApplicationListener.java 2011-11-08 09:01:17 UTC (rev 20)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/ApplicationListener.java 2011-11-08 09:03:06 UTC (rev 21)
@@ -1,255 +0,0 @@
-/*
- * #%L
- * EchoBase :: UI
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2011 Ifremer, Codelutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- * #L%
- */
-package fr.ifremer.echobase.ui;
-
-import com.google.common.base.Supplier;
-import fr.ifremer.echobase.EchoBaseConfiguration;
-import fr.ifremer.echobase.EchoBaseTechnicalException;
-import fr.ifremer.echobase.EchoBaseTopiaRootContextSupplierFactory;
-import fr.ifremer.echobase.entities.EchoBaseUser;
-import fr.ifremer.echobase.entities.EchoBaseUserDTO;
-import fr.ifremer.echobase.entities.EchoBaseUserDTOImpl;
-import fr.ifremer.echobase.entities.EchoBaseUserImpl;
-import fr.ifremer.echobase.services.EchoBaseServiceContext;
-import fr.ifremer.echobase.services.EchoBaseServiceContextImpl;
-import fr.ifremer.echobase.services.EchoBaseServiceFactory;
-import fr.ifremer.echobase.services.UserService;
-import fr.ifremer.echobase.ui.actions.EchoBaseActionSupport;
-import fr.ird.converter.FloatConverter;
-import org.apache.commons.beanutils.ConvertUtils;
-import org.apache.commons.beanutils.Converter;
-import org.apache.commons.collections.CollectionUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.nuiton.i18n.I18n;
-import org.nuiton.i18n.init.DefaultI18nInitializer;
-import org.nuiton.topia.TopiaContext;
-import org.nuiton.topia.TopiaException;
-import org.nuiton.topia.framework.TopiaContextImplementor;
-import org.nuiton.topia.framework.TopiaUtil;
-import org.nuiton.util.converter.ConverterUtil;
-
-import javax.servlet.ServletContextEvent;
-import javax.servlet.ServletContextListener;
-import java.util.Date;
-import java.util.List;
-import java.util.Locale;
-import java.util.Properties;
-
-/**
- * To listen start or end of the application.
- * <p/>
- * On start we will load the configuration and check connection to internal
- * database, creates schema and create an admin user in none found in database.
- * <p/>
- * On stop, just release the application configuration.
- *
- * @author chemit <chemit(a)codelutin.com>
- * @since 0.1
- */
-public class ApplicationListener implements ServletContextListener {
-
- /** Logger. */
- protected static final Log log =
- LogFactory.getLog(ApplicationListener.class);
-
- private Supplier<TopiaContext> rootContextSupplier;
-
- @Override
- public void contextInitialized(ServletContextEvent sce) {
-
- if (log.isInfoEnabled()) {
- log.info("Application starting at " + new Date() + "...");
- }
-
- // init I18n
- DefaultI18nInitializer i18nInitializer =
- new DefaultI18nInitializer("echobase-i18n");
- i18nInitializer.setMissingKeyReturnNull(true);
- I18n.init(i18nInitializer, Locale.getDefault());
-
- EchoBaseApplicationContext applicationContext = new EchoBaseApplicationContext();
- sce.getServletContext().setAttribute(EchoBaseActionSupport.APPLICATION_CONTEXT_PARAMETER, applicationContext);
-
- // initialize configuration
- EchoBaseConfiguration configuration = new EchoBaseConfiguration();
- applicationContext.setConfiguration(configuration);
-
- if (log.isInfoEnabled()) {
- log.info("Initializing RootContextSupplier...");
- }
- EchoBaseTopiaRootContextSupplierFactory factory =
- new EchoBaseTopiaRootContextSupplierFactory();
- rootContextSupplier = factory.newDatabaseFromConfig(configuration);
- applicationContext.setRootContextSupplier(rootContextSupplier);
-
- // register our not locale dependant converter
- Converter converter = ConverterUtil.getConverter(Float.class);
- if (converter != null) {
- ConvertUtils.deregister(Float.class);
- }
- ConvertUtils.register(new FloatConverter(), Float.class);
-
- // init database (and create minimal admin user if required)
- try {
- boolean schemaExist = isSchemaCreated();
- if (!schemaExist) {
-
- updateSchema(configuration);
- }
-
- createAdminUser(configuration);
- } catch (TopiaException e) {
- throw new EchoBaseTechnicalException("Could not init db", e);
- }
- }
-
- @Override
- public void contextDestroyed(ServletContextEvent sce) {
-
- if (log.isInfoEnabled()) {
- log.info("Application is ending at " + new Date() + "...");
- }
- if (rootContextSupplier != null) {
- if (log.isInfoEnabled()) {
- log.info("Shuting down RootContextSupplier...");
- }
- TopiaContext rootContext = rootContextSupplier.get();
- if (!rootContext.isClosed()) {
- try {
- rootContext.closeContext();
- } catch (TopiaException te) {
- if (log.isErrorEnabled()) {
- log.error("Could not close rootContext", te);
- }
- }
- }
- }
- }
-
- protected void updateSchema(EchoBaseConfiguration configuration) throws TopiaException {
- if (log.isInfoEnabled()) {
- log.info("Will create or update schema for db.");
- }
- // must create the schema
-
- Properties dbConf = configuration.getProperties();
-
- dbConf.put("hibernate.hbm2ddl.auto", "update");
-
- EchoBaseTopiaRootContextSupplierFactory factory =
- new EchoBaseTopiaRootContextSupplierFactory();
- Supplier<TopiaContext> topiaContextSupplier =
- factory.newDatabaseFromProperties(dbConf);
-
- // start a connexion to load schema
- TopiaContext tx = null;
-
- try {
- tx = topiaContextSupplier.get().beginTransaction();
-
- } finally {
-
- // no more update of schema...
- dbConf.put("hibernate.hbm2ddl.auto", "none");
-
- closeTransaction(tx);
- }
- }
-
- /**
- * Creates the adminsitrator ({@code admin/admin}) on the internal
- * database.
- *
- * @param configuration EchoBase configuration
- * @throws TopiaException if could not create the user.
- */
- protected void createAdminUser(EchoBaseConfiguration configuration) throws TopiaException {
-
- EchoBaseServiceFactory serviceFactory =
- new EchoBaseServiceFactory();
- TopiaContext transaction = rootContextSupplier.get().beginTransaction();
-
- try {
- EchoBaseServiceContext serviceContext = new EchoBaseServiceContextImpl(
- transaction,
- configuration,
- serviceFactory
- );
-
- UserService service = serviceFactory.newService(UserService.class, serviceContext);
-
- List<EchoBaseUser> users = service.getUsers();
-
- if (CollectionUtils.isEmpty(users)) {
-
- // no users in database create the admin user
- if (log.isInfoEnabled()) {
- log.info("No user in database, will create default " +
- "admin user (password admin).");
- }
-
- EchoBaseUserDTO userDTO = new EchoBaseUserDTOImpl();
- userDTO.setEmail("admin");
- userDTO.setPassword("admin");
- userDTO.setAdmin(true);
- service.createOrUpdate(userDTO);
- }
- } finally {
- transaction.closeContext();
- }
-
- }
-
- protected boolean isSchemaCreated() throws TopiaException {
-
- TopiaContextImplementor tx =
- (TopiaContextImplementor)
- rootContextSupplier.get();
- try {
- boolean schemaFound = TopiaUtil.isSchemaExist(
- tx.getHibernateConfiguration(),
- EchoBaseUserImpl.class.getName()
- );
-
- return schemaFound;
-
- } finally {
- closeTransaction(tx);
- }
- }
-
- /**
- * Try to close the given transaction.
- *
- * @param tx the transaction to close
- * @throws TopiaException if could not close the transaction
- */
- protected void closeTransaction(TopiaContext tx) throws TopiaException {
- if (tx != null && !tx.isClosed()) {
- tx.closeContext();
- }
- }
-
-}
Modified: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/EchoBaseApplicationContext.java
===================================================================
--- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/EchoBaseApplicationContext.java 2011-11-08 09:01:17 UTC (rev 20)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/EchoBaseApplicationContext.java 2011-11-08 09:03:06 UTC (rev 21)
@@ -28,7 +28,7 @@
import org.nuiton.topia.TopiaContext;
/**
- * @author chemit <chemit(a)codelutin.com>
+ * @author tchemit <chemit(a)codelutin.com>
* @since 0.1
*/
public class EchoBaseApplicationContext {
Modified: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/EchoBaseApplicationListener.java
===================================================================
--- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/EchoBaseApplicationListener.java 2011-11-08 09:01:17 UTC (rev 20)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/EchoBaseApplicationListener.java 2011-11-08 09:03:06 UTC (rev 21)
@@ -65,7 +65,7 @@
* <p/>
* On stop, just release the application configuration.
*
- * @author chemit <chemit(a)codelutin.com>
+ * @author tchemit <chemit(a)codelutin.com>
* @since 0.1
*/
public class EchoBaseApplicationListener implements ServletContextListener {
@@ -198,7 +198,8 @@
serviceFactory
);
- UserService service = serviceFactory.newService(UserService.class, serviceContext);
+ UserService service =
+ serviceFactory.newService(UserService.class, serviceContext);
List<EchoBaseUser> users = service.getUsers();
@@ -215,11 +216,18 @@
userDTO.setPassword("admin");
userDTO.setAdmin(true);
service.createOrUpdate(userDTO);
+
+ for (int i = 0; i < 1000; i++) {
+
+ userDTO.setEmail("admin" + i);
+ userDTO.setPassword("admin");
+ userDTO.setAdmin(true);
+ service.createOrUpdate(userDTO);
+ }
}
} finally {
transaction.closeContext();
}
-
}
protected boolean isSchemaCreated() throws TopiaException {
Modified: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/EchoBaseSession.java
===================================================================
--- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/EchoBaseSession.java 2011-11-08 09:01:17 UTC (rev 20)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/EchoBaseSession.java 2011-11-08 09:03:06 UTC (rev 21)
@@ -33,7 +33,7 @@
/**
* The session object of EchoBase to put in servlet session.
*
- * @author chemit <chemit(a)codelutin.com>
+ * @author tchemit <chemit(a)codelutin.com>
* @since 0.1
*/
public class EchoBaseSession {
Modified: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/EchoBaseActionSupport.java
===================================================================
--- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/EchoBaseActionSupport.java 2011-11-08 09:01:17 UTC (rev 20)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/EchoBaseActionSupport.java 2011-11-08 09:03:06 UTC (rev 21)
@@ -47,7 +47,7 @@
* we do NOT want this behaviour in gui, prefer to return the marked
* untranslated key.
*
- * @author chemit <chemit(a)codelutin.com>
+ * @author tchemit <chemit(a)codelutin.com>
* @since 0.1
*/
public class EchoBaseActionSupport extends BaseAction implements TopiaTransactionAware {
Modified: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/EditActionEnum.java
===================================================================
--- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/EditActionEnum.java 2011-11-08 09:01:17 UTC (rev 20)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/EditActionEnum.java 2011-11-08 09:03:06 UTC (rev 21)
@@ -26,7 +26,7 @@
/**
* Operations possible for a simple CRUD.
*
- * @author chemit <chemit(a)codelutin.com>
+ * @author tchemit <chemit(a)codelutin.com>
* @since 0.1
*/
public enum EditActionEnum {
Modified: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/LoginAction.java
===================================================================
--- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/LoginAction.java 2011-11-08 09:01:17 UTC (rev 20)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/LoginAction.java 2011-11-08 09:03:06 UTC (rev 21)
@@ -38,7 +38,7 @@
/**
* Login and Logout action.
*
- * @author chemit <chemit(a)codelutin.com>
+ * @author tchemit <chemit(a)codelutin.com>
* @since 0.1
*/
public class LoginAction extends EchoBaseActionSupport implements SessionAware {
Added: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/DbEditorUtil.java
===================================================================
--- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/DbEditorUtil.java (rev 0)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/DbEditorUtil.java 2011-11-08 09:03:06 UTC (rev 21)
@@ -0,0 +1,67 @@
+package fr.ifremer.echobase.ui.actions.dbeditor;
+
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import fr.ifremer.echobase.entities.EchoBaseDAOHelper;
+import fr.ifremer.echobase.entities.EchoBaseUser;
+import fr.ifremer.echobase.entities.ExportQuery;
+import fr.ifremer.echobase.services.DbEditorService;
+import org.nuiton.topia.TopiaContext;
+import org.nuiton.topia.persistence.TopiaEntity;
+
+import java.beans.Introspector;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * Helper for the db editor.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.1
+ */
+public class DbEditorUtil {
+
+ protected static Map<String, String> tableNames;
+
+ public static Map<String, String> getTableNames() {
+
+ if (tableNames == null) {
+ tableNames = Maps.newTreeMap();
+ Class<? extends TopiaEntity>[] contractClasses =
+ EchoBaseDAOHelper.getContractClasses();
+ for (Class<? extends TopiaEntity> contractClass : contractClasses) {
+ tableNames.put(contractClass.getName(), _("echobase.common." + Introspector.decapitalize(contractClass.getSimpleName())));
+ }
+ }
+ return tableNames;
+ }
+
+ public static List<DbEditorService.TableMeta> getTableMeta(String tableName, TopiaContext transaction) {
+
+ List<DbEditorService.TableMeta> result = Lists.newLinkedList();
+ if (EchoBaseUser.class.getName().equals(tableName)) {
+// result.add(newMeta(EchoBaseUser.TOPIA_ID, String.class));
+ result.add(DbEditorService.newMeta(EchoBaseUser.PROPERTY_EMAIL, String.class));
+ result.add(DbEditorService.newMeta(EchoBaseUser.PROPERTY_ADMIN, boolean.class));
+ }
+
+ if (ExportQuery.class.getName().equals(tableName)) {
+
+// result.add(newMeta(ExportQuery.TOPIA_ID, String.class));
+ result.add(DbEditorService.newMeta(ExportQuery.PROPERTY_NAME, String.class));
+ result.add(DbEditorService.newMeta(ExportQuery.PROPERTY_DESCRIPTION, String.class));
+ result.add(DbEditorService.newMeta(ExportQuery.PROPERTY_SQL_QUERY, String.class));
+ result.add(DbEditorService.newMeta(ExportQuery.PROPERTY_LAST_MODIFIED_DATE, Date.class));
+ result.add(DbEditorService.newMeta(ExportQuery.PROPERTY_LAST_MODIFIED_USER, EchoBaseUser.class));
+ }
+ return result;
+ }
+
+ protected DbEditorUtil() {
+ // helper classes, avoid constructor
+ }
+
+}
Added: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/GetTableDatas.java
===================================================================
--- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/GetTableDatas.java (rev 0)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/GetTableDatas.java 2011-11-08 09:03:06 UTC (rev 21)
@@ -0,0 +1,37 @@
+package fr.ifremer.echobase.ui.actions.dbeditor;
+
+import com.google.common.collect.Lists;
+import fr.ifremer.echobase.services.DbEditorService;
+import fr.ifremer.echobase.ui.actions.EchoBaseActionSupport;
+
+import java.util.List;
+
+/**
+ * To obtain the data for the given request.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.1
+ */
+public class GetTableDatas extends EchoBaseActionSupport {
+
+ private static final long serialVersionUID = 1L;
+
+ /** Name of the table to load. */
+ protected String tableName;
+
+ /** Metas of the table */
+ protected List<DbEditorService.TableMeta> tableMetas;
+
+ public void setTableName(String tableName) {
+ this.tableName = tableName;
+ }
+
+ @Override
+ public String execute() throws Exception {
+ tableMetas = Lists.newLinkedList();
+ tableMetas.addAll(DbEditorUtil.getTableMeta(tableName));
+ return SUCCESS;
+ }
+
+
+}
Added: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/LoadTablePage.java
===================================================================
--- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/LoadTablePage.java (rev 0)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/LoadTablePage.java 2011-11-08 09:03:06 UTC (rev 21)
@@ -0,0 +1,84 @@
+package fr.ifremer.echobase.ui.actions.dbeditor;
+
+import com.google.common.base.Preconditions;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import fr.ifremer.echobase.entities.EchoBaseEntityEnum;
+import fr.ifremer.echobase.services.DbEditorService;
+import fr.ifremer.echobase.ui.actions.EchoBaseActionSupport;
+import org.apache.commons.lang.StringUtils;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.mapping.Column;
+import org.hibernate.mapping.PersistentClass;
+import org.hibernate.mapping.Table;
+import org.nuiton.topia.framework.TopiaContextImplementor;
+import org.nuiton.topia.persistence.TopiaEntity;
+
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * To load the db editor page.s
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.1
+ */
+public class LoadTablePage extends EchoBaseActionSupport {
+
+ private static final long serialVersionUID = 1L;
+
+ /** Name of the table to load. */
+ protected String tableName;
+
+ /** All tables availables */
+ protected Map<String, String> tableNames;
+
+ /** Metas of the table */
+ protected List<DbEditorService.TableMeta> tableMetas;
+
+ public String getTableName() {
+ return tableName;
+ }
+
+ public Map<String, String> getTableNames() {
+ return tableNames;
+ }
+
+ public List<DbEditorService.TableMeta> getTableMetas() {
+ return tableMetas;
+ }
+
+ public void setTableName(String tableName) {
+ this.tableName = tableName;
+ }
+
+ @Override
+ public String input() throws Exception {
+ tableNames = Maps.newTreeMap();
+ tableNames.putAll(DbEditorUtil.getTableNames());
+ if (StringUtils.isNotEmpty(tableName)) {
+
+ // load also table metas
+ EchoBaseEntityEnum entityEnum = EchoBaseEntityEnum.valueOf(tableName);
+ Preconditions.checkNotNull(entityEnum);
+ String implementationFQN = entityEnum.getImplementationFQN();
+ TopiaContextImplementor tx = (TopiaContextImplementor) getTransaction();
+ Configuration hibernateConfiguration = tx.getHibernateConfiguration();
+ PersistentClass classMapping = hibernateConfiguration.getClassMapping(implementationFQN);
+ Table table = classMapping.getTable();
+ Iterator<?> columnIterator = table.getColumnIterator();
+ while (columnIterator.hasNext()) {
+ Column column = (Column) columnIterator.next();
+ String name = column.getName();
+ if (TopiaEntity.TOPIA_CREATE_DATE.equals(name)) {
+
+ // skip it
+ }
+ }
+ tableMetas = Lists.newLinkedList();
+ tableMetas.addAll(DbEditorUtil.getTableMeta(tableName, getTransaction()));
+ }
+ return INPUT;
+ }
+}
Modified: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/json/GetUsersAction.java
===================================================================
--- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/json/GetUsersAction.java 2011-11-08 09:01:17 UTC (rev 20)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/json/GetUsersAction.java 2011-11-08 09:03:06 UTC (rev 21)
@@ -41,7 +41,7 @@
private static final long serialVersionUID = 1L;
- protected transient UserService service;
+// protected transient UserService service;
protected List<EchoBaseUserDTO> users;
@@ -49,17 +49,18 @@
return users;
}
- protected UserService getUserService() {
- if (service == null) {
- service = newService(UserService.class);
- }
- return service;
- }
+// protected UserService getUserService() {
+// if (service == null) {
+// service = newService(UserService.class);
+// }
+// return service;
+// }
@Override
public String execute() throws Exception {
- List<EchoBaseUser> allUsers = getUserService().getUsers();
+// List<EchoBaseUser> allUsers = getUserService().getUsers();
+ List<EchoBaseUser> allUsers = newService(UserService.class).getUsers();
users = new ArrayList<EchoBaseUserDTO>(allUsers.size());
for (EchoBaseUser user : allUsers) {
Modified: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/interceptors/CheckInUserSessionInterceptor.java
===================================================================
--- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/interceptors/CheckInUserSessionInterceptor.java 2011-11-08 09:01:17 UTC (rev 20)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/interceptors/CheckInUserSessionInterceptor.java 2011-11-08 09:03:06 UTC (rev 21)
@@ -38,7 +38,7 @@
/**
* To check if some data are in the user session.
*
- * @author chemit <chemit(a)codelutin.com>
+ * @author tchemit <chemit(a)codelutin.com>
* @see EchoBaseSession
* @since 0.1
*/
Added: trunk/echobase-ui/src/main/resources/config/struts-dbeditor.xml
===================================================================
--- trunk/echobase-ui/src/main/resources/config/struts-dbeditor.xml (rev 0)
+++ trunk/echobase-ui/src/main/resources/config/struts-dbeditor.xml 2011-11-08 09:03:06 UTC (rev 21)
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE struts PUBLIC
+ "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
+ "http://struts.apache.org/dtds/struts-2.1.7.dtd">
+
+<struts>
+
+ <package name="dbeditor" extends="loggued" namespace="/dbeditor">
+
+ <action name="dbeditor" method="input"
+ class="fr.ifremer.echobase.ui.actions.dbeditor.LoadTablePage">
+ <interceptor-ref name="basicStackLoggued"/>
+ <result name="input">/WEB-INF/jsp/dbeditor/dbeditor.jsp</result>
+ </action>
+
+ <action name="getTableDatas"
+ class="fr.ifremer.echobase.ui.actions.dbeditor.GetTableDatas">
+ <interceptor-ref name="basicStackLoggued"/>
+ <result type="json"/>
+ </action>
+
+ </package>
+
+</struts>
+
Modified: trunk/echobase-ui/src/main/resources/struts.xml
===================================================================
--- trunk/echobase-ui/src/main/resources/struts.xml 2011-11-08 09:01:17 UTC (rev 20)
+++ trunk/echobase-ui/src/main/resources/struts.xml 2011-11-08 09:03:06 UTC (rev 21)
@@ -141,6 +141,7 @@
</package>
+ <include file="config/struts-dbeditor.xml"/>
<include file="config/struts-json.xml"/>
<include file="config/struts-user.xml"/>
Added: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/dbeditor/dbeditor.jsp
===================================================================
--- trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/dbeditor/dbeditor.jsp (rev 0)
+++ trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/dbeditor/dbeditor.jsp 2011-11-08 09:03:06 UTC (rev 21)
@@ -0,0 +1,89 @@
+<%--
+ #%L
+ EchoBase :: UI
+
+ $Id: export.jsp 17 2011-11-07 10:57:50Z tchemit $
+ $HeadURL: http://svn.forge.codelutin.com/svn/echobase/trunk/echobase-ui/src/main/weba… $
+ %%
+ Copyright (C) 2011 Ifremer, Codelutin
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+ #L%
+ --%>
+<%@page contentType="text/html" pageEncoding="UTF-8" %>
+<%@ taglib prefix="s" uri="/struts-tags" %>
+<%@ taglib prefix="sj" uri="/struts-jquery-tags" %>
+<%@ taglib prefix="sjg" uri="/struts-jquery-grid-tags" %>
+
+<s:url id="reloadUrl" action="dbeditor" namespace="/dbeditor"/>
+
+<title><s:text name="echobase.title.dbEditor"/></title>
+
+<script type="text/javascript">
+
+ jQuery(document).ready(function () {
+
+ $('[name="tableName"]').change(function(event) {
+
+ var url = "${reloadUrl}?" + $.param({ tableName:this.value});
+ window.location = url;
+ });
+ });
+</script>
+
+<div>
+<s:select key="tableName" href='%{getTableNamesUrl}'
+ label='%{getText("echobase.common.tableName")}'
+
+ list="tableNames" headerKey="" headerValue=""/>
+
+ </div>
+<br/>
+
+<s:if test="tableName == ''">
+ <p>Aucune table sélectionnée</p>
+</s:if>
+<s:else>
+
+ <s:url id="loadUrl" action="getTableDatas" namespace="/dbeditor"
+ escapeAmp="false">
+ <s:param name="tableName" value="%{tableName}"/>
+ </s:url>
+
+ <sjg:grid id="tableDatas"
+ caption="%{getText('echobase.common.tableDatas', tableNames[tableName])}"
+ dataType="json" href="%{loadUrl}" gridModel="trips"
+ pager="true" pagerButtons="false" pagerInput="false"
+ navigator="true" autowidth="true" rownumbers="false"
+ navigatorEdit="true"
+ navigatorDelete="false"
+ navigatorSearch="true"
+ navigatorRefresh="true"
+ navigatorAdd="false"
+ resizable="true" editinline="false">
+
+ <sjg:gridColumn name="id" title="id" hidden="true"/>
+
+ <s:iterator value="tableMetas" var="meta" status="status">
+
+ <sjg:gridColumn name="%{#meta.name}" title="%{#meta.label}"
+ edittype="%{#meta.columnType}"
+ sortable="false" editable="true"/>
+
+ </s:iterator>
+
+ </sjg:grid>
+
+</s:else>
+
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-08 09:01:17 UTC (rev 20)
+++ trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/home.jsp 2011-11-08 09:03:06 UTC (rev 21)
@@ -28,4 +28,5 @@
<h2><s:text name="echobase.label.welcome"/></h2>
+<s:a action="dbeditor" namespace="/dbeditor">Modification du référentiel</s:a>
<hr/>
\ No newline at end of file
1
0
r20 - trunk/echobase-services/src/main/java/fr/ifremer/echobase/services
by tchemit@users.forge.codelutin.com 08 Nov '11
by tchemit@users.forge.codelutin.com 08 Nov '11
08 Nov '11
Author: tchemit
Date: 2011-11-08 10:01:17 +0100 (Tue, 08 Nov 2011)
New Revision: 20
Url: http://forge.codelutin.com/repositories/revision/echobase/20
Log:
add DbEdtiorservice + some cleans on services
Added:
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/DbEditorService.java
Modified:
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EchoBaseService.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EchoBaseServiceContext.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EchoBaseServiceContextImpl.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EchoBaseServiceFactory.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/UserService.java
Added: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/DbEditorService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/DbEditorService.java (rev 0)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/DbEditorService.java 2011-11-08 09:01:17 UTC (rev 20)
@@ -0,0 +1,116 @@
+/*
+ * #%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.collect.Lists;
+import fr.ifremer.echobase.EchoBaseTechnicalException;
+import org.apache.commons.beanutils.ResultSetDynaClass;
+import org.hibernate.mapping.Column;
+import org.nuiton.topia.persistence.TopiaEntity;
+
+import java.io.Serializable;
+import java.sql.SQLException;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * Service to edit the database.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.1
+ */
+public class DbEditorService extends AbstractEchoBaseService {
+
+ protected static TableMeta newMeta(String name, Class<?> type) {
+ return new TableMeta(name, type);
+ }
+
+ public List<TableMeta> getMetas(String tableName) {
+ List<TableMeta> result = Lists.newLinkedList();
+ return result;
+ }
+
+ public ResultSetDynaClass getDatas(String tableName) {
+ try {
+ ResultSetDynaClass result = null;
+ result = new ResultSetDynaClass(null);
+ return result;
+ } catch (SQLException eee) {
+ throw new EchoBaseTechnicalException("Could not obtain data", eee);
+ }
+ }
+
+ public static class TableMeta implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ protected String name;
+
+ protected String label;
+
+ protected Column hibernateColumn;
+
+ protected Class<?> type;
+
+ public TableMeta(String name, Class<?> type) {
+ this(name, name, type);
+ }
+
+ public TableMeta(String name, String label, Class<?> type) {
+ this.name = name;
+ this.label = label;
+ this.type = type;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getLabel() {
+ return label;
+ }
+
+ public Class<?> getType() {
+ return type;
+ }
+
+ public String getColumnType() {
+ String result = "string";
+ if (boolean.class.equals(type)) {
+ result = "boolean";
+ } else if (Date.class.equals(type)) {
+ result = "date";
+ }
+ return result;
+ }
+
+ public boolean isFK() {
+ return TopiaEntity.class.isAssignableFrom(type);
+ }
+
+ public Column getHibernateColumn() {
+ return hibernateColumn;
+ }
+ }
+}
Property changes on: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/DbEditorService.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/EchoBaseService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EchoBaseService.java 2011-11-08 08:56:23 UTC (rev 19)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EchoBaseService.java 2011-11-08 09:01:17 UTC (rev 20)
@@ -28,7 +28,7 @@
* Contract to place on each EchBase service to push the {@code serviceContext}
* inside the service.
*
- * @author chemit <chemit(a)codelutin.com>
+ * @author tchemit <chemit(a)codelutin.com>
* @see EchoBaseServiceContext
* @since 0.1
*/
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EchoBaseServiceContext.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EchoBaseServiceContext.java 2011-11-08 08:56:23 UTC (rev 19)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EchoBaseServiceContext.java 2011-11-08 09:01:17 UTC (rev 20)
@@ -32,7 +32,7 @@
* Objects provided may be injected in services returned by
* {@link EchoBaseServiceFactory#newService(Class, EchoBaseServiceContext)}
*
- * @author chemit <chemit(a)codelutin.com>
+ * @author tchemit <chemit(a)codelutin.com>
* @since 0.1
*/
public interface EchoBaseServiceContext {
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EchoBaseServiceContextImpl.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EchoBaseServiceContextImpl.java 2011-11-08 08:56:23 UTC (rev 19)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EchoBaseServiceContextImpl.java 2011-11-08 09:01:17 UTC (rev 20)
@@ -29,7 +29,7 @@
/** Instances of this class will be given to service factory.
*
- * @author chemit <chemit(a)codelutin.com>
+ * @author tchemit <chemit(a)codelutin.com>
* @since 0.1
**/
public class EchoBaseServiceContextImpl implements EchoBaseServiceContext {
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EchoBaseServiceFactory.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EchoBaseServiceFactory.java 2011-11-08 08:56:23 UTC (rev 19)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EchoBaseServiceFactory.java 2011-11-08 09:01:17 UTC (rev 20)
@@ -30,7 +30,7 @@
/**
* Factory of services.
*
- * @author chemit <chemit(a)codelutin.com>
+ * @author tchemit <chemit(a)codelutin.com>
* @since 0.1
*/
public class EchoBaseServiceFactory {
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/UserService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/UserService.java 2011-11-08 08:56:23 UTC (rev 19)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/UserService.java 2011-11-08 09:01:17 UTC (rev 20)
@@ -38,17 +38,12 @@
/**
* @author sletellier <letellier(a)codelutin.com>
* @since 0.1
- **/
+ */
public class UserService extends AbstractEchoBaseService {
- public EchoBaseUserDAO getDAO() throws TopiaException {
- return EchoBaseDAOHelper.getEchoBaseUserDAO(getTransaction());
- }
-
- public List<EchoBaseUser> getUsers() throws EchoBaseTechnicalException {
+ public List<EchoBaseUser> getUsers() {
try {
List<EchoBaseUser> users = getDAO().findAll();
-
return users;
} catch (TopiaException eee) {
throw new EchoBaseTechnicalException(eee);
@@ -58,7 +53,16 @@
public EchoBaseUser getUserById(String topiaId) {
try {
EchoBaseUser user = getDAO().findByTopiaId(topiaId);
+ return user;
+ } catch (TopiaException eee) {
+ throw new EchoBaseTechnicalException(eee);
+ }
+ }
+ public EchoBaseUser getUserByEmail(String email) {
+ Preconditions.checkNotNull(email);
+ try {
+ EchoBaseUser user = getDAO().findByEmail(email);
return user;
} catch (TopiaException eee) {
throw new EchoBaseTechnicalException(eee);
@@ -84,7 +88,6 @@
user.setPassword(encodePassword(password));
}
dao.update(user);
-
getTransaction().commitTransaction();
} catch (TopiaException eee) {
throw new EchoBaseTechnicalException(eee);
@@ -95,26 +98,13 @@
try {
EchoBaseUserDAO dao = getDAO();
EchoBaseUser user = dao.findByTopiaId(userDTO.getId());
-
dao.delete(user);
-
getTransaction().commitTransaction();
} catch (TopiaException eee) {
throw new EchoBaseTechnicalException(eee);
}
}
- public EchoBaseUser getUserByEmail(String email) {
- Preconditions.checkNotNull(email);
- try {
- EchoBaseUserDAO dao = getDAO();
- EchoBaseUser user = dao.findByEmail(email);
- return user;
- } catch (TopiaException eee) {
- throw new EchoBaseTechnicalException(eee);
- }
- }
-
public boolean checkPassword(EchoBaseUser user,
String password) throws Exception {
String s = encodePassword(password);
@@ -125,4 +115,8 @@
String encodedPassword = StringUtil.encodeMD5(password);
return encodedPassword;
}
+
+ protected EchoBaseUserDAO getDAO() throws TopiaException {
+ return EchoBaseDAOHelper.getEchoBaseUserDAO(getTransaction());
+ }
}
1
0