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
September 2012
- 3 participants
- 127 discussions
10 Sep '12
Author: tchemit
Date: 2012-09-10 18:00:37 +0200 (Mon, 10 Sep 2012)
New Revision: 643
Url: http://forge.codelutin.com/repositories/revision/echobase/643
Log:
refs #1485: Permettre une import EchoBase plus cibl?\195?\169
Modified:
trunk/echobase-domain/src/main/java/fr/ifremer/echobase/entities/ImportType.java
trunk/echobase-domain/src/main/resources/i18n/echobase-domain_en_GB.properties
trunk/echobase-domain/src/main/resources/i18n/echobase-domain_fr_FR.properties
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdb/ImportDbMode.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdb/ImportDbService.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/RemoveDataService.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/LegacyVoyageRemoveDataStrategy.java
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/importDb/Configure.java
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/importDb/Import.java
trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/importDb/configure.jsp
trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/importDb/progress.jsp
Modified: trunk/echobase-domain/src/main/java/fr/ifremer/echobase/entities/ImportType.java
===================================================================
--- trunk/echobase-domain/src/main/java/fr/ifremer/echobase/entities/ImportType.java 2012-09-10 14:18:37 UTC (rev 642)
+++ trunk/echobase-domain/src/main/java/fr/ifremer/echobase/entities/ImportType.java 2012-09-10 16:00:37 UTC (rev 643)
@@ -35,8 +35,8 @@
*/
public enum ImportType implements I18nAble {
- /** Import a legacy Voyage with all his data. */
- LEGACY_VOYAGE(n_("echobase.common.importType.legacyVoyage")),
+ /** Import a voyage with all his data. */
+ VOYAGE(n_("echobase.common.importType.voyage")),
/** Import Voyage / Transit / Transect. */
COMMON_ALL(n_("echobase.common.importType.commonDataAll")),
Modified: trunk/echobase-domain/src/main/resources/i18n/echobase-domain_en_GB.properties
===================================================================
--- trunk/echobase-domain/src/main/resources/i18n/echobase-domain_en_GB.properties 2012-09-10 14:18:37 UTC (rev 642)
+++ trunk/echobase-domain/src/main/resources/i18n/echobase-domain_en_GB.properties 2012-09-10 16:00:37 UTC (rev 643)
@@ -4,7 +4,7 @@
echobase.common.importType.catches=Fishing data import
echobase.common.importType.commonDataAll=Voyage / Transit / Transects import
echobase.common.importType.commonDataTransect=Transects import
-echobase.common.importType.legacyVoyage=Legacy voyage import
+echobase.common.importType.voyage=Voyage import
echobase.common.importType.operation=Operations data import
echobase.common.importType.resultsEsdu=Import the “ESDU” cells results
echobase.common.importType.resultsMap=Import the “map” cells results
Modified: trunk/echobase-domain/src/main/resources/i18n/echobase-domain_fr_FR.properties
===================================================================
--- trunk/echobase-domain/src/main/resources/i18n/echobase-domain_fr_FR.properties 2012-09-10 14:18:37 UTC (rev 642)
+++ trunk/echobase-domain/src/main/resources/i18n/echobase-domain_fr_FR.properties 2012-09-10 16:00:37 UTC (rev 643)
@@ -4,7 +4,7 @@
echobase.common.importType.catches=Import des données de pêche
echobase.common.importType.commonDataAll=Import Voyage / Transit / Transects
echobase.common.importType.commonDataTransect=Import Transects
-echobase.common.importType.legacyVoyage=Import Campagne "ancienne"
+echobase.common.importType.voyage=Import Campagne
echobase.common.importType.operation=Import des opérations
echobase.common.importType.resultsEsdu=Import des résultats des cellules de type "ESDU"
echobase.common.importType.resultsMap=Import des cellules de type Carte
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdb/ImportDbMode.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdb/ImportDbMode.java 2012-09-10 14:18:37 UTC (rev 642)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdb/ImportDbMode.java 2012-09-10 16:00:37 UTC (rev 643)
@@ -40,7 +40,7 @@
REFERENTIAL(n_("echobase.common.importDbMode.referential")),
/** Import only data. */
- LEGACY_VOYAGE(ImportType.LEGACY_VOYAGE.getI18nKey()),
+ VOYAGE(ImportType.VOYAGE.getI18nKey()),
/** Import what you want. */
FREE(n_("echobase.common.importDbMode.free"));
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdb/ImportDbService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdb/ImportDbService.java 2012-09-10 14:18:37 UTC (rev 642)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdb/ImportDbService.java 2012-09-10 16:00:37 UTC (rev 643)
@@ -266,10 +266,10 @@
// create a importLog entry
ImportLog importLog = importLogDAO.create(
- ImportLog.PROPERTY_IMPORT_TYPE, ImportType.LEGACY_VOYAGE,
+ ImportLog.PROPERTY_IMPORT_TYPE, ImportType.VOYAGE,
ImportLog.PROPERTY_IMPORT_USER, user.getEmail(),
ImportLog.PROPERTY_IMPORT_DATE, newDate(),
- ImportLog.PROPERTY_IMPORT_TYPE, "import legacy voyage " + decorator.toString(importedVoyage) + " from file " + file.getName()
+ ImportLog.PROPERTY_IMPORT_TEXT, "import legacy voyage " + decorator.toString(importedVoyage) + " from file " + file.getName()
);
importLog.addImportId(importedVoyage.getTopiaId());
}
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/RemoveDataService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/RemoveDataService.java 2012-09-10 14:18:37 UTC (rev 642)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/RemoveDataService.java 2012-09-10 16:00:37 UTC (rev 643)
@@ -75,7 +75,7 @@
public static Class<? extends AbstractRemoveDataStrategy> getStrategy(ImportType importType) {
if (strategies == null) {
strategies = Maps.newEnumMap(ImportType.class);
- strategies.put(ImportType.LEGACY_VOYAGE, LegacyVoyageRemoveDataStrategy.class);
+ strategies.put(ImportType.VOYAGE, LegacyVoyageRemoveDataStrategy.class);
strategies.put(ImportType.COMMON_ALL, CommonAllRemoveDataStrategy.class);
strategies.put(ImportType.COMMON_TRANSECT, CommonTransectRemoveDataStrategy.class);
strategies.put(ImportType.OPERATION, OperationRemoveDataStrategy.class);
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/LegacyVoyageRemoveDataStrategy.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/LegacyVoyageRemoveDataStrategy.java 2012-09-10 14:18:37 UTC (rev 642)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/LegacyVoyageRemoveDataStrategy.java 2012-09-10 16:00:37 UTC (rev 643)
@@ -34,7 +34,7 @@
import java.util.Set;
/**
- * Remove a {@link ImportType#LEGACY_VOYAGE} import.
+ * Remove a {@link ImportType#VOYAGE} import.
* <p/>
* Can remove only {@link Voyage}.
*
Modified: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/importDb/Configure.java
===================================================================
--- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/importDb/Configure.java 2012-09-10 14:18:37 UTC (rev 642)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/importDb/Configure.java 2012-09-10 16:00:37 UTC (rev 643)
@@ -98,7 +98,7 @@
return execute();
}
- public String execute_legacyVoyage() throws Exception {
+ public String execute_voyage() throws Exception {
return execute();
}
Modified: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/importDb/Import.java
===================================================================
--- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/importDb/Import.java 2012-09-10 14:18:37 UTC (rev 642)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/importDb/Import.java 2012-09-10 16:00:37 UTC (rev 643)
@@ -79,7 +79,7 @@
model.getActionTime());
break;
- case LEGACY_VOYAGE:
+ case VOYAGE:
service.importLegacyData(model, user);
addFlashMessage(_("echobase.info.import.succeded"));
Modified: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/importDb/configure.jsp
===================================================================
--- trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/importDb/configure.jsp 2012-09-10 14:18:37 UTC (rev 642)
+++ trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/importDb/configure.jsp 2012-09-10 16:00:37 UTC (rev 643)
@@ -84,7 +84,7 @@
value='%{getText("echobase.action.import")}'/>
</s:form>
-<s:form id="LEGACY_VOYAGE" namespace="/importDb" method="POST"
+<s:form id="VOYAGE" namespace="/importDb" method="POST"
enctype="multipart/form-data" cssClass="hidden importDbMode">
<fieldset>
@@ -93,20 +93,20 @@
</legend>
<div class="cleanBoth help">
- <s:a href="%{getDocumentation('importDb.html','legacy-voyage')}"
+ <s:a href="%{getDocumentation('importDb.html','voyage')}"
target="doc">
<s:text name="echobase.action.show.importDb.documentation"/>
</s:a>
</div>
<br/>
- <s:hidden key="model.importDbMode" value="LEGACY_VOYAGE" label=''/>
+ <s:hidden key="model.importDbMode" value="VOYAGE" label=''/>
<s:file name="input" required="true"
key="echobase.common.importDbFile"/>
</fieldset>
<br/>
- <s:submit action="configure-legacyVoyage"
+ <s:submit action="configure-voyage"
value='%{getText("echobase.action.import")}'/>
</s:form>
Modified: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/importDb/progress.jsp
===================================================================
--- trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/importDb/progress.jsp 2012-09-10 14:18:37 UTC (rev 642)
+++ trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/importDb/progress.jsp 2012-09-10 16:00:37 UTC (rev 643)
@@ -25,8 +25,7 @@
<%@ taglib prefix="s" uri="/struts-tags" %>
<%@ taglib prefix="sj" uri="/struts-jquery-tags" %>
-<s:url id="url" action="import" namespace="/importDb"/>
-<meta http-equiv="refresh" content="10;url=${url}"/>
+<meta http-equiv="refresh" content="10;url=<s:url action="import" namespace="/importDb"/>"/>
<title><s:text name="echobase.title.importDbProgress"/></title>
1
0
r642 - trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/removeData
by tchemit@users.forge.codelutin.com 10 Sep '12
by tchemit@users.forge.codelutin.com 10 Sep '12
10 Sep '12
Author: tchemit
Date: 2012-09-10 16:18:37 +0200 (Mon, 10 Sep 2012)
New Revision: 642
Url: http://forge.codelutin.com/repositories/revision/echobase/642
Log:
fix import
Modified:
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/removeData/ConfirmDelete.java
Modified: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/removeData/ConfirmDelete.java
===================================================================
--- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/removeData/ConfirmDelete.java 2012-09-10 14:06:45 UTC (rev 641)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/removeData/ConfirmDelete.java 2012-09-10 14:18:37 UTC (rev 642)
@@ -28,7 +28,7 @@
import fr.ifremer.echobase.services.EchoBaseServiceSupport;
import fr.ifremer.echobase.services.removedata.RemoveDataConfiguration;
import fr.ifremer.echobase.ui.actions.AbstractConfigureAction;
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
1
0
10 Sep '12
Author: tchemit
Date: 2012-09-10 16:06:45 +0200 (Mon, 10 Sep 2012)
New Revision: 641
Url: http://forge.codelutin.com/repositories/revision/echobase/641
Log:
refs #1437: Suppression des imports (revue des algorithmes de suppression)
refs #1485: Permettre une import EchoBase plus cibl?\195?\169
Added:
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdb/ImportDbMode.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/LegacyVoyageRemoveDataStrategy.java
Modified:
trunk/echobase-domain/src/main/java/fr/ifremer/echobase/entities/ImportType.java
trunk/echobase-domain/src/main/java/fr/ifremer/echobase/services/EchoBaseServiceSupport.java
trunk/echobase-domain/src/main/resources/i18n/echobase-domain_en_GB.properties
trunk/echobase-domain/src/main/resources/i18n/echobase-domain_fr_FR.properties
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/exportdb/ExportService.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/AbstractImportDataService.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdb/DefaultImportStrategy.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdb/ImportDbConfiguration.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdb/ImportDbService.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/RemoveDataService.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/AbstractRemoveDataStrategy.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/AcousticRemoveDataStrategy.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/CatchesRemoveDataStrategy.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/CommonAllRemoveDataStrategy.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/CommonTransectRemoveDataStrategy.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/OperationRemoveDataStrategy.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/ResultEsduRemoveDataStrategy.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/ResultMapRemoveDataStrategy.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/ResultRegionRemoveDataStrategy.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/ResultVoyageRemoveDataStrategy.java
trunk/echobase-services/src/main/resources/i18n/echobase-services_en_GB.properties
trunk/echobase-services/src/main/resources/i18n/echobase-services_fr_FR.properties
trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/AbstractImportDataServiceIT.java
trunk/echobase-ui/pom.xml
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/importDb/Configure.java
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/importDb/Import.java
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/removeData/ConfirmDelete.java
trunk/echobase-ui/src/main/resources/config/struts-importDb.xml
trunk/echobase-ui/src/main/resources/i18n/echobase-ui_en_GB.properties
trunk/echobase-ui/src/main/resources/i18n/echobase-ui_fr_FR.properties
trunk/echobase-ui/src/main/webapp/WEB-INF/includes/header.jsp
trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/home.jsp
trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/importDb/configure.jsp
trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/importDb/progress.jsp
trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/importDb/result.jsp
trunk/echobase-ui/src/main/webapp/css/screen.css
Modified: trunk/echobase-domain/src/main/java/fr/ifremer/echobase/entities/ImportType.java
===================================================================
--- trunk/echobase-domain/src/main/java/fr/ifremer/echobase/entities/ImportType.java 2012-09-10 10:00:46 UTC (rev 640)
+++ trunk/echobase-domain/src/main/java/fr/ifremer/echobase/entities/ImportType.java 2012-09-10 14:06:45 UTC (rev 641)
@@ -35,6 +35,9 @@
*/
public enum ImportType implements I18nAble {
+ /** Import a legacy Voyage with all his data. */
+ LEGACY_VOYAGE(n_("echobase.common.importType.legacyVoyage")),
+
/** Import Voyage / Transit / Transect. */
COMMON_ALL(n_("echobase.common.importType.commonDataAll")),
Modified: trunk/echobase-domain/src/main/java/fr/ifremer/echobase/services/EchoBaseServiceSupport.java
===================================================================
--- trunk/echobase-domain/src/main/java/fr/ifremer/echobase/services/EchoBaseServiceSupport.java 2012-09-10 10:00:46 UTC (rev 640)
+++ trunk/echobase-domain/src/main/java/fr/ifremer/echobase/services/EchoBaseServiceSupport.java 2012-09-10 14:06:45 UTC (rev 641)
@@ -223,11 +223,23 @@
}
}
- protected final void flushTransaction() throws TopiaException {
+ protected final void flushTransaction(String errorMessage) {
TopiaContextImplementor tx = (TopiaContextImplementor) getTransaction();
- tx.getHibernate().flush();
+ try {
+ tx.getHibernate().flush();
+ } catch (TopiaException e) {
+ throw new EchoBaseTechnicalException(errorMessage, e);
+ }
}
+ protected final void clearCache() {
+ try {
+ getTransaction().clearCache();
+ } catch (TopiaException e) {
+ throw new EchoBaseTechnicalException("Could not clear hibernate cache", e);
+ }
+ }
+
protected <E extends TopiaEntity> TopiaContext getTransaction(Class<E> entitytype) {
TopiaContext result;
if (EchobaseInternalEntity.class.isAssignableFrom(entitytype)) {
Modified: trunk/echobase-domain/src/main/resources/i18n/echobase-domain_en_GB.properties
===================================================================
--- trunk/echobase-domain/src/main/resources/i18n/echobase-domain_en_GB.properties 2012-09-10 10:00:46 UTC (rev 640)
+++ trunk/echobase-domain/src/main/resources/i18n/echobase-domain_en_GB.properties 2012-09-10 14:06:45 UTC (rev 641)
@@ -4,6 +4,7 @@
echobase.common.importType.catches=Fishing data import
echobase.common.importType.commonDataAll=Voyage / Transit / Transects import
echobase.common.importType.commonDataTransect=Transects import
+echobase.common.importType.legacyVoyage=Legacy voyage import
echobase.common.importType.operation=Operations data import
echobase.common.importType.resultsEsdu=Import the “ESDU” cells results
echobase.common.importType.resultsMap=Import the “map” cells results
Modified: trunk/echobase-domain/src/main/resources/i18n/echobase-domain_fr_FR.properties
===================================================================
--- trunk/echobase-domain/src/main/resources/i18n/echobase-domain_fr_FR.properties 2012-09-10 10:00:46 UTC (rev 640)
+++ trunk/echobase-domain/src/main/resources/i18n/echobase-domain_fr_FR.properties 2012-09-10 14:06:45 UTC (rev 641)
@@ -4,8 +4,9 @@
echobase.common.importType.catches=Import des données de pêche
echobase.common.importType.commonDataAll=Import Voyage / Transit / Transects
echobase.common.importType.commonDataTransect=Import Transects
+echobase.common.importType.legacyVoyage=Import Campagne "ancienne"
echobase.common.importType.operation=Import des opérations
-echobase.common.importType.resultsEsdu=Import des résultats des cellules de type «ESDU”
+echobase.common.importType.resultsEsdu=Import des résultats des cellules de type "ESDU"
echobase.common.importType.resultsMap=Import des cellules de type Carte
echobase.common.importType.resultsRegion=Import des cellules de type Région
echobase.common.importType.resultsVoyage=Import des résultats du voyage
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/exportdb/ExportService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/exportdb/ExportService.java 2012-09-10 10:00:46 UTC (rev 640)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/exportdb/ExportService.java 2012-09-10 14:06:45 UTC (rev 641)
@@ -23,14 +23,12 @@
*/
package fr.ifremer.echobase.services.exportdb;
-import fr.ifremer.echobase.EchoBaseTechnicalException;
import fr.ifremer.echobase.entities.EchoBaseEntityEnum;
import fr.ifremer.echobase.services.DbEditorService;
import fr.ifremer.echobase.services.DecoratorService;
import fr.ifremer.echobase.services.EchoBaseServiceSupport;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.nuiton.topia.TopiaException;
import org.nuiton.topia.persistence.TopiaEntity;
import org.nuiton.topia.persistence.csv.EntityCsvModel;
import org.nuiton.topia.persistence.csv.out.EntityAssociationExportModel;
@@ -56,74 +54,6 @@
/** Logger. */
private static final Log log = LogFactory.getLog(ExportService.class);
-// public static final TimeLog TIME_LOG = new TimeLog(ExportService.class);
-
-// public ExportModelFactory<EchoBaseEntityEnum> getDefaultExportFactory() {
-// return defaultExportFactory;
-// }
-
-// public ExportModelFactory<EchoBaseEntityEnum> getAsSeenExportFactory() {
-// return asSeenExportFactory;
-// }
-
-// @Override
-// public <E extends TopiaEntity> ExportModel<E> buildForExport(AssociationMeta<EchoBaseEntityEnum> associationMeta) {
-//
-// ExportModel<E> model = EntityAssociationExportModel.newExportModel(
-// getConfiguration().getCsvSeparator(),
-// associationMeta
-// );
-// return model;
-// }
-//
-// @Override
-// public <E extends TopiaEntity> ExportModel<E> buildForExport(TableMeta<EchoBaseEntityEnum> meta, boolean asSeen) {
-//
-// EntityCsvModel<EchoBaseEntityEnum, E> model;
-//
-// if (asSeen) {
-//
-// // no need to have topiaId as first column
-// model = EntityCsvModel.newModel(
-// getConfiguration().getCsvSeparator(),
-// meta
-// );
-// } else {
-//
-// // normla export add topiaId column
-// model = EntityCsvModel.newModel(
-// getConfiguration().getCsvSeparator(),
-// meta,
-// TopiaEntity.TOPIA_ID
-// );
-// }
-//
-// DecoratorService service = getService(DecoratorService.class);
-//
-// for (ColumnMeta columnMeta : meta) {
-// String propertyName = columnMeta.getName();
-// Class<?> type = columnMeta.getType();
-// if (columnMeta.isFK()) {
-//
-// Class<TopiaEntity> entityType = (Class<TopiaEntity>) type;
-// if (asSeen) {
-//
-// // export decorated foreign key value
-// Decorator<TopiaEntity> decorator =
-// service.getDecorator(getLocale(), entityType, null);
-// model.addDecoratedForeignKeyForExport(propertyName, propertyName, decorator);
-// } else {
-//
-// // export foreign key value as his topiaId
-// model.addForeignKeyForExport(propertyName, entityType);
-// }
-// } else {
-// model.addDefaultColumn(propertyName, type);
-// }
-// }
-// return model;
-// }
-
public String exportData(TableMeta<EchoBaseEntityEnum> meta, boolean asSeen) {
if (log.isInfoEnabled()) {
@@ -133,14 +63,6 @@
getModelFactory(asSeen),
defaultPrepareDataForExport);
return result;
-//
-// Export<TopiaEntity> export = prepareExport(tableMeta, asSeen);
-//
-// try {
-// return export.toString(Charsets.UTF_8);
-// } catch (Exception eee) {
-// throw new EchoBaseTechnicalException("Can not export datas", eee);
-// }
}
public void exportData(TableMeta<EchoBaseEntityEnum> meta, File file) {
@@ -155,19 +77,6 @@
file);
clearCache();
-// if (log.isInfoEnabled()) {
-// log.info("Export table " + tableMeta + " to " + file);
-// }
-// long s1 = TimeLog.getTime();
-// Export<TopiaEntity> export = prepareExport(tableMeta, false);
-// TIME_LOG.log(s1, "exportData::prepareExport");
-// long s2 = TimeLog.getTime();
-// try {
-// export.write(file, Charsets.UTF_8);
-// } catch (Exception eee) {
-// throw new EchoBaseTechnicalException("Can not export datas", eee);
-// }
-// TIME_LOG.log(s2, "exportData::exportToFile");
}
@@ -182,20 +91,6 @@
file);
clearCache();
-// if (log.isInfoEnabled()) {
-// log.info("Export association " + associationMeta + " to " + file);
-// }
-// long s1 = TimeLog.getTime();
-// Export<TopiaEntity> export = prepareExport(associationMeta);
-// TIME_LOG.log(s1, "exportData::prepareExport");
-//
-// long s2 = TimeLog.getTime();
-// try {
-// export.write(file, Charsets.UTF_8);
-// } catch (Exception eee) {
-// throw new EchoBaseTechnicalException("Can not export datas", eee);
-// }
-// TIME_LOG.log(s2, "exportData::exportToFile");
}
public ExportModelFactory<EchoBaseEntityEnum> getModelFactory(boolean asSeen) {
@@ -208,35 +103,6 @@
return result;
}
-// protected Export<TopiaEntity> prepareExport(TableMeta<EchoBaseEntityEnum> tableMeta, boolean asSeen) {
-//
-// List<TopiaEntity> datas = defaultPrepareDataForExport.prepareData(tableMeta);
-//
-// ExportModel<TopiaEntity> model;
-// if (asSeen) {
-// model = asSeenExportFactory.buildForExport(tableMeta);
-// } else {
-// model = defaultExportFactory.buildForExport(tableMeta);
-//
-// }
-// return Export.newExport(model, datas);
-// }
-
-// protected Export<TopiaEntity> prepareExport(AssociationMeta<EchoBaseEntityEnum> associationMeta) {
-//
-// List<TopiaEntity> datas = defaultPrepareDataForExport.prepareExport(associationMeta);
-// ExportModel<TopiaEntity> model = defaultExportFactory.buildForExport(associationMeta);
-// return Export.newExport(model, datas);
-// }
-
- protected void clearCache() {
- try {
- getTransaction().clearCache();
- } catch (TopiaException e) {
- throw new EchoBaseTechnicalException("Could not clear db cache", e);
- }
- }
-
private ExportModelFactory<EchoBaseEntityEnum> defaultExportFactory = new ExportModelFactory<EchoBaseEntityEnum>() {
@Override
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/AbstractImportDataService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/AbstractImportDataService.java 2012-09-10 10:00:46 UTC (rev 640)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/AbstractImportDataService.java 2012-09-10 14:06:45 UTC (rev 641)
@@ -282,14 +282,10 @@
if (rowNumber % 1000 == 0) {
// flush each 1000 imported rows
String message = getImportMessage(configuration, inputFile);
- try {
- long s0 = TimeLog.getTime();
- flushTransaction();
- TIME_LOG.log(s0, message);
- } catch (TopiaException e) {
- throw new EchoBaseTechnicalException(
- "Could not flush transaction " + message, e);
- }
+ long s0 = TimeLog.getTime();
+ flushTransaction("Could not flush transaction " + message);
+ TIME_LOG.log(s0, message);
+
}
}
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdb/DefaultImportStrategy.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdb/DefaultImportStrategy.java 2012-09-10 10:00:46 UTC (rev 640)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdb/DefaultImportStrategy.java 2012-09-10 14:06:45 UTC (rev 641)
@@ -68,7 +68,8 @@
}
@Override
- public <E extends TopiaEntity> void importTable(TableMeta<EchoBaseEntityEnum> meta, Import<E> importer,
+ public <E extends TopiaEntity> void importTable(TableMeta<EchoBaseEntityEnum> meta,
+ Import<E> importer,
CsvImportResult<EchoBaseEntityEnum> csvResult) throws TopiaException {
TopiaDAO<E> dao = persistenceHelper.getDAO(tx, meta.getSource());
@@ -76,6 +77,18 @@
}
@Override
+ public <E extends TopiaEntity> Iterable<E> importTableAndReturnThem(TableMeta<EchoBaseEntityEnum> meta,
+ Import<E> importer,
+ CsvImportResult<EchoBaseEntityEnum> csvResult) throws TopiaException {
+ TopiaDAO<E> dao = persistenceHelper.getDAO(tx, meta.getSource());
+
+ Iterable<E> result = TopiaCsvImports.importAllEntitiesAndReturnThem(
+ dao, meta, importer, csvResult);
+ return result;
+
+ }
+
+ @Override
public void importAssociation(AssociationMeta<EchoBaseEntityEnum> meta,
ImportToMap importer,
CsvImportResult<EchoBaseEntityEnum> csvResult) throws TopiaException {
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdb/ImportDbConfiguration.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdb/ImportDbConfiguration.java 2012-09-10 10:00:46 UTC (rev 640)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdb/ImportDbConfiguration.java 2012-09-10 14:06:45 UTC (rev 641)
@@ -48,6 +48,8 @@
protected final InputFile input;
+ protected ImportDbMode importDbMode;
+
public ImportDbConfiguration(ProgressionModel progressionModel,
Locale locale) {
super(progressionModel);
@@ -66,10 +68,18 @@
return input;
}
+ public ImportDbMode getImportDbMode() {
+ return importDbMode;
+ }
+
public void setWorkingDirectory(File workingDirectory) {
this.workingDirectory = workingDirectory;
}
+ public void setImportDbMode(ImportDbMode importDbMode) {
+ this.importDbMode = importDbMode;
+ }
+
@Override
public void destroy() throws IOException {
if (workingDirectory != null) {
Added: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdb/ImportDbMode.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdb/ImportDbMode.java (rev 0)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdb/ImportDbMode.java 2012-09-10 14:06:45 UTC (rev 641)
@@ -0,0 +1,58 @@
+package fr.ifremer.echobase.services.importdb;
+
+/*
+ * #%L
+ * EchoBase :: Services
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 - 2012 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%
+ */
+
+import fr.ifremer.echobase.I18nAble;
+import fr.ifremer.echobase.entities.ImportType;
+
+import static org.nuiton.i18n.I18n.n_;
+
+/**
+ * Select import db mode.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.2
+ */
+public enum ImportDbMode implements I18nAble {
+
+ /** Import only referential. */
+ REFERENTIAL(n_("echobase.common.importDbMode.referential")),
+
+ /** Import only data. */
+ LEGACY_VOYAGE(ImportType.LEGACY_VOYAGE.getI18nKey()),
+
+ /** Import what you want. */
+ FREE(n_("echobase.common.importDbMode.free"));
+
+ private final String i18nKey;
+
+ ImportDbMode(String i18nKey) {
+ this.i18nKey = i18nKey;
+ }
+
+ @Override
+ public String getI18nKey() {
+ return i18nKey;
+ }
+}
Property changes on: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdb/ImportDbMode.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/importdb/ImportDbService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdb/ImportDbService.java 2012-09-10 10:00:46 UTC (rev 640)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdb/ImportDbService.java 2012-09-10 14:06:45 UTC (rev 641)
@@ -24,11 +24,16 @@
package fr.ifremer.echobase.services.importdb;
import com.google.common.collect.Lists;
-import fr.ifremer.echobase.persistence.EchoBaseDbMeta;
import fr.ifremer.echobase.entities.EchoBaseEntityEnum;
import fr.ifremer.echobase.entities.EchoBaseUser;
import fr.ifremer.echobase.entities.EntityModificationLog;
+import fr.ifremer.echobase.entities.ImportLog;
+import fr.ifremer.echobase.entities.ImportType;
+import fr.ifremer.echobase.entities.data.Voyage;
+import fr.ifremer.echobase.persistence.EchoBaseDbMeta;
+import fr.ifremer.echobase.services.DecoratorService;
import fr.ifremer.echobase.services.EchoBaseServiceSupport;
+import fr.ifremer.echobase.services.importdata.ImportException;
import org.apache.commons.io.IOUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -39,6 +44,7 @@
import org.nuiton.topia.persistence.metadata.AssociationMeta;
import org.nuiton.topia.persistence.metadata.TableMeta;
import org.nuiton.util.TimeLog;
+import org.nuiton.util.decorator.Decorator;
import java.io.File;
import java.io.IOException;
@@ -64,8 +70,230 @@
public static final TimeLog TIME_LOG = new TimeLog(ImportDbService.class);
/**
- * Import a complete db from the given zip file.
+ * Import a referential db from the given echobase file.
*
+ * @param model model of the db import operation
+ * @param user user which perform the import
+ * @throws IOException if any io exception while import
+ * @throws TopiaException if any pb while topia treatment
+ * @since 1.2
+ */
+ public void importReferential(ImportDbConfiguration model,
+ EchoBaseUser user) throws IOException, TopiaException, ImportException {
+
+ File file = model.getInput().getFile();
+
+ ZipFile zipFile = new ZipFile(file);
+ try {
+
+ List<String> missingEntries = Lists.newArrayList();
+
+ EchoBaseDbMeta dbMeta = getDbMeta();
+
+ Map<TableMeta<EchoBaseEntityEnum>, ZipEntry> tables =
+ getTables(zipFile, missingEntries, dbMeta);
+
+ Map<AssociationMeta<EchoBaseEntityEnum>, ZipEntry> associations =
+ getAssociations(zipFile, missingEntries, dbMeta);
+
+ int size = tables.size() + associations.size();
+ model.setNbSteps(size + missingEntries.size());
+
+ // check that contains only referential entries
+ List<EchoBaseEntityEnum> badTableTypes = Lists.newArrayList();
+ List<TableMeta<EchoBaseEntityEnum>> dataTables = dbMeta.getDataTables();
+ for (TableMeta<EchoBaseEntityEnum> tableMetas : tables.keySet()) {
+ if (dataTables.contains(tableMetas)) {
+ badTableTypes.add(tableMetas.getSource());
+ }
+ }
+
+ if (!badTableTypes.isEmpty()) {
+ throw new ImportException(
+ "In referential import, can not accept " +
+ "data type, but found some data types: " + badTableTypes);
+ }
+
+ List<EchoBaseEntityEnum> badAssociationTypes = Lists.newArrayList();
+ List<AssociationMeta<EchoBaseEntityEnum>> associationTables = dbMeta.getDataAssociations();
+ for (AssociationMeta<EchoBaseEntityEnum> tableMetas : associations.keySet()) {
+ if (associationTables.contains(tableMetas)) {
+ badAssociationTypes.add(tableMetas.getSource());
+ }
+ }
+ if (!badAssociationTypes.isEmpty()) {
+ throw new ImportException(
+ "In referential import, can not accept " +
+ "data type, but found some data associations files: " +
+ badAssociationTypes);
+ }
+
+ for (String missingEntry : missingEntries) {
+
+ // skip thoses not found entries
+ model.incrementsProgression();
+
+ if (log.isInfoEnabled()) {
+ log.info("Skip not found entry " + missingEntry);
+ }
+ }
+
+ DefaultImportStrategy strategy = new DefaultImportStrategy(
+ getService(ImportService.class),
+ getTransaction(),
+ dbMeta.getPersistenceHelper(),
+ 1000
+ );
+
+ importTables(strategy, model, zipFile, tables, false, false);
+
+ importAssociations(strategy, model, zipFile, associations);
+
+ // add a log entry of import db
+ if (log.isInfoEnabled()) {
+ log.info("Import done with user " + user.getEmail());
+ }
+ TopiaDAO<EntityModificationLog> dao =
+ getDAO(EntityModificationLog.class);
+
+ dao.create(
+ EntityModificationLog.PROPERTY_ENTITY_TYPE, "Import db",
+ EntityModificationLog.PROPERTY_ENTITY_ID, "Complete db",
+ EntityModificationLog.PROPERTY_MODIFICATION_USER, user.getEmail(),
+ EntityModificationLog.PROPERTY_MODIFICATION_DATE, newDate(),
+ EntityModificationLog.PROPERTY_MODIFICATION_TEXT, "import db from file " + file.getName()
+ );
+ commitTransaction("Could not commit db import from file " + file);
+
+ } finally {
+ zipFile.close();
+ }
+ }
+
+ /**
+ * Import a legacy data db from the given echobase file.
+ *
+ * @param model model of the db import operation
+ * @param user user which perform the import
+ * @throws IOException if any io exception while import
+ * @throws TopiaException if any pb while topia treatment
+ * @since 1.2
+ */
+ public void importLegacyData(ImportDbConfiguration model,
+ EchoBaseUser user) throws IOException, TopiaException, ImportException {
+
+ File file = model.getInput().getFile();
+
+ ZipFile zipFile = new ZipFile(file);
+ try {
+
+ List<String> missingEntries = Lists.newArrayList();
+
+ EchoBaseDbMeta dbMeta = getDbMeta();
+
+ Map<TableMeta<EchoBaseEntityEnum>, ZipEntry> tables = getTables(zipFile, missingEntries, dbMeta);
+
+ Map<AssociationMeta<EchoBaseEntityEnum>, ZipEntry> associations = getAssociations(zipFile, missingEntries, dbMeta);
+
+ int size = tables.size() + associations.size();
+ model.setNbSteps(size + missingEntries.size());
+
+ // check that contains only referential entries
+ List<EchoBaseEntityEnum> badTableTypes = Lists.newArrayList();
+ List<TableMeta<EchoBaseEntityEnum>> dataTables = dbMeta.getReferenceTables();
+ for (TableMeta<EchoBaseEntityEnum> tableMetas : tables.keySet()) {
+ if (dataTables.contains(tableMetas)) {
+ badTableTypes.add(tableMetas.getSource());
+ }
+ }
+
+ if (!badTableTypes.isEmpty()) {
+ throw new ImportException(
+ "In data import, can not accept " +
+ "referential type, but found some referential files: " + badTableTypes);
+ }
+
+ List<EchoBaseEntityEnum> badAssociationTypes = Lists.newArrayList();
+ List<AssociationMeta<EchoBaseEntityEnum>> associationTables = dbMeta.getReferenceAssociations();
+ for (AssociationMeta<EchoBaseEntityEnum> tableMetas : associations.keySet()) {
+ if (associationTables.contains(tableMetas)) {
+ badAssociationTypes.add(tableMetas.getSource());
+ }
+ }
+ if (!badAssociationTypes.isEmpty()) {
+ throw new ImportException(
+ "In data import, can not accept " +
+ "referential type, but found some referential associations files: " +
+ badAssociationTypes);
+ }
+
+ for (String missingEntry : missingEntries) {
+
+ // skip thoses not found entries
+ model.incrementsProgression();
+
+ if (log.isInfoEnabled()) {
+ log.info("Skip not found entry " + missingEntry);
+ }
+ }
+
+ DefaultImportStrategy strategy = new DefaultImportStrategy(
+ getService(ImportService.class),
+ getTransaction(),
+ dbMeta.getPersistenceHelper(),
+ 1000
+ );
+
+ Iterable<Voyage> importedVoyages =
+ importTables(strategy,
+ model,
+ zipFile,
+ tables,
+ false,
+ true);
+
+ importAssociations(strategy, model, zipFile, associations);
+
+ // add a log entry of import db
+ if (log.isInfoEnabled()) {
+ log.info("Import done with user " + user.getEmail());
+ }
+
+ TopiaDAO<ImportLog> importLogDAO = getDAO(ImportLog.class);
+
+ Decorator<Voyage> decorator = getService(DecoratorService.class).getDecorator(getLocale(), Voyage.class, null);
+ for (Voyage importedVoyage : importedVoyages) {
+
+ // create a importLog entry
+ ImportLog importLog = importLogDAO.create(
+ ImportLog.PROPERTY_IMPORT_TYPE, ImportType.LEGACY_VOYAGE,
+ ImportLog.PROPERTY_IMPORT_USER, user.getEmail(),
+ ImportLog.PROPERTY_IMPORT_DATE, newDate(),
+ ImportLog.PROPERTY_IMPORT_TYPE, "import legacy voyage " + decorator.toString(importedVoyage) + " from file " + file.getName()
+ );
+ importLog.addImportId(importedVoyage.getTopiaId());
+ }
+
+ TopiaDAO<EntityModificationLog> dao =
+ getDAO(EntityModificationLog.class);
+
+ dao.create(
+ EntityModificationLog.PROPERTY_ENTITY_TYPE, "Import db",
+ EntityModificationLog.PROPERTY_ENTITY_ID, "Complete db",
+ EntityModificationLog.PROPERTY_MODIFICATION_USER, user.getEmail(),
+ EntityModificationLog.PROPERTY_MODIFICATION_DATE, newDate(),
+ EntityModificationLog.PROPERTY_MODIFICATION_TEXT, "import db from file " + file.getName()
+ );
+ commitTransaction("Could not commit db import from file " + file);
+
+ } finally {
+ zipFile.close();
+ }
+ }
+
+ /**
+ * Import a complete db from the given echobase file.
+ *
* @param model model of the db import operation
* @param user user which perform the import
* @param computeSteps flag to compute stesp inside this method
@@ -87,13 +315,9 @@
EchoBaseDbMeta dbMeta = getDbMeta();
- Map<TableMeta<EchoBaseEntityEnum>, ZipEntry> tables = TopiaCsvImports.discoverEntries(
- "echobase/", dbMeta.getAllTables(),
- zipFile, missingEntries);
+ Map<TableMeta<EchoBaseEntityEnum>, ZipEntry> tables = getTables(zipFile, missingEntries, dbMeta);
- Map<AssociationMeta<EchoBaseEntityEnum>, ZipEntry> associations = TopiaCsvImports.discoverEntries(
- "echobase/", dbMeta.getAllAssociations(),
- zipFile, missingEntries);
+ Map<AssociationMeta<EchoBaseEntityEnum>, ZipEntry> associations = getAssociations(zipFile, missingEntries, dbMeta);
if (computeSteps) {
int size = tables.size() + associations.size();
@@ -117,7 +341,7 @@
1000
);
- importTables(strategy, model, zipFile, tables, commitAfterEachFile);
+ importTables(strategy, model, zipFile, tables, commitAfterEachFile, false);
importAssociations(strategy, model, zipFile, associations);
@@ -142,12 +366,31 @@
}
}
- private void importTables(DefaultImportStrategy strategy,
- ImportDbConfiguration model,
- ZipFile zipFile,
- Map<TableMeta<EchoBaseEntityEnum>, ZipEntry> entriestoConsume,
- boolean commitAfterEachFile) throws IOException, TopiaException {
+ private Map<TableMeta<EchoBaseEntityEnum>, ZipEntry> getTables(ZipFile zipFile,
+ List<String> missingEntries,
+ EchoBaseDbMeta dbMeta) {
+ return TopiaCsvImports.discoverEntries(
+ "echobase/", dbMeta.getAllTables(),
+ zipFile, missingEntries);
+ }
+ private Map<AssociationMeta<EchoBaseEntityEnum>, ZipEntry> getAssociations(ZipFile zipFile,
+ List<String> missingEntries,
+ EchoBaseDbMeta dbMeta) {
+ return TopiaCsvImports.discoverEntries(
+ "echobase/", dbMeta.getAllAssociations(),
+ zipFile, missingEntries);
+ }
+
+ private Iterable<Voyage> importTables(DefaultImportStrategy strategy,
+ ImportDbConfiguration model,
+ ZipFile zipFile,
+ Map<TableMeta<EchoBaseEntityEnum>, ZipEntry> entriestoConsume,
+ boolean commitAfterEachFile,
+ boolean keepVoyages) throws IOException, TopiaException {
+
+ Iterable<Voyage> result = null;
+
for (Map.Entry<TableMeta<EchoBaseEntityEnum>, ZipEntry> entry :
entriestoConsume.entrySet()) {
@@ -161,7 +404,8 @@
false
);
- Reader reader = IOUtils.toBufferedReader(new InputStreamReader(zipFile.getInputStream(value)));
+ Reader reader = IOUtils.toBufferedReader(
+ new InputStreamReader(zipFile.getInputStream(value)));
try {
long s0 = TimeLog.getTime();
@@ -169,15 +413,25 @@
if (log.isInfoEnabled()) {
log.info("Will import " + entryDef);
}
- TopiaCsvImports.importTable(reader,
- strategy,
- entryDef,
- csvResult
- );
+ if (EchoBaseEntityEnum.Voyage == entryDef.getSource() &&
+ keepVoyages) {
+ result = TopiaCsvImports.importTableAndReturn(reader,
+ strategy,
+ entryDef,
+ csvResult
+ );
+ } else {
+ TopiaCsvImports.importTable(reader,
+ strategy,
+ entryDef,
+ csvResult
+ );
+ }
+
s0 = TIME_LOG.log(s0, "importFile::done");
- flushTransaction();
+ flushTransaction("Could not flush " + entryDef + " to db.");
TIME_LOG.log(s0, "importFile::flushTransaction");
} finally {
@@ -188,8 +442,12 @@
"Could not commit db import from file " +
zipFile.getName() + "#" + entryDef.getFilename());
}
+
+ clearCache();
}
}
+
+ return result;
}
private void importAssociations(DefaultImportStrategy strategy,
@@ -226,7 +484,7 @@
s0 = TIME_LOG.log(s0, "importFile::done");
- flushTransaction();
+ flushTransaction("Could not flush associations to db.");
TIME_LOG.log(s0, "importFile::flushTransaction");
} finally {
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/RemoveDataService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/RemoveDataService.java 2012-09-10 10:00:46 UTC (rev 640)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/RemoveDataService.java 2012-09-10 14:06:45 UTC (rev 641)
@@ -38,6 +38,7 @@
import fr.ifremer.echobase.services.removedata.strategy.CatchesRemoveDataStrategy;
import fr.ifremer.echobase.services.removedata.strategy.CommonAllRemoveDataStrategy;
import fr.ifremer.echobase.services.removedata.strategy.CommonTransectRemoveDataStrategy;
+import fr.ifremer.echobase.services.removedata.strategy.LegacyVoyageRemoveDataStrategy;
import fr.ifremer.echobase.services.removedata.strategy.OperationRemoveDataStrategy;
import fr.ifremer.echobase.services.removedata.strategy.ResultEsduRemoveDataStrategy;
import fr.ifremer.echobase.services.removedata.strategy.ResultMapRemoveDataStrategy;
@@ -74,6 +75,7 @@
public static Class<? extends AbstractRemoveDataStrategy> getStrategy(ImportType importType) {
if (strategies == null) {
strategies = Maps.newEnumMap(ImportType.class);
+ strategies.put(ImportType.LEGACY_VOYAGE, LegacyVoyageRemoveDataStrategy.class);
strategies.put(ImportType.COMMON_ALL, CommonAllRemoveDataStrategy.class);
strategies.put(ImportType.COMMON_TRANSECT, CommonTransectRemoveDataStrategy.class);
strategies.put(ImportType.OPERATION, OperationRemoveDataStrategy.class);
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/AbstractRemoveDataStrategy.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/AbstractRemoveDataStrategy.java 2012-09-10 10:00:46 UTC (rev 640)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/AbstractRemoveDataStrategy.java 2012-09-10 14:06:45 UTC (rev 641)
@@ -23,15 +23,25 @@
* #L%
*/
+import com.google.common.collect.Lists;
+import com.google.common.collect.Sets;
import fr.ifremer.echobase.EchoBaseTechnicalException;
import fr.ifremer.echobase.entities.ImportLog;
import fr.ifremer.echobase.entities.ImportType;
+import fr.ifremer.echobase.entities.data.Category;
+import fr.ifremer.echobase.entities.data.CategoryDAO;
+import fr.ifremer.echobase.entities.data.Echotype;
+import fr.ifremer.echobase.entities.data.LengthAgeKey;
+import fr.ifremer.echobase.entities.data.LengthWeightKey;
+import fr.ifremer.echobase.entities.data.Voyage;
import fr.ifremer.echobase.services.EchoBaseServiceSupport;
import fr.ifremer.echobase.services.removedata.RemoveDataConfiguration;
import org.nuiton.topia.TopiaException;
import org.nuiton.topia.persistence.TopiaDAO;
import org.nuiton.topia.persistence.TopiaEntity;
+import java.util.Collection;
+import java.util.List;
import java.util.Set;
/**
@@ -48,7 +58,7 @@
return importLabel;
}
- protected abstract void removeData(String id);
+ protected abstract void removeData(String id) throws TopiaException;
public abstract Set<ImportType> getPossibleSubImportType();
@@ -60,16 +70,15 @@
currentIndex++;
if (currentIndex % 1000 == 0) {
- try {
- flushTransaction();
- } catch (TopiaException e) {
- throw new EchoBaseTechnicalException(
- "Could not flush transaction", e);
- }
+ flushTransaction("Could not flush transaction");
}
model.incrementsProgression();
- removeData(importId);
+ try {
+ removeData(importId);
+ } catch (TopiaException e) {
+ throw new EchoBaseTechnicalException(e);
+ }
}
}
@@ -103,4 +112,79 @@
" from service " + this);
}
+ protected void removeLengthWeightKey(LengthWeightKey lengthWeightKey,
+ Voyage entity) throws TopiaException {
+ TopiaDAO<LengthWeightKey> dao = getDAO(LengthWeightKey.class);
+ dao.delete(lengthWeightKey);
+
+ if (entity != null) {
+
+ // remove it from the voyage
+ entity.removeLengthWeightKey(lengthWeightKey);
+ }
+ }
+
+ protected void removeLengthAgeKey(LengthAgeKey lengthAgeKey,
+ Voyage entity) throws TopiaException {
+ TopiaDAO<LengthAgeKey> dao = getDAO(LengthAgeKey.class);
+ dao.delete(lengthAgeKey);
+
+ if (entity != null) {
+
+ // remove it from the voyage
+ entity.removeLengthAgeKey(lengthAgeKey);
+ }
+ }
+
+ protected void removeEchotype(Echotype echotype,
+ Voyage entity) throws TopiaException {
+
+ // delete all category
+ CategoryDAO categoryDAO = getDAO(Category.class, CategoryDAO.class);
+ List<Category> allByEchotype = categoryDAO.findAllByEchotype(echotype);
+ categoryDAO.deleteAll(allByEchotype);
+
+ // delete echotype
+ TopiaDAO<Echotype> dao = getDAO(Echotype.class);
+ dao.delete(echotype);
+
+ if (entity != null) {
+
+ // remove it from the voyage
+ entity.removeEchotype(echotype);
+ }
+ }
+
+ protected void removeVoyage(TopiaDAO<Voyage> dao, Voyage entity) throws TopiaException {
+
+ Collection<LengthWeightKey> lengthWeightKeys = Lists.newArrayList(entity.getLengthWeightKey());
+ Collection<LengthAgeKey> lengthAgeKeys = Lists.newArrayList(entity.getLengthAgeKey());
+ Set<Echotype> echotypes = Sets.newHashSet(entity.getEchotype());
+
+ // clean this data
+ entity.clearLengthWeightKey();
+ entity.clearLengthAgeKey();
+ entity.clearEchotype();
+
+ // delete voyage
+ delete(dao, entity);
+
+ flushTransaction("Could not flush voyage deletion");
+
+ // delete all lengthWeightKeys
+ for (LengthWeightKey lengthWeightKey : lengthWeightKeys) {
+ removeLengthWeightKey(lengthWeightKey, null);
+ }
+
+ // delete all lengthAgeKeys
+ for (LengthAgeKey lengthAgeKey : lengthAgeKeys) {
+ removeLengthAgeKey(lengthAgeKey, null);
+ }
+
+ // delete all echotypes
+ for (Echotype echotype : echotypes) {
+ removeEchotype(echotype, null);
+ }
+ }
+
}
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/AcousticRemoveDataStrategy.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/AcousticRemoveDataStrategy.java 2012-09-10 10:00:46 UTC (rev 640)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/AcousticRemoveDataStrategy.java 2012-09-10 14:06:45 UTC (rev 641)
@@ -30,7 +30,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import java.util.HashSet;
import java.util.Set;
/**
@@ -79,12 +78,10 @@
@Override
public Set<ImportType> getPossibleSubImportType() {
- HashSet<ImportType> result = Sets.newHashSet(ImportType.values());
- result.remove(ImportType.COMMON_ALL);
- result.remove(ImportType.COMMON_TRANSECT);
- result.remove(ImportType.OPERATION);
- result.remove(ImportType.CATCHES);
- result.remove(ImportType.ACOUSTIC);
+ Set<ImportType> result = Sets.newHashSet(ImportType.RESULT_VOYAGE,
+ ImportType.RESULT_ESDU,
+ ImportType.RESULT_MAP,
+ ImportType.RESULT_REGION);
return result;
}
}
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/CatchesRemoveDataStrategy.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/CatchesRemoveDataStrategy.java 2012-09-10 10:00:46 UTC (rev 640)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/CatchesRemoveDataStrategy.java 2012-09-10 14:06:45 UTC (rev 641)
@@ -23,13 +23,12 @@
* #L%
*/
-import com.google.common.collect.Sets;
import fr.ifremer.echobase.entities.ImportType;
import fr.ifremer.echobase.entities.data.Sample;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import java.util.HashSet;
+import java.util.Collections;
import java.util.Set;
/**
@@ -67,11 +66,7 @@
@Override
public Set<ImportType> getPossibleSubImportType() {
- HashSet<ImportType> result = Sets.newHashSet(ImportType.values());
- result.remove(ImportType.COMMON_ALL);
- result.remove(ImportType.COMMON_TRANSECT);
- result.remove(ImportType.OPERATION);
- result.remove(ImportType.CATCHES);
+ Set<ImportType> result = Collections.emptySet();
return result;
}
}
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/CommonAllRemoveDataStrategy.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/CommonAllRemoveDataStrategy.java 2012-09-10 10:00:46 UTC (rev 640)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/CommonAllRemoveDataStrategy.java 2012-09-10 14:06:45 UTC (rev 641)
@@ -28,8 +28,9 @@
import fr.ifremer.echobase.entities.data.Voyage;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.nuiton.topia.TopiaException;
+import org.nuiton.topia.persistence.TopiaDAO;
-import java.util.HashSet;
import java.util.Set;
/**
@@ -47,7 +48,7 @@
LogFactory.getLog(CommonAllRemoveDataStrategy.class);
@Override
- protected void removeData(String id) {
+ protected void removeData(String id) throws TopiaException {
if (id.startsWith(Voyage.class.getName())) {
@@ -58,18 +59,33 @@
}
}
- protected void removeVoyage(String id) {
- Voyage entity = removeEntity(id);
+ protected void removeVoyage(String id) throws TopiaException {
+
+ // get dao
+ TopiaDAO<Voyage> dao = getDAOFromId(id);
+
+ // get entity to delete
+ Voyage entity = findById(dao, id);
+
+ // delete it
+ removeVoyage(dao, entity);
+
if (log.isInfoEnabled()) {
log.info("Voyage " + entity.getTopiaId() + " was removed");
}
}
+
@Override
public Set<ImportType> getPossibleSubImportType() {
- HashSet<ImportType> result = Sets.newHashSet(ImportType.values());
- result.remove(ImportType.COMMON_ALL);
- result.remove(ImportType.COMMON_TRANSECT);
+ Set<ImportType> result = Sets.newHashSet(ImportType.COMMON_TRANSECT,
+ ImportType.OPERATION,
+ ImportType.CATCHES,
+ ImportType.ACOUSTIC,
+ ImportType.RESULT_VOYAGE,
+ ImportType.RESULT_ESDU,
+ ImportType.RESULT_MAP,
+ ImportType.RESULT_REGION);
return result;
}
}
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/CommonTransectRemoveDataStrategy.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/CommonTransectRemoveDataStrategy.java 2012-09-10 10:00:46 UTC (rev 640)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/CommonTransectRemoveDataStrategy.java 2012-09-10 14:06:45 UTC (rev 641)
@@ -29,7 +29,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import java.util.HashSet;
import java.util.Set;
/**
@@ -67,9 +66,13 @@
@Override
public Set<ImportType> getPossibleSubImportType() {
- HashSet<ImportType> result = Sets.newHashSet(ImportType.values());
- result.remove(ImportType.COMMON_ALL);
- result.remove(ImportType.COMMON_TRANSECT);
+ Set<ImportType> result = Sets.newHashSet(ImportType.OPERATION,
+ ImportType.CATCHES,
+ ImportType.ACOUSTIC,
+ ImportType.RESULT_VOYAGE,
+ ImportType.RESULT_ESDU,
+ ImportType.RESULT_MAP,
+ ImportType.RESULT_REGION);
return result;
}
}
Added: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/LegacyVoyageRemoveDataStrategy.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/LegacyVoyageRemoveDataStrategy.java (rev 0)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/LegacyVoyageRemoveDataStrategy.java 2012-09-10 14:06:45 UTC (rev 641)
@@ -0,0 +1,92 @@
+package fr.ifremer.echobase.services.removedata.strategy;
+
+/*
+ * #%L
+ * EchoBase :: Services
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 - 2012 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%
+ */
+
+import com.google.common.collect.Sets;
+import fr.ifremer.echobase.entities.ImportType;
+import fr.ifremer.echobase.entities.data.Voyage;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.topia.TopiaException;
+import org.nuiton.topia.persistence.TopiaDAO;
+
+import java.util.Set;
+
+/**
+ * Remove a {@link ImportType#LEGACY_VOYAGE} import.
+ * <p/>
+ * Can remove only {@link Voyage}.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.2
+ */
+public class LegacyVoyageRemoveDataStrategy extends AbstractRemoveDataStrategy {
+
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(LegacyVoyageRemoveDataStrategy.class);
+
+ @Override
+ protected void removeData(String id) throws TopiaException {
+
+ if (id.startsWith(Voyage.class.getName())) {
+
+ // remove voyage
+ removeVoyage(id);
+ } else {
+ canNotDealWithId(id);
+ }
+ }
+
+ protected void removeVoyage(String id) throws TopiaException {
+
+ // get dao
+ TopiaDAO<Voyage> dao = getDAOFromId(id);
+
+ // get entity to delete
+ Voyage entity = findById(dao, id);
+
+ // delete it
+ removeVoyage(dao, entity);
+
+ if (log.isInfoEnabled()) {
+ log.info("Voyage " + entity.getTopiaId() + " was removed");
+ }
+ }
+
+
+ @Override
+ public Set<ImportType> getPossibleSubImportType() {
+ Set<ImportType> result = Sets.newHashSet(ImportType.COMMON_TRANSECT,
+ ImportType.OPERATION,
+ ImportType.CATCHES,
+ ImportType.ACOUSTIC,
+ ImportType.RESULT_VOYAGE,
+ ImportType.RESULT_ESDU,
+ ImportType.RESULT_MAP,
+ ImportType.RESULT_REGION);
+ return result;
+ }
+
+}
Property changes on: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/LegacyVoyageRemoveDataStrategy.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/removedata/strategy/OperationRemoveDataStrategy.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/OperationRemoveDataStrategy.java 2012-09-10 10:00:46 UTC (rev 640)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/OperationRemoveDataStrategy.java 2012-09-10 14:06:45 UTC (rev 641)
@@ -29,7 +29,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import java.util.HashSet;
import java.util.Set;
/**
@@ -67,10 +66,7 @@
@Override
public Set<ImportType> getPossibleSubImportType() {
- HashSet<ImportType> result = Sets.newHashSet(ImportType.values());
- result.remove(ImportType.COMMON_ALL);
- result.remove(ImportType.COMMON_TRANSECT);
- result.remove(ImportType.OPERATION);
+ Set<ImportType> result = Sets.newHashSet(ImportType.CATCHES);
return result;
}
}
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/ResultEsduRemoveDataStrategy.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/ResultEsduRemoveDataStrategy.java 2012-09-10 10:00:46 UTC (rev 640)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/ResultEsduRemoveDataStrategy.java 2012-09-10 14:06:45 UTC (rev 641)
@@ -23,13 +23,12 @@
* #L%
*/
-import com.google.common.collect.Sets;
import fr.ifremer.echobase.entities.ImportType;
import fr.ifremer.echobase.entities.data.Result;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import java.util.HashSet;
+import java.util.Collections;
import java.util.Set;
/**
@@ -67,14 +66,7 @@
@Override
public Set<ImportType> getPossibleSubImportType() {
- HashSet<ImportType> result = Sets.newHashSet(ImportType.values());
- result.remove(ImportType.COMMON_ALL);
- result.remove(ImportType.COMMON_TRANSECT);
- result.remove(ImportType.OPERATION);
- result.remove(ImportType.CATCHES);
- result.remove(ImportType.ACOUSTIC);
- result.remove(ImportType.RESULT_VOYAGE);
- result.remove(ImportType.RESULT_ESDU);
+ Set<ImportType> result = Collections.emptySet();
return result;
}
}
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/ResultMapRemoveDataStrategy.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/ResultMapRemoveDataStrategy.java 2012-09-10 10:00:46 UTC (rev 640)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/ResultMapRemoveDataStrategy.java 2012-09-10 14:06:45 UTC (rev 641)
@@ -23,13 +23,12 @@
* #L%
*/
-import com.google.common.collect.Sets;
import fr.ifremer.echobase.entities.ImportType;
import fr.ifremer.echobase.entities.data.Cell;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import java.util.HashSet;
+import java.util.Collections;
import java.util.Set;
/**
@@ -67,7 +66,7 @@
@Override
public Set<ImportType> getPossibleSubImportType() {
- HashSet<ImportType> result = Sets.newHashSet();
+ Set<ImportType> result = Collections.emptySet();
return result;
}
}
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/ResultRegionRemoveDataStrategy.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/ResultRegionRemoveDataStrategy.java 2012-09-10 10:00:46 UTC (rev 640)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/ResultRegionRemoveDataStrategy.java 2012-09-10 14:06:45 UTC (rev 641)
@@ -23,13 +23,12 @@
* #L%
*/
-import com.google.common.collect.Sets;
import fr.ifremer.echobase.entities.ImportType;
import fr.ifremer.echobase.entities.data.Cell;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import java.util.HashSet;
+import java.util.Collections;
import java.util.Set;
/**
@@ -67,15 +66,7 @@
@Override
public Set<ImportType> getPossibleSubImportType() {
- HashSet<ImportType> result = Sets.newHashSet(ImportType.values());
- result.remove(ImportType.COMMON_ALL);
- result.remove(ImportType.COMMON_TRANSECT);
- result.remove(ImportType.OPERATION);
- result.remove(ImportType.CATCHES);
- result.remove(ImportType.ACOUSTIC);
- result.remove(ImportType.RESULT_VOYAGE);
- result.remove(ImportType.RESULT_ESDU);
- result.remove(ImportType.RESULT_VOYAGE);
+ Set<ImportType> result = Collections.emptySet();
return result;
}
}
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/ResultVoyageRemoveDataStrategy.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/ResultVoyageRemoveDataStrategy.java 2012-09-10 10:00:46 UTC (rev 640)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/ResultVoyageRemoveDataStrategy.java 2012-09-10 14:06:45 UTC (rev 641)
@@ -25,17 +25,30 @@
import com.google.common.collect.Sets;
import fr.ifremer.echobase.entities.ImportType;
+import fr.ifremer.echobase.entities.data.Cell;
import fr.ifremer.echobase.entities.data.Echotype;
import fr.ifremer.echobase.entities.data.LengthAgeKey;
import fr.ifremer.echobase.entities.data.LengthWeightKey;
+import fr.ifremer.echobase.entities.data.Result;
+import fr.ifremer.echobase.entities.data.Voyage;
+import fr.ifremer.echobase.entities.data.VoyageDAO;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.nuiton.topia.TopiaException;
+import org.nuiton.topia.framework.TopiaContextImplementor;
+import org.nuiton.topia.framework.TopiaSQLQuery;
+import org.nuiton.topia.persistence.TopiaDAO;
-import java.util.HashSet;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.Collection;
+import java.util.List;
import java.util.Set;
/**
- * remove a {@link ImportType#OPERATION} import.
+ * Remove a {@link ImportType#OPERATION} import.
* <p/>
* Can remove only {@link Echotype}, {@link LengthAgeKey} or
* {@link LengthWeightKey}.
@@ -49,42 +62,154 @@
private static final Log log =
LogFactory.getLog(ResultVoyageRemoveDataStrategy.class);
+ protected Voyage voyage;
+
@Override
- protected void removeData(String id) {
+ protected void removeData(String id) throws TopiaException {
if (id.startsWith(Echotype.class.getName())) {
+ // get dao
+ TopiaDAO<Echotype> dao = getDAOFromId(id);
+
+ // get entity to delete
+ Echotype entity = findById(dao, id);
+
+ if (voyage == null) {
+
+ // load voyage
+ VoyageDAO voyageDao = getDAO(Voyage.class, VoyageDAO.class);
+ voyage = voyageDao.findContainsEchotype(entity);
+
+ // remove data from voyage
+ removeVoyageData(voyage);
+ }
+
// remove echotype
- removeEchotype(id);
+ removeEchotype(entity);
} else if (id.startsWith(LengthAgeKey.class.getName())) {
+ // get dao
+ TopiaDAO<LengthAgeKey> dao = getDAOFromId(id);
+
+ // get entity to delete
+ LengthAgeKey entity = findById(dao, id);
+
+ if (voyage == null) {
+
+ // load voyage
+ VoyageDAO voyageDao = getDAO(Voyage.class, VoyageDAO.class);
+ voyage = voyageDao.findContainsLengthAgeKey(entity);
+
+ // remove data from voyage
+ removeVoyageData(voyage);
+ }
+
// remove lengthAgeKey
- removeLengthAgeKey(id);
+ removeLengthAgeKey(entity);
} else if (id.startsWith(LengthWeightKey.class.getName())) {
+ // get dao
+ TopiaDAO<LengthWeightKey> dao = getDAOFromId(id);
+
+ // get entity to delete
+ LengthWeightKey entity = findById(dao, id);
+
+ if (voyage == null) {
+
+ // load voyage
+ VoyageDAO voyageDao = getDAO(Voyage.class, VoyageDAO.class);
+ voyage = voyageDao.findContainsLengthWeightKey(entity);
+
+ // remove data from voyage
+ removeVoyageData(voyage);
+ }
+
// remove lengthAgeKey
- removeLengthWeightKey(id);
+ removeLengthWeightKey(entity);
} else {
canNotDealWithId(id);
}
}
- protected void removeEchotype(String id) {
- Echotype entity = removeEntity(id);
+ protected void removeVoyageData(final Voyage voyage) throws TopiaException {
+
+ // suppress all postCell from the voyage
+ TopiaDAO<Cell> cellDAO = getDAO(Cell.class);
+ for (Cell postCell : voyage.getPostCell()) {
+ voyage.removePostCell(postCell);
+ delete(cellDAO, postCell);
+ }
+
+ flushTransaction("Could not flush transaction after removing postCells");
+
+ // Get all cells of the voyage
+ TopiaSQLQuery<String> query = new TopiaSQLQuery<String>() {
+ @Override
+ protected PreparedStatement prepareQuery(Connection connection) throws SQLException {
+ String hql = "SELECT c.topiaid FROM TransitImpl ta, " +
+ " TransectImpl te, " +
+ " DataAcquisitionImpl da, " +
+ " DataProcessingImpl dp, " +
+ " CellImpl c " +
+ "WHERE ta.voyage = ? " +
+ "AND ta.topiaId = te.transit " +
+ "AND te.topiaId = da.transect " +
+ "AND da.topiaId = dp.dataacquisition" +
+ "AND dp.topiaId = c.dataprocessing";
+ PreparedStatement result = connection.prepareStatement(hql);
+ result.setString(1, voyage.getTopiaId());
+ return result;
+ }
+
+ @Override
+ protected String prepareResult(ResultSet set) throws SQLException {
+ return set.getString(1);
+ }
+ };
+
+ List<String> cellIds = query.findMultipleResult(
+ (TopiaContextImplementor) getTransaction());
+
+ // remove all result of cells
+
+ TopiaDAO<Result> resultDAO = getDAO(Result.class);
+
+ for (String cellId : cellIds) {
+ Cell cell = findById(cellDAO, cellId);
+ Collection<Result> cellResult = cell.getResult();
+ for (Result result : cellResult) {
+ cell.removeResult(result);
+ }
+ resultDAO.deleteAll(cellResult);
+ }
+
+ flushTransaction(
+ "Could not flush transaction after deleting data from voyage");
+ }
+
+ protected void removeEchotype(Echotype entity) throws TopiaException {
+
+ removeEchotype(entity, voyage);
+
if (log.isInfoEnabled()) {
log.info("Echotype " + entity.getTopiaId() + " was removed");
}
}
- protected void removeLengthAgeKey(String id) {
- LengthAgeKey entity = removeEntity(id);
+ protected void removeLengthAgeKey(LengthAgeKey entity) throws TopiaException {
+
+ removeLengthAgeKey(entity, voyage);
+
if (log.isInfoEnabled()) {
log.info("LengthAgeKey " + entity.getTopiaId() + " was removed");
}
}
- protected void removeLengthWeightKey(String id) {
- LengthWeightKey entity = removeEntity(id);
+ protected void removeLengthWeightKey(LengthWeightKey entity) throws TopiaException {
+
+ removeLengthWeightKey(entity, voyage);
+
if (log.isInfoEnabled()) {
log.info("LengthWeightKey " + entity.getTopiaId() + " was removed");
}
@@ -92,13 +217,9 @@
@Override
public Set<ImportType> getPossibleSubImportType() {
- HashSet<ImportType> result = Sets.newHashSet(ImportType.values());
- result.remove(ImportType.COMMON_ALL);
- result.remove(ImportType.COMMON_TRANSECT);
- result.remove(ImportType.OPERATION);
- result.remove(ImportType.CATCHES);
- result.remove(ImportType.ACOUSTIC);
- result.remove(ImportType.RESULT_VOYAGE);
+ Set<ImportType> result = Sets.newHashSet(ImportType.RESULT_ESDU,
+ ImportType.RESULT_MAP,
+ ImportType.RESULT_REGION);
return result;
}
}
Modified: trunk/echobase-services/src/main/resources/i18n/echobase-services_en_GB.properties
===================================================================
--- trunk/echobase-services/src/main/resources/i18n/echobase-services_en_GB.properties 2012-09-10 10:00:46 UTC (rev 640)
+++ trunk/echobase-services/src/main/resources/i18n/echobase-services_en_GB.properties 2012-09-10 14:06:45 UTC (rev 641)
@@ -13,6 +13,8 @@
echobase.common.esduBySpeciesAndSizeCategoryFile=Results per ESDU / species / size file
echobase.common.gearMetadataFile=Gear metadata file
echobase.common.importDbFile=Import file (.zip)
+echobase.common.importDbMode.free=Free import
+echobase.common.importDbMode.referential=Referential import
echobase.common.lengthAgeKeyFile=Size-age equations file
echobase.common.lengthWeightKeyFile=Size-weight equations file
echobase.common.moviesFile=Acoustic data file
Modified: trunk/echobase-services/src/main/resources/i18n/echobase-services_fr_FR.properties
===================================================================
--- trunk/echobase-services/src/main/resources/i18n/echobase-services_fr_FR.properties 2012-09-10 10:00:46 UTC (rev 640)
+++ trunk/echobase-services/src/main/resources/i18n/echobase-services_fr_FR.properties 2012-09-10 14:06:45 UTC (rev 641)
@@ -13,6 +13,8 @@
echobase.common.esduBySpeciesAndSizeCategoryFile=Fichier de résultats par ESDU / espèce / taille
echobase.common.gearMetadataFile=Fichier de méta-données d'engin
echobase.common.importDbFile=Fichier d'import (zip)
+echobase.common.importDbMode.free=Import libre
+echobase.common.importDbMode.referential=Import Référentiel
echobase.common.lengthAgeKeyFile=Fichier des relations taille-âge
echobase.common.lengthWeightKeyFile=Fichier des relations taille-poids
echobase.common.moviesFile=Fichier des données acoustiques
Modified: trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/AbstractImportDataServiceIT.java
===================================================================
--- trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/AbstractImportDataServiceIT.java 2012-09-10 10:00:46 UTC (rev 640)
+++ trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/AbstractImportDataServiceIT.java 2012-09-10 14:06:45 UTC (rev 641)
@@ -313,7 +313,7 @@
}
}
- flushTransaction();
+ flushTransaction("Could not flush transaction of esdu cells.");
} finally {
Modified: trunk/echobase-ui/pom.xml
===================================================================
--- trunk/echobase-ui/pom.xml 2012-09-10 10:00:46 UTC (rev 640)
+++ trunk/echobase-ui/pom.xml 2012-09-10 14:06:45 UTC (rev 641)
@@ -120,7 +120,7 @@
<webAppConfig>
<contextPath>/echobase</contextPath>
</webAppConfig>
- <jvmArgs>-Xms512m -Xmx1512m</jvmArgs>
+ <jvmArgs>-Xms512m -Xmx2048m</jvmArgs>
<systemProperties>
<systemProperty>
<name>echobase.log.dir</name>
Modified: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/importDb/Configure.java
===================================================================
--- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/importDb/Configure.java 2012-09-10 10:00:46 UTC (rev 640)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/importDb/Configure.java 2012-09-10 14:06:45 UTC (rev 641)
@@ -26,6 +26,7 @@
import fr.ifremer.echobase.io.EchoBaseIOUtil;
import fr.ifremer.echobase.io.InputFile;
import fr.ifremer.echobase.services.importdb.ImportDbConfiguration;
+import fr.ifremer.echobase.services.importdb.ImportDbMode;
import fr.ifremer.echobase.ui.actions.AbstractConfigureAction;
import org.apache.commons.io.FileUtils;
import org.apache.commons.logging.Log;
@@ -34,6 +35,7 @@
import java.io.File;
import java.io.IOException;
+import java.util.Map;
/**
* Configure a db import.
@@ -48,6 +50,14 @@
/** Logger. */
private static final Log log = LogFactory.getLog(Configure.class);
+
+ /** Universe of possible import modes. */
+ protected Map<String, String> modes;
+
+ public Map<String, String> getModes() {
+ return modes;
+ }
+
public Configure() {
super(ImportDbConfiguration.class);
}
@@ -58,6 +68,16 @@
}
@Override
+ protected void prepareInputAction(ImportDbConfiguration model) {
+ modes = decorateEnums(ImportDbMode.values());
+
+ if (model.getImportDbMode() == null) {
+
+ model.setImportDbMode(ImportDbMode.REFERENTIAL);
+ }
+ }
+
+ @Override
protected void prepareExecuteAction(ImportDbConfiguration model) throws IOException {
File tempDirectory = FileUtils.getTempDirectory();
@@ -74,6 +94,18 @@
EchoBaseIOUtil.copyFile(input, dataDirectory);
}
+ public String execute_referential() throws Exception {
+ return execute();
+ }
+
+ public String execute_legacyVoyage() throws Exception {
+ return execute();
+ }
+
+ public String execute_free() throws Exception {
+ return execute();
+ }
+
public void setInputFileName(String fileName) {
getModel().getInput().setFileName(fileName);
}
Modified: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/importDb/Import.java
===================================================================
--- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/importDb/Import.java 2012-09-10 10:00:46 UTC (rev 640)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/importDb/Import.java 2012-09-10 14:06:45 UTC (rev 641)
@@ -23,12 +23,18 @@
*/
package fr.ifremer.echobase.ui.actions.importDb;
+import fr.ifremer.echobase.entities.EchoBaseUser;
import fr.ifremer.echobase.services.importdb.ImportDbConfiguration;
+import fr.ifremer.echobase.services.importdb.ImportDbMode;
import fr.ifremer.echobase.services.importdb.ImportDbService;
import fr.ifremer.echobase.ui.actions.AbstractWaitAndExecAction;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import java.util.Locale;
+
+import static org.nuiton.i18n.I18n.l_;
+
/**
* Start the import db.
*
@@ -42,6 +48,12 @@
/** Logger. */
private static final Log log = LogFactory.getLog(Import.class);
+ protected String result;
+
+ public String getResult() {
+ return result;
+ }
+
public Import() {
super(ImportDbConfiguration.class, ImportDbService.class);
}
@@ -54,12 +66,39 @@
model.getInput().getFileName());
}
- service.importDb(model, getEchoBaseSession().getUser(), true, false);
+ ImportDbMode importDbMode = model.getImportDbMode();
+ Locale locale = getLocale();
+ EchoBaseUser user = getEchoBaseSession().getUser();
+ switch (importDbMode) {
+
+ case REFERENTIAL:
+ service.importReferential(model, user);
+
+ addFlashMessage(_("echobase.info.import.succeded"));
+ result = l_(locale, "echobase.importDb.referentialResult",
+ model.getActionTime());
+
+ break;
+ case LEGACY_VOYAGE:
+ service.importLegacyData(model, user);
+
+ addFlashMessage(_("echobase.info.import.succeded"));
+ result = l_(locale, "echobase.importDb.legacyVoyageResult",
+ model.getActionTime());
+
+ break;
+ case FREE:
+ service.importDb(model, user, true, false);
+
+ addFlashMessage(_("echobase.info.import.succeded"));
+ result = l_(locale, "echobase.importDb.freeResult",
+ model.getActionTime());
+ break;
+ }
}
@Override
protected void closeAction(ImportDbConfiguration model) throws Exception {
-
destroyModel(model);
}
}
\ No newline at end of file
Modified: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/removeData/ConfirmDelete.java
===================================================================
--- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/removeData/ConfirmDelete.java 2012-09-10 10:00:46 UTC (rev 640)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/removeData/ConfirmDelete.java 2012-09-10 14:06:45 UTC (rev 641)
@@ -75,6 +75,7 @@
// nothing special to do here
}
+ @Override
protected void prepareInputAction(RemoveDataConfiguration model) {
String importLogId = model.getImportLogId();
Modified: trunk/echobase-ui/src/main/resources/config/struts-importDb.xml
===================================================================
--- trunk/echobase-ui/src/main/resources/config/struts-importDb.xml 2012-09-10 10:00:46 UTC (rev 640)
+++ trunk/echobase-ui/src/main/resources/config/struts-importDb.xml 2012-09-10 14:06:45 UTC (rev 641)
@@ -31,7 +31,7 @@
<package name="importDb" extends="loggued" namespace="/importDb">
<!-- Configure import -->
- <action name="configure"
+ <action name="configure-*" method="execute_{1}"
class="fr.ifremer.echobase.ui.actions.importDb.Configure">
<interceptor-ref name="prepareParamsStackLoggued"/>
<result name="input">/WEB-INF/jsp/importDb/configure.jsp</result>
Modified: trunk/echobase-ui/src/main/resources/i18n/echobase-ui_en_GB.properties
===================================================================
--- trunk/echobase-ui/src/main/resources/i18n/echobase-ui_en_GB.properties 2012-09-10 10:00:46 UTC (rev 640)
+++ trunk/echobase-ui/src/main/resources/i18n/echobase-ui_en_GB.properties 2012-09-10 14:06:45 UTC (rev 641)
@@ -32,6 +32,7 @@
echobase.action.saveSqlQuery=Update query
echobase.action.show.embedded.documentation=How to use a portable database
echobase.action.show.import.documentation=How to import data
+echobase.action.show.importDb.documentation=How to import db data
echobase.action.showImportLogs=Liste des imports\=Show import logs
echobase.action.toEnglish=English
echobase.action.toFrench=French
@@ -75,6 +76,7 @@
echobase.common.importDataMode=Import type
echobase.common.importDate=Import date
echobase.common.importDbFile=
+echobase.common.importDbMode=Import db mode
echobase.common.importError=Error\:
echobase.common.importLogActions=Actions
echobase.common.importNotes=Import notes
@@ -214,6 +216,9 @@
echobase.error.workingDbConfiguration.url.already.exists=A configuration with same url already exists
echobase.error.workingDbConfiguration.url.required=Mandatory jdbc url
echobase.header.request.result=SQL query result
+echobase.importDb.freeResult=Free db import was succesful in %s.
+echobase.importDb.legacyVoyageResult=Legacy voyage db import was sucessful in %s.
+echobase.importDb.referentialResult=Referential db import was succesul in %s.
echobase.info.click.to.select=You can select value with a simple click then copy it (Ctrl-C)
echobase.info.dbeditor.propertyDiffsResult=Data import results
echobase.info.documentation=EchoBase online documentation
@@ -278,7 +283,11 @@
echobase.legend.importData.configure=Import configuration
echobase.legend.importData.createMission=Mission caracteristics
echobase.legend.importData.result.resume=Results
-echobase.legend.importDb.configuration.files=Import file selection (.zip file)
+echobase.legend.importDb.configuration.files=Import file selection (.echobase file)
+echobase.legend.importDb.configuration.freeMode=Free import configuration
+echobase.legend.importDb.configuration.legacyVoyageMode=Data import configuration
+echobase.legend.importDb.configuration.referentialMode=Referential import configuration
+echobase.legend.importDb.configuration.selectImportDbMode=Select import db mode
echobase.legend.libreOfficeQuery=Translate a SQL query from Libre Office
echobase.legend.sqlQuery.configuration=Query definition
echobase.legend.sqlQuery.result=Query results
@@ -292,6 +301,7 @@
echobase.menu.importData=Import data
echobase.menu.importDb=Complete database import
echobase.menu.logs=Change log
+echobase.menu.removeData=Remove data
echobase.menu.users=Manage users
echobase.menu.viewData=Display data
echobase.message.no.row.selected=No data selected
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 2012-09-10 10:00:46 UTC (rev 640)
+++ trunk/echobase-ui/src/main/resources/i18n/echobase-ui_fr_FR.properties 2012-09-10 14:06:45 UTC (rev 641)
@@ -32,6 +32,7 @@
echobase.action.saveSqlQuery=Mettre à jour
echobase.action.show.embedded.documentation=Comment utiliser une application embarquée
echobase.action.show.import.documentation=Comment importer des données
+echobase.action.show.importDb.documentation=Comment importer des données
echobase.action.showImportLogs=Liste des imports
echobase.action.toEnglish=En anglais
echobase.action.toFrench=En français
@@ -75,6 +76,7 @@
echobase.common.importDataMode=Type d'import
echobase.common.importDate=Date de l'import
echobase.common.importDbFile=
+echobase.common.importDbMode=Mode d'import
echobase.common.importError=Une erreur est survenue pendant l'import \:
echobase.common.importLogActions=Actions
echobase.common.importNotes=Remarques sur l'import
@@ -214,6 +216,9 @@
echobase.error.workingDbConfiguration.url.already.exists=Une configuration existe déjà avec cette url
echobase.error.workingDbConfiguration.url.required=Url jdbc obligatoire
echobase.header.request.result=Résultat de la requête SQL
+echobase.importDb.freeResult=L'import de type libre s'est déroulé avec succès en %s.
+echobase.importDb.legacyVoyageResult=L'import de type données ancienne s'est déroulé abec succès en %s.
+echobase.importDb.referentialResult=L'import de type référentiel s'est déroulé avec succès en %s.
echobase.info.click.to.select=Vous pouvez sélectionner la valeur en un simple click puis la copier (Ctrl-C)
echobase.info.dbeditor.propertyDiffsResult=Résultat d'import de données
echobase.info.documentation=Documentation en ligne d'EchoBase
@@ -278,7 +283,11 @@
echobase.legend.importData.configure=Configurer l'import
echobase.legend.importData.createMission=Caractéristiques de la mission
echobase.legend.importData.result.resume=Résultats
-echobase.legend.importDb.configuration.files=Choix du fichier à importer (fichier .zip)
+echobase.legend.importDb.configuration.files=Choix du fichier à importer (fichier .echobase)
+echobase.legend.importDb.configuration.freeMode=Configuration import "libre"
+echobase.legend.importDb.configuration.legacyVoyageMode=Configuration import "données"
+echobase.legend.importDb.configuration.referentialMode=Configuration import "référentiel"
+echobase.legend.importDb.configuration.selectImportDbMode=Choix du mode d'import
echobase.legend.libreOfficeQuery=Traduire une requête SQL issue de Libre Office
echobase.legend.sqlQuery.configuration=Définition de la requête
echobase.legend.sqlQuery.result=Résultats de la requête
@@ -292,6 +301,7 @@
echobase.menu.importData=Importer des données
echobase.menu.importDb=Importer une base complète
echobase.menu.logs=Journal des modifications
+echobase.menu.removeData=Supprimer des données
echobase.menu.users=Gérer les utilisateurs
echobase.menu.viewData=Visualiser les données
echobase.message.no.row.selected=Aucune donnée sélectionnée
Modified: trunk/echobase-ui/src/main/webapp/WEB-INF/includes/header.jsp
===================================================================
--- trunk/echobase-ui/src/main/webapp/WEB-INF/includes/header.jsp 2012-09-10 10:00:46 UTC (rev 640)
+++ trunk/echobase-ui/src/main/webapp/WEB-INF/includes/header.jsp 2012-09-10 14:06:45 UTC (rev 641)
@@ -110,6 +110,11 @@
</s:a>
</li>
<li>
+ <s:a action="importLogs" namespace="/removeData"
+ method="input" cssClass="delDonnee">
+ <span><s:text name="echobase.menu.removeData"/></s:a></span>
+ </li>
+ <li>
<s:a action="dbeditor" namespace="/dbeditor" cssClass="modif">
<span><s:text name="echobase.menu.editData"/></span>
</s:a>
Modified: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/home.jsp
===================================================================
--- trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/home.jsp 2012-09-10 10:00:46 UTC (rev 640)
+++ trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/home.jsp 2012-09-10 14:06:45 UTC (rev 641)
@@ -61,14 +61,4 @@
</li>
</ul>
</s:form>
-</s:if>
-<s:else>
- <s:form namespace="/removeData" action="importLogs">
- <ul class="toolbar floatLeft">
- <li>
- <s:submit theme="simple" action="importLogs"
- key="echobase.action.showImportLogs"/>
- </li>
- </ul>
- </s:form>
-</s:else>
\ No newline at end of file
+</s:if>
\ No newline at end of file
Modified: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/importDb/configure.jsp
===================================================================
--- trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/importDb/configure.jsp 2012-09-10 10:00:46 UTC (rev 640)
+++ trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/importDb/configure.jsp 2012-09-10 14:06:45 UTC (rev 641)
@@ -26,20 +26,111 @@
<title><s:text name="echobase.title.importDb"/></title>
+
+<script type="text/javascript">
+
+ jQuery(document).ready(function () {
+
+ // to change form when mode is changed
+ $('[name="model.importDbMode"]').change(function (event) {
+ $('[class~="importDbMode"]').hide();
+ $('#' + this.value).show();
+ $('#' + this.value + ' .errorMessage').hide();
+ });
+
+ // show incoming mode
+ var incomingVal = $('[name="model.importDbMode"][checked="checked"]').val();
+ $('#' + incomingVal).show();
+ });
+</script>
+
<s:form namespace="/importDb" method="POST" enctype="multipart/form-data">
<fieldset>
<legend>
- <s:text name="echobase.legend.importDb.configuration.files"/>
+ <s:text name="echobase.legend.importDb.configuration.selectImportDbMode"/>
</legend>
+ <s:radio key='model.importDbMode' list="modes" cssClass="cleanBoth"
+ label='%{getText("echobase.common.importDbMode")}'
+ required="true" template="myradiomap"/>
+ </fieldset>
+</s:form>
+
+<s:form id="REFERENTIAL" namespace="/importDb" method="POST"
+ enctype="multipart/form-data" cssClass="hidden importDbMode">
+
+ <fieldset>
+ <legend>
+ <s:text name="echobase.legend.importDb.configuration.referentialMode"/>
+ </legend>
+
+
+ <div class="cleanBoth help">
+ <s:a href="%{getDocumentation('importDb.html','referential')}"
+ target="doc">
+ <s:text name="echobase.action.show.importDb.documentation"/>
+ </s:a>
+ </div>
+ <br/>
+ <s:hidden key="model.importDbMode" value="REFERENTIAL" label=''/>
+
<s:file name="input" required="true"
key="echobase.common.importDbFile"/>
</fieldset>
<br/>
- <s:submit action="configure"
+ <s:submit action="configure-referential"
value='%{getText("echobase.action.import")}'/>
+</s:form>
+<s:form id="LEGACY_VOYAGE" namespace="/importDb" method="POST"
+ enctype="multipart/form-data" cssClass="hidden importDbMode">
+ <fieldset>
+ <legend>
+ <s:text name="echobase.legend.importDb.configuration.legacyVoyageMode"/>
+ </legend>
+
+ <div class="cleanBoth help">
+ <s:a href="%{getDocumentation('importDb.html','legacy-voyage')}"
+ target="doc">
+ <s:text name="echobase.action.show.importDb.documentation"/>
+ </s:a>
+ </div>
+ <br/>
+ <s:hidden key="model.importDbMode" value="LEGACY_VOYAGE" label=''/>
+
+ <s:file name="input" required="true"
+ key="echobase.common.importDbFile"/>
+
+ </fieldset>
+ <br/>
+ <s:submit action="configure-legacyVoyage"
+ value='%{getText("echobase.action.import")}'/>
+</s:form>
+
+<s:form id="FREE" namespace="/importDb" method="POST"
+ enctype="multipart/form-data" cssClass="hidden importDbMode">
+
+ <fieldset>
+ <legend>
+ <s:text name="echobase.legend.importDb.configuration.freeMode"/>
+ </legend>
+
+ <div class="cleanBoth help">
+ <s:a href="%{getDocumentation('importDb.html','free')}"
+ target="doc">
+ <s:text name="echobase.action.show.importDb.documentation"/>
+ </s:a>
+ </div>
+ <br/>
+ <s:hidden key="model.importDbMode" value="FREE" label=''/>
+
+ <s:file name="input" required="true" key="echobase.common.importDbFile"/>
+
+ </fieldset>
+ <br/>
+ <s:submit action="configure-free"
+ value='%{getText("echobase.action.import")}'/>
</s:form>
\ No newline at end of file
Modified: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/importDb/progress.jsp
===================================================================
--- trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/importDb/progress.jsp 2012-09-10 10:00:46 UTC (rev 640)
+++ trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/importDb/progress.jsp 2012-09-10 14:06:45 UTC (rev 641)
@@ -26,7 +26,7 @@
<%@ taglib prefix="sj" uri="/struts-jquery-tags" %>
<s:url id="url" action="import" namespace="/importDb"/>
-<meta http-equiv="refresh" content="5;url=${url}"/>
+<meta http-equiv="refresh" content="10;url=${url}"/>
<title><s:text name="echobase.title.importDbProgress"/></title>
Modified: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/importDb/result.jsp
===================================================================
--- trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/importDb/result.jsp 2012-09-10 10:00:46 UTC (rev 640)
+++ trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/importDb/result.jsp 2012-09-10 14:06:45 UTC (rev 641)
@@ -27,10 +27,6 @@
<title><s:text name="echobase.title.importDbResult"/></title>
<div>
- L'import de la base complête a réussi en <s:property value="model.actionTime"/>.
+ <s:property value="%{result}"/>
</div>
-<div>
- EchoBase possède désormais un référentiel et les campagnes contenues dans
- la sauvegarde importée.
-</div>
Modified: trunk/echobase-ui/src/main/webapp/css/screen.css
===================================================================
--- trunk/echobase-ui/src/main/webapp/css/screen.css 2012-09-10 10:00:46 UTC (rev 640)
+++ trunk/echobase-ui/src/main/webapp/css/screen.css 2012-09-10 14:06:45 UTC (rev 641)
@@ -632,6 +632,14 @@
.menu .expDonnee:hover{
background-position:-144px -48px;
}
+.menu .delDonnee{
+ background-position:-144px 0;
+}
+
+.menu .delDonnee:hover{
+ background-position:-144px -48px;
+}
+
.menu .modif{
background-position:-192px 0;
}
1
0
Author: tchemit
Date: 2012-09-10 12:00:46 +0200 (Mon, 10 Sep 2012)
New Revision: 640
Url: http://forge.codelutin.com/repositories/revision/echobase/640
Log:
add reunion CR
Added:
trunk/src/doc/reunions/reunion-2012-09-10.txt
Added: trunk/src/doc/reunions/reunion-2012-09-10.txt
===================================================================
--- trunk/src/doc/reunions/reunion-2012-09-10.txt (rev 0)
+++ trunk/src/doc/reunions/reunion-2012-09-10.txt 2012-09-10 10:00:46 UTC (rev 640)
@@ -0,0 +1,89 @@
+========
+Echobase
+========
+
+Lundi 10 septembre 2012 (Ifremer)
+
+Présents : Mathieu et Tony
+
+But
+===
+
+Point sur les suppressions d'import.
+
+Suppression des imports
+=======================
+
+Import Voyage/Transit/Transect
+------------------------------
+
+- voyage / echotypes / category
+
+Import Transect
+---------------
+
+- transect
+
+Import Opération
+----------------
+
+- Operation
+
+Import Catches
+--------------
+
+- Sample
+
+Import Acoustic
+---------------
+
+- DataAcquisition ou Cell
+
+Import Résultat Voyage
+----------------------
+
+- Tous les résultats pour le voyage + Echotype / Category
+
+Import Résultat Esdu
+--------------------
+
+- Result
+
+Import Résultat Région
+----------------------
+
+- Cell
+
+Import Résultat Map
+-------------------
+
+- Cell
+
+Discussion sur la doc
+=====================
+
+On pourrait utiliser les cartes mentales pour la doc utilisateur car c'est
+assez clair comme approche.
+
+A faire
+=======
+
+- Mathieu fournit une base minimale (avec des données de tests),
+ à intégrer dans les fichiers de release.
+- Tony
+ - continuer la doc
+ - ajouter dans la page d'accueil liens vers les fichiers téléchargeables + dans le footer rapport de bugs.
+ - Spliter l'import de la base complete en
+ - import reférentiel
+ - import voyages
+ - import all
+ avec plus de check (pour les deux premiers imports).
+ - Ajouter un importLog pour chaque voyage importer dans le deuxième type d'import
+ - Remplacer le .zip par .echobase dans les import export
+ - release 0.2
+
+Prochaine réunion
+=================
+
+- Jeudi 20 à 10 heures à la boutique mère pour parler du lissage des données.
+
Property changes on: trunk/src/doc/reunions/reunion-2012-09-10.txt
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
1
0
Author: mdoray
Date: 2012-09-10 10:59:53 +0200 (Mon, 10 Sep 2012)
New Revision: 639
Url: http://forge.codelutin.com/repositories/revision/echobase/639
Log:
>From scmwebeditor --
Modified:
trunk/src/site/en/rst/index.rst
Modified: trunk/src/site/en/rst/index.rst
===================================================================
--- trunk/src/site/en/rst/index.rst 2012-09-09 19:57:02 UTC (rev 638)
+++ trunk/src/site/en/rst/index.rst 2012-09-10 08:59:53 UTC (rev 639)
@@ -37,14 +37,14 @@
Echobase provide a web-browser interface for importing, editing and querying data,
large storage capacities, and an easy integration into Geographical Information Systems or dynamic websites.
-The Echobase acoustic metadata format follows the `ICES WGFAST`_.Topic Group on metadata standards recommendations.
+The Echobase acoustic metadata format follows the `ICES WGFAST`_ Topic Group on metadata standards recommendations.
Documentation
-------------
-- How to `install`_. Echobase.
+- How to `install`_ Echobase.
- The Echobase `model`_.
1
0
09 Sep '12
Author: tchemit
Date: 2012-09-09 21:57:02 +0200 (Sun, 09 Sep 2012)
New Revision: 638
Url: http://forge.codelutin.com/repositories/revision/echobase/638
Log:
refs #1437: Suppression des imports (add ui + implements strategies)
Added:
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/RemoveDataConfiguration.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/RemoveDataService.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/AbstractRemoveDataStrategy.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/AcousticRemoveDataStrategy.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/CatchesRemoveDataStrategy.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/CommonAllRemoveDataStrategy.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/CommonTransectRemoveDataStrategy.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/OperationRemoveDataStrategy.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/ResultEsduRemoveDataStrategy.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/ResultMapRemoveDataStrategy.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/ResultRegionRemoveDataStrategy.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/ResultVoyageRemoveDataStrategy.java
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/removeData/
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/removeData/ConfirmDelete.java
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/removeData/Delete.java
trunk/echobase-ui/src/main/resources/config/struts-removeData.xml
trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/removeData/
trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/removeData/confirmDelete.jsp
trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/removeData/dashboard.jsp
trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/removeData/deleteProgress.jsp
trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/removeData/deleteResult.jsp
trunk/echobase-ui/src/main/webapp/images/delete.png
trunk/src/site/rst/db.rst
trunk/src/site/rst/usage.rst
Removed:
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/AbstractRemoveDataService.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/AcousticRemoveDataService.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/CatchesRemoveDataService.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/CommonAllRemoveDataService.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/CommonTransectRemoveDataService.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/OperationRemoveDataService.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/ResultEsduRemoveDataService.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/ResultMapRemoveDataService.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/ResultRegionRemoveDataService.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/ResultVoyageRemoveDataService.java
Modified:
trunk/echobase-domain/src/main/java/fr/ifremer/echobase/services/EchoBaseServiceSupport.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/DbEditorService.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/AbstractImportDataService.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/AcousticImportService.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdb/ImportService.java
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/GetEntities.java
trunk/echobase-ui/src/main/resources/config/struts-exportDb.xml
trunk/echobase-ui/src/main/resources/config/struts-user.xml
trunk/echobase-ui/src/main/resources/config/struts-workingDb.xml
trunk/echobase-ui/src/main/resources/i18n/echobase-ui_en_GB.properties
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.xml
trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/home.jsp
trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/importData/configureResultsImport.jsp
trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/importData/resultResultsImport.jsp
trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/importDb/result.jsp
trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/workingDb/modifications.jsp
trunk/echobase-ui/src/main/webapp/js/gridHelper.js
trunk/src/site/rst/embedded.rst
Modified: trunk/echobase-domain/src/main/java/fr/ifremer/echobase/services/EchoBaseServiceSupport.java
===================================================================
--- trunk/echobase-domain/src/main/java/fr/ifremer/echobase/services/EchoBaseServiceSupport.java 2012-09-08 11:23:33 UTC (rev 637)
+++ trunk/echobase-domain/src/main/java/fr/ifremer/echobase/services/EchoBaseServiceSupport.java 2012-09-09 19:57:02 UTC (rev 638)
@@ -32,9 +32,11 @@
import org.apache.commons.lang3.StringUtils;
import org.nuiton.topia.TopiaContext;
import org.nuiton.topia.TopiaException;
+import org.nuiton.topia.TopiaNotFoundException;
import org.nuiton.topia.framework.TopiaContextImplementor;
import org.nuiton.topia.persistence.TopiaDAO;
import org.nuiton.topia.persistence.TopiaEntity;
+import org.nuiton.topia.persistence.TopiaId;
import java.util.Date;
import java.util.List;
@@ -188,6 +190,17 @@
throw new EchoBaseTechnicalException("Could not obtain query db", e);
}
}
+
+ protected <E extends TopiaEntity> TopiaDAO<E> getDAOFromId(String id) {
+ try {
+ return getDAO(TopiaId.getClassName(id));
+ } catch (TopiaNotFoundException e) {
+
+ throw new EchoBaseTechnicalException(
+ "Could not find class from id: " + id, e);
+ }
+ }
+
protected final <E extends TopiaEntity, D extends TopiaDAO<E>> D getDAO(Class<E> entityType, Class<D> daoType) {
TopiaDAO<E> dao = getDAO(entityType);
Preconditions.checkState(daoType.isAssignableFrom(dao.getClass()));
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 2012-09-08 11:23:33 UTC (rev 637)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/DbEditorService.java 2012-09-09 19:57:02 UTC (rev 638)
@@ -76,7 +76,7 @@
return getService(DecoratorService.class);
}
- public <E extends TopiaEntity> List<E> getForeignDatas(Class<E> entityType) {
+ public <E extends TopiaEntity> List<E> getForeignData(Class<E> entityType) {
Preconditions.checkNotNull(entityType);
try {
TopiaDAO<E> dao = getDAO(entityType);
@@ -95,10 +95,10 @@
}
//TODO Use an object to filter datas
- public Map<?, ?>[] getDatas(EchoBaseEntityEnum entityType,
- TopiaFilterPagerUtil.FilterPagerBean pager,
- String sidx,
- Boolean ascendantOrder) {
+ public Map<?, ?>[] getData(EchoBaseEntityEnum entityType,
+ TopiaFilterPagerUtil.FilterPagerBean pager,
+ String sidx,
+ Boolean ascendantOrder) {
TableMeta<EchoBaseEntityEnum> meta = getTableMeta(entityType);
@@ -294,7 +294,7 @@
TopiaDAO<E> dao = (TopiaDAO<E>) getDAO(tableMeta.getSource().getContract());
String hql = "FROM " +
- dao.getTopiaEntityEnum().getImplementationFQN()+" e";
+ dao.getTopiaEntityEnum().getImplementationFQN() + " e";
if (extraWhereQuery != null) {
hql += " WHERE " + extraWhereQuery;
}
@@ -551,7 +551,7 @@
if (columnMeta.isFK()) {
Class<TopiaEntity> entityType = (Class<TopiaEntity>) type;
- Collection<TopiaEntity> universe = getForeignDatas(entityType);
+ Collection<TopiaEntity> universe = getForeignData(entityType);
// translate foreign key to his id
model.addForeignKeyForImport(propertyName, entityType, universe);
@@ -607,6 +607,10 @@
model.addDefaultColumn(propertyName, type);
}
+ } else if ("importId".equals(propertyName) &&
+ Collection.class.equals(type)) {
+
+ // special case we do not want to deal with {@link ImportLog#importId}
} else {
model.addDefaultColumn(propertyName, type);
}
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/AbstractImportDataService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/AbstractImportDataService.java 2012-09-08 11:23:33 UTC (rev 637)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/AbstractImportDataService.java 2012-09-09 19:57:02 UTC (rev 638)
@@ -94,14 +94,9 @@
public static final TimeLog TIME_LOG =
new TimeLog(AbstractImportDataService.class);
- protected String importLabel;
-
public final String doImport(M configuration,
EchoBaseUser user) throws ImportException {
- Locale locale = getLocale();
- importLabel = l_(locale, configuration.getImportType().getI18nKey());
-
long s0 = TimeLog.getTime();
long nbSteps = configuration.computeNbSteps();
@@ -121,7 +116,7 @@
TimeLog.getTime() - s0);
// do commit
- commitTransaction("Could not execute import " + getImportLabel());
+ commitTransaction("Could not execute import " + getImportLabel(configuration));
return result;
} catch (EchoBaseTechnicalException e) {
throw new ImportException(e.getMessage(), e);
@@ -146,7 +141,7 @@
ImportLog.PROPERTY_IMPORT_TEXT, configuration.getImportNotes());
- String importType = getImportLabel();
+ String importType = getImportLabel(configuration);
StringBuilder buffer = new StringBuilder();
@@ -195,8 +190,10 @@
return result;
}
- protected final String getImportLabel() {
- return importLabel;
+ protected final String getImportLabel(M configuration) {
+ Locale locale = getLocale();
+ String result = l_(locale, configuration.getImportType().getI18nKey());
+ return result;
}
protected abstract void startImport(M configuration,
@@ -272,9 +269,9 @@
}
}
- protected String getImportMessage(InputFile inputFile) {
+ protected String getImportMessage(M configuration, InputFile inputFile) {
String message = l_(getLocale(), "echobase.importLabel.withFile",
- getImportLabel(), inputFile.getFileName());
+ getImportLabel(configuration), inputFile.getFileName());
return message;
}
@@ -284,7 +281,7 @@
configuration.incrementsProgression();
if (rowNumber % 1000 == 0) {
// flush each 1000 imported rows
- String message = getImportMessage(inputFile);
+ String message = getImportMessage(configuration, inputFile);
try {
long s0 = TimeLog.getTime();
flushTransaction();
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/AcousticImportService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/AcousticImportService.java 2012-09-08 11:23:33 UTC (rev 637)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/AcousticImportService.java 2012-09-09 19:57:02 UTC (rev 638)
@@ -142,7 +142,7 @@
InputFile inputFile = configuration.getMoviesFile();
if (log.isInfoEnabled()) {
- log.info("Starts " + getImportMessage(inputFile));
+ log.info("Starts " + getImportMessage(configuration, inputFile));
}
EchoBaseCsvFileImportResult importResult = newImportResult(inputFile);
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdb/ImportService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdb/ImportService.java 2012-09-08 11:23:33 UTC (rev 637)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdb/ImportService.java 2012-09-09 19:57:02 UTC (rev 638)
@@ -77,7 +77,7 @@
if (columnMeta.isFK()) {
Class<TopiaEntity> entityType = (Class<TopiaEntity>) type;
- Collection<TopiaEntity> universe = service.getForeignDatas(entityType);
+ Collection<TopiaEntity> universe = service.getForeignData(entityType);
model.addForeignKeyForImport(propertyName, entityType, universe);
} else {
model.addDefaultColumn(propertyName, type);
Deleted: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/AbstractRemoveDataService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/AbstractRemoveDataService.java 2012-09-08 11:23:33 UTC (rev 637)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/AbstractRemoveDataService.java 2012-09-09 19:57:02 UTC (rev 638)
@@ -1,239 +0,0 @@
-package fr.ifremer.echobase.services.removedata;
-
-/*
- * #%L
- * EchoBase :: Services
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2011 - 2012 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%
- */
-
-import com.google.common.collect.Lists;
-import fr.ifremer.echobase.EchoBaseTechnicalException;
-import fr.ifremer.echobase.entities.EchoBaseUser;
-import fr.ifremer.echobase.entities.EntityModificationLog;
-import fr.ifremer.echobase.entities.ImportLog;
-import fr.ifremer.echobase.entities.ImportType;
-import fr.ifremer.echobase.services.DecoratorService;
-import fr.ifremer.echobase.services.EchoBaseServiceSupport;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.nuiton.topia.TopiaException;
-import org.nuiton.topia.TopiaNotFoundException;
-import org.nuiton.topia.persistence.TopiaDAO;
-import org.nuiton.topia.persistence.TopiaEntity;
-import org.nuiton.topia.persistence.TopiaId;
-import org.nuiton.util.StringUtil;
-import org.nuiton.util.TimeLog;
-import org.nuiton.util.decorator.Decorator;
-
-import java.util.List;
-import java.util.Locale;
-import java.util.Set;
-
-import static org.nuiton.i18n.I18n.l_;
-
-/**
- * Abstract service to remove import data.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.2
- */
-public abstract class AbstractRemoveDataService extends EchoBaseServiceSupport {
-
- /** Logger. */
- private static final Log log =
- LogFactory.getLog(AbstractRemoveDataService.class);
-
- public static final TimeLog TIME_LOG =
- new TimeLog(AbstractRemoveDataService.class);
-
- protected static final String ID_REQUEST =
- "SELECT COUNT(*) FROM %s WHERE topiaid = :id";
-
- protected String importLabel;
-
- public String getImportLabel() {
- return importLabel;
- }
-
- protected abstract void removeData(String id);
-
- protected abstract Set<ImportType> getPossibleSubImportType();
-
- public String doRemove(ImportLog importLog, EchoBaseUser user) {
-
- Locale locale = getLocale();
- importLabel = l_(locale, importLog.getImportType().getI18nKey());
-
- long s0 = TimeLog.getTime();
-
- for (String importId : importLog.getImportId()) {
-
- removeData(importId);
- }
-
- s0 = TIME_LOG.log(s0, "removeData");
-
- List<ImportLog> removedImortLog = removeObsoleteImportLogs(importLog);
-
- s0 = TIME_LOG.log(s0, "removeObsoleteImportLogs");
-
- // add result in log book and compute resume to show in result
- String result = computeLogBookEntry(importLog,
- removedImortLog,
- user,
- TimeLog.getTime() - s0);
-
- // do commit
- commitTransaction("Could not remove import " + getImportLabel());
- return result;
- }
-
- protected List<ImportLog> removeObsoleteImportLogs(ImportLog importLog) {
-
- List<ImportLog> result = Lists.newArrayList();
-
- Set<ImportType> possibleSubImportType = getPossibleSubImportType();
-
- TopiaDAO<ImportLog> dao = getDAO(ImportLog.class);
-
- for (ImportLog logEntry : dao) {
-
- if (importLog.equals(logEntry)) {
-
- // for sure remove me
- // but do not add to result
- delete(dao, logEntry);
- continue;
- }
-
- if (possibleSubImportType.contains(logEntry.getImportType())) {
-
- // ok can try to remove this import log
- // try to find out if first id is still exists
- String firstId = importLog.getImportId().iterator().next();
-
- if (!isIdExists(firstId)) {
-
- // one of id does not exist, can safely remove importLog
-
- if (log.isInfoEnabled()) {
- log.info("Will remove obsolete importLog " +
- importLog.getTopiaId());
- }
-
- delete(dao, logEntry);
-
- // add it in result
- result.add(logEntry);
- }
- }
- }
- return result;
- }
-
- protected String computeLogBookEntry(ImportLog importLog,
- List<ImportLog> obsoleteImportLogs,
- EchoBaseUser user,
- long time) {
-
- Decorator<ImportLog> decorator = getService(DecoratorService.class).
- getDecorator(getLocale(), ImportLog.class, null);
-
- StringBuilder buffer = new StringBuilder();
- buffer.append("Suppression import ");
- buffer.append(decorator.toString(importLog));
- buffer.append("\nOpération réalisée en ");
- buffer.append(StringUtil.convertTime(time));
-
- for (ImportLog obsoleteImportLog : obsoleteImportLogs) {
-
- buffer.append("\n- Suppression en cascade de l'import ");
- buffer.append(decorator.toString(obsoleteImportLog));
- }
-
- String result = buffer.toString();
-
- if (log.isDebugEnabled()) {
- log.debug("Log text: " + result);
- }
- create(getDAO(EntityModificationLog.class),
- EntityModificationLog.PROPERTY_ENTITY_TYPE, "Remove Import",
- EntityModificationLog.PROPERTY_ENTITY_ID, importLog.getImportType(),
- EntityModificationLog.PROPERTY_MODIFICATION_USER, user.getEmail(),
- EntityModificationLog.PROPERTY_MODIFICATION_DATE, newDate(),
- EntityModificationLog.PROPERTY_MODIFICATION_TEXT, result
- );
- return result;
- }
-
- protected boolean isIdExists(String id) {
-
- try {
-
- boolean result = getDAOFromId(id).existByTopiaId(id);
- return result;
- } catch (TopiaException e) {
- throw new EchoBaseTechnicalException(
- "Could not find out if id " + id + " exists.", e);
- }
- }
-
- protected <E extends TopiaEntity> E findById(TopiaDAO<E> dao, String id) {
-
- try {
- E result = dao.findByTopiaId(id);
- return result;
- } catch (TopiaException e) {
- throw new EchoBaseTechnicalException("Could not find entity with id " + id, e);
- }
- }
-
- protected <E extends TopiaEntity> TopiaDAO<E> getDAOFromId(String id) {
- try {
- return getDAO(TopiaId.getClassName(id));
- } catch (TopiaNotFoundException e) {
-
- throw new EchoBaseTechnicalException(
- "Could not find class from id: " + id, e);
- }
- }
-
- protected <E extends TopiaEntity> E removeEntity(String id) {
-
- // get dao
- TopiaDAO<E> dao = getDAOFromId(id);
-
- // get entity to delete
- E entity = findById(dao, id);
-
- // delete it
- delete(dao, entity);
-
- return entity;
- }
-
-
- protected void canNotDealWithId(String id) {
- throw new IllegalStateException(
- "Can not deal with this type of id " + id +
- " from service " + this);
- }
-
-}
Deleted: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/AcousticRemoveDataService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/AcousticRemoveDataService.java 2012-09-08 11:23:33 UTC (rev 637)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/AcousticRemoveDataService.java 2012-09-09 19:57:02 UTC (rev 638)
@@ -1,90 +0,0 @@
-package fr.ifremer.echobase.services.removedata;
-
-/*
- * #%L
- * EchoBase :: Services
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2011 - 2012 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%
- */
-
-import com.google.common.collect.Sets;
-import fr.ifremer.echobase.entities.ImportType;
-import fr.ifremer.echobase.entities.data.Cell;
-import fr.ifremer.echobase.entities.data.DataAcquisition;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import java.util.HashSet;
-import java.util.Set;
-
-/**
- * Remove a {@link ImportType#ACOUSTIC} import.
- * <p/>
- * Can remove only {@link DataAcquisition} or {@link Cell}.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.2
- */
-public class AcousticRemoveDataService extends AbstractRemoveDataService {
-
- /** Logger. */
- private static final Log log =
- LogFactory.getLog(AcousticRemoveDataService.class);
-
- @Override
- protected void removeData(String id) {
-
- if (id.startsWith(DataAcquisition.class.getName())) {
-
- // remove dataAcquisition
- removeDataAcquisition(id);
- } else if (id.startsWith(Cell.class.getName())) {
-
- // remove cell
- removeCell(id);
- } else {
- canNotDealWithId(id);
- }
- }
-
- protected void removeDataAcquisition(String id) {
- DataAcquisition entity = removeEntity(id);
- if (log.isInfoEnabled()) {
- log.info("DataAcquisition " + entity.getTopiaId() + " was removed");
- }
- }
-
- protected void removeCell(String id) {
- Cell entity = removeEntity(id);
- if (log.isInfoEnabled()) {
- log.info("Cell " + entity.getTopiaId() + " was removed");
- }
- }
-
- @Override
- protected Set<ImportType> getPossibleSubImportType() {
- HashSet<ImportType> result = Sets.newHashSet(ImportType.values());
- result.remove(ImportType.COMMON_ALL);
- result.remove(ImportType.COMMON_TRANSECT);
- result.remove(ImportType.OPERATION);
- result.remove(ImportType.CATCHES);
- result.remove(ImportType.ACOUSTIC);
- return result;
- }
-}
Deleted: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/CatchesRemoveDataService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/CatchesRemoveDataService.java 2012-09-08 11:23:33 UTC (rev 637)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/CatchesRemoveDataService.java 2012-09-09 19:57:02 UTC (rev 638)
@@ -1,77 +0,0 @@
-package fr.ifremer.echobase.services.removedata;
-
-/*
- * #%L
- * EchoBase :: Services
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2011 - 2012 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%
- */
-
-import com.google.common.collect.Sets;
-import fr.ifremer.echobase.entities.ImportType;
-import fr.ifremer.echobase.entities.data.Sample;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import java.util.HashSet;
-import java.util.Set;
-
-/**
- * Remove a {@link ImportType#CATCHES} import.
- * <p/>
- * Can remove only {@link Sample}.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.2
- */
-public class CatchesRemoveDataService extends AbstractRemoveDataService {
-
- /** Logger. */
- private static final Log log =
- LogFactory.getLog(CatchesRemoveDataService.class);
-
- @Override
- protected void removeData(String id) {
-
- if (id.startsWith(Sample.class.getName())) {
-
- // remove sample
- removeSample(id);
- } else {
- canNotDealWithId(id);
- }
- }
-
- protected void removeSample(String id) {
- Sample entity = removeEntity(id);
- if (log.isInfoEnabled()) {
- log.info("Sample " + entity.getTopiaId() + " was removed");
- }
- }
-
- @Override
- protected Set<ImportType> getPossibleSubImportType() {
- HashSet<ImportType> result = Sets.newHashSet(ImportType.values());
- result.remove(ImportType.COMMON_ALL);
- result.remove(ImportType.COMMON_TRANSECT);
- result.remove(ImportType.OPERATION);
- result.remove(ImportType.CATCHES);
- return result;
- }
-}
Deleted: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/CommonAllRemoveDataService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/CommonAllRemoveDataService.java 2012-09-08 11:23:33 UTC (rev 637)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/CommonAllRemoveDataService.java 2012-09-09 19:57:02 UTC (rev 638)
@@ -1,75 +0,0 @@
-package fr.ifremer.echobase.services.removedata;
-
-/*
- * #%L
- * EchoBase :: Services
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2011 - 2012 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%
- */
-
-import com.google.common.collect.Sets;
-import fr.ifremer.echobase.entities.ImportType;
-import fr.ifremer.echobase.entities.data.Voyage;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import java.util.HashSet;
-import java.util.Set;
-
-/**
- * Remove a {@link ImportType#COMMON_ALL} import.
- * <p/>
- * Can remove only {@link Voyage}.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.2
- */
-public class CommonAllRemoveDataService extends AbstractRemoveDataService {
-
- /** Logger. */
- private static final Log log =
- LogFactory.getLog(CommonAllRemoveDataService.class);
-
- @Override
- protected void removeData(String id) {
-
- if (id.startsWith(Voyage.class.getName())) {
-
- // remove voyage
- removeVoyage(id);
- } else {
- canNotDealWithId(id);
- }
- }
-
- protected void removeVoyage(String id) {
- Voyage entity = removeEntity(id);
- if (log.isInfoEnabled()) {
- log.info("Voyage " + entity.getTopiaId() + " was removed");
- }
- }
-
- @Override
- protected Set<ImportType> getPossibleSubImportType() {
- HashSet<ImportType> result = Sets.newHashSet(ImportType.values());
- result.remove(ImportType.COMMON_ALL);
- result.remove(ImportType.COMMON_TRANSECT);
- return result;
- }
-}
Deleted: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/CommonTransectRemoveDataService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/CommonTransectRemoveDataService.java 2012-09-08 11:23:33 UTC (rev 637)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/CommonTransectRemoveDataService.java 2012-09-09 19:57:02 UTC (rev 638)
@@ -1,75 +0,0 @@
-package fr.ifremer.echobase.services.removedata;
-
-/*
- * #%L
- * EchoBase :: Services
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2011 - 2012 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%
- */
-
-import com.google.common.collect.Sets;
-import fr.ifremer.echobase.entities.ImportType;
-import fr.ifremer.echobase.entities.data.Transect;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import java.util.HashSet;
-import java.util.Set;
-
-/**
- * Remove a {@link ImportType#COMMON_TRANSECT} import.
- * <p/>
- * Can remove only {@link Transect}.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.2
- */
-public class CommonTransectRemoveDataService extends AbstractRemoveDataService {
-
- /** Logger. */
- private static final Log log =
- LogFactory.getLog(CommonTransectRemoveDataService.class);
-
- @Override
- protected void removeData(String id) {
-
- if (id.startsWith(Transect.class.getName())) {
-
- // remove transect
- removeTransect(id);
- } else {
- canNotDealWithId(id);
- }
- }
-
- protected void removeTransect(String id) {
- Transect entity = removeEntity(id);
- if (log.isInfoEnabled()) {
- log.info("Transect " + entity.getTopiaId() + " was removed");
- }
- }
-
- @Override
- protected Set<ImportType> getPossibleSubImportType() {
- HashSet<ImportType> result = Sets.newHashSet(ImportType.values());
- result.remove(ImportType.COMMON_ALL);
- result.remove(ImportType.COMMON_TRANSECT);
- return result;
- }
-}
Deleted: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/OperationRemoveDataService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/OperationRemoveDataService.java 2012-09-08 11:23:33 UTC (rev 637)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/OperationRemoveDataService.java 2012-09-09 19:57:02 UTC (rev 638)
@@ -1,76 +0,0 @@
-package fr.ifremer.echobase.services.removedata;
-
-/*
- * #%L
- * EchoBase :: Services
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2011 - 2012 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%
- */
-
-import com.google.common.collect.Sets;
-import fr.ifremer.echobase.entities.ImportType;
-import fr.ifremer.echobase.entities.data.Operation;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import java.util.HashSet;
-import java.util.Set;
-
-/**
- * Remove a {@link ImportType#OPERATION} import.
- * <p/>
- * Can remove only {@link Operation}.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.2
- */
-public class OperationRemoveDataService extends AbstractRemoveDataService {
-
- /** Logger. */
- private static final Log log =
- LogFactory.getLog(OperationRemoveDataService.class);
-
- @Override
- protected void removeData(String id) {
-
- if (id.startsWith(Operation.class.getName())) {
-
- // remove operation
- removeOperation(id);
- } else {
- canNotDealWithId(id);
- }
- }
-
- protected void removeOperation(String id) {
- Operation entity = removeEntity(id);
- if (log.isInfoEnabled()) {
- log.info("Operation " + entity.getTopiaId() + " was removed");
- }
- }
-
- @Override
- protected Set<ImportType> getPossibleSubImportType() {
- HashSet<ImportType> result = Sets.newHashSet(ImportType.values());
- result.remove(ImportType.COMMON_ALL);
- result.remove(ImportType.COMMON_TRANSECT);
- result.remove(ImportType.OPERATION);
- return result;
- }
-}
Added: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/RemoveDataConfiguration.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/RemoveDataConfiguration.java (rev 0)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/RemoveDataConfiguration.java 2012-09-09 19:57:02 UTC (rev 638)
@@ -0,0 +1,47 @@
+package fr.ifremer.echobase.services.removedata;
+
+/*
+ * #%L
+ * EchoBase :: Services
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 - 2012 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%
+ */
+
+import fr.ifremer.echobase.services.AbstractEchobaseActionConfiguration;
+
+/**
+ * Configuration for a remve data action.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.2
+ */
+public class RemoveDataConfiguration extends AbstractEchobaseActionConfiguration {
+
+ private static final long serialVersionUID = 1L;
+
+ private String importLogId;
+
+ public String getImportLogId() {
+ return importLogId;
+ }
+
+ public void setImportLogId(String importLogId) {
+ this.importLogId = importLogId;
+ }
+}
Property changes on: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/RemoveDataConfiguration.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/RemoveDataService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/RemoveDataService.java (rev 0)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/RemoveDataService.java 2012-09-09 19:57:02 UTC (rev 638)
@@ -0,0 +1,226 @@
+package fr.ifremer.echobase.services.removedata;
+
+/*
+ * #%L
+ * EchoBase :: Services
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 - 2012 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%
+ */
+
+import com.google.common.base.Preconditions;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import fr.ifremer.echobase.EchoBaseTechnicalException;
+import fr.ifremer.echobase.entities.EchoBaseUser;
+import fr.ifremer.echobase.entities.EntityModificationLog;
+import fr.ifremer.echobase.entities.ImportLog;
+import fr.ifremer.echobase.entities.ImportType;
+import fr.ifremer.echobase.services.DecoratorService;
+import fr.ifremer.echobase.services.EchoBaseServiceSupport;
+import fr.ifremer.echobase.services.removedata.strategy.AbstractRemoveDataStrategy;
+import fr.ifremer.echobase.services.removedata.strategy.AcousticRemoveDataStrategy;
+import fr.ifremer.echobase.services.removedata.strategy.CatchesRemoveDataStrategy;
+import fr.ifremer.echobase.services.removedata.strategy.CommonAllRemoveDataStrategy;
+import fr.ifremer.echobase.services.removedata.strategy.CommonTransectRemoveDataStrategy;
+import fr.ifremer.echobase.services.removedata.strategy.OperationRemoveDataStrategy;
+import fr.ifremer.echobase.services.removedata.strategy.ResultEsduRemoveDataStrategy;
+import fr.ifremer.echobase.services.removedata.strategy.ResultMapRemoveDataStrategy;
+import fr.ifremer.echobase.services.removedata.strategy.ResultRegionRemoveDataStrategy;
+import fr.ifremer.echobase.services.removedata.strategy.ResultVoyageRemoveDataStrategy;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.topia.TopiaException;
+import org.nuiton.topia.persistence.TopiaDAO;
+import org.nuiton.util.StringUtil;
+import org.nuiton.util.TimeLog;
+import org.nuiton.util.decorator.Decorator;
+
+import java.util.EnumMap;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * Service to remove an import data.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.2
+ */
+public class RemoveDataService extends EchoBaseServiceSupport {
+
+ /** Logger. */
+ private static final Log log = LogFactory.getLog(RemoveDataService.class);
+
+
+ public static final TimeLog TIME_LOG = new TimeLog(RemoveDataService.class);
+
+ protected static EnumMap<ImportType, Class<? extends AbstractRemoveDataStrategy>> strategies;
+
+ public static Class<? extends AbstractRemoveDataStrategy> getStrategy(ImportType importType) {
+ if (strategies == null) {
+ strategies = Maps.newEnumMap(ImportType.class);
+ strategies.put(ImportType.COMMON_ALL, CommonAllRemoveDataStrategy.class);
+ strategies.put(ImportType.COMMON_TRANSECT, CommonTransectRemoveDataStrategy.class);
+ strategies.put(ImportType.OPERATION, OperationRemoveDataStrategy.class);
+ strategies.put(ImportType.CATCHES, CatchesRemoveDataStrategy.class);
+ strategies.put(ImportType.ACOUSTIC, AcousticRemoveDataStrategy.class);
+ strategies.put(ImportType.RESULT_VOYAGE, ResultVoyageRemoveDataStrategy.class);
+ strategies.put(ImportType.RESULT_ESDU, ResultEsduRemoveDataStrategy.class);
+ strategies.put(ImportType.RESULT_MAP, ResultMapRemoveDataStrategy.class);
+ strategies.put(ImportType.RESULT_REGION, ResultRegionRemoveDataStrategy.class);
+ Preconditions.checkState(
+ ImportType.values().length == strategies.size(),
+ "It miss some remove data strategies...");
+ }
+ return strategies.get(importType);
+ }
+
+ public String removeImport(RemoveDataConfiguration model, EchoBaseUser user) {
+
+ String importLogId = model.getImportLogId();
+
+ ImportLog importLog = getEntityById(ImportLog.class, importLogId);
+
+ int nbSteps = importLog.getImportId().size() + 3;
+ model.setNbSteps(nbSteps);
+
+ ImportType importType = importLog.getImportType();
+
+ Class<? extends AbstractRemoveDataStrategy> strategyType =
+ getStrategy(importType);
+
+ long s0 = TimeLog.getTime();
+ AbstractRemoveDataStrategy strategy = getService(strategyType);
+
+ strategy.doRemove(model, importLog);
+
+ s0 = TIME_LOG.log(s0, "removeData");
+
+ List<ImportLog> removedImportLog = removeObsoleteImportLogs(strategy,
+ importLog);
+
+ model.incrementsProgression();
+ s0 = TIME_LOG.log(s0, "removeObsoleteImportLogs");
+
+ // add result in log book and compute resume to show in result
+ String result = computeLogBookEntry(importLog,
+ removedImportLog,
+ user,
+ TimeLog.getTime() - s0);
+
+ model.incrementsProgression();
+ // do commit
+ commitTransaction("Could not remove import " +
+ strategy.getImportLabel());
+
+ model.incrementsProgression();
+ return result;
+ }
+
+ protected List<ImportLog> removeObsoleteImportLogs(AbstractRemoveDataStrategy strategy,
+ ImportLog importLog) {
+
+ List<ImportLog> result = Lists.newArrayList();
+
+ Set<ImportType> possibleSubImportType =
+ strategy.getPossibleSubImportType();
+
+ TopiaDAO<ImportLog> dao = getDAO(ImportLog.class);
+
+ for (ImportLog logEntry : dao) {
+
+ if (importLog.equals(logEntry)) {
+
+ // for sure remove me
+ // but do not add to result
+ delete(dao, logEntry);
+ continue;
+ }
+
+ if (possibleSubImportType.contains(logEntry.getImportType())) {
+
+ // ok can try to remove this import log
+ // try to find out if first id is still exists
+ String firstId = importLog.getImportId().iterator().next();
+
+ if (!isIdExists(firstId)) {
+
+ // one of id does not exist, can safely remove importLog
+
+ if (log.isInfoEnabled()) {
+ log.info("Will remove obsolete importLog " +
+ importLog.getTopiaId());
+ }
+
+ delete(dao, logEntry);
+
+ // add it in result
+ result.add(logEntry);
+ }
+ }
+ }
+ return result;
+ }
+
+ protected String computeLogBookEntry(ImportLog importLog,
+ List<ImportLog> obsoleteImportLogs,
+ EchoBaseUser user,
+ long time) {
+
+ Decorator<ImportLog> decorator = getService(DecoratorService.class).
+ getDecorator(getLocale(), ImportLog.class, null);
+
+ StringBuilder buffer = new StringBuilder();
+ buffer.append("Suppression import ");
+ buffer.append(decorator.toString(importLog));
+ buffer.append("\nOpération réalisée en ");
+ buffer.append(StringUtil.convertTime(time));
+
+ for (ImportLog obsoleteImportLog : obsoleteImportLogs) {
+
+ buffer.append("\n- Suppression en cascade de l'import ");
+ buffer.append(decorator.toString(obsoleteImportLog));
+ }
+
+ String result = buffer.toString();
+
+ if (log.isDebugEnabled()) {
+ log.debug("Log text: " + result);
+ }
+ create(getDAO(EntityModificationLog.class),
+ EntityModificationLog.PROPERTY_ENTITY_TYPE, "Remove Import",
+ EntityModificationLog.PROPERTY_ENTITY_ID, decorator.toString(importLog),
+ EntityModificationLog.PROPERTY_MODIFICATION_USER, user.getEmail(),
+ EntityModificationLog.PROPERTY_MODIFICATION_DATE, newDate(),
+ EntityModificationLog.PROPERTY_MODIFICATION_TEXT, result
+ );
+ return result;
+ }
+
+ protected boolean isIdExists(String id) {
+
+ try {
+
+ boolean result = getDAOFromId(id).existByTopiaId(id);
+ return result;
+ } catch (TopiaException e) {
+ throw new EchoBaseTechnicalException(
+ "Could not find out if id " + id + " exists.", e);
+ }
+ }
+}
Property changes on: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/RemoveDataService.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Deleted: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/ResultEsduRemoveDataService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/ResultEsduRemoveDataService.java 2012-09-08 11:23:33 UTC (rev 637)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/ResultEsduRemoveDataService.java 2012-09-09 19:57:02 UTC (rev 638)
@@ -1,80 +0,0 @@
-package fr.ifremer.echobase.services.removedata;
-
-/*
- * #%L
- * EchoBase :: Services
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2011 - 2012 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%
- */
-
-import com.google.common.collect.Sets;
-import fr.ifremer.echobase.entities.ImportType;
-import fr.ifremer.echobase.entities.data.Result;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import java.util.HashSet;
-import java.util.Set;
-
-/**
- * Remove a {@link ImportType#RESULT_ESDU} import.
- * <p/>
- * Can remove only {@link Result}.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.2
- */
-public class ResultEsduRemoveDataService extends AbstractRemoveDataService {
-
- /** Logger. */
- private static final Log log =
- LogFactory.getLog(ResultEsduRemoveDataService.class);
-
- @Override
- protected void removeData(String id) {
-
- if (id.startsWith(Result.class.getName())) {
-
- // remove result
- removeResult(id);
- } else {
- canNotDealWithId(id);
- }
- }
-
- protected void removeResult(String id) {
- Result entity = removeEntity(id);
- if (log.isInfoEnabled()) {
- log.info("Result " + entity.getTopiaId() + " was removed");
- }
- }
-
- @Override
- protected Set<ImportType> getPossibleSubImportType() {
- HashSet<ImportType> result = Sets.newHashSet(ImportType.values());
- result.remove(ImportType.COMMON_ALL);
- result.remove(ImportType.COMMON_TRANSECT);
- result.remove(ImportType.OPERATION);
- result.remove(ImportType.CATCHES);
- result.remove(ImportType.ACOUSTIC);
- result.remove(ImportType.RESULT_VOYAGE);
- result.remove(ImportType.RESULT_ESDU);
- return result;
- }
-}
Deleted: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/ResultMapRemoveDataService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/ResultMapRemoveDataService.java 2012-09-08 11:23:33 UTC (rev 637)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/ResultMapRemoveDataService.java 2012-09-09 19:57:02 UTC (rev 638)
@@ -1,73 +0,0 @@
-package fr.ifremer.echobase.services.removedata;
-
-/*
- * #%L
- * EchoBase :: Services
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2011 - 2012 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%
- */
-
-import com.google.common.collect.Sets;
-import fr.ifremer.echobase.entities.ImportType;
-import fr.ifremer.echobase.entities.data.Cell;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import java.util.HashSet;
-import java.util.Set;
-
-/**
- * Remove a {@link ImportType#RESULT_MAP} import.
- * <p/>
- * Can remove only {@link Cell}.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.2
- */
-public class ResultMapRemoveDataService extends AbstractRemoveDataService {
-
- /** Logger. */
- private static final Log log =
- LogFactory.getLog(ResultMapRemoveDataService.class);
-
- @Override
- protected void removeData(String id) {
-
- if (id.startsWith(Cell.class.getName())) {
-
- // remove cell
- removeCell(id);
- } else {
- canNotDealWithId(id);
- }
- }
-
- protected void removeCell(String id) {
- Cell entity = removeEntity(id);
- if (log.isInfoEnabled()) {
- log.info("Cell " + entity.getTopiaId() + " was removed");
- }
- }
-
- @Override
- protected Set<ImportType> getPossibleSubImportType() {
- HashSet<ImportType> result = Sets.newHashSet();
- return result;
- }
-}
Deleted: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/ResultRegionRemoveDataService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/ResultRegionRemoveDataService.java 2012-09-08 11:23:33 UTC (rev 637)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/ResultRegionRemoveDataService.java 2012-09-09 19:57:02 UTC (rev 638)
@@ -1,81 +0,0 @@
-package fr.ifremer.echobase.services.removedata;
-
-/*
- * #%L
- * EchoBase :: Services
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2011 - 2012 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%
- */
-
-import com.google.common.collect.Sets;
-import fr.ifremer.echobase.entities.ImportType;
-import fr.ifremer.echobase.entities.data.Cell;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import java.util.HashSet;
-import java.util.Set;
-
-/**
- * Remove a {@link ImportType#RESULT_REGION} import.
- * <p/>
- * Can remove only {@link Cell}.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.2
- */
-public class ResultRegionRemoveDataService extends AbstractRemoveDataService {
-
- /** Logger. */
- private static final Log log =
- LogFactory.getLog(ResultRegionRemoveDataService.class);
-
- @Override
- protected void removeData(String id) {
-
- if (id.startsWith(Cell.class.getName())) {
-
- // remove echotype
- removeCell(id);
- } else {
- canNotDealWithId(id);
- }
- }
-
- protected void removeCell(String id) {
- Cell entity = removeEntity(id);
- if (log.isInfoEnabled()) {
- log.info("Cell " + entity.getTopiaId() + " was removed");
- }
- }
-
- @Override
- protected Set<ImportType> getPossibleSubImportType() {
- HashSet<ImportType> result = Sets.newHashSet(ImportType.values());
- result.remove(ImportType.COMMON_ALL);
- result.remove(ImportType.COMMON_TRANSECT);
- result.remove(ImportType.OPERATION);
- result.remove(ImportType.CATCHES);
- result.remove(ImportType.ACOUSTIC);
- result.remove(ImportType.RESULT_VOYAGE);
- result.remove(ImportType.RESULT_ESDU);
- result.remove(ImportType.RESULT_VOYAGE);
- return result;
- }
-}
Deleted: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/ResultVoyageRemoveDataService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/ResultVoyageRemoveDataService.java 2012-09-08 11:23:33 UTC (rev 637)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/ResultVoyageRemoveDataService.java 2012-09-09 19:57:02 UTC (rev 638)
@@ -1,104 +0,0 @@
-package fr.ifremer.echobase.services.removedata;
-
-/*
- * #%L
- * EchoBase :: Services
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2011 - 2012 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%
- */
-
-import com.google.common.collect.Sets;
-import fr.ifremer.echobase.entities.ImportType;
-import fr.ifremer.echobase.entities.data.Echotype;
-import fr.ifremer.echobase.entities.data.LengthAgeKey;
-import fr.ifremer.echobase.entities.data.LengthWeightKey;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import java.util.HashSet;
-import java.util.Set;
-
-/**
- * remove a {@link ImportType#OPERATION} import.
- * <p/>
- * Can remove only {@link Echotype}, {@link LengthAgeKey} or
- * {@link LengthWeightKey}.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.2
- */
-public class ResultVoyageRemoveDataService extends AbstractRemoveDataService {
-
- /** Logger. */
- private static final Log log =
- LogFactory.getLog(ResultVoyageRemoveDataService.class);
-
- @Override
- protected void removeData(String id) {
-
- if (id.startsWith(Echotype.class.getName())) {
-
- // remove echotype
- removeEchotype(id);
- } else if (id.startsWith(LengthAgeKey.class.getName())) {
-
- // remove lengthAgeKey
- removeLengthAgeKey(id);
- } else if (id.startsWith(LengthWeightKey.class.getName())) {
-
- // remove lengthAgeKey
- removeLengthWeightKey(id);
- } else {
- canNotDealWithId(id);
- }
- }
-
- protected void removeEchotype(String id) {
- Echotype entity = removeEntity(id);
- if (log.isInfoEnabled()) {
- log.info("Echotype " + entity.getTopiaId() + " was removed");
- }
- }
-
- protected void removeLengthAgeKey(String id) {
- LengthAgeKey entity = removeEntity(id);
- if (log.isInfoEnabled()) {
- log.info("LengthAgeKey " + entity.getTopiaId() + " was removed");
- }
- }
-
- protected void removeLengthWeightKey(String id) {
- LengthWeightKey entity = removeEntity(id);
- if (log.isInfoEnabled()) {
- log.info("LengthWeightKey " + entity.getTopiaId() + " was removed");
- }
- }
-
- @Override
- protected Set<ImportType> getPossibleSubImportType() {
- HashSet<ImportType> result = Sets.newHashSet(ImportType.values());
- result.remove(ImportType.COMMON_ALL);
- result.remove(ImportType.COMMON_TRANSECT);
- result.remove(ImportType.OPERATION);
- result.remove(ImportType.CATCHES);
- result.remove(ImportType.ACOUSTIC);
- result.remove(ImportType.RESULT_VOYAGE);
- return result;
- }
-}
Copied: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/AbstractRemoveDataStrategy.java (from rev 636, trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/AbstractRemoveDataService.java)
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/AbstractRemoveDataStrategy.java (rev 0)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/AbstractRemoveDataStrategy.java 2012-09-09 19:57:02 UTC (rev 638)
@@ -0,0 +1,106 @@
+package fr.ifremer.echobase.services.removedata.strategy;
+
+/*
+ * #%L
+ * EchoBase :: Services
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 - 2012 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%
+ */
+
+import fr.ifremer.echobase.EchoBaseTechnicalException;
+import fr.ifremer.echobase.entities.ImportLog;
+import fr.ifremer.echobase.entities.ImportType;
+import fr.ifremer.echobase.services.EchoBaseServiceSupport;
+import fr.ifremer.echobase.services.removedata.RemoveDataConfiguration;
+import org.nuiton.topia.TopiaException;
+import org.nuiton.topia.persistence.TopiaDAO;
+import org.nuiton.topia.persistence.TopiaEntity;
+
+import java.util.Set;
+
+/**
+ * Abstract service to remove import data.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.2
+ */
+public abstract class AbstractRemoveDataStrategy extends EchoBaseServiceSupport {
+
+ protected String importLabel;
+
+ public String getImportLabel() {
+ return importLabel;
+ }
+
+ protected abstract void removeData(String id);
+
+ public abstract Set<ImportType> getPossibleSubImportType();
+
+ public void doRemove(RemoveDataConfiguration model, ImportLog importLog) {
+
+ int currentIndex = 0;
+ for (String importId : importLog.getImportId()) {
+
+ currentIndex++;
+
+ if (currentIndex % 1000 == 0) {
+ try {
+ flushTransaction();
+ } catch (TopiaException e) {
+ throw new EchoBaseTechnicalException(
+ "Could not flush transaction", e);
+ }
+ }
+ model.incrementsProgression();
+
+ removeData(importId);
+ }
+ }
+
+ protected <E extends TopiaEntity> E findById(TopiaDAO<E> dao, String id) {
+
+ try {
+ E result = dao.findByTopiaId(id);
+ return result;
+ } catch (TopiaException e) {
+ throw new EchoBaseTechnicalException("Could not find entity with id " + id, e);
+ }
+ }
+
+ protected <E extends TopiaEntity> E removeEntity(String id) {
+
+ // get dao
+ TopiaDAO<E> dao = getDAOFromId(id);
+
+ // get entity to delete
+ E entity = findById(dao, id);
+
+ // delete it
+ delete(dao, entity);
+
+ return entity;
+ }
+
+ protected void canNotDealWithId(String id) {
+ throw new IllegalStateException(
+ "Can not deal with this type of id " + id +
+ " from service " + this);
+ }
+
+}
Property changes on: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/AbstractRemoveDataStrategy.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/AcousticRemoveDataStrategy.java (from rev 636, trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/AcousticRemoveDataService.java)
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/AcousticRemoveDataStrategy.java (rev 0)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/AcousticRemoveDataStrategy.java 2012-09-09 19:57:02 UTC (rev 638)
@@ -0,0 +1,90 @@
+package fr.ifremer.echobase.services.removedata.strategy;
+
+/*
+ * #%L
+ * EchoBase :: Services
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 - 2012 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%
+ */
+
+import com.google.common.collect.Sets;
+import fr.ifremer.echobase.entities.ImportType;
+import fr.ifremer.echobase.entities.data.Cell;
+import fr.ifremer.echobase.entities.data.DataAcquisition;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * Remove a {@link ImportType#ACOUSTIC} import.
+ * <p/>
+ * Can remove only {@link DataAcquisition} or {@link Cell}.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.2
+ */
+public class AcousticRemoveDataStrategy extends AbstractRemoveDataStrategy {
+
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(AcousticRemoveDataStrategy.class);
+
+ @Override
+ protected void removeData(String id) {
+
+ if (id.startsWith(DataAcquisition.class.getName())) {
+
+ // remove dataAcquisition
+ removeDataAcquisition(id);
+ } else if (id.startsWith(Cell.class.getName())) {
+
+ // remove cell
+ removeCell(id);
+ } else {
+ canNotDealWithId(id);
+ }
+ }
+
+ protected void removeDataAcquisition(String id) {
+ DataAcquisition entity = removeEntity(id);
+ if (log.isInfoEnabled()) {
+ log.info("DataAcquisition " + entity.getTopiaId() + " was removed");
+ }
+ }
+
+ protected void removeCell(String id) {
+ Cell entity = removeEntity(id);
+ if (log.isInfoEnabled()) {
+ log.info("Cell " + entity.getTopiaId() + " was removed");
+ }
+ }
+
+ @Override
+ public Set<ImportType> getPossibleSubImportType() {
+ HashSet<ImportType> result = Sets.newHashSet(ImportType.values());
+ result.remove(ImportType.COMMON_ALL);
+ result.remove(ImportType.COMMON_TRANSECT);
+ result.remove(ImportType.OPERATION);
+ result.remove(ImportType.CATCHES);
+ result.remove(ImportType.ACOUSTIC);
+ return result;
+ }
+}
Property changes on: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/AcousticRemoveDataStrategy.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/CatchesRemoveDataStrategy.java (from rev 636, trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/CatchesRemoveDataService.java)
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/CatchesRemoveDataStrategy.java (rev 0)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/CatchesRemoveDataStrategy.java 2012-09-09 19:57:02 UTC (rev 638)
@@ -0,0 +1,77 @@
+package fr.ifremer.echobase.services.removedata.strategy;
+
+/*
+ * #%L
+ * EchoBase :: Services
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 - 2012 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%
+ */
+
+import com.google.common.collect.Sets;
+import fr.ifremer.echobase.entities.ImportType;
+import fr.ifremer.echobase.entities.data.Sample;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * Remove a {@link ImportType#CATCHES} import.
+ * <p/>
+ * Can remove only {@link Sample}.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.2
+ */
+public class CatchesRemoveDataStrategy extends AbstractRemoveDataStrategy {
+
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(CatchesRemoveDataStrategy.class);
+
+ @Override
+ protected void removeData(String id) {
+
+ if (id.startsWith(Sample.class.getName())) {
+
+ // remove sample
+ removeSample(id);
+ } else {
+ canNotDealWithId(id);
+ }
+ }
+
+ protected void removeSample(String id) {
+ Sample entity = removeEntity(id);
+ if (log.isInfoEnabled()) {
+ log.info("Sample " + entity.getTopiaId() + " was removed");
+ }
+ }
+
+ @Override
+ public Set<ImportType> getPossibleSubImportType() {
+ HashSet<ImportType> result = Sets.newHashSet(ImportType.values());
+ result.remove(ImportType.COMMON_ALL);
+ result.remove(ImportType.COMMON_TRANSECT);
+ result.remove(ImportType.OPERATION);
+ result.remove(ImportType.CATCHES);
+ return result;
+ }
+}
Property changes on: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/CatchesRemoveDataStrategy.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/CommonAllRemoveDataStrategy.java (from rev 636, trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/CommonAllRemoveDataService.java)
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/CommonAllRemoveDataStrategy.java (rev 0)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/CommonAllRemoveDataStrategy.java 2012-09-09 19:57:02 UTC (rev 638)
@@ -0,0 +1,75 @@
+package fr.ifremer.echobase.services.removedata.strategy;
+
+/*
+ * #%L
+ * EchoBase :: Services
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 - 2012 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%
+ */
+
+import com.google.common.collect.Sets;
+import fr.ifremer.echobase.entities.ImportType;
+import fr.ifremer.echobase.entities.data.Voyage;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * Remove a {@link ImportType#COMMON_ALL} import.
+ * <p/>
+ * Can remove only {@link Voyage}.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.2
+ */
+public class CommonAllRemoveDataStrategy extends AbstractRemoveDataStrategy {
+
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(CommonAllRemoveDataStrategy.class);
+
+ @Override
+ protected void removeData(String id) {
+
+ if (id.startsWith(Voyage.class.getName())) {
+
+ // remove voyage
+ removeVoyage(id);
+ } else {
+ canNotDealWithId(id);
+ }
+ }
+
+ protected void removeVoyage(String id) {
+ Voyage entity = removeEntity(id);
+ if (log.isInfoEnabled()) {
+ log.info("Voyage " + entity.getTopiaId() + " was removed");
+ }
+ }
+
+ @Override
+ public Set<ImportType> getPossibleSubImportType() {
+ HashSet<ImportType> result = Sets.newHashSet(ImportType.values());
+ result.remove(ImportType.COMMON_ALL);
+ result.remove(ImportType.COMMON_TRANSECT);
+ return result;
+ }
+}
Property changes on: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/CommonAllRemoveDataStrategy.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/CommonTransectRemoveDataStrategy.java (from rev 636, trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/CommonTransectRemoveDataService.java)
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/CommonTransectRemoveDataStrategy.java (rev 0)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/CommonTransectRemoveDataStrategy.java 2012-09-09 19:57:02 UTC (rev 638)
@@ -0,0 +1,75 @@
+package fr.ifremer.echobase.services.removedata.strategy;
+
+/*
+ * #%L
+ * EchoBase :: Services
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 - 2012 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%
+ */
+
+import com.google.common.collect.Sets;
+import fr.ifremer.echobase.entities.ImportType;
+import fr.ifremer.echobase.entities.data.Transect;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * Remove a {@link ImportType#COMMON_TRANSECT} import.
+ * <p/>
+ * Can remove only {@link Transect}.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.2
+ */
+public class CommonTransectRemoveDataStrategy extends AbstractRemoveDataStrategy {
+
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(CommonTransectRemoveDataStrategy.class);
+
+ @Override
+ protected void removeData(String id) {
+
+ if (id.startsWith(Transect.class.getName())) {
+
+ // remove transect
+ removeTransect(id);
+ } else {
+ canNotDealWithId(id);
+ }
+ }
+
+ protected void removeTransect(String id) {
+ Transect entity = removeEntity(id);
+ if (log.isInfoEnabled()) {
+ log.info("Transect " + entity.getTopiaId() + " was removed");
+ }
+ }
+
+ @Override
+ public Set<ImportType> getPossibleSubImportType() {
+ HashSet<ImportType> result = Sets.newHashSet(ImportType.values());
+ result.remove(ImportType.COMMON_ALL);
+ result.remove(ImportType.COMMON_TRANSECT);
+ return result;
+ }
+}
Property changes on: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/CommonTransectRemoveDataStrategy.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/OperationRemoveDataStrategy.java (from rev 636, trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/OperationRemoveDataService.java)
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/OperationRemoveDataStrategy.java (rev 0)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/OperationRemoveDataStrategy.java 2012-09-09 19:57:02 UTC (rev 638)
@@ -0,0 +1,76 @@
+package fr.ifremer.echobase.services.removedata.strategy;
+
+/*
+ * #%L
+ * EchoBase :: Services
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 - 2012 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%
+ */
+
+import com.google.common.collect.Sets;
+import fr.ifremer.echobase.entities.ImportType;
+import fr.ifremer.echobase.entities.data.Operation;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * Remove a {@link ImportType#OPERATION} import.
+ * <p/>
+ * Can remove only {@link Operation}.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.2
+ */
+public class OperationRemoveDataStrategy extends AbstractRemoveDataStrategy {
+
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(OperationRemoveDataStrategy.class);
+
+ @Override
+ protected void removeData(String id) {
+
+ if (id.startsWith(Operation.class.getName())) {
+
+ // remove operation
+ removeOperation(id);
+ } else {
+ canNotDealWithId(id);
+ }
+ }
+
+ protected void removeOperation(String id) {
+ Operation entity = removeEntity(id);
+ if (log.isInfoEnabled()) {
+ log.info("Operation " + entity.getTopiaId() + " was removed");
+ }
+ }
+
+ @Override
+ public Set<ImportType> getPossibleSubImportType() {
+ HashSet<ImportType> result = Sets.newHashSet(ImportType.values());
+ result.remove(ImportType.COMMON_ALL);
+ result.remove(ImportType.COMMON_TRANSECT);
+ result.remove(ImportType.OPERATION);
+ return result;
+ }
+}
Property changes on: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/OperationRemoveDataStrategy.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/ResultEsduRemoveDataStrategy.java (from rev 636, trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/ResultEsduRemoveDataService.java)
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/ResultEsduRemoveDataStrategy.java (rev 0)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/ResultEsduRemoveDataStrategy.java 2012-09-09 19:57:02 UTC (rev 638)
@@ -0,0 +1,80 @@
+package fr.ifremer.echobase.services.removedata.strategy;
+
+/*
+ * #%L
+ * EchoBase :: Services
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 - 2012 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%
+ */
+
+import com.google.common.collect.Sets;
+import fr.ifremer.echobase.entities.ImportType;
+import fr.ifremer.echobase.entities.data.Result;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * Remove a {@link ImportType#RESULT_ESDU} import.
+ * <p/>
+ * Can remove only {@link Result}.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.2
+ */
+public class ResultEsduRemoveDataStrategy extends AbstractRemoveDataStrategy {
+
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(ResultEsduRemoveDataStrategy.class);
+
+ @Override
+ protected void removeData(String id) {
+
+ if (id.startsWith(Result.class.getName())) {
+
+ // remove result
+ removeResult(id);
+ } else {
+ canNotDealWithId(id);
+ }
+ }
+
+ protected void removeResult(String id) {
+ Result entity = removeEntity(id);
+ if (log.isDebugEnabled()) {
+ log.debug("Result " + entity.getTopiaId() + " was removed");
+ }
+ }
+
+ @Override
+ public Set<ImportType> getPossibleSubImportType() {
+ HashSet<ImportType> result = Sets.newHashSet(ImportType.values());
+ result.remove(ImportType.COMMON_ALL);
+ result.remove(ImportType.COMMON_TRANSECT);
+ result.remove(ImportType.OPERATION);
+ result.remove(ImportType.CATCHES);
+ result.remove(ImportType.ACOUSTIC);
+ result.remove(ImportType.RESULT_VOYAGE);
+ result.remove(ImportType.RESULT_ESDU);
+ return result;
+ }
+}
Property changes on: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/ResultEsduRemoveDataStrategy.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/ResultMapRemoveDataStrategy.java (from rev 636, trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/ResultMapRemoveDataService.java)
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/ResultMapRemoveDataStrategy.java (rev 0)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/ResultMapRemoveDataStrategy.java 2012-09-09 19:57:02 UTC (rev 638)
@@ -0,0 +1,73 @@
+package fr.ifremer.echobase.services.removedata.strategy;
+
+/*
+ * #%L
+ * EchoBase :: Services
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 - 2012 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%
+ */
+
+import com.google.common.collect.Sets;
+import fr.ifremer.echobase.entities.ImportType;
+import fr.ifremer.echobase.entities.data.Cell;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * Remove a {@link ImportType#RESULT_MAP} import.
+ * <p/>
+ * Can remove only {@link Cell}.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.2
+ */
+public class ResultMapRemoveDataStrategy extends AbstractRemoveDataStrategy {
+
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(ResultMapRemoveDataStrategy.class);
+
+ @Override
+ protected void removeData(String id) {
+
+ if (id.startsWith(Cell.class.getName())) {
+
+ // remove cell
+ removeCell(id);
+ } else {
+ canNotDealWithId(id);
+ }
+ }
+
+ protected void removeCell(String id) {
+ Cell entity = removeEntity(id);
+ if (log.isInfoEnabled()) {
+ log.info("Cell " + entity.getTopiaId() + " was removed");
+ }
+ }
+
+ @Override
+ public Set<ImportType> getPossibleSubImportType() {
+ HashSet<ImportType> result = Sets.newHashSet();
+ return result;
+ }
+}
Property changes on: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/ResultMapRemoveDataStrategy.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/ResultRegionRemoveDataStrategy.java (from rev 636, trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/ResultRegionRemoveDataService.java)
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/ResultRegionRemoveDataStrategy.java (rev 0)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/ResultRegionRemoveDataStrategy.java 2012-09-09 19:57:02 UTC (rev 638)
@@ -0,0 +1,81 @@
+package fr.ifremer.echobase.services.removedata.strategy;
+
+/*
+ * #%L
+ * EchoBase :: Services
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 - 2012 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%
+ */
+
+import com.google.common.collect.Sets;
+import fr.ifremer.echobase.entities.ImportType;
+import fr.ifremer.echobase.entities.data.Cell;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * Remove a {@link ImportType#RESULT_REGION} import.
+ * <p/>
+ * Can remove only {@link Cell}.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.2
+ */
+public class ResultRegionRemoveDataStrategy extends AbstractRemoveDataStrategy {
+
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(ResultRegionRemoveDataStrategy.class);
+
+ @Override
+ protected void removeData(String id) {
+
+ if (id.startsWith(Cell.class.getName())) {
+
+ // remove echotype
+ removeCell(id);
+ } else {
+ canNotDealWithId(id);
+ }
+ }
+
+ protected void removeCell(String id) {
+ Cell entity = removeEntity(id);
+ if (log.isInfoEnabled()) {
+ log.info("Cell " + entity.getTopiaId() + " was removed");
+ }
+ }
+
+ @Override
+ public Set<ImportType> getPossibleSubImportType() {
+ HashSet<ImportType> result = Sets.newHashSet(ImportType.values());
+ result.remove(ImportType.COMMON_ALL);
+ result.remove(ImportType.COMMON_TRANSECT);
+ result.remove(ImportType.OPERATION);
+ result.remove(ImportType.CATCHES);
+ result.remove(ImportType.ACOUSTIC);
+ result.remove(ImportType.RESULT_VOYAGE);
+ result.remove(ImportType.RESULT_ESDU);
+ result.remove(ImportType.RESULT_VOYAGE);
+ return result;
+ }
+}
Property changes on: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/ResultRegionRemoveDataStrategy.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/ResultVoyageRemoveDataStrategy.java (from rev 636, trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/ResultVoyageRemoveDataService.java)
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/ResultVoyageRemoveDataStrategy.java (rev 0)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/ResultVoyageRemoveDataStrategy.java 2012-09-09 19:57:02 UTC (rev 638)
@@ -0,0 +1,104 @@
+package fr.ifremer.echobase.services.removedata.strategy;
+
+/*
+ * #%L
+ * EchoBase :: Services
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 - 2012 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%
+ */
+
+import com.google.common.collect.Sets;
+import fr.ifremer.echobase.entities.ImportType;
+import fr.ifremer.echobase.entities.data.Echotype;
+import fr.ifremer.echobase.entities.data.LengthAgeKey;
+import fr.ifremer.echobase.entities.data.LengthWeightKey;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * remove a {@link ImportType#OPERATION} import.
+ * <p/>
+ * Can remove only {@link Echotype}, {@link LengthAgeKey} or
+ * {@link LengthWeightKey}.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.2
+ */
+public class ResultVoyageRemoveDataStrategy extends AbstractRemoveDataStrategy {
+
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(ResultVoyageRemoveDataStrategy.class);
+
+ @Override
+ protected void removeData(String id) {
+
+ if (id.startsWith(Echotype.class.getName())) {
+
+ // remove echotype
+ removeEchotype(id);
+ } else if (id.startsWith(LengthAgeKey.class.getName())) {
+
+ // remove lengthAgeKey
+ removeLengthAgeKey(id);
+ } else if (id.startsWith(LengthWeightKey.class.getName())) {
+
+ // remove lengthAgeKey
+ removeLengthWeightKey(id);
+ } else {
+ canNotDealWithId(id);
+ }
+ }
+
+ protected void removeEchotype(String id) {
+ Echotype entity = removeEntity(id);
+ if (log.isInfoEnabled()) {
+ log.info("Echotype " + entity.getTopiaId() + " was removed");
+ }
+ }
+
+ protected void removeLengthAgeKey(String id) {
+ LengthAgeKey entity = removeEntity(id);
+ if (log.isInfoEnabled()) {
+ log.info("LengthAgeKey " + entity.getTopiaId() + " was removed");
+ }
+ }
+
+ protected void removeLengthWeightKey(String id) {
+ LengthWeightKey entity = removeEntity(id);
+ if (log.isInfoEnabled()) {
+ log.info("LengthWeightKey " + entity.getTopiaId() + " was removed");
+ }
+ }
+
+ @Override
+ public Set<ImportType> getPossibleSubImportType() {
+ HashSet<ImportType> result = Sets.newHashSet(ImportType.values());
+ result.remove(ImportType.COMMON_ALL);
+ result.remove(ImportType.COMMON_TRANSECT);
+ result.remove(ImportType.OPERATION);
+ result.remove(ImportType.CATCHES);
+ result.remove(ImportType.ACOUSTIC);
+ result.remove(ImportType.RESULT_VOYAGE);
+ return result;
+ }
+}
Property changes on: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/ResultVoyageRemoveDataStrategy.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/GetEntities.java
===================================================================
--- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/GetEntities.java 2012-09-08 11:23:33 UTC (rev 637)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/GetEntities.java 2012-09-09 19:57:02 UTC (rev 638)
@@ -24,6 +24,7 @@
package fr.ifremer.echobase.ui.actions.dbeditor;
import fr.ifremer.echobase.entities.EchoBaseEntityEnum;
+import fr.ifremer.echobase.entities.ImportType;
import fr.ifremer.echobase.services.DbEditorService;
import fr.ifremer.echobase.ui.actions.AbstractJSONPaginedAction;
import org.apache.commons.logging.Log;
@@ -92,7 +93,7 @@
log.debug("sord = " + ascendantOrder);
}
- datas = getService(DbEditorService.class).getDatas(
+ datas = getService(DbEditorService.class).getData(
entityType,
pager,
sortColumn,
@@ -112,4 +113,19 @@
execute();
return SUCCESS;
}
+
+ public String entityImportLogs() throws Exception {
+ entityType = EchoBaseEntityEnum.ImportLog;
+ execute();
+ Map<String, String> importTypes = decorateEnums(ImportType.values());
+
+ for (Map row : datas) {
+
+ String importType = (String) row.get("importType");
+ String importTypeToString = importTypes.get(importType);
+ row.put("importType", importTypeToString);
+
+ }
+ return SUCCESS;
+ }
}
Added: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/removeData/ConfirmDelete.java
===================================================================
--- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/removeData/ConfirmDelete.java (rev 0)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/removeData/ConfirmDelete.java 2012-09-09 19:57:02 UTC (rev 638)
@@ -0,0 +1,94 @@
+package fr.ifremer.echobase.ui.actions.removeData;
+
+/*
+ * #%L
+ * EchoBase :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 - 2012 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%
+ */
+
+import com.google.common.base.Preconditions;
+import fr.ifremer.echobase.entities.ImportLog;
+import fr.ifremer.echobase.services.EchoBaseServiceSupport;
+import fr.ifremer.echobase.services.removedata.RemoveDataConfiguration;
+import fr.ifremer.echobase.ui.actions.AbstractConfigureAction;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.io.IOException;
+
+/**
+ * Confirm to delete a import log.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.2
+ */
+public class ConfirmDelete extends AbstractConfigureAction<RemoveDataConfiguration> {
+
+ private static final long serialVersionUID = 1L;
+
+ /** Logger. */
+ private static final Log log = LogFactory.getLog(ConfirmDelete.class);
+
+ protected ImportLog importLog;
+
+
+ protected String importType;
+
+ public ConfirmDelete() {
+ super(RemoveDataConfiguration.class);
+ }
+
+ public String getImportType() {
+ return importType;
+ }
+
+ public ImportLog getImportLog() {
+ return importLog;
+ }
+
+ @Override
+ protected RemoveDataConfiguration createModel() {
+ return new RemoveDataConfiguration();
+ }
+
+ @Override
+ protected void prepareExecuteAction(RemoveDataConfiguration model) throws IOException {
+
+ // nothing special to do here
+ }
+
+ protected void prepareInputAction(RemoveDataConfiguration model) {
+
+ String importLogId = model.getImportLogId();
+
+ Preconditions.checkArgument(StringUtils.isNotBlank(importLogId));
+
+ if (log.isInfoEnabled()) {
+ log.info("Load import log " + importLogId);
+ }
+ EchoBaseServiceSupport service =
+ getService(EchoBaseServiceSupport.class);
+ importLog = service.getEntityById(ImportLog.class, importLogId);
+
+ importType = decorateEnums(importLog.getImportType()).entrySet().iterator().next().getValue();
+ }
+
+}
\ No newline at end of file
Property changes on: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/removeData/ConfirmDelete.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/removeData/Delete.java
===================================================================
--- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/removeData/Delete.java (rev 0)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/removeData/Delete.java 2012-09-09 19:57:02 UTC (rev 638)
@@ -0,0 +1,66 @@
+package fr.ifremer.echobase.ui.actions.removeData;
+
+/*
+ * #%L
+ * EchoBase :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 - 2012 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%
+ */
+
+import fr.ifremer.echobase.services.removedata.RemoveDataConfiguration;
+import fr.ifremer.echobase.services.removedata.RemoveDataService;
+import fr.ifremer.echobase.ui.actions.AbstractWaitAndExecAction;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Delete a selected import Log.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.2
+ */
+public class Delete extends AbstractWaitAndExecAction<RemoveDataConfiguration, RemoveDataService> {
+
+ private static final long serialVersionUID = 1L;
+
+ /** Logger. */
+ private static final Log log = LogFactory.getLog(Delete.class);
+
+ protected String result;
+
+ public Delete() {
+ super(RemoveDataConfiguration.class, RemoveDataService.class);
+ }
+
+ public String getResult() {
+ return result;
+ }
+
+ @Override
+ protected void startAction(RemoveDataService service,
+ RemoveDataConfiguration model) throws Exception {
+
+ if (log.isInfoEnabled()) {
+ log.info("Will remove importLog : " + model.getImportLogId());
+ }
+
+ result = service.removeImport(model, getEchoBaseSession().getUser());
+ }
+
+}
Property changes on: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/removeData/Delete.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/echobase-ui/src/main/resources/config/struts-exportDb.xml
===================================================================
--- trunk/echobase-ui/src/main/resources/config/struts-exportDb.xml 2012-09-08 11:23:33 UTC (rev 637)
+++ trunk/echobase-ui/src/main/resources/config/struts-exportDb.xml 2012-09-09 19:57:02 UTC (rev 638)
@@ -42,9 +42,8 @@
</action>
<!-- Build export -->
- <action name="export"
- class="fr.ifremer.echobase.ui.actions.exportDb.Export"
- method="execute">
+ <action name="export" method="execute"
+ class="fr.ifremer.echobase.ui.actions.exportDb.Export">
<interceptor-ref name="basicStackLoggued"/>
<interceptor-ref name="execAndWait"/>
<result name="wait">/WEB-INF/jsp/exportDb/progress.jsp</result>
Added: trunk/echobase-ui/src/main/resources/config/struts-removeData.xml
===================================================================
--- trunk/echobase-ui/src/main/resources/config/struts-removeData.xml (rev 0)
+++ trunk/echobase-ui/src/main/resources/config/struts-removeData.xml 2012-09-09 19:57:02 UTC (rev 638)
@@ -0,0 +1,63 @@
+<!--
+ #%L
+ EchoBase :: UI
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2011 - 2012 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.3//EN"
+ "http://struts.apache.org/dtds/struts-2.3.dtd">
+
+<struts>
+
+ <package name="removeData" extends="loggued" namespace="/removeData">
+
+ <!-- Confirm to delete the importLog -->
+ <action name="confirmDelete"
+ class="fr.ifremer.echobase.ui.actions.removeData.ConfirmDelete">
+ <result name="input">/WEB-INF/jsp/removeData/confirmDelete.jsp</result>
+ <result type="redirectAction">
+ <param name="namespace">/removeData</param>
+ <param name="actionName">delete</param>
+ </result>
+ </action>
+
+ <!-- Delete the importLog -->
+ <action name="delete" method="execute"
+ class="fr.ifremer.echobase.ui.actions.removeData.Delete">
+ <interceptor-ref name="basicStackLoggued"/>
+ <interceptor-ref name="execAndWait"/>
+ <result name="wait">/WEB-INF/jsp/removeData/deleteProgress.jsp</result>
+ <result>/WEB-INF/jsp/removeData/deleteResult.jsp</result>
+ </action>
+
+ <!-- Get importLogs -->
+ <action name="importLogs"
+ class="fr.ifremer.echobase.ui.actions.EchoBaseActionSupport">
+ <result>/WEB-INF/jsp/removeData/dashboard.jsp</result>
+ </action>
+
+ <!-- Get import logs entries -->
+ <action name="getImportLogs" method="entityImportLogs"
+ class="fr.ifremer.echobase.ui.actions.dbeditor.GetEntities">
+ <result type="json"/>
+ </action>
+ </package>
+
+</struts>
Property changes on: trunk/echobase-ui/src/main/resources/config/struts-removeData.xml
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/echobase-ui/src/main/resources/config/struts-user.xml
===================================================================
--- trunk/echobase-ui/src/main/resources/config/struts-user.xml 2012-09-08 11:23:33 UTC (rev 637)
+++ trunk/echobase-ui/src/main/resources/config/struts-user.xml 2012-09-09 19:57:02 UTC (rev 638)
@@ -65,20 +65,12 @@
<result>/WEB-INF/jsp/user/userList.jsp</result>
</action>
-
-
<!-- Get list of users in database -->
<action name="getUsers"
class="fr.ifremer.echobase.ui.actions.user.GetUsers">
<result type="json"/>
</action>
- <!-- Get modification logs entries -->
- <action name="getEntityModificationLogs" method="entityModificationLogs"
- class="fr.ifremer.echobase.ui.actions.dbeditor.GetEntities">
- <result type="json"/>
- </action>
-
</package>
</struts>
Modified: trunk/echobase-ui/src/main/resources/config/struts-workingDb.xml
===================================================================
--- trunk/echobase-ui/src/main/resources/config/struts-workingDb.xml 2012-09-08 11:23:33 UTC (rev 637)
+++ trunk/echobase-ui/src/main/resources/config/struts-workingDb.xml 2012-09-09 19:57:02 UTC (rev 638)
@@ -127,6 +127,12 @@
</result>
</action>
+ <!-- Get modification logs entries -->
+ <action name="getEntityModificationLogs" method="entityModificationLogs"
+ class="fr.ifremer.echobase.ui.actions.dbeditor.GetEntities">
+ <result type="json"/>
+ </action>
+
</package>
</struts>
Modified: trunk/echobase-ui/src/main/resources/i18n/echobase-ui_en_GB.properties
===================================================================
--- trunk/echobase-ui/src/main/resources/i18n/echobase-ui_en_GB.properties 2012-09-08 11:23:33 UTC (rev 637)
+++ trunk/echobase-ui/src/main/resources/i18n/echobase-ui_en_GB.properties 2012-09-09 19:57:02 UTC (rev 638)
@@ -1,3 +1,4 @@
+echobase.action.backToImportLogs=Back to import logs
echobase.action.backToUserList=Back to users list
echobase.action.cancel=Cancel
echobase.action.clone=Clone
@@ -17,6 +18,7 @@
echobase.action.exportTable=Export
echobase.action.generateSqlQuery=Generate query
echobase.action.import=Import
+echobase.action.importLogDelete=Delete
echobase.action.importTable=Import
echobase.action.login=Connect
echobase.action.logout=Disconnect
@@ -30,6 +32,7 @@
echobase.action.saveSqlQuery=Update query
echobase.action.show.embedded.documentation=How to use a portable database
echobase.action.show.import.documentation=How to import data
+echobase.action.showImportLogs=Liste des imports\=Show import logs
echobase.action.toEnglish=English
echobase.action.toFrench=French
echobase.action.usingEnglish=English
@@ -68,17 +71,22 @@
echobase.common.esduBySpeciesAndSizeCategoryFile=
echobase.common.gearMetadataFile=
echobase.common.id=ID
+echobase.common.imortType=import type
echobase.common.importDataMode=Import type
+echobase.common.importDate=Import date
echobase.common.importDbFile=
echobase.common.importError=Error\:
+echobase.common.importLogActions=Actions
echobase.common.importNotes=Import notes
echobase.common.importResult=Import results
+echobase.common.importText=import description
echobase.common.importType=Import type
echobase.common.importType.acoustic=
echobase.common.importType.catches=
echobase.common.importType.common=Voyage / Transit / Transect data import
echobase.common.importType.operation=
echobase.common.importType.results=Results import
+echobase.common.importUser=Import user
echobase.common.inProgress=Processing...
echobase.common.institution=Institution
echobase.common.jdbcDriver=Jdbc driver name
@@ -132,6 +140,7 @@
echobase.common.voyage=Cruise
echobase.common.voyageDescription=Description
echobase.common.voyageFile=
+echobase.confirm.delete.importData=Delete import
echobase.confirm.delete.query=Delete query
echobase.confirm.delete.workingDbConfiguration=Delete working database configuration
echobase.error.bad.password=Invalid password
@@ -287,9 +296,11 @@
echobase.menu.viewData=Display data
echobase.message.no.row.selected=No data selected
echobase.message.noEntrySelection=No field selected
+echobase.message.removeData.result=data was successful removed in %s.
echobase.message.warnEmbeddedApplicationInProgress=Please do not close the window to access the new portable database file
echobase.message.warnExportInProgress=Please do not close the window to access the export file
echobase.message.warnImportInProgress=Please do not close the window to access the imported file
+echobase.message.warnRemoveDataInProgress=Please do not close the window to access remove data result
echobase.title.confirm.deleteQuery=Delete a query
echobase.title.confirm.deleteWorkingDbConfiguration=Delete a configuration
echobase.title.connectToDbInformations=Database connection information
@@ -297,6 +308,7 @@
echobase.title.createMission=Create a mission
echobase.title.dbEditor=Modify data
echobase.title.dbEditor.read=Data display
+echobase.title.delete.importLog=Delete a import
echobase.title.embeddedApplicationProgress=Creating the portable database
echobase.title.embeddedApplicationResult=Results of the portable database creation
echobase.title.entityModificationLogs=Change log
@@ -309,10 +321,14 @@
echobase.title.importDb=Complete database import
echobase.title.importDbProgress=Importing data
echobase.title.importDbResult=Data import results
+echobase.title.importLog.detail=Import detail
+echobase.title.importLogs=Import logs
echobase.title.importTable=Import a table
echobase.title.login=Connection
echobase.title.modification.detail=Modification details
echobase.title.newLibreOfficeQuery=Translate a SQL query from Libre Office
+echobase.title.removeDataProgress=Remove import data
+echobase.title.removeDataResult=Result of remove import data
echobase.title.users=Administrate users
echobase.title.welcome=Welcome to Echobase
echobase.title.workingDbConfiguration=Manage working database configurations
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 2012-09-08 11:23:33 UTC (rev 637)
+++ trunk/echobase-ui/src/main/resources/i18n/echobase-ui_fr_FR.properties 2012-09-09 19:57:02 UTC (rev 638)
@@ -1,3 +1,4 @@
+echobase.action.backToImportLogs=Retour à la liste des imports
echobase.action.backToUserList=Retour à la liste des utilisateurs
echobase.action.cancel=Annuler
echobase.action.clone=Cloner
@@ -17,6 +18,7 @@
echobase.action.exportTable=Exporter
echobase.action.generateSqlQuery=Générer la requête
echobase.action.import=Importer
+echobase.action.importLogDelete=Supprimer
echobase.action.importTable=Importer
echobase.action.login=Connexion
echobase.action.logout=Déconnexion
@@ -30,6 +32,7 @@
echobase.action.saveSqlQuery=Mettre à jour
echobase.action.show.embedded.documentation=Comment utiliser une application embarquée
echobase.action.show.import.documentation=Comment importer des données
+echobase.action.showImportLogs=Liste des imports
echobase.action.toEnglish=En anglais
echobase.action.toFrench=En français
echobase.action.usingEnglish=Version anglaise
@@ -68,17 +71,22 @@
echobase.common.esduBySpeciesAndSizeCategoryFile=
echobase.common.gearMetadataFile=
echobase.common.id=Identifiant
+echobase.common.imortType=Type d'import
echobase.common.importDataMode=Type d'import
+echobase.common.importDate=Date de l'import
echobase.common.importDbFile=
echobase.common.importError=Une erreur est survenue pendant l'import \:
+echobase.common.importLogActions=Actions
echobase.common.importNotes=Remarques sur l'import
echobase.common.importResult=Résultat de l'import
+echobase.common.importText=Description
echobase.common.importType=Type d'import
echobase.common.importType.acoustic=
echobase.common.importType.catches=
echobase.common.importType.common=Import des données de Voyage / Transit / Transect
echobase.common.importType.operation=
echobase.common.importType.results=Import des résultats
+echobase.common.importUser=Utilisateur
echobase.common.inProgress=En cours...
echobase.common.institution=Institution
echobase.common.jdbcDriver=Nom du pilote jdbc
@@ -132,6 +140,7 @@
echobase.common.voyage=Campagne
echobase.common.voyageDescription=Description
echobase.common.voyageFile=
+echobase.confirm.delete.importData=Confirmer la suppression de l'import
echobase.confirm.delete.query=Confirmer la suppression de la requête
echobase.confirm.delete.workingDbConfiguration=Confirmer la suppression de la configuration suivante
echobase.error.bad.password=Mot de passe incorrect
@@ -287,9 +296,11 @@
echobase.menu.viewData=Visualiser les données
echobase.message.no.row.selected=Aucune donnée sélectionnée
echobase.message.noEntrySelection=Pas de champ sélectionné
+echobase.message.removeData.result=Résultat de la suppression de l'import %s
echobase.message.warnEmbeddedApplicationInProgress=Merci de ne pas fermer la fenêtre pour pouvoir accéder aux résultats de la création de l'application embarquée
echobase.message.warnExportInProgress=Merci de ne pas fermer la fenêtre pour pouvoir accéder aux résultats de l'export
echobase.message.warnImportInProgress=Merci de ne pas fermer la fenêtre pour pouvoir accéder aux résultats de l'import
+echobase.message.warnRemoveDataInProgress=Merci de ne pas fermer la fenètre pour pouvoir accéder aux résultats de la suppression de l'import
echobase.title.confirm.deleteQuery=Supprimer une requête
echobase.title.confirm.deleteWorkingDbConfiguration=Supprimer la configuration
echobase.title.connectToDbInformations=Informations de connexion à la base de données
@@ -297,6 +308,7 @@
echobase.title.createMission=Créer une mission
echobase.title.dbEditor=Modification des données
echobase.title.dbEditor.read=Visualisation des données
+echobase.title.delete.importLog=Confirmer la suppression d'un import
echobase.title.embeddedApplicationProgress=Création de l'application embarquée en cours
echobase.title.embeddedApplicationResult=Résultat de la création de l'application embarquée
echobase.title.entityModificationLogs=Journal des modifications
@@ -309,13 +321,18 @@
echobase.title.importDb=Import d'une base complète
echobase.title.importDbProgress=Import de données en cours
echobase.title.importDbResult=Résultats de l'import de données
+echobase.title.importLog.detail=Détil d'un import
+echobase.title.importLogs=Liste des imports
echobase.title.importTable=Importer une table
echobase.title.login=Connexion
echobase.title.modification.detail=Détails de la modification
echobase.title.newLibreOfficeQuery=Traduire une requête SQL issue de Libre Office
+echobase.title.removeDataProgress=Suppression d'un import en cours...
+echobase.title.removeDataResult=Résultat de la suppression d'un import
echobase.title.users=Administration des utilisateurs
echobase.title.welcome=Bienvenue dans EchoBase
echobase.title.workingDbConfiguration=Administration des configurations de base de travail
echobase.tooltip.disconnectWorkingDb=Changer de base de travail
echobase.tooltip.logout=Se déconnecter
echobase.tooltip.selectWorkingDb=Sélectionner une base de travail
+ehobase.message.removeData.result=Import supprimé avec succès en %s
Modified: trunk/echobase-ui/src/main/resources/struts.xml
===================================================================
--- trunk/echobase-ui/src/main/resources/struts.xml 2012-09-08 11:23:33 UTC (rev 637)
+++ trunk/echobase-ui/src/main/resources/struts.xml 2012-09-09 19:57:02 UTC (rev 638)
@@ -158,6 +158,7 @@
<include file="config/struts-importDb.xml"/>
<include file="config/struts-exportDb.xml"/>
+ <include file="config/struts-removeData.xml"/>
</struts>
Modified: trunk/echobase-ui/src/main/webapp/WEB-INF/decorators.xml
===================================================================
--- trunk/echobase-ui/src/main/webapp/WEB-INF/decorators.xml 2012-09-08 11:23:33 UTC (rev 637)
+++ trunk/echobase-ui/src/main/webapp/WEB-INF/decorators.xml 2012-09-09 19:57:02 UTC (rev 638)
@@ -36,6 +36,7 @@
<pattern>/exportQuery/confirmDelete*</pattern>
<pattern>/importData/get*</pattern>
<pattern>/workingDb/confirmDelete*</pattern>
+ <pattern>/removeData/confirmDelete*</pattern>
</excludes>
<decorator name="layout-default" page="layout-default.jsp">
Modified: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/home.jsp
===================================================================
--- trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/home.jsp 2012-09-08 11:23:33 UTC (rev 637)
+++ trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/home.jsp 2012-09-09 19:57:02 UTC (rev 638)
@@ -61,4 +61,14 @@
</li>
</ul>
</s:form>
-</s:if>
\ No newline at end of file
+</s:if>
+<s:else>
+ <s:form namespace="/removeData" action="importLogs">
+ <ul class="toolbar floatLeft">
+ <li>
+ <s:submit theme="simple" action="importLogs"
+ key="echobase.action.showImportLogs"/>
+ </li>
+ </ul>
+ </s:form>
+</s:else>
\ No newline at end of file
Modified: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/importData/configureResultsImport.jsp
===================================================================
--- trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/importData/configureResultsImport.jsp 2012-09-08 11:23:33 UTC (rev 637)
+++ trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/importData/configureResultsImport.jsp 2012-09-09 19:57:02 UTC (rev 638)
@@ -37,7 +37,7 @@
// to change form when mode is changed
$('[name="model.importType"]').change(function (event) {
- $('[class~="importMode"]').hide();
+ $('[class~="importType"]').hide();
$('#' + this.value).show();
$('#' + this.value + ' .errorMessage').hide();
});
@@ -61,7 +61,7 @@
label='%{getText("echobase.common.importType")}' />
<s:form id="RESULT_VOYAGE" namespace="/importData" method="POST"
- enctype="multipart/form-data" cssClass="hidden importMode">
+ enctype="multipart/form-data" cssClass="hidden importType">
<fieldset>
<legend>
@@ -102,7 +102,7 @@
</s:form>
<s:form id="RESULT_ESDU" namespace="/importData" method="POST"
- enctype="multipart/form-data" cssClass="hidden importMode">
+ enctype="multipart/form-data" cssClass="hidden importType">
<fieldset>
<legend>
@@ -153,7 +153,7 @@
</s:form>
<s:form id="RESULT_REGION" namespace="/importData" method="POST"
- enctype="multipart/form-data" cssClass="hidden importMode">
+ enctype="multipart/form-data" cssClass="hidden importType">
<fieldset>
<legend>
@@ -193,7 +193,7 @@
</s:form>
<s:form id="RESULT_MAP" namespace="/importData" method="POST"
- enctype="multipart/form-data" cssClass="hidden importMode">
+ enctype="multipart/form-data" cssClass="hidden importType">
<fieldset>
<legend>
Modified: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/importData/resultResultsImport.jsp
===================================================================
--- trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/importData/resultResultsImport.jsp 2012-09-08 11:23:33 UTC (rev 637)
+++ trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/importData/resultResultsImport.jsp 2012-09-09 19:57:02 UTC (rev 638)
@@ -30,7 +30,7 @@
<h4>
<s:text name="echobase.common.importType.results"/>
- ( <s:property value="%{getText(model.importMode.i18nKey)}"/> )
+ ( <s:property value="%{getText(model.importType.i18nKey)}"/> )
</h4>
<%@ include file="/WEB-INF/includes/importDataResults.jsp" %>
Modified: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/importDb/result.jsp
===================================================================
--- trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/importDb/result.jsp 2012-09-08 11:23:33 UTC (rev 637)
+++ trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/importDb/result.jsp 2012-09-09 19:57:02 UTC (rev 638)
@@ -27,8 +27,7 @@
<title><s:text name="echobase.title.importDbResult"/></title>
<div>
- L'import de la base complête a réussi en <s:property
- value="model.actionTime"/>.
+ L'import de la base complête a réussi en <s:property value="model.actionTime"/>.
</div>
<div>
EchoBase possède désormais un référentiel et les campagnes contenues dans
Added: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/removeData/confirmDelete.jsp
===================================================================
--- trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/removeData/confirmDelete.jsp (rev 0)
+++ trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/removeData/confirmDelete.jsp 2012-09-09 19:57:02 UTC (rev 638)
@@ -0,0 +1,79 @@
+<%--
+ #%L
+ EchoBase :: UI
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2011 - 2012 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" %>
+
+<script type="text/javascript">
+
+function cancel() {
+$('#confirmDeleteDialog').dialog('close');
+return false;
+}
+</script>
+
+<div class="dialogContainer ui-corner-all">
+
+ <s:label key="echobase.confirm.delete.importData" theme="simple"/>
+
+ <fieldset class="ui-corner-all">
+
+ <s:label key='echobase.common.importType' value=''/>
+ <div class="clearBoth"/>
+ <pre id='importLogImportType' style="font-weight: bold;">
+ <s:property value="%{importType}"/>
+ </pre>
+
+ <s:label key='echobase.common.importDate' value=''/>
+ <div class="clearBoth"/>
+ <pre id='importLogDate' style="font-weight: bold;">
+ <s:property value="%{importLog.importDate}"/>
+ </pre>
+
+ <s:label key='echobase.common.importText' value=''/>
+ <div class="clearBoth"/>
+ <pre id='importLogText' style="font-weight: bold;">
+ <s:property value="%{importLog.importText}"/>
+ </pre>
+
+ <s:label key='echobase.common.importUser' value=''/>
+ <div class="clearBoth"/>
+ <pre id='importLogUser' style="font-weight: bold;">
+ <s:property value="%{importLog.importUser}"/>
+ </pre>
+
+ <s:form namespace="/removeData">
+
+ <s:hidden key="model.importLogId" label=''/>
+ <ul class="toolbar floatRight">
+ <li>
+ <s:submit onclick="return cancel();" theme="simple"
+ key="echobase.action.cancel"/>
+ </li>
+ <li>
+ <s:submit action="confirmDelete" theme="simple"
+ key="echobase.action.delete"/>
+ </li>
+ </ul>
+ </s:form>
+ </fieldset>
+</div>
\ No newline at end of file
Property changes on: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/removeData/confirmDelete.jsp
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/removeData/dashboard.jsp
===================================================================
--- trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/removeData/dashboard.jsp (rev 0)
+++ trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/removeData/dashboard.jsp 2012-09-09 19:57:02 UTC (rev 638)
@@ -0,0 +1,126 @@
+<%--
+#%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" %>
+<%@ taglib prefix="sjg" uri="/struts-jquery-grid-tags" %>
+<script type="text/javascript"
+ src="<s:url value='/js/gridHelper.js' />"></script>
+<s:set var="emptySelection">
+ <s:text name="echobase.message.noEntrySelection"/>
+</s:set>
+
+<s:url id='deleteImg' value='/images/delete.png'/>
+<s:set id='deleteTitle'><s:text name="echobase.action.importLogDelete"/></s:set>
+<s:url id='delUrl' action="confirmDelete" namespace="/removeData" method="input"
+ escapeAmp="false"/>
+<script type="text/javascript">
+
+ function confirmDelete(id) {
+ var dialog = $("#confirmDeleteDialog");
+ dialog.html('');
+ var url = "${delUrl}";
+ url += '?' + $.param({'model.importLogId':id});
+ dialog.load(url);
+ dialog.dialog('open');
+ return false;
+ }
+
+ jQuery(document).ready(function () {
+ $.addRowSelectTopic('datas', function (event) {
+ $('#extraInfos').show();
+ var text = $("tr[aria-selected=true] td[aria-describedby='datas_importText']").text();
+ $('#importLogText').html(text);
+ var user = $("tr[aria-selected=true] td[aria-describedby='datas_importUser']").text();
+ $('#importLogUser').html(user);
+ var date = $("tr[aria-selected=true] td[aria-describedby='datas_importDate']").text();
+ $('#importLogDate').html(date);
+ var importType = $("tr[aria-selected=true] td[aria-describedby='datas_importType']").text();
+ $('#importLogImportType').html(importType);
+
+ });
+ $.addClearSelectTopic('datas', function (event) {
+ $('#extraInfos').hide();
+ });
+ $.addSingleRowTopic2('datas', 'Delete', function (event, id) {
+ return confirmDelete(id);
+ });
+ $.addEvenAndOddClasses('datas');
+ });
+</script>
+
+<title><s:text name="echobase.title.importLogs"/></title>
+<s:url id="loadUrl" action="getImportLogs" namespace="/removeData"
+ escapeAmp="false"/>
+
+<sjg:grid id="datas" dataType="json" href="%{loadUrl}" gridModel="datas"
+ pager="true" pagerButtons="true" pagerInput="true" navigator="true"
+ autowidth="true" rownumbers="false" viewrecords="true"
+ navigatorEdit="false" navigatorSearch="false"
+ navigatorDelete="false" navigatorAdd="false"
+ rowList="10,15,20,50,100,250,500" rowNum="10"
+ onSelectRowTopics='datas-rowSelect'
+ onCompleteTopics="datas-clearSelect,datas-CompleteTopics"
+ navigatorExtraButtons="{
+ delete: { title : 'Supprimer', icon: 'ui-icon-trash', topic: 'datas-rowDelete' }
+ }"
+ >
+
+ <sjg:gridColumn name="id" title="id" hidden="true"/>
+ <sjg:gridColumn name="importType" sortable="true"
+ title="%{getText('echobase.common.importType')}"/>
+ <sjg:gridColumn name="importDate" sortable="true"
+ title="%{getText('echobase.common.importDate')}"/>
+ <sjg:gridColumn name="importText" sortable="true"
+ title="%{getText('echobase.common.importText')}"/>
+ <sjg:gridColumn name="importUser" sortable="true"
+ title="%{getText('echobase.common.importUser')}"/>
+</sjg:grid>
+<br/>
+<fieldset>
+ <legend><s:text name="echobase.title.importLog.detail"/></legend>
+ <div id="extraInfos">
+
+ <s:label key='echobase.common.importType' value=''/>
+ <div class="clearBoth"/>
+ <pre id='importLogImportType' style="font-weight: bold;"></pre>
+ <br/>
+
+ <s:label key='echobase.common.importDate' value=''/>
+ <div class="clearBoth"/>
+ <pre id='importLogDate' style="font-weight: bold;"></pre>
+ <br/>
+
+ <s:label key='echobase.common.importText' value=''/>
+ <div class="clearBoth"/>
+ <pre id='importLogText' style="font-weight: bold;"></pre>
+ <br/>
+
+ <s:label key='echobase.common.importUser' value=''/>
+ <div class="clearBoth"/>
+ <pre id='importLogUser' style="font-weight: bold;"></pre>
+ </div>
+</fieldset>
+
+<sj:dialog id="confirmDeleteDialog" autoOpen="false" modal="true" width="780"
+ title='%{getText("echobase.title.delete.importLog")}'/>
\ No newline at end of file
Property changes on: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/removeData/dashboard.jsp
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/removeData/deleteProgress.jsp
===================================================================
--- trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/removeData/deleteProgress.jsp (rev 0)
+++ trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/removeData/deleteProgress.jsp 2012-09-09 19:57:02 UTC (rev 638)
@@ -0,0 +1,40 @@
+<%--
+ #%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" %>
+
+<meta http-equiv="refresh"
+ content='5;url=<s:url action="delete" namespace="/removeData"/>'/>
+
+<title><s:text name="echobase.title.removeDataProgress"/></title>
+
+<%-- TODO letellier 20111104 : Add warn icon --%>
+<p><s:text name="echobase.message.warnRemoveDataInProgress"/></p>
+
+<br/>
+
+<div>
+ <sj:progressbar value="%{model.progression}"/>
+</div>
\ No newline at end of file
Property changes on: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/removeData/deleteProgress.jsp
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/removeData/deleteResult.jsp
===================================================================
--- trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/removeData/deleteResult.jsp (rev 0)
+++ trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/removeData/deleteResult.jsp 2012-09-09 19:57:02 UTC (rev 638)
@@ -0,0 +1,46 @@
+<%--
+ #%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.removeDataResult"/></title>
+
+<div>
+ <s:text name="echobase.message.removeData.result">
+ <s:param><s:property value="model.actionTime"/></s:param>
+ </s:text>
+ <pre>
+ <s:property value="result"/>
+ </pre>
+</div>
+
+<s:form id="createForm" namespace="/removeData">
+ <ul class="toolbar floatLeft">
+ <li>
+ <s:submit theme="simple" action="importLogs"
+ key="echobase.action.backToImportLogs"/>
+ </li>
+ </ul>
+</s:form>
+
Property changes on: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/removeData/deleteResult.jsp
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/workingDb/modifications.jsp
===================================================================
--- trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/workingDb/modifications.jsp 2012-09-08 11:23:33 UTC (rev 637)
+++ trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/workingDb/modifications.jsp 2012-09-09 19:57:02 UTC (rev 638)
@@ -49,7 +49,7 @@
</script>
<title><s:text name="echobase.title.entityModificationLogs"/></title>
-<s:url id="loadUrl" action="getEntityModificationLogs" namespace="/user"
+<s:url id="loadUrl" action="getEntityModificationLogs" namespace="/workingDb"
escapeAmp="false"/>
<sjg:grid id="datas" dataType="json" href="%{loadUrl}" gridModel="datas"
Added: trunk/echobase-ui/src/main/webapp/images/delete.png
===================================================================
(Binary files differ)
Property changes on: trunk/echobase-ui/src/main/webapp/images/delete.png
___________________________________________________________________
Added: svn:mime-type
+ image/png
Added: svn:keywords
+ Author Date Id Revision HeadURL
Modified: trunk/echobase-ui/src/main/webapp/js/gridHelper.js
===================================================================
--- trunk/echobase-ui/src/main/webapp/js/gridHelper.js 2012-09-08 11:23:33 UTC (rev 637)
+++ trunk/echobase-ui/src/main/webapp/js/gridHelper.js 2012-09-09 19:57:02 UTC (rev 638)
@@ -74,6 +74,19 @@
}, {id:gridId, url:url, parameterName:parameterName});
},
+ addSingleRowTopic2:function (gridId, action, callback) {
+ $.subscribe(gridId + '-row' + action, function (event) {
+
+
+ var gridId = event.data.id;
+ var opts = jQuery.struts2_jquery[gridId];
+ var selectedId = opts['selectedRow'];
+ if (selectedId) {
+ event.data.callback(event, selectedId);
+ }
+ }, {id:gridId, callback:callback});
+ },
+
addMultiRowTopic:function (gridId, action, target, checkboxName, callback) {
$.subscribe(gridId + '-row' + action, function (event) {
var gridId = event.data.id;
@@ -247,6 +260,10 @@
return $(document).addSingleRowTopic(gridId, action, url, parameterName);
},
+ addSingleRowTopic2:function (gridId, action, callback) {
+ return $(document).addSingleRowTopic2(gridId, action, callback);
+ },
+
addMultiRowTopic:function (gridId, action, target, checkboxName, calbback) {
return $(document).addMultiRowTopic(gridId, action, target, checkboxName, calbback);
},
Added: trunk/src/site/rst/db.rst
===================================================================
--- trunk/src/site/rst/db.rst (rev 0)
+++ trunk/src/site/rst/db.rst 2012-09-09 19:57:02 UTC (rev 638)
@@ -0,0 +1,121 @@
+.. -
+.. * #%L
+.. * EchoBase
+.. * $Id$
+.. * $HeadURL$
+.. * %%
+.. * Copyright (C) 2011 - 2012 Ifremer, Codelutin
+.. * %%
+.. * This program is free software: you can redistribute it and/or modify
+.. * it under the terms of the GNU Affero General Public License as published by
+.. * the Free Software Foundation, either version 3 of the License, or
+.. * (at your option) any later version.
+.. *
+.. * This program is distributed in the hope that it will be useful,
+.. * but WITHOUT ANY WARRANTY; without even the implied warranty of
+.. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+.. * GNU General Public License for more details.
+.. *
+.. * You should have received a copy of the GNU Affero General Public License
+.. * along with this program. If not, see <http://www.gnu.org/licenses/>.
+.. * #L%
+.. -
+==========================
+Echobase - Base de données
+==========================
+
+.. contents:: Table des matières
+ :depth: 2
+
+.. sectnum::
+ :start: 1
+ :depth: 2
+
+Les bases de données dans EchoBase
+----------------------------------
+
+*EchoBase* permet l'utilisation de plusieurs bases de données que nous appelons
+*bases de travail*.
+
+Il est nécessaire de se connecter à une telle base de travail avant tout
+import/consultation/... de données dans l'application.
+
+Il est possible de gérer les paramètres de connexion à une base de travail.
+
+On distinque deux types de base :
+
+- les bases de données de type *H2*
+- les bases de données de type *Postgresql*
+
+Utilisation d'une base H2
+-------------------------
+
+L'avantage de ce type base est de pouvoir les créer facilement sans aucune
+maintenance (la base est stockée dans un simple fichier). Par contre elles sont
+moins performantes et perenne que les bases de type *Postgresql*.
+
+Pour utiliser une telle base, il suffit de créer une configuration de type *H2*
+en spécifiant une url de type :
+
+::
+ jdbc:h2:file:/cheminVersLaBase/nomDeLaBase
+
+Vous pouvez ensuite utiliser cette base qui va être crée automatiquement à
+l'endroit spécifié.
+
+Il est recommandé de fournir un mot de passe bien que cela ne soit pas
+obligatoire (mais cela peut être requis par certains outils externes).
+
+Par convention, nous utilisons les identifiants suivants :
+
+::
+ login: sa
+ password: sa
+
+Utilisation d'une base Postgres
+-------------------------------
+
+C'est ce genre de base que l'on doit utiliser sur un serveur pour conserver de
+manière perenne les données.
+
+Pour utiliser une telle base il faut configurer le serveur postgres comme
+indiqué dans la section suivante.
+
+Une fois la base créée sur le serveur, il suffit de créer une configuration de
+base de travail dans *EchoBase* de type *Postgresql* avec une url de type :
+
+::
+ jdbc:postgresql://adresseDuServeur/nomDeLaBase
+
+Les identifiants vous sont fournit par l'administrateur qui a installé la base
+postgresql sur le serveur.
+
+Création d'une base postgresql
+------------------------------
+
+Pré-requis :
+ - **postgres** doit être installé sur la machine (exemple pour un système
+ Debian : **sudo apt-get install postgresql**)
+ - être connecté avec l'utilisateur (postgres par défaut) qui a les droits
+ d'administrer cette base de donnée dans une console shell.
+
+1. Création de l'utilisateur Postgres
+
+::
+
+ createuser -U postgres -sdRP echobase
+
+2. Création de la base de donnée "echobase"
+
+::
+
+ createdb -U postgres -E UTF-8 -O echobase echobase
+
+3. Donner les droits d'acces à l'utilisateur echobase (cela varie d'un système
+ à l'autre, donc se référer à la documentation du système). Cela fonctionne
+ lorsqu'on peut accéder à la base via cette commande :
+
+::
+
+ psql -h localhost -U echobase echobase
+
Property changes on: trunk/src/site/rst/db.rst
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/src/site/rst/embedded.rst
===================================================================
--- trunk/src/site/rst/embedded.rst 2012-09-08 11:23:33 UTC (rev 637)
+++ trunk/src/site/rst/embedded.rst 2012-09-09 19:57:02 UTC (rev 638)
@@ -51,118 +51,13 @@
données), elle est téléchargeable depuis une page de résultat de l'opération
(normalement l'archive se met toute seule en téléchargement).
-Architecture de l'application embarquée
+Utilisation d'une application embarquée
=======================================
-L'archive une fois décompressé à la forme suivante :
+L'application embarquée est en fait une version *mode autonome* d'EchoBase
+avec en plus un jeu de données.
-::
+Consultez la `page d'utilisation`_ pour les détails d'utilisation et
+configuration d'EchoBase.
- echobase-embedded-0.6-pelgas2010
- ├── db (1) contient la base de données au format h2.
- │ └── echobase.h2.db
- ├── drivers (2) contient les drivers jdbc à utiliser dans LibreOffice
- │ ├── h2-1.3.165.jar
- │ └── postgresql-9.1-901-1.jdbc4.jar
- ├── echobase.properties (3) Fichier de configuration de l'application embarquée
- ├── echobase-ui-0.6.war (4) Application embarquée (war auto-exécutable)
- ├── logs (5) contient les logs de l'application
- │ └── echobase.log
- ├── README.txt
- ├── startEchobase.bat (6) Script de démarrage (windows)
- └── startEchobase.sh (7) Script de démarrage (linux)
-
-Utilisateurs
-============
-
-Deux utilisateurs sont fournis dans la base embarquée :
-
-- admin / admin (avec des droits d'administration)
-- user / user (pour la consultation)
-
-
-Utilisation de l'application embarquée (windows)
-------------------------------------------------
-
-Pré-requis
-==========
-
-Installer un environnement java de développement (une JDK) et pas une JRE
-qui ne suffit pas.
-
-`Page de téléchargement Oracle`_
-
-Une fois la JDK téléchargée et installée, ajouter la variable d'environnement
-**JDK_HOME** qui est le chemin vers où a été installé Java.
-
-::
-
- JDK_HOME -> C:/Program Files/Java/jdk1.7.0_03
-
-Installation d'echobase
-=======================
-
-- Dézipper l'archive précédemment téléchargée du site central.
-
-- Ouvrir une console (Touche Windows + R , taper *cmd* , Touche Entrée)
-- Se placer dans le répertoire où a été dézippée l'archive
-
-::
- cd Chemin vers l'archive dézippée
-
-- Enfin lancer le script
-
-::
- startEchobase.bat
-
-- Dans la console on doit voir l'application démarré et produire des logs
-- Lorsque l'application est prête, un navigateur s'ouvre sur la page
- de login.
-
-Utilisation de l'application embarquée (linux)
-----------------------------------------------
-
-Pré-requis
-==========
-
-Installer un environnement java de développement (une JDK) et pas une JRE
-qui ne suffit pas.
-
-`Page de téléchargement Oracle`_
-
-Une fois la JDK téléchargée et installée, ajouter dans les variables
-d'environnement :
-
-::
-
- JDK_HOME -> chemin vers où a été installé la JDK
-
- Pour ajouter une variable d'environnement, écrire dans ton fichier /home/Utilisateur/.bashrc la ligne :
-
-export JDK_HOME=/path/vers/jdk
-
-Installation d'echobase
-=======================
-
-- Dézipper l'archive précédemment téléchargée du site central.
-- Ouvrir une console
-- Se placer dans le répertoire où a été dézippée l'archive
-
-::
- cd Chemin vers l'archive dézippée
-
-- Rendre le script de démarrage exécutable
-
-::
- chmod +x startEchobase.sh
-
-- Enfin lancer le script
-
-::
- ./startEchobase.sh
-
-- Dans la console on doit voir l'application démarré et produire des logs
-- Lorsque l'application est prête, un navigateur s'ouvre sur la page
- de login.
-
-.. _Page de téléchargement Oracle: http://www.oracle.com/technetwork/java/javase/downloads/index.html
+.. _page d'utilisation: ./usage.html#utiliser-la-version-mode-portable
Added: trunk/src/site/rst/usage.rst
===================================================================
--- trunk/src/site/rst/usage.rst (rev 0)
+++ trunk/src/site/rst/usage.rst 2012-09-09 19:57:02 UTC (rev 638)
@@ -0,0 +1,189 @@
+.. -
+.. * #%L
+.. * EchoBase
+.. * $Id$
+.. * $HeadURL$
+.. * %%
+.. * Copyright (C) 2011 - 2012 Ifremer, Codelutin
+.. * %%
+.. * This program is free software: you can redistribute it and/or modify
+.. * it under the terms of the GNU Affero General Public License as published by
+.. * the Free Software Foundation, either version 3 of the License, or
+.. * (at your option) any later version.
+.. *
+.. * This program is distributed in the hope that it will be useful,
+.. * but WITHOUT ANY WARRANTY; without even the implied warranty of
+.. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+.. * GNU General Public License for more details.
+.. *
+.. * You should have received a copy of the GNU Affero General Public License
+.. * along with this program. If not, see <http://www.gnu.org/licenses/>.
+.. * #L%
+.. -
+======================
+EchoBase - Utilisation
+======================
+
+.. contents:: Table des matières
+ :depth: 2
+
+.. sectnum::
+ :start: 1
+ :depth: 2
+
+Comment utiliser EchoBase
+-------------------------
+
+L'application est fournit sous deux modes:
+
+- une version en *mode portable* qui ne nécessite pas de serveur
+- une version en *mode serveur* qui nécessite l'installation d'*EchoBase* dans
+ un serveur web de type *tomcat* ou *jetty*.
+
+Nous détaillons dans les sections suivantes comment utiliser les différentes
+versions.
+
+Utiliser la version mode portable
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+En mode portable, pas besoin de serveur, il faut juste avoir java d'installer
+sur la machine avec la varaible d'environnement *JDK_HOME* de bien positionner
+sur le repertoire où est installer Java.
+
+Pré-requis pour utilisation sous Windows
+________________________________________
+
+Installer un environnement java de développement (une JDK) et pas une JRE
+qui ne suffit pas.
+
+`Page de téléchargement Oracle`_
+
+Une fois la JDK téléchargée et installée, ajouter la variable d'environnement
+**JDK_HOME** qui est le chemin vers où a été installé Java.
+
+::
+
+ JDK_HOME -> C:/Program Files/Java/jdk1.7.0_03
+
+Pré-requis pour utilisation sous Linux
+______________________________________
+
+Installer un environnement java de développement (une JDK) et pas une JRE
+qui ne suffit pas.
+
+`Page de téléchargement Oracle`_
+
+Une fois la JDK téléchargée et installée, ajouter dans les variables
+d'environnement :
+
+::
+
+ JDK_HOME -> chemin vers où a été installé la JDK
+
+ Pour ajouter une variable d'environnement, écrire dans ton fichier /home/Utilisateur/.bashrc la ligne :
+
+export JDK_HOME=/path/vers/jdk
+
+Procédure d'installation
+________________________
+
+Une fois les pré-requis remplis, c'est très simple :
+
+- Récupérer l'archive zip `echobase-${project.version}-embedded.zip`_.
+
+- Décompresser l'archive, vous obtenez une arborescence de ce type:
+
+::
+
+ echobase-ui-1.1-embedded
+ ├── echobase.properties (1) Fichier de configuration de l'application embarquée
+ ├── echobase-ui-1.1-embedded.war
+ ├── LICENSE.txt
+ ├── README.txt
+ ├── startEchobase.bat (2) Script de démarrage (windows)
+ ├── startEchobase.sh (3) Script de démarrage (linux)
+ └── THIRD-PARTY.txt
+
+- Lancer le script *startEchobase.sh* (linux) ou *startEchobase.bat* (windows).
+
+L'application va démarrer et est accessible à l'adresse suivante:
+
+::
+ http://localhost:8888
+
+Procédure détaillée (sous windows)
+__________________________________
+
+- Dézipper l'archive précédemment téléchargée du site central.
+
+- Ouvrir une console (Touche Windows + R , taper *cmd* , Touche Entrée)
+- Se placer dans le répertoire où a été dézippée l'archive
+
+::
+ cd Chemin vers l'archive dézippée
+
+- Enfin lancer le script
+
+::
+ startEchobase.bat
+
+- Dans la console on doit voir l'application démarré et produire des logs
+- Lorsque l'application est prête, un navigateur s'ouvre sur la page
+ de login.
+
+Procédure détaillée (sous linux)
+________________________________
+
+- Dézipper l'archive précédemment téléchargée du site central.
+- Ouvrir une console
+- Se placer dans le répertoire où a été dézippée l'archive
+
+::
+ cd Chemin vers l'archive dézippée
+
+- Rendre le script de démarrage exécutable
+
+::
+ chmod +x startEchobase.sh
+
+- Enfin lancer le script
+
+::
+ ./startEchobase.sh
+
+- Dans la console on doit voir l'application démarré et produire des logs
+- Lorsque l'application est prête, un navigateur s'ouvre sur la page
+ de login.
+
+Utilisateurs
+____________
+
+Par défaut, deux utilisateurs sont fournis dans la base embarquée :
+
+- admin / admin (avec des droits d'administration)
+- user / user (pour la consultation)
+
+Configuration base de travail
+_____________________________
+
+Une configuration de base de travail est aussi crée automatiquement vers une
+base de type *H2* stoquée dans le répertoire *db* avec les identifiants suivants :
+
+- login: *sa*
+- mot de passe: *sa*
+
+Utiliser la version mode serveur
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Il faut que l'application est au préalable installée sur un serveur web.
+
+Demandez à votre administrateur l'url de connexion, et les identifiants.
+
+Si vous voulez installer EchoBase sur un serveur, veuillez consulter la
+`page installation`_.
+
+.. _echobase-${project.version}-embedded.zip: http://forge.codelutin.com/projects/echobase/files
+.. _page installation: ./install.html
+.. _Page de téléchargement Oracle: http://www.oracle.com/technetwork/java/javase/downloads/index.html
+
+
Property changes on: trunk/src/site/rst/usage.rst
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
1
0
Author: tchemit
Date: 2012-09-08 13:23:33 +0200 (Sat, 08 Sep 2012)
New Revision: 637
Url: http://forge.codelutin.com/repositories/revision/echobase/637
Log:
>From scmwebeditor -- fix documentation
Modified:
trunk/src/site/rst/index.rst
Modified: trunk/src/site/rst/index.rst
===================================================================
--- trunk/src/site/rst/index.rst 2012-09-07 20:58:54 UTC (rev 636)
+++ trunk/src/site/rst/index.rst 2012-09-08 11:23:33 UTC (rev 637)
@@ -55,8 +55,8 @@
- Comment créer une `application embarquée`_.
-.. _Ifremer forge: https://forge.ifremer.fr/www/echor
-.. _ICES WGFAST: http://www.acoustics.washington.edu/FAST
+.. _forge Ifremer: https://forge.ifremer.fr/www/echor
+.. _groupe de travail CIEM WGFAST: http://www.acoustics.washington.edu/FAST
.. _installation: ./install.html
.. _modèle: ./model.html
.. _imports: ./imports.html
1
0
r636 - in trunk: echobase-domain/src/main/java/fr/ifremer/echobase/services echobase-services/src/main/java/fr/ifremer/echobase/services echobase-services/src/main/java/fr/ifremer/echobase/services/importdata echobase-services/src/main/java/fr/ifremer/echobase/services/removedata
by tchemit@users.forge.codelutin.com 07 Sep '12
by tchemit@users.forge.codelutin.com 07 Sep '12
07 Sep '12
Author: tchemit
Date: 2012-09-07 22:58:54 +0200 (Fri, 07 Sep 2012)
New Revision: 636
Url: http://forge.codelutin.com/repositories/revision/echobase/636
Log:
refs #1437: Suppression des imports (add remove basic service)
Added:
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/AbstractRemoveDataService.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/AcousticRemoveDataService.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/CatchesRemoveDataService.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/CommonAllRemoveDataService.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/CommonTransectRemoveDataService.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/OperationRemoveDataService.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/ResultEsduRemoveDataService.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/ResultMapRemoveDataService.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/ResultRegionRemoveDataService.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/ResultVoyageRemoveDataService.java
Modified:
trunk/echobase-domain/src/main/java/fr/ifremer/echobase/services/EchoBaseServiceSupport.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/DecoratorService.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/AbstractImportDataService.java
Modified: trunk/echobase-domain/src/main/java/fr/ifremer/echobase/services/EchoBaseServiceSupport.java
===================================================================
--- trunk/echobase-domain/src/main/java/fr/ifremer/echobase/services/EchoBaseServiceSupport.java 2012-09-07 16:34:49 UTC (rev 635)
+++ trunk/echobase-domain/src/main/java/fr/ifremer/echobase/services/EchoBaseServiceSupport.java 2012-09-07 20:58:54 UTC (rev 636)
@@ -157,6 +157,37 @@
}
}
+ protected <E extends TopiaEntity> E create(TopiaDAO<E> dao,
+ Object... properties) {
+ try {
+ E result = dao.create(properties);
+ return result;
+ } catch (TopiaException e) {
+ throw new EchoBaseTechnicalException("Could not create entity", e);
+ }
+ }
+
+ protected final <E extends TopiaEntity> void delete(TopiaDAO<E> dao, E entity) {
+
+ try {
+ dao.delete(entity);
+ } catch (TopiaException e) {
+
+ throw new EchoBaseTechnicalException("Could not delete entity " + entity, e);
+ }
+ }
+
+ protected <E extends TopiaEntity> E findByProperties(TopiaDAO<E> dao,
+ String propertyName,
+ Object value,
+ Object... others) {
+ try {
+ E result = dao.findByProperties(propertyName, value, others);
+ return result;
+ } catch (TopiaException e) {
+ throw new EchoBaseTechnicalException("Could not obtain query db", e);
+ }
+ }
protected final <E extends TopiaEntity, D extends TopiaDAO<E>> D getDAO(Class<E> entityType, Class<D> daoType) {
TopiaDAO<E> dao = getDAO(entityType);
Preconditions.checkState(daoType.isAssignableFrom(dao.getClass()));
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/DecoratorService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/DecoratorService.java 2012-09-07 16:34:49 UTC (rev 635)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/DecoratorService.java 2012-09-07 20:58:54 UTC (rev 636)
@@ -28,6 +28,7 @@
import com.google.common.collect.Maps;
import fr.ifremer.echobase.entities.EchoBaseUser;
import fr.ifremer.echobase.entities.ExportQuery;
+import fr.ifremer.echobase.entities.ImportLog;
import fr.ifremer.echobase.entities.WorkingDbConfiguration;
import fr.ifremer.echobase.entities.data.Category;
import fr.ifremer.echobase.entities.data.Cell;
@@ -179,6 +180,10 @@
// ExportQuery decorator
registerJXPathDecorator(locale, ExportQuery.class, "${name}$s - ${description}$s");
+ // ImportLog decorator
+ registerJXPathDecorator(locale, ImportLog.class, "${importType}$s - ${importDate}$s - ${importText}$s");
+
+
// WorkingDbConfiguration decorator
registerJXPathDecorator(locale, WorkingDbConfiguration.class, "${url}$s - ${login}$s (${description}$s)");
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/AbstractImportDataService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/AbstractImportDataService.java 2012-09-07 16:34:49 UTC (rev 635)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/AbstractImportDataService.java 2012-09-07 20:58:54 UTC (rev 636)
@@ -136,7 +136,6 @@
EchoBaseUser user,
long time) {
-
Date importDate = newDate();
String importUser = user.getEmail();
@@ -261,16 +260,6 @@
}
}
- protected <E extends TopiaEntity> E create(TopiaDAO<E> dao,
- Object... properties) {
- try {
- E result = dao.create(properties);
- return result;
- } catch (TopiaException e) {
- throw new EchoBaseTechnicalException("Could not create entity", e);
- }
- }
-
protected <E extends TopiaEntity> E findByProperties(TopiaDAO<E> dao,
String propertyName,
Object value,
Added: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/AbstractRemoveDataService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/AbstractRemoveDataService.java (rev 0)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/AbstractRemoveDataService.java 2012-09-07 20:58:54 UTC (rev 636)
@@ -0,0 +1,239 @@
+package fr.ifremer.echobase.services.removedata;
+
+/*
+ * #%L
+ * EchoBase :: Services
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 - 2012 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%
+ */
+
+import com.google.common.collect.Lists;
+import fr.ifremer.echobase.EchoBaseTechnicalException;
+import fr.ifremer.echobase.entities.EchoBaseUser;
+import fr.ifremer.echobase.entities.EntityModificationLog;
+import fr.ifremer.echobase.entities.ImportLog;
+import fr.ifremer.echobase.entities.ImportType;
+import fr.ifremer.echobase.services.DecoratorService;
+import fr.ifremer.echobase.services.EchoBaseServiceSupport;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.topia.TopiaException;
+import org.nuiton.topia.TopiaNotFoundException;
+import org.nuiton.topia.persistence.TopiaDAO;
+import org.nuiton.topia.persistence.TopiaEntity;
+import org.nuiton.topia.persistence.TopiaId;
+import org.nuiton.util.StringUtil;
+import org.nuiton.util.TimeLog;
+import org.nuiton.util.decorator.Decorator;
+
+import java.util.List;
+import java.util.Locale;
+import java.util.Set;
+
+import static org.nuiton.i18n.I18n.l_;
+
+/**
+ * Abstract service to remove import data.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.2
+ */
+public abstract class AbstractRemoveDataService extends EchoBaseServiceSupport {
+
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(AbstractRemoveDataService.class);
+
+ public static final TimeLog TIME_LOG =
+ new TimeLog(AbstractRemoveDataService.class);
+
+ protected static final String ID_REQUEST =
+ "SELECT COUNT(*) FROM %s WHERE topiaid = :id";
+
+ protected String importLabel;
+
+ public String getImportLabel() {
+ return importLabel;
+ }
+
+ protected abstract void removeData(String id);
+
+ protected abstract Set<ImportType> getPossibleSubImportType();
+
+ public String doRemove(ImportLog importLog, EchoBaseUser user) {
+
+ Locale locale = getLocale();
+ importLabel = l_(locale, importLog.getImportType().getI18nKey());
+
+ long s0 = TimeLog.getTime();
+
+ for (String importId : importLog.getImportId()) {
+
+ removeData(importId);
+ }
+
+ s0 = TIME_LOG.log(s0, "removeData");
+
+ List<ImportLog> removedImortLog = removeObsoleteImportLogs(importLog);
+
+ s0 = TIME_LOG.log(s0, "removeObsoleteImportLogs");
+
+ // add result in log book and compute resume to show in result
+ String result = computeLogBookEntry(importLog,
+ removedImortLog,
+ user,
+ TimeLog.getTime() - s0);
+
+ // do commit
+ commitTransaction("Could not remove import " + getImportLabel());
+ return result;
+ }
+
+ protected List<ImportLog> removeObsoleteImportLogs(ImportLog importLog) {
+
+ List<ImportLog> result = Lists.newArrayList();
+
+ Set<ImportType> possibleSubImportType = getPossibleSubImportType();
+
+ TopiaDAO<ImportLog> dao = getDAO(ImportLog.class);
+
+ for (ImportLog logEntry : dao) {
+
+ if (importLog.equals(logEntry)) {
+
+ // for sure remove me
+ // but do not add to result
+ delete(dao, logEntry);
+ continue;
+ }
+
+ if (possibleSubImportType.contains(logEntry.getImportType())) {
+
+ // ok can try to remove this import log
+ // try to find out if first id is still exists
+ String firstId = importLog.getImportId().iterator().next();
+
+ if (!isIdExists(firstId)) {
+
+ // one of id does not exist, can safely remove importLog
+
+ if (log.isInfoEnabled()) {
+ log.info("Will remove obsolete importLog " +
+ importLog.getTopiaId());
+ }
+
+ delete(dao, logEntry);
+
+ // add it in result
+ result.add(logEntry);
+ }
+ }
+ }
+ return result;
+ }
+
+ protected String computeLogBookEntry(ImportLog importLog,
+ List<ImportLog> obsoleteImportLogs,
+ EchoBaseUser user,
+ long time) {
+
+ Decorator<ImportLog> decorator = getService(DecoratorService.class).
+ getDecorator(getLocale(), ImportLog.class, null);
+
+ StringBuilder buffer = new StringBuilder();
+ buffer.append("Suppression import ");
+ buffer.append(decorator.toString(importLog));
+ buffer.append("\nOpération réalisée en ");
+ buffer.append(StringUtil.convertTime(time));
+
+ for (ImportLog obsoleteImportLog : obsoleteImportLogs) {
+
+ buffer.append("\n- Suppression en cascade de l'import ");
+ buffer.append(decorator.toString(obsoleteImportLog));
+ }
+
+ String result = buffer.toString();
+
+ if (log.isDebugEnabled()) {
+ log.debug("Log text: " + result);
+ }
+ create(getDAO(EntityModificationLog.class),
+ EntityModificationLog.PROPERTY_ENTITY_TYPE, "Remove Import",
+ EntityModificationLog.PROPERTY_ENTITY_ID, importLog.getImportType(),
+ EntityModificationLog.PROPERTY_MODIFICATION_USER, user.getEmail(),
+ EntityModificationLog.PROPERTY_MODIFICATION_DATE, newDate(),
+ EntityModificationLog.PROPERTY_MODIFICATION_TEXT, result
+ );
+ return result;
+ }
+
+ protected boolean isIdExists(String id) {
+
+ try {
+
+ boolean result = getDAOFromId(id).existByTopiaId(id);
+ return result;
+ } catch (TopiaException e) {
+ throw new EchoBaseTechnicalException(
+ "Could not find out if id " + id + " exists.", e);
+ }
+ }
+
+ protected <E extends TopiaEntity> E findById(TopiaDAO<E> dao, String id) {
+
+ try {
+ E result = dao.findByTopiaId(id);
+ return result;
+ } catch (TopiaException e) {
+ throw new EchoBaseTechnicalException("Could not find entity with id " + id, e);
+ }
+ }
+
+ protected <E extends TopiaEntity> TopiaDAO<E> getDAOFromId(String id) {
+ try {
+ return getDAO(TopiaId.getClassName(id));
+ } catch (TopiaNotFoundException e) {
+
+ throw new EchoBaseTechnicalException(
+ "Could not find class from id: " + id, e);
+ }
+ }
+
+ protected <E extends TopiaEntity> E removeEntity(String id) {
+
+ // get dao
+ TopiaDAO<E> dao = getDAOFromId(id);
+
+ // get entity to delete
+ E entity = findById(dao, id);
+
+ // delete it
+ delete(dao, entity);
+
+ return entity;
+ }
+
+
+ protected void canNotDealWithId(String id) {
+ throw new IllegalStateException(
+ "Can not deal with this type of id " + id +
+ " from service " + this);
+ }
+
+}
Property changes on: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/AbstractRemoveDataService.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/AcousticRemoveDataService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/AcousticRemoveDataService.java (rev 0)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/AcousticRemoveDataService.java 2012-09-07 20:58:54 UTC (rev 636)
@@ -0,0 +1,90 @@
+package fr.ifremer.echobase.services.removedata;
+
+/*
+ * #%L
+ * EchoBase :: Services
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 - 2012 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%
+ */
+
+import com.google.common.collect.Sets;
+import fr.ifremer.echobase.entities.ImportType;
+import fr.ifremer.echobase.entities.data.Cell;
+import fr.ifremer.echobase.entities.data.DataAcquisition;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * Remove a {@link ImportType#ACOUSTIC} import.
+ * <p/>
+ * Can remove only {@link DataAcquisition} or {@link Cell}.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.2
+ */
+public class AcousticRemoveDataService extends AbstractRemoveDataService {
+
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(AcousticRemoveDataService.class);
+
+ @Override
+ protected void removeData(String id) {
+
+ if (id.startsWith(DataAcquisition.class.getName())) {
+
+ // remove dataAcquisition
+ removeDataAcquisition(id);
+ } else if (id.startsWith(Cell.class.getName())) {
+
+ // remove cell
+ removeCell(id);
+ } else {
+ canNotDealWithId(id);
+ }
+ }
+
+ protected void removeDataAcquisition(String id) {
+ DataAcquisition entity = removeEntity(id);
+ if (log.isInfoEnabled()) {
+ log.info("DataAcquisition " + entity.getTopiaId() + " was removed");
+ }
+ }
+
+ protected void removeCell(String id) {
+ Cell entity = removeEntity(id);
+ if (log.isInfoEnabled()) {
+ log.info("Cell " + entity.getTopiaId() + " was removed");
+ }
+ }
+
+ @Override
+ protected Set<ImportType> getPossibleSubImportType() {
+ HashSet<ImportType> result = Sets.newHashSet(ImportType.values());
+ result.remove(ImportType.COMMON_ALL);
+ result.remove(ImportType.COMMON_TRANSECT);
+ result.remove(ImportType.OPERATION);
+ result.remove(ImportType.CATCHES);
+ result.remove(ImportType.ACOUSTIC);
+ return result;
+ }
+}
Property changes on: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/AcousticRemoveDataService.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/CatchesRemoveDataService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/CatchesRemoveDataService.java (rev 0)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/CatchesRemoveDataService.java 2012-09-07 20:58:54 UTC (rev 636)
@@ -0,0 +1,77 @@
+package fr.ifremer.echobase.services.removedata;
+
+/*
+ * #%L
+ * EchoBase :: Services
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 - 2012 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%
+ */
+
+import com.google.common.collect.Sets;
+import fr.ifremer.echobase.entities.ImportType;
+import fr.ifremer.echobase.entities.data.Sample;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * Remove a {@link ImportType#CATCHES} import.
+ * <p/>
+ * Can remove only {@link Sample}.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.2
+ */
+public class CatchesRemoveDataService extends AbstractRemoveDataService {
+
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(CatchesRemoveDataService.class);
+
+ @Override
+ protected void removeData(String id) {
+
+ if (id.startsWith(Sample.class.getName())) {
+
+ // remove sample
+ removeSample(id);
+ } else {
+ canNotDealWithId(id);
+ }
+ }
+
+ protected void removeSample(String id) {
+ Sample entity = removeEntity(id);
+ if (log.isInfoEnabled()) {
+ log.info("Sample " + entity.getTopiaId() + " was removed");
+ }
+ }
+
+ @Override
+ protected Set<ImportType> getPossibleSubImportType() {
+ HashSet<ImportType> result = Sets.newHashSet(ImportType.values());
+ result.remove(ImportType.COMMON_ALL);
+ result.remove(ImportType.COMMON_TRANSECT);
+ result.remove(ImportType.OPERATION);
+ result.remove(ImportType.CATCHES);
+ return result;
+ }
+}
Property changes on: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/CatchesRemoveDataService.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/CommonAllRemoveDataService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/CommonAllRemoveDataService.java (rev 0)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/CommonAllRemoveDataService.java 2012-09-07 20:58:54 UTC (rev 636)
@@ -0,0 +1,75 @@
+package fr.ifremer.echobase.services.removedata;
+
+/*
+ * #%L
+ * EchoBase :: Services
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 - 2012 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%
+ */
+
+import com.google.common.collect.Sets;
+import fr.ifremer.echobase.entities.ImportType;
+import fr.ifremer.echobase.entities.data.Voyage;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * Remove a {@link ImportType#COMMON_ALL} import.
+ * <p/>
+ * Can remove only {@link Voyage}.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.2
+ */
+public class CommonAllRemoveDataService extends AbstractRemoveDataService {
+
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(CommonAllRemoveDataService.class);
+
+ @Override
+ protected void removeData(String id) {
+
+ if (id.startsWith(Voyage.class.getName())) {
+
+ // remove voyage
+ removeVoyage(id);
+ } else {
+ canNotDealWithId(id);
+ }
+ }
+
+ protected void removeVoyage(String id) {
+ Voyage entity = removeEntity(id);
+ if (log.isInfoEnabled()) {
+ log.info("Voyage " + entity.getTopiaId() + " was removed");
+ }
+ }
+
+ @Override
+ protected Set<ImportType> getPossibleSubImportType() {
+ HashSet<ImportType> result = Sets.newHashSet(ImportType.values());
+ result.remove(ImportType.COMMON_ALL);
+ result.remove(ImportType.COMMON_TRANSECT);
+ return result;
+ }
+}
Property changes on: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/CommonAllRemoveDataService.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/CommonTransectRemoveDataService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/CommonTransectRemoveDataService.java (rev 0)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/CommonTransectRemoveDataService.java 2012-09-07 20:58:54 UTC (rev 636)
@@ -0,0 +1,75 @@
+package fr.ifremer.echobase.services.removedata;
+
+/*
+ * #%L
+ * EchoBase :: Services
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 - 2012 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%
+ */
+
+import com.google.common.collect.Sets;
+import fr.ifremer.echobase.entities.ImportType;
+import fr.ifremer.echobase.entities.data.Transect;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * Remove a {@link ImportType#COMMON_TRANSECT} import.
+ * <p/>
+ * Can remove only {@link Transect}.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.2
+ */
+public class CommonTransectRemoveDataService extends AbstractRemoveDataService {
+
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(CommonTransectRemoveDataService.class);
+
+ @Override
+ protected void removeData(String id) {
+
+ if (id.startsWith(Transect.class.getName())) {
+
+ // remove transect
+ removeTransect(id);
+ } else {
+ canNotDealWithId(id);
+ }
+ }
+
+ protected void removeTransect(String id) {
+ Transect entity = removeEntity(id);
+ if (log.isInfoEnabled()) {
+ log.info("Transect " + entity.getTopiaId() + " was removed");
+ }
+ }
+
+ @Override
+ protected Set<ImportType> getPossibleSubImportType() {
+ HashSet<ImportType> result = Sets.newHashSet(ImportType.values());
+ result.remove(ImportType.COMMON_ALL);
+ result.remove(ImportType.COMMON_TRANSECT);
+ return result;
+ }
+}
Property changes on: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/CommonTransectRemoveDataService.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/OperationRemoveDataService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/OperationRemoveDataService.java (rev 0)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/OperationRemoveDataService.java 2012-09-07 20:58:54 UTC (rev 636)
@@ -0,0 +1,76 @@
+package fr.ifremer.echobase.services.removedata;
+
+/*
+ * #%L
+ * EchoBase :: Services
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 - 2012 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%
+ */
+
+import com.google.common.collect.Sets;
+import fr.ifremer.echobase.entities.ImportType;
+import fr.ifremer.echobase.entities.data.Operation;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * Remove a {@link ImportType#OPERATION} import.
+ * <p/>
+ * Can remove only {@link Operation}.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.2
+ */
+public class OperationRemoveDataService extends AbstractRemoveDataService {
+
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(OperationRemoveDataService.class);
+
+ @Override
+ protected void removeData(String id) {
+
+ if (id.startsWith(Operation.class.getName())) {
+
+ // remove operation
+ removeOperation(id);
+ } else {
+ canNotDealWithId(id);
+ }
+ }
+
+ protected void removeOperation(String id) {
+ Operation entity = removeEntity(id);
+ if (log.isInfoEnabled()) {
+ log.info("Operation " + entity.getTopiaId() + " was removed");
+ }
+ }
+
+ @Override
+ protected Set<ImportType> getPossibleSubImportType() {
+ HashSet<ImportType> result = Sets.newHashSet(ImportType.values());
+ result.remove(ImportType.COMMON_ALL);
+ result.remove(ImportType.COMMON_TRANSECT);
+ result.remove(ImportType.OPERATION);
+ return result;
+ }
+}
Property changes on: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/OperationRemoveDataService.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/ResultEsduRemoveDataService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/ResultEsduRemoveDataService.java (rev 0)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/ResultEsduRemoveDataService.java 2012-09-07 20:58:54 UTC (rev 636)
@@ -0,0 +1,80 @@
+package fr.ifremer.echobase.services.removedata;
+
+/*
+ * #%L
+ * EchoBase :: Services
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 - 2012 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%
+ */
+
+import com.google.common.collect.Sets;
+import fr.ifremer.echobase.entities.ImportType;
+import fr.ifremer.echobase.entities.data.Result;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * Remove a {@link ImportType#RESULT_ESDU} import.
+ * <p/>
+ * Can remove only {@link Result}.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.2
+ */
+public class ResultEsduRemoveDataService extends AbstractRemoveDataService {
+
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(ResultEsduRemoveDataService.class);
+
+ @Override
+ protected void removeData(String id) {
+
+ if (id.startsWith(Result.class.getName())) {
+
+ // remove result
+ removeResult(id);
+ } else {
+ canNotDealWithId(id);
+ }
+ }
+
+ protected void removeResult(String id) {
+ Result entity = removeEntity(id);
+ if (log.isInfoEnabled()) {
+ log.info("Result " + entity.getTopiaId() + " was removed");
+ }
+ }
+
+ @Override
+ protected Set<ImportType> getPossibleSubImportType() {
+ HashSet<ImportType> result = Sets.newHashSet(ImportType.values());
+ result.remove(ImportType.COMMON_ALL);
+ result.remove(ImportType.COMMON_TRANSECT);
+ result.remove(ImportType.OPERATION);
+ result.remove(ImportType.CATCHES);
+ result.remove(ImportType.ACOUSTIC);
+ result.remove(ImportType.RESULT_VOYAGE);
+ result.remove(ImportType.RESULT_ESDU);
+ return result;
+ }
+}
Property changes on: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/ResultEsduRemoveDataService.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/ResultMapRemoveDataService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/ResultMapRemoveDataService.java (rev 0)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/ResultMapRemoveDataService.java 2012-09-07 20:58:54 UTC (rev 636)
@@ -0,0 +1,73 @@
+package fr.ifremer.echobase.services.removedata;
+
+/*
+ * #%L
+ * EchoBase :: Services
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 - 2012 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%
+ */
+
+import com.google.common.collect.Sets;
+import fr.ifremer.echobase.entities.ImportType;
+import fr.ifremer.echobase.entities.data.Cell;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * Remove a {@link ImportType#RESULT_MAP} import.
+ * <p/>
+ * Can remove only {@link Cell}.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.2
+ */
+public class ResultMapRemoveDataService extends AbstractRemoveDataService {
+
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(ResultMapRemoveDataService.class);
+
+ @Override
+ protected void removeData(String id) {
+
+ if (id.startsWith(Cell.class.getName())) {
+
+ // remove cell
+ removeCell(id);
+ } else {
+ canNotDealWithId(id);
+ }
+ }
+
+ protected void removeCell(String id) {
+ Cell entity = removeEntity(id);
+ if (log.isInfoEnabled()) {
+ log.info("Cell " + entity.getTopiaId() + " was removed");
+ }
+ }
+
+ @Override
+ protected Set<ImportType> getPossibleSubImportType() {
+ HashSet<ImportType> result = Sets.newHashSet();
+ return result;
+ }
+}
Property changes on: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/ResultMapRemoveDataService.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/ResultRegionRemoveDataService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/ResultRegionRemoveDataService.java (rev 0)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/ResultRegionRemoveDataService.java 2012-09-07 20:58:54 UTC (rev 636)
@@ -0,0 +1,81 @@
+package fr.ifremer.echobase.services.removedata;
+
+/*
+ * #%L
+ * EchoBase :: Services
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 - 2012 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%
+ */
+
+import com.google.common.collect.Sets;
+import fr.ifremer.echobase.entities.ImportType;
+import fr.ifremer.echobase.entities.data.Cell;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * Remove a {@link ImportType#RESULT_REGION} import.
+ * <p/>
+ * Can remove only {@link Cell}.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.2
+ */
+public class ResultRegionRemoveDataService extends AbstractRemoveDataService {
+
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(ResultRegionRemoveDataService.class);
+
+ @Override
+ protected void removeData(String id) {
+
+ if (id.startsWith(Cell.class.getName())) {
+
+ // remove echotype
+ removeCell(id);
+ } else {
+ canNotDealWithId(id);
+ }
+ }
+
+ protected void removeCell(String id) {
+ Cell entity = removeEntity(id);
+ if (log.isInfoEnabled()) {
+ log.info("Cell " + entity.getTopiaId() + " was removed");
+ }
+ }
+
+ @Override
+ protected Set<ImportType> getPossibleSubImportType() {
+ HashSet<ImportType> result = Sets.newHashSet(ImportType.values());
+ result.remove(ImportType.COMMON_ALL);
+ result.remove(ImportType.COMMON_TRANSECT);
+ result.remove(ImportType.OPERATION);
+ result.remove(ImportType.CATCHES);
+ result.remove(ImportType.ACOUSTIC);
+ result.remove(ImportType.RESULT_VOYAGE);
+ result.remove(ImportType.RESULT_ESDU);
+ result.remove(ImportType.RESULT_VOYAGE);
+ return result;
+ }
+}
Property changes on: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/ResultRegionRemoveDataService.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/ResultVoyageRemoveDataService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/ResultVoyageRemoveDataService.java (rev 0)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/ResultVoyageRemoveDataService.java 2012-09-07 20:58:54 UTC (rev 636)
@@ -0,0 +1,104 @@
+package fr.ifremer.echobase.services.removedata;
+
+/*
+ * #%L
+ * EchoBase :: Services
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 - 2012 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%
+ */
+
+import com.google.common.collect.Sets;
+import fr.ifremer.echobase.entities.ImportType;
+import fr.ifremer.echobase.entities.data.Echotype;
+import fr.ifremer.echobase.entities.data.LengthAgeKey;
+import fr.ifremer.echobase.entities.data.LengthWeightKey;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * remove a {@link ImportType#OPERATION} import.
+ * <p/>
+ * Can remove only {@link Echotype}, {@link LengthAgeKey} or
+ * {@link LengthWeightKey}.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.2
+ */
+public class ResultVoyageRemoveDataService extends AbstractRemoveDataService {
+
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(ResultVoyageRemoveDataService.class);
+
+ @Override
+ protected void removeData(String id) {
+
+ if (id.startsWith(Echotype.class.getName())) {
+
+ // remove echotype
+ removeEchotype(id);
+ } else if (id.startsWith(LengthAgeKey.class.getName())) {
+
+ // remove lengthAgeKey
+ removeLengthAgeKey(id);
+ } else if (id.startsWith(LengthWeightKey.class.getName())) {
+
+ // remove lengthAgeKey
+ removeLengthWeightKey(id);
+ } else {
+ canNotDealWithId(id);
+ }
+ }
+
+ protected void removeEchotype(String id) {
+ Echotype entity = removeEntity(id);
+ if (log.isInfoEnabled()) {
+ log.info("Echotype " + entity.getTopiaId() + " was removed");
+ }
+ }
+
+ protected void removeLengthAgeKey(String id) {
+ LengthAgeKey entity = removeEntity(id);
+ if (log.isInfoEnabled()) {
+ log.info("LengthAgeKey " + entity.getTopiaId() + " was removed");
+ }
+ }
+
+ protected void removeLengthWeightKey(String id) {
+ LengthWeightKey entity = removeEntity(id);
+ if (log.isInfoEnabled()) {
+ log.info("LengthWeightKey " + entity.getTopiaId() + " was removed");
+ }
+ }
+
+ @Override
+ protected Set<ImportType> getPossibleSubImportType() {
+ HashSet<ImportType> result = Sets.newHashSet(ImportType.values());
+ result.remove(ImportType.COMMON_ALL);
+ result.remove(ImportType.COMMON_TRANSECT);
+ result.remove(ImportType.OPERATION);
+ result.remove(ImportType.CATCHES);
+ result.remove(ImportType.ACOUSTIC);
+ result.remove(ImportType.RESULT_VOYAGE);
+ return result;
+ }
+}
Property changes on: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/ResultVoyageRemoveDataService.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
1
0
07 Sep '12
Author: tchemit
Date: 2012-09-07 18:34:49 +0200 (Fri, 07 Sep 2012)
New Revision: 635
Url: http://forge.codelutin.com/repositories/revision/echobase/635
Log:
remove migraiont 0.9 (was only ther for test purpose)
make import test works again (migrate them to version 1.2)
make test use the working db as in real life
refs #1437: Suppression des imports (test ImportResult ids and it works!)
Added:
trunk/echobase-services/src/test/resources/echobase-1.2-importDb-referentiel.zip
trunk/echobase-services/src/test/resources/import-data/echobase-1.2-catches-and-voyage-result.h2.db.gz
trunk/echobase-services/src/test/resources/import-data/echobase-1.2-catches.h2.db.gz
trunk/echobase-services/src/test/resources/import-data/echobase-1.2-commonData.h2.db.gz
trunk/echobase-services/src/test/resources/import-data/echobase-1.2-nodata.h2.db.gz
trunk/echobase-services/src/test/resources/import-data/echobase-1.2-operation.h2.db.gz
Removed:
trunk/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/migration/workingDb/MigrationCallbackV0_9.java
trunk/echobase-services/src/test/resources/echobase-0.3-importDb-referentiel.zip
trunk/echobase-services/src/test/resources/import-data/echobase-0.3-catches-and-voyage-result.h2.db.gz
trunk/echobase-services/src/test/resources/import-data/echobase-0.3-catches.h2.db.gz
trunk/echobase-services/src/test/resources/import-data/echobase-0.3-commonData.h2.db.gz
trunk/echobase-services/src/test/resources/import-data/echobase-0.3-nodata.h2.db.gz
trunk/echobase-services/src/test/resources/import-data/echobase-0.3-operation.h2.db.gz
Modified:
trunk/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/EchobaseTopiaContexts.java
trunk/echobase-domain/src/main/resources/META-INF/services/fr.ifremer.echobase.persistence.migration.workingDb.MigrationCallBackForVersion
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/ResultsVoyageImportService.java
trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/EchoBaseTestServiceSupport.java
trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/FakeEchoBaseServiceContext.java
trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/ImportDbServiceTest.java
trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/AbstractImportDataServiceIT.java
trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/AcousticImportServiceIT.java
trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/CatchesImportServiceIT.java
trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/CommonAllImportServiceIT.java
trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/CommonTransectImportServiceIT.java
trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/OperationImportServiceIT.java
trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/ResultsEsduCellImportServiceIT.java
trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/ResultsMapCellImportServiceIT.java
trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/ResultsRegionCellImportServiceIT.java
trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/ResultsVoyageImportServiceIT.java
trunk/echobase-services/src/test/resources/import-data/common/transect.csv.gz
trunk/echobase-services/src/test/resources/import-data/common/transit.csv.gz
trunk/echobase-services/src/test/resources/import-data/common/voyage.csv.gz
trunk/echobase-services/src/test/resources/import-data/operation/operation.csv.gz
trunk/echobase-services/src/test/resources/import-data/result/voyage/lengthWeightKey.csv.gz
trunk/echobase-services/update-import-data-db.sh
Modified: trunk/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/EchobaseTopiaContexts.java
===================================================================
--- trunk/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/EchobaseTopiaContexts.java 2012-09-07 14:02:07 UTC (rev 634)
+++ trunk/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/EchobaseTopiaContexts.java 2012-09-07 16:34:49 UTC (rev 635)
@@ -187,7 +187,7 @@
* @param configuration topia configuration
* @return the new fresh root context
*/
- public static TopiaContext newDb(Properties configuration) {
+ private static TopiaContext newDb(Properties configuration) {
try {
if (log.isInfoEnabled()) {
log.info("Starts a db at : " +
Deleted: trunk/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/migration/workingDb/MigrationCallbackV0_9.java
===================================================================
--- trunk/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/migration/workingDb/MigrationCallbackV0_9.java 2012-09-07 14:02:07 UTC (rev 634)
+++ trunk/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/migration/workingDb/MigrationCallbackV0_9.java 2012-09-07 16:34:49 UTC (rev 635)
@@ -1,113 +0,0 @@
-package fr.ifremer.echobase.persistence.migration.workingDb;
-
-/*
- * #%L
- * EchoBase :: Domain
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2011 - 2012 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%
- */
-
-import org.hibernate.dialect.Dialect;
-import org.hibernate.dialect.H2Dialect;
-import org.hibernate.dialect.PostgreSQLDialect;
-import org.nuiton.topia.TopiaException;
-import org.nuiton.topia.TopiaNotFoundException;
-import org.nuiton.topia.framework.TopiaContextImplementor;
-import org.nuiton.util.Version;
-import org.nuiton.util.VersionUtil;
-
-import java.util.List;
-
-/**
- * Migration for version {@code 0.9}.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.2
- */
-public class MigrationCallbackV0_9 extends MigrationCallBackForVersion {
-
- @Override
- public Version getVersion() {
- return VersionUtil.valueOf("0.9");
- }
-
- @Override
- protected void prepareMigrationScript(TopiaContextImplementor tx,
- List<String> queries,
- boolean showSql,
- boolean showProgression) throws TopiaException {
-
-
- // add strata column on lengthweightkey table
- addStrataToLengthWeightKeyTable(tx, queries);
-
-// createSexCategoryTable(tx,queries);
- }
-
- protected void addStrataToLengthWeightKeyTable(TopiaContextImplementor tx,
- List<String> queries) throws TopiaNotFoundException {
- Dialect dialect =
- Dialect.getDialect(tx.getHibernateConfiguration().getProperties());
-
- if (dialect instanceof PostgreSQLDialect) {
-
- queries.add("ALTER TABLE lengthweightkey ADD COLUMN strata character varying(255);");
-
- queries.add("ALTER TABLE lengthweightkey ADD CONSTRAINT FK1687F88192874545_INDEX_E FOREIGN KEY(strata) REFERENCES strata(topiaid);");
-
- } else if (dialect instanceof H2Dialect) {
-
- queries.add("ALTER TABLE lengthweightkey ADD COLUMN strata VARCHAR(255);");
-
- queries.add("ALTER TABLE lengthweightkey ADD CONSTRAINT FK1687F88192874545_INDEX_E FOREIGN KEY(strata) REFERENCES strata(topiaid);");
- }
- }
-
-//
-// protected void createSexCategoryTable(TopiaContextImplementor tx,
-// List<String> queries) throws TopiaNotFoundException {
-// Dialect dialect =
-// Dialect.getDialect(tx.getHibernateConfiguration().getProperties());
-//
-// if (dialect instanceof PostgreSQLDialect) {
-// queries.add("CREATE TABLE sexcategory (\n" +
-// "topiaid character varying(255) NOT NULL,\n" +
-// "topiaversion bigint NOT NULL,\n" +
-// "topiacreatedate date,\n" +
-// "name character varying(1024),\n" +
-// "meaning character varying(255)\n" +
-// ");");
-// queries.add("ALTER TABLE sexcategory ADD CONSTRAINT PRIMARY_KEY_472 PRIMARY KEY(topiaid);");
-// queries.add("ALTER TABLE sexcategory ADD CONSTRAINT CONSTRAINT_INDEX_472 UNIQUE KEY(name);");
-//
-// } else if (dialect instanceof H2Dialect) {
-//
-// queries.add("CREATE TABLE sexcategory (\n" +
-// "topiaid VARCHAR(255) NOT NULL,\n" +
-// "topiaversion BIGINT NOT NULL,\n" +
-// "topiacreatedate DATE,\n" +
-// "name VARCHAR(1024),\n" +
-// "meaning VARCHAR(255)\n" +
-// ");");
-//
-// queries.add("ALTER TABLE sexcategory ADD CONSTRAINT PRIMARY_KEY_472 PRIMARY KEY(topiaid);");
-// queries.add("ALTER TABLE sexcategory ADD CONSTRAINT CONSTRAINT_INDEX_472 UNIQUE KEY(topiaid);");
-// }
-// }
-}
Modified: trunk/echobase-domain/src/main/resources/META-INF/services/fr.ifremer.echobase.persistence.migration.workingDb.MigrationCallBackForVersion
===================================================================
--- trunk/echobase-domain/src/main/resources/META-INF/services/fr.ifremer.echobase.persistence.migration.workingDb.MigrationCallBackForVersion 2012-09-07 14:02:07 UTC (rev 634)
+++ trunk/echobase-domain/src/main/resources/META-INF/services/fr.ifremer.echobase.persistence.migration.workingDb.MigrationCallBackForVersion 2012-09-07 16:34:49 UTC (rev 635)
@@ -1,3 +1,2 @@
-fr.ifremer.echobase.persistence.migration.workingDb.MigrationCallbackV0_9
fr.ifremer.echobase.persistence.migration.workingDb.MigrationCallbackV1_1
fr.ifremer.echobase.persistence.migration.workingDb.MigrationCallbackV1_2
\ No newline at end of file
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/ResultsVoyageImportService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/ResultsVoyageImportService.java 2012-09-07 14:02:07 UTC (rev 634)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/ResultsVoyageImportService.java 2012-09-07 16:34:49 UTC (rev 635)
@@ -199,7 +199,9 @@
// attach it to voyage
voyage.addLengthWeightKey(lengthWeightKey);
- importResult.incrementsNumberCreated(EchoBaseEntityEnum.LengthWeightKey);
+ // collect ids
+ importResult.addId(EchoBaseEntityEnum.LengthWeightKey,
+ lengthWeightKey);
}
return importResult;
Modified: trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/EchoBaseTestServiceSupport.java
===================================================================
--- trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/EchoBaseTestServiceSupport.java 2012-09-07 14:02:07 UTC (rev 634)
+++ trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/EchoBaseTestServiceSupport.java 2012-09-07 16:34:49 UTC (rev 635)
@@ -138,29 +138,25 @@
protected <E extends TopiaEntity> void assertCsvImportResult(EchoBaseCsvFileImportResult actual,
Class<E> entityType,
- int numberCreated,
- int nbIds) throws TopiaException {
+ int numberCreated) throws TopiaException {
assertCsvImportResult(actual,
entityType,
numberCreated,
0,
- numberCreated,
- nbIds);
+ numberCreated);
}
protected <E extends TopiaEntity> void assertCsvImportResult(List<EchoBaseCsvFileImportResult> actual,
int pos,
Class<E> entityType,
- int numberCreated,
- int nbIds) throws TopiaException {
+ int numberCreated) throws TopiaException {
Assert.assertTrue(actual.size() >= pos);
assertCsvImportResult(actual.get(pos),
entityType,
numberCreated,
0,
- numberCreated,
- nbIds);
+ numberCreated);
}
@@ -168,8 +164,7 @@
Class<E> entityType,
int numberCreated,
int numberUpdated,
- int nbCount,
- int nbIds) throws TopiaException {
+ int nbCount) throws TopiaException {
Assert.assertNotNull(actual);
Set<EchoBaseEntityEnum> entityTypes = actual.getEntityTypes();
EchoBaseEntityEnum expectedEntityType = EchoBaseEntityEnum.valueOf(entityType);
@@ -177,7 +172,6 @@
Assert.assertEquals(numberCreated, actual.getNumberCreated(expectedEntityType));
Assert.assertEquals(numberUpdated, actual.getNumberUpdated(expectedEntityType));
assertNbEntities(entityType, nbCount);
- Assert.assertEquals(nbIds, actual.getIds().size());
}
protected <E extends TopiaEntity> void assertCsvImportResult(List<EchoBaseCsvFileImportResult> results,
@@ -185,8 +179,7 @@
Class<E> entityType,
int numberCreated,
int numberUpdated,
- int nbCount,
- int nbIds) throws TopiaException {
+ int nbCount) throws TopiaException {
Assert.assertTrue(results.size() >= pos);
EchoBaseCsvFileImportResult actual = results.get(pos);
Assert.assertNotNull(actual);
@@ -196,6 +189,14 @@
Assert.assertEquals(numberCreated, actual.getNumberCreated(expectedEntityType));
Assert.assertEquals(numberUpdated, actual.getNumberUpdated(expectedEntityType));
assertNbEntities(entityType, nbCount);
+ }
+
+ protected <E extends TopiaEntity> void assertNbIDs(List<EchoBaseCsvFileImportResult> results,
+ int pos,
+ int nbIds) throws TopiaException {
+ Assert.assertTrue(results.size() >= pos);
+ EchoBaseCsvFileImportResult actual = results.get(pos);
+ Assert.assertNotNull(actual);
Assert.assertEquals(nbIds, actual.getIds().size());
}
Modified: trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/FakeEchoBaseServiceContext.java
===================================================================
--- trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/FakeEchoBaseServiceContext.java 2012-09-07 14:02:07 UTC (rev 634)
+++ trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/FakeEchoBaseServiceContext.java 2012-09-07 16:34:49 UTC (rev 635)
@@ -149,11 +149,7 @@
configuration = new EchoBaseConfiguration(defaultProps);
JdbcConfiguration dbConf = JdbcConfiguration.newEmbeddedConfig(testDir);
- Properties properties = EchobaseTopiaContexts.loadWorkingDbConfiguration(dbConf);
-
- //FIXME should never try to update db, tests db should always be uptodate...
- //properties.put("hibernate.hbm2ddl.auto", "update");
- rootContext = EchobaseTopiaContexts.newDb(properties);
+ rootContext = EchobaseTopiaContexts.newWorkingDb(dbConf);
}
@Override
Modified: trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/ImportDbServiceTest.java
===================================================================
--- trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/ImportDbServiceTest.java 2012-09-07 14:02:07 UTC (rev 634)
+++ trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/ImportDbServiceTest.java 2012-09-07 16:34:49 UTC (rev 635)
@@ -43,6 +43,8 @@
*/
public class ImportDbServiceTest extends EchoBaseTestServiceSupport {
+ public static final String DB_VERSION = "1.2";
+
@Override
protected FakeEchoBaseServiceContext initContext() {
return new FakeEchoBaseServiceContext(null);
@@ -51,8 +53,6 @@
@Test
public void importDb() throws IOException, TopiaException {
- serviceContext.getTransaction().updateSchema();
-
ImportDbService service = getService(ImportDbService.class);
ImportDbConfiguration conf = new ImportDbConfiguration(getLocale());
@@ -61,7 +61,7 @@
FileUtil.createDirectoryIfNecessary(workingDirectory);
conf.setWorkingDirectory(workingDirectory);
- prepareInputFile(conf.getInput(), "/echobase-0.3-importDb-referentiel.zip");
+ prepareInputFile(conf.getInput(), "/echobase-" + DB_VERSION + "-importDb-referentiel.zip");
EchoBaseUser user = new EchoBaseUserImpl();
user.setEmail("testUser(a)fake.fr");
Modified: trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/AbstractImportDataServiceIT.java
===================================================================
--- trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/AbstractImportDataServiceIT.java 2012-09-07 14:02:07 UTC (rev 634)
+++ trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/AbstractImportDataServiceIT.java 2012-09-07 16:34:49 UTC (rev 635)
@@ -50,6 +50,7 @@
import fr.ifremer.echobase.entities.references.CellType;
import fr.ifremer.echobase.io.InputFile;
import fr.ifremer.echobase.services.EchoBaseTestServiceSupport;
+import fr.ifremer.echobase.services.ImportDbServiceTest;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.junit.Assert;
@@ -81,19 +82,19 @@
public static final TimeLog TIME_LOG = new TimeLog(AbstractImportDataServiceIT.class);
- public static final String IMPORT_DATA_ECHOBASE_NO_DATA = "/import-data/echobase-0.3-nodata.h2.db.gz";
+ public static final String IMPORT_DATA_ECHOBASE_NO_DATA = "/import-data/echobase-" + ImportDbServiceTest.DB_VERSION + "-nodata.h2.db.gz";
- public static final String IMPORT_DATA_ECHOBASE_COMMON_DATA = "/import-data/echobase-0.3-commonData.h2.db.gz";
+ public static final String IMPORT_DATA_ECHOBASE_COMMON_DATA = "/import-data/echobase-" + ImportDbServiceTest.DB_VERSION + "-commonData.h2.db.gz";
- public static final String IMPORT_DATA_ECHOBASE_OPERATION = "/import-data/echobase-0.3-operation.h2.db.gz";
+ public static final String IMPORT_DATA_ECHOBASE_OPERATION = "/import-data/echobase-" + ImportDbServiceTest.DB_VERSION + "-operation.h2.db.gz";
- public static final String IMPORT_DATA_ECHOBASE_CATCHES = "/import-data/echobase-0.3-catches.h2.db.gz";
+ public static final String IMPORT_DATA_ECHOBASE_CATCHES = "/import-data/echobase-" + ImportDbServiceTest.DB_VERSION + "-catches.h2.db.gz";
- public static final String IMPORT_DATA_ECHOBASE_CATCHES_AND_VOYAGE_RESULT = "/import-data/echobase-0.3-catches-and-voyage-result.h2.db.gz";
+ public static final String IMPORT_DATA_ECHOBASE_CATCHES_AND_VOYAGE_RESULT = "/import-data/echobase-" + ImportDbServiceTest.DB_VERSION + "-catches-and-voyage-result.h2.db.gz";
-// public static final String IMPORT_DATA_ECHOBASE_CATCHES_AND_ACOUSTIC = "/import-data/echobase-0.3-catches-and-acoustic.h2.db.gz";
+// public static final String IMPORT_DATA_ECHOBASE_CATCHES_AND_ACOUSTIC = "/import-data/echobase-" + ImportDbServiceTest.DB_VERSION + "-catches-and-acoustic.h2.db.gz";
-// public static final String IMPORT_DATA_ECHOBASE_CATCHES_AND_ACOUSTIC_AND_VOYAGE_RESULT = "/import-data/echobase-0.3-catches-and-acoustic-and-voyage-result.h2.db.gz";
+// public static final String IMPORT_DATA_ECHOBASE_CATCHES_AND_ACOUSTIC_AND_VOYAGE_RESULT = "/import-data/echobase-" + ImportDbServiceTest.DB_VERSION + "-catches-and-acoustic-and-voyage-result.h2.db.gz";
public static final String VESSEL_ID = "fr.ifremer.echobase.entities.references.Vessel#1323196672049#0.9790502711645855";
Modified: trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/AcousticImportServiceIT.java
===================================================================
--- trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/AcousticImportServiceIT.java 2012-09-07 14:02:07 UTC (rev 634)
+++ trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/AcousticImportServiceIT.java 2012-09-07 16:34:49 UTC (rev 635)
@@ -85,11 +85,13 @@
List<EchoBaseCsvFileImportResult> result;
result = doImport(conf, AcousticImportService.class, 1);
- assertCsvImportResult(result, 0, DataAcquisition.class, NB_DATA_ACQUISITION,NB_DATA_ACQUISITION);
- assertCsvImportResult(result, 0, DataProcessing.class, NB_DATA_PROCESSING,0);
- assertCsvImportResult(result, 0, Cell.class, NB_CELL,0);
- assertCsvImportResult(result, 0, Data.class, NB_DATA,0);
+ assertNbIDs(result, 0, NB_CELL);
+ assertCsvImportResult(result, 0, DataAcquisition.class, NB_DATA_ACQUISITION);
+ assertCsvImportResult(result, 0, DataProcessing.class, NB_DATA_PROCESSING);
+ assertCsvImportResult(result, 0, Cell.class, NB_CELL);
+ assertCsvImportResult(result, 0, Data.class, NB_DATA);
+
assertImportAcousticDatas();
}
Modified: trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/CatchesImportServiceIT.java
===================================================================
--- trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/CatchesImportServiceIT.java 2012-09-07 14:02:07 UTC (rev 634)
+++ trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/CatchesImportServiceIT.java 2012-09-07 16:34:49 UTC (rev 635)
@@ -70,17 +70,21 @@
List<EchoBaseCsvFileImportResult> result;
result = doImport(conf, CatchesImportService.class, 3);
- assertCsvImportResult(result, 0, Sample.class, NB_SAMPLE_TOTAL, 0, NB_SAMPLE, NB_SAMPLE_TOTAL);
- assertCsvImportResult(result, 0, SampleData.class, NB_SAMPLE_DATA_TOTAL, 0, NB_SAMPLE_DATA, 0);
- assertCsvImportResult(result, 0, SpeciesCategory.class, 4, 0, 456, 0);
+ assertNbIDs(result, 0, NB_SAMPLE_TOTAL);
- assertCsvImportResult(result, 1, Sample.class, NB_SAMPLE_UNSORTED, 0, NB_SAMPLE, NB_SAMPLE_UNSORTED);
- assertCsvImportResult(result, 1, SampleData.class, NB_SAMPLE_DATA_UNSORTED, 0, NB_SAMPLE_DATA, 0);
- assertCsvImportResult(result, 1, SpeciesCategory.class, 9, 0, 456, 0);
+ assertCsvImportResult(result, 0, Sample.class, NB_SAMPLE_TOTAL, 0, NB_SAMPLE);
+ assertCsvImportResult(result, 0, SampleData.class, NB_SAMPLE_DATA_TOTAL, 0, NB_SAMPLE_DATA);
+ assertCsvImportResult(result, 0, SpeciesCategory.class, 4, 0, 456);
- assertCsvImportResult(result, 2, Sample.class, NB_SAMPLE_BIOMETRY, 0, NB_SAMPLE, NB_SAMPLE_BIOMETRY);
- assertCsvImportResult(result, 2, SampleData.class, NB_SAMPLE_DATA_BIOMETRY, 0, NB_SAMPLE_DATA, 0);
+ assertNbIDs(result, 1, NB_SAMPLE_UNSORTED);
+ assertCsvImportResult(result, 1, Sample.class, NB_SAMPLE_UNSORTED, 0, NB_SAMPLE);
+ assertCsvImportResult(result, 1, SampleData.class, NB_SAMPLE_DATA_UNSORTED, 0, NB_SAMPLE_DATA);
+ assertCsvImportResult(result, 1, SpeciesCategory.class, 9, 0, 456);
+ assertNbIDs(result, 2, NB_SAMPLE_BIOMETRY);
+ assertCsvImportResult(result, 2, Sample.class, NB_SAMPLE_BIOMETRY, 0, NB_SAMPLE);
+ assertCsvImportResult(result, 2, SampleData.class, NB_SAMPLE_DATA_BIOMETRY, 0, NB_SAMPLE_DATA);
+
assertImportSampleDatas();
}
@@ -103,8 +107,9 @@
List<EchoBaseCsvFileImportResult> result;
result = doImport(conf, CatchesImportService.class, 1);
- assertCsvImportResult(result, 0, Sample.class, NB_SAMPLE_TOTAL, NB_SAMPLE_TOTAL);
- assertCsvImportResult(result, 0, SampleData.class, NB_SAMPLE_DATA_TOTAL, 0);
+ assertNbIDs(result, 0, NB_SAMPLE_TOTAL);
+ assertCsvImportResult(result, 0, Sample.class, NB_SAMPLE_TOTAL);
+ assertCsvImportResult(result, 0, SampleData.class, NB_SAMPLE_DATA_TOTAL);
}
@Ignore
@@ -126,8 +131,9 @@
List<EchoBaseCsvFileImportResult> result;
result = doImport(conf, CatchesImportService.class, 1);
- assertCsvImportResult(result, 0, Sample.class, NB_SAMPLE_UNSORTED, NB_SAMPLE_UNSORTED);
- assertCsvImportResult(result, 0, SampleData.class, NB_SAMPLE_DATA_UNSORTED, 0);
+ assertNbIDs(result, 0, NB_SAMPLE_UNSORTED);
+ assertCsvImportResult(result, 0, Sample.class, NB_SAMPLE_UNSORTED);
+ assertCsvImportResult(result, 0, SampleData.class, NB_SAMPLE_DATA_UNSORTED);
}
@Ignore
@@ -148,8 +154,10 @@
List<EchoBaseCsvFileImportResult> result;
result = doImport(conf, CatchesImportService.class, 1);
- assertCsvImportResult(result, 0, Sample.class, NB_SAMPLE_BIOMETRY, NB_SAMPLE_BIOMETRY);
- assertCsvImportResult(result, 0, SampleData.class, NB_SAMPLE_DATA_BIOMETRY, 0);
+
+ assertNbIDs(result, 0, NB_SAMPLE_BIOMETRY);
+ assertCsvImportResult(result, 0, Sample.class, NB_SAMPLE_BIOMETRY);
+ assertCsvImportResult(result, 0, SampleData.class, NB_SAMPLE_DATA_BIOMETRY);
}
}
Modified: trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/CommonAllImportServiceIT.java
===================================================================
--- trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/CommonAllImportServiceIT.java 2012-09-07 14:02:07 UTC (rev 634)
+++ trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/CommonAllImportServiceIT.java 2012-09-07 16:34:49 UTC (rev 635)
@@ -80,10 +80,15 @@
List<EchoBaseCsvFileImportResult> result;
result = doImport(conf, CommonAllImportService.class, 3);
- assertCsvImportResult(result, 0, Voyage.class, NB_VOYAGE,NB_VOYAGE);
- assertCsvImportResult(result, 1, Transit.class, NB_TRANSIT,0);
- assertCsvImportResult(result, 2, Transect.class, NB_TRANSECT,0);
+ assertNbIDs(result, 0, NB_VOYAGE);
+ assertCsvImportResult(result, 0, Voyage.class, NB_VOYAGE);
+ assertNbIDs(result, 1, 0);
+ assertCsvImportResult(result, 1, Transit.class, NB_TRANSIT);
+
+ assertNbIDs(result, 2, 0);
+ assertCsvImportResult(result, 2, Transect.class, NB_TRANSECT);
+
assertImportCommonData();
}
Modified: trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/CommonTransectImportServiceIT.java
===================================================================
--- trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/CommonTransectImportServiceIT.java 2012-09-07 14:02:07 UTC (rev 634)
+++ trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/CommonTransectImportServiceIT.java 2012-09-07 16:34:49 UTC (rev 635)
@@ -76,7 +76,8 @@
List<EchoBaseCsvFileImportResult> result;
result = doImport(conf, CommonTransectImportService.class, 1);
- assertCsvImportResult(result, 0, Transect.class, NB_TRANSECT,NB_TRANSECT);
+ assertNbIDs(result, 0, NB_TRANSECT);
+ assertCsvImportResult(result, 0, Transect.class, NB_TRANSECT);
assertImportCommonData();
}
Modified: trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/OperationImportServiceIT.java
===================================================================
--- trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/OperationImportServiceIT.java 2012-09-07 14:02:07 UTC (rev 634)
+++ trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/OperationImportServiceIT.java 2012-09-07 16:34:49 UTC (rev 635)
@@ -71,10 +71,15 @@
List<EchoBaseCsvFileImportResult> result;
result = doImport(conf, OperationImportService.class, 3);
- assertCsvImportResult(result, 0, Operation.class, NB_OPERATION,NB_OPERATION);
- assertCsvImportResult(result, 1, OperationMetadataValue.class, NB_OPERATION_METADATAVALUE,0);
- assertCsvImportResult(result, 2, GearMetadataValue.class, NB_GEAR_METADATAVALUE,0);
+ assertNbIDs(result, 0, NB_OPERATION);
+ assertCsvImportResult(result, 0, Operation.class, NB_OPERATION);
+ assertNbIDs(result, 1, 0);
+ assertCsvImportResult(result, 1, OperationMetadataValue.class, NB_OPERATION_METADATAVALUE);
+
+ assertNbIDs(result, 2, 0);
+ assertCsvImportResult(result, 2, GearMetadataValue.class, NB_GEAR_METADATAVALUE);
+
assertImportOperations();
}
}
Modified: trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/ResultsEsduCellImportServiceIT.java
===================================================================
--- trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/ResultsEsduCellImportServiceIT.java 2012-09-07 14:02:07 UTC (rev 634)
+++ trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/ResultsEsduCellImportServiceIT.java 2012-09-07 16:34:49 UTC (rev 635)
@@ -80,8 +80,10 @@
List<EchoBaseCsvFileImportResult> result;
result = doImport(conf, ResultsEsduCellImportService.class, 1);
- assertCsvImportResult(result, 0, Result.class, 43533,43533);
- assertCsvImportResult(result, 0, Category.class, 7,0);
+ assertNbIDs(result, 0, 43533);
+
+ assertCsvImportResult(result, 0, Result.class, 43533);
+ assertCsvImportResult(result, 0, Category.class, 7);
}
@Test
@@ -112,9 +114,11 @@
List<EchoBaseCsvFileImportResult> result;
result = doImport(conf, ResultsEsduCellImportService.class, 1);
- assertCsvImportResult(result, 0, Result.class, 357291,357291);
- assertCsvImportResult(result, 0, Category.class, 27,0);
- assertCsvImportResult(result, 0, SpeciesCategory.class, 1, 0, 457,0);
+ assertNbIDs(result, 0, 357291);
+
+ assertCsvImportResult(result, 0, Result.class, 357291);
+ assertCsvImportResult(result, 0, Category.class, 27);
+ assertCsvImportResult(result, 0, SpeciesCategory.class, 1, 0, 457);
}
@Test
@@ -145,10 +149,11 @@
List<EchoBaseCsvFileImportResult> result;
result = doImport(conf, ResultsEsduCellImportService.class, 1);
- assertCsvImportResult(result, 0, Result.class, 68108,68108);
- assertCsvImportResult(result, 0, Category.class, 129,0);
- assertCsvImportResult(result, 0, SpeciesCategory.class, 129, 0, 585,0);
- assertCsvImportResult(result, 0, SizeCategory.class, 62, 0, 69,0);
+ assertNbIDs(result, 0, 68108);
+ assertCsvImportResult(result, 0, Result.class, 68108);
+ assertCsvImportResult(result, 0, Category.class, 129);
+ assertCsvImportResult(result, 0, SpeciesCategory.class, 129, 0, 585);
+ assertCsvImportResult(result, 0, SizeCategory.class, 62, 0, 69);
}
@Test
@@ -179,10 +184,11 @@
List<EchoBaseCsvFileImportResult> result;
result = doImport(conf, ResultsEsduCellImportService.class, 1);
- assertCsvImportResult(result, 0, Category.class, 14,0);
- assertCsvImportResult(result, 0, Result.class, 10021,10021);
- assertCsvImportResult(result, 0, AgeCategory.class, 6, 0, 10,0);
- assertCsvImportResult(result, 0, SpeciesCategory.class, 14, 0, 470,0);
+ assertNbIDs(result, 0, 10021);
+ assertCsvImportResult(result, 0, Category.class, 14);
+ assertCsvImportResult(result, 0, Result.class, 10021);
+ assertCsvImportResult(result, 0, AgeCategory.class, 6, 0, 10);
+ assertCsvImportResult(result, 0, SpeciesCategory.class, 14, 0, 470);
}
}
\ No newline at end of file
Modified: trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/ResultsMapCellImportServiceIT.java
===================================================================
--- trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/ResultsMapCellImportServiceIT.java 2012-09-07 14:02:07 UTC (rev 634)
+++ trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/ResultsMapCellImportServiceIT.java 2012-09-07 16:34:49 UTC (rev 635)
@@ -72,10 +72,12 @@
List<EchoBaseCsvFileImportResult> result;
result = doImport(conf, ResultsMapCellImportService.class, 1);
- assertCsvImportResult(result, 0, Cell.class, 380, 380);
- assertCsvImportResult(result, 0, Data.class, 2280, 0);
- assertCsvImportResult(result, 0, Result.class, 380, 0);
- assertCsvImportResult(result, 0, Category.class, 1, 0);
+ assertNbIDs(result,0,380);
+
+ assertCsvImportResult(result, 0, Cell.class, 380);
+ assertCsvImportResult(result, 0, Data.class, 2280);
+ assertCsvImportResult(result, 0, Result.class, 380);
+ assertCsvImportResult(result, 0, Category.class, 1);
}
}
\ No newline at end of file
Modified: trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/ResultsRegionCellImportServiceIT.java
===================================================================
--- trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/ResultsRegionCellImportServiceIT.java 2012-09-07 14:02:07 UTC (rev 634)
+++ trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/ResultsRegionCellImportServiceIT.java 2012-09-07 16:34:49 UTC (rev 635)
@@ -82,12 +82,14 @@
List<EchoBaseCsvFileImportResult> result;
result = doImport(conf, ResultsRegionCellImportService.class, 3);
- assertCsvImportResult(result, 0, Cell.class, 10, 0, 2083,10);
- assertCsvImportResult(result, 0, Data.class, 238,0);
- assertCsvImportResult(result, 1, Cell.class, 0, 4146, 2083,0);
- assertCsvImportResult(result, 2, Result.class, 2128,0);
- assertCsvImportResult(result, 2, Category.class, 27,0);
- assertCsvImportResult(result, 2, SpeciesCategory.class, 1, 0, 457,0);
+ assertNbIDs(result, 0, 10);
+
+ assertCsvImportResult(result, 0, Cell.class, 10, 0, 2083);
+ assertCsvImportResult(result, 0, Data.class, 238);
+ assertCsvImportResult(result, 1, Cell.class, 0, 4146, 2083);
+ assertCsvImportResult(result, 2, Result.class, 2128);
+ assertCsvImportResult(result, 2, Category.class, 27);
+ assertCsvImportResult(result, 2, SpeciesCategory.class, 1, 0, 457);
}
}
\ No newline at end of file
Modified: trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/ResultsVoyageImportServiceIT.java
===================================================================
--- trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/ResultsVoyageImportServiceIT.java 2012-09-07 14:02:07 UTC (rev 634)
+++ trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/ResultsVoyageImportServiceIT.java 2012-09-07 16:34:49 UTC (rev 635)
@@ -75,9 +75,14 @@
List<EchoBaseCsvFileImportResult> result;
result = doImport(conf, ResultsVoyageImportService.class, 3);
- assertCsvImportResult(result, 0, LengthAgeKey.class, NB_LENGTH_AGE_KEY, NB_LENGTH_AGE_KEY);
- assertCsvImportResult(result, 1, LengthWeightKey.class, NB_LENGTH_WEIGHT_KEY, NB_LENGTH_WEIGHT_KEY);
- assertCsvImportResult(result, 2, Echotype.class, NB_ECHOTYPE, NB_ECHOTYPE);
+ assertNbIDs(result, 0, NB_LENGTH_AGE_KEY);
+ assertCsvImportResult(result, 0, LengthAgeKey.class, NB_LENGTH_AGE_KEY);
+
+ assertNbIDs(result, 1, NB_LENGTH_WEIGHT_KEY);
+ assertCsvImportResult(result, 1, LengthWeightKey.class, NB_LENGTH_WEIGHT_KEY);
+
+ assertNbIDs(result, 2, NB_ECHOTYPE);
+ assertCsvImportResult(result, 2, Echotype.class, NB_ECHOTYPE);
}
@Ignore
@@ -102,7 +107,8 @@
List<EchoBaseCsvFileImportResult> result;
result = doImport(conf, ResultsVoyageImportService.class, 1);
- assertCsvImportResult(result, 0, LengthAgeKey.class, NB_LENGTH_AGE_KEY, NB_LENGTH_AGE_KEY);
+ assertNbIDs(result, 0, NB_LENGTH_AGE_KEY);
+ assertCsvImportResult(result, 0, LengthAgeKey.class, NB_LENGTH_AGE_KEY);
}
@Ignore
@@ -127,7 +133,8 @@
List<EchoBaseCsvFileImportResult> result;
result = doImport(conf, ResultsVoyageImportService.class, 1);
- assertCsvImportResult(result, 0, LengthWeightKey.class, NB_LENGTH_WEIGHT_KEY, NB_LENGTH_WEIGHT_KEY);
+ assertNbIDs(result, 0, NB_LENGTH_WEIGHT_KEY);
+ assertCsvImportResult(result, 0, LengthWeightKey.class, NB_LENGTH_WEIGHT_KEY);
}
@Ignore
@@ -151,7 +158,8 @@
List<EchoBaseCsvFileImportResult> result;
result = doImport(conf, ResultsVoyageImportService.class, 1);
- assertCsvImportResult(result, 0, Echotype.class, NB_ECHOTYPE, NB_ECHOTYPE);
+ assertNbIDs(result, 0, NB_ECHOTYPE);
+ assertCsvImportResult(result, 0, Echotype.class, NB_ECHOTYPE);
}
}
\ No newline at end of file
Deleted: trunk/echobase-services/src/test/resources/echobase-0.3-importDb-referentiel.zip
===================================================================
(Binary files differ)
Copied: trunk/echobase-services/src/test/resources/echobase-1.2-importDb-referentiel.zip (from rev 622, trunk/echobase-services/src/test/resources/echobase-0.3-importDb-referentiel.zip)
===================================================================
(Binary files differ)
Property changes on: trunk/echobase-services/src/test/resources/echobase-1.2-importDb-referentiel.zip
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: svn:keywords
+ Author Date Id Revision HeadURL
Modified: trunk/echobase-services/src/test/resources/import-data/common/transect.csv.gz
===================================================================
(Binary files differ)
Modified: trunk/echobase-services/src/test/resources/import-data/common/transit.csv.gz
===================================================================
(Binary files differ)
Modified: trunk/echobase-services/src/test/resources/import-data/common/voyage.csv.gz
===================================================================
(Binary files differ)
Deleted: trunk/echobase-services/src/test/resources/import-data/echobase-0.3-catches-and-voyage-result.h2.db.gz
===================================================================
(Binary files differ)
Deleted: trunk/echobase-services/src/test/resources/import-data/echobase-0.3-catches.h2.db.gz
===================================================================
(Binary files differ)
Deleted: trunk/echobase-services/src/test/resources/import-data/echobase-0.3-commonData.h2.db.gz
===================================================================
(Binary files differ)
Deleted: trunk/echobase-services/src/test/resources/import-data/echobase-0.3-nodata.h2.db.gz
===================================================================
(Binary files differ)
Deleted: trunk/echobase-services/src/test/resources/import-data/echobase-0.3-operation.h2.db.gz
===================================================================
(Binary files differ)
Copied: trunk/echobase-services/src/test/resources/import-data/echobase-1.2-catches-and-voyage-result.h2.db.gz (from rev 622, trunk/echobase-services/src/test/resources/import-data/echobase-0.3-catches-and-voyage-result.h2.db.gz)
===================================================================
(Binary files differ)
Copied: trunk/echobase-services/src/test/resources/import-data/echobase-1.2-catches.h2.db.gz (from rev 622, trunk/echobase-services/src/test/resources/import-data/echobase-0.3-catches.h2.db.gz)
===================================================================
(Binary files differ)
Copied: trunk/echobase-services/src/test/resources/import-data/echobase-1.2-commonData.h2.db.gz (from rev 622, trunk/echobase-services/src/test/resources/import-data/echobase-0.3-commonData.h2.db.gz)
===================================================================
(Binary files differ)
Copied: trunk/echobase-services/src/test/resources/import-data/echobase-1.2-nodata.h2.db.gz (from rev 622, trunk/echobase-services/src/test/resources/import-data/echobase-0.3-nodata.h2.db.gz)
===================================================================
(Binary files differ)
Copied: trunk/echobase-services/src/test/resources/import-data/echobase-1.2-operation.h2.db.gz (from rev 622, trunk/echobase-services/src/test/resources/import-data/echobase-0.3-operation.h2.db.gz)
===================================================================
(Binary files differ)
Modified: trunk/echobase-services/src/test/resources/import-data/operation/operation.csv.gz
===================================================================
(Binary files differ)
Modified: trunk/echobase-services/src/test/resources/import-data/result/voyage/lengthWeightKey.csv.gz
===================================================================
(Binary files differ)
Modified: trunk/echobase-services/update-import-data-db.sh
===================================================================
--- trunk/echobase-services/update-import-data-db.sh 2012-09-07 14:02:07 UTC (rev 634)
+++ trunk/echobase-services/update-import-data-db.sh 2012-09-07 16:34:49 UTC (rev 635)
@@ -8,7 +8,7 @@
exit
fi
-dbnameprefix="echobase-0.3"
+dbnameprefix="echobase-1.2"
dbDir=src/test/resources/import-data
@@ -16,7 +16,7 @@
testId=$1
dbdst=$2
echo "execute mvn test -Dtest=$testId ..."
- mvn test -Dtest=$testId &>/tmp/maven-$testId.log
+ mvn test -Dtest=$testId -Dmaven.surefire.debug &>/tmp/maven-$testId.log
if [ $? -eq 1 ]; then
echo "Error with test $testId, see /tmp/maven-$testId.log"
exit 1
1
0
Author: tchemit
Date: 2012-09-07 16:02:07 +0200 (Fri, 07 Sep 2012)
New Revision: 634
Url: http://forge.codelutin.com/repositories/revision/echobase/634
Log:
check i18n only at release time
Modified:
trunk/echobase-ui/pom.xml
trunk/pom.xml
Modified: trunk/echobase-ui/pom.xml
===================================================================
--- trunk/echobase-ui/pom.xml 2012-09-07 10:57:12 UTC (rev 633)
+++ trunk/echobase-ui/pom.xml 2012-09-07 14:02:07 UTC (rev 634)
@@ -1,6 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
@@ -89,7 +91,6 @@
<userRulesFiles>
<file>${basedir}/src/main/validationRules.txt</file>
</userRulesFiles>
- <keepGetters>true</keepGetters>
</configuration>
</execution>
<execution>
@@ -340,9 +341,12 @@
</activation>
<properties>
<env>prod</env>
+
+ <!-- make sure i18n is fully complete -->
+ <i18n.failsIfWarning>true</i18n.failsIfWarning>
</properties>
</profile>
-
+
<profile>
<id>assembly</id>
<activation>
@@ -368,7 +372,7 @@
<phase>generate-resources</phase>
<configuration>
<target>
- <mkdir dir="${embeddedWarDir}/WEB-INF/classes" />
+ <mkdir dir="${embeddedWarDir}/WEB-INF/classes"/>
</target>
</configuration>
<goals>
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2012-09-07 10:57:12 UTC (rev 633)
+++ trunk/pom.xml 2012-09-07 14:02:07 UTC (rev 634)
@@ -159,7 +159,6 @@
<i18n.bundles>fr_FR,en_GB</i18n.bundles>
<i18n.silent>true</i18n.silent>
<echobaseI18nBundle>echobase-i18n</echobaseI18nBundle>
- <i18n.failsIfWarning>true</i18n.failsIfWarning>
<!--Site configuration -->
<locales>fr,en</locales>
1
0