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
20 Sep '12
Author: tchemit
Date: 2012-09-20 18:03:59 +0200 (Thu, 20 Sep 2012)
New Revision: 675
Url: http://forge.codelutin.com/repositories/revision/echobase/675
Log:
refs #1437: Suppression des imports (suppression de plusieurs imports ?\195?\160 la fois)
Added:
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/removeData/ImportLogs.java
trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/removeData/importLogs.jsp
trunk/src/doc/reunions/reunion-2012-09-20.txt
Removed:
trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/removeData/dashboard.jsp
Modified:
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/test/java/fr/ifremer/echobase/ui/actions/removedata/AbstractRemoveDataServiceTest.java
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/GetEntities.java
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/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/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/decorators.xml
trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/removeData/confirmDelete.jsp
Modified: 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 2012-09-20 10:19:24 UTC (rev 674)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/RemoveDataConfiguration.java 2012-09-20 16:03:59 UTC (rev 675)
@@ -25,6 +25,8 @@
import fr.ifremer.echobase.services.AbstractEchobaseActionConfiguration;
+import java.util.List;
+
/**
* Configuration for a remve data action.
*
@@ -35,13 +37,13 @@
private static final long serialVersionUID = 1L;
- private String importLogId;
+ private String[] importLogIds;
- public String getImportLogId() {
- return importLogId;
+ public String[] getImportLogIds() {
+ return importLogIds;
}
- public void setImportLogId(String importLogId) {
- this.importLogId = importLogId;
+ public void setImportLogIds(String[] importLogIds) {
+ this.importLogIds = importLogIds;
}
}
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-20 10:19:24 UTC (rev 674)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/RemoveDataService.java 2012-09-20 16:03:59 UTC (rev 675)
@@ -94,12 +94,30 @@
public String removeImport(RemoveDataConfiguration model, EchoBaseUser user) {
- String importLogId = model.getImportLogId();
+ // compute nb steps
+ int nbSteps = 0;
+ for (String id : model.getImportLogIds()) {
+ ImportLog importLog = getEntityById(ImportLog.class, id);
+ nbSteps += importLog.getImportId().size() + 3;
+ }
+ model.setNbSteps(nbSteps);
+ StringBuilder result = new StringBuilder();
+ for (String id : model.getImportLogIds()) {
+ String importResult = removeImport(model, id, user);
+ result.append(importResult).append('\n');
+ }
+ return result.toString().trim();
+ }
+ public String removeImport(RemoveDataConfiguration model,
+ String importLogId, EchoBaseUser user) {
+
ImportLog importLog = getEntityById(ImportLog.class, importLogId);
- int nbSteps = importLog.getImportId().size() + 3;
- model.setNbSteps(nbSteps);
+ if (importLog == null) {
+ // import was already removed (from a previously remove I guess)
+ return "\n";
+ }
ImportType importType = importLog.getImportType();
Modified: trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/AbstractRemoveDataServiceTest.java
===================================================================
--- trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/AbstractRemoveDataServiceTest.java 2012-09-20 10:19:24 UTC (rev 674)
+++ trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/AbstractRemoveDataServiceTest.java 2012-09-20 16:03:59 UTC (rev 675)
@@ -273,7 +273,7 @@
protected void removeImport(String importId) {
RemoveDataConfiguration conf = new RemoveDataConfiguration();
- conf.setImportLogId(importId);
+ conf.setImportLogIds(new String[]{importId});
RemoveDataService service = getService(RemoveDataService.class);
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-20 10:19:24 UTC (rev 674)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/GetEntities.java 2012-09-20 16:03:59 UTC (rev 675)
@@ -31,10 +31,14 @@
import fr.ifremer.echobase.services.DecoratorService;
import fr.ifremer.echobase.services.EchoBaseServiceSupport;
import fr.ifremer.echobase.ui.actions.AbstractJSONPaginedAction;
+import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.nuiton.topia.persistence.pager.FilterRule;
+import org.nuiton.topia.persistence.pager.FilterRuleOperator;
import org.nuiton.util.decorator.Decorator;
+import java.util.Arrays;
import java.util.Map;
/**
@@ -56,6 +60,12 @@
/** Datas of the given table. */
protected Map<?, ?>[] datas;
+ protected String voyageId;
+
+ public void setVoyageId(String voyageId) {
+ this.voyageId = voyageId;
+ }
+
public void setEntityType(EchoBaseEntityEnum entityType) {
this.entityType = entityType;
}
@@ -106,6 +116,13 @@
EchoBaseServiceSupport service =
getService(EchoBaseServiceSupport.class);
+ if (StringUtils.isNotBlank(voyageId)) {
+
+ // add a filter on voyageId
+ pager.setRules(Arrays.asList(new FilterRule(
+ FilterRuleOperator.eq, ImportLog.PROPERTY_VOYAGE_ID, voyageId
+ )));
+ }
for (Map row : datas) {
String importType = (String) row.get(ImportLog.PROPERTY_IMPORT_TYPE);
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-20 10:19:24 UTC (rev 674)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/removeData/ConfirmDelete.java 2012-09-20 16:03:59 UTC (rev 675)
@@ -23,18 +23,22 @@
* #L%
*/
-import com.google.common.base.Preconditions;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
import fr.ifremer.echobase.entities.ImportLog;
+import fr.ifremer.echobase.entities.ImportType;
import fr.ifremer.echobase.entities.data.Voyage;
import fr.ifremer.echobase.services.DecoratorService;
import fr.ifremer.echobase.services.EchoBaseServiceSupport;
import fr.ifremer.echobase.services.removedata.RemoveDataConfiguration;
import fr.ifremer.echobase.ui.actions.AbstractConfigureAction;
-import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.nuiton.util.decorator.Decorator;
import java.io.IOException;
+import java.util.List;
+import java.util.Map;
/**
* Confirm to delete a import log.
@@ -49,28 +53,18 @@
/** Logger. */
private static final Log log = LogFactory.getLog(ConfirmDelete.class);
- protected ImportLog importLog;
+ protected Map<String, String> importTypes;
- protected String voyage;
+ protected List<String> importLogs;
- protected String importType;
-
public ConfirmDelete() {
super(RemoveDataConfiguration.class);
}
- public String getImportType() {
- return importType;
+ public List<String> getImportLogs() {
+ return importLogs;
}
- public ImportLog getImportLog() {
- return importLog;
- }
-
- public String getVoyage() {
- return voyage;
- }
-
@Override
protected RemoveDataConfiguration createModel() {
return new RemoveDataConfiguration();
@@ -85,22 +79,30 @@
@Override
protected void prepareInputAction(RemoveDataConfiguration model) {
- String importLogId = model.getImportLogId();
+ importTypes = decorateEnums(ImportType.values());
- Preconditions.checkArgument(StringUtils.isNotBlank(importLogId));
+ importLogs = Lists.newArrayList();
- 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();
+ Decorator<Voyage> decorator = getService(DecoratorService.class).getDecorator(getLocale(), Voyage.class, null);
- Voyage voyageEntity = service.getEntityById(Voyage.class, importLog.getVoyageId());
- this.voyage = getService(DecoratorService.class).decorate(getLocale(), voyageEntity, null);
+ for (String id : model.getImportLogIds()) {
+ if (log.isInfoEnabled()) {
+ log.info("Load import log " + id);
+ }
+ ImportLog importLog = service.getEntityById(ImportLog.class, id);
+ Voyage voyageEntity = service.getEntityById(Voyage.class, importLog.getVoyageId());
+ String voyage = decorator.toString(voyageEntity);
+ String importType = importTypes.get(importLog.getImportType().name());
+ String result = _("echobase.common.importLogToDelete",
+ voyage,
+ importType,
+ importLog.getImportDate());
+ importLogs.add(result);
+ }
+
}
-
}
\ No newline at end of file
Modified: 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 2012-09-20 10:19:24 UTC (rev 674)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/removeData/Delete.java 2012-09-20 16:03:59 UTC (rev 675)
@@ -75,12 +75,9 @@
protected void startAction(RemoveDataService service,
RemoveDataConfiguration model) throws Exception {
- if (log.isInfoEnabled()) {
- log.info("Will remove importLog : " + model.getImportLogId());
- }
-
- model.setResultMessage(
- service.removeImport(model, getEchoBaseSession().getUser()));
+ String resultMessage = service.removeImport(
+ model, getEchoBaseSession().getUser());
+ model.setResultMessage(resultMessage);
}
@Override
Added: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/removeData/ImportLogs.java
===================================================================
--- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/removeData/ImportLogs.java (rev 0)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/removeData/ImportLogs.java 2012-09-20 16:03:59 UTC (rev 675)
@@ -0,0 +1,41 @@
+package fr.ifremer.echobase.ui.actions.removeData;
+
+import fr.ifremer.echobase.entities.data.Voyage;
+import fr.ifremer.echobase.ui.actions.EchoBaseActionSupport;
+
+import java.util.Map;
+
+/**
+ * To display imports logs page.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.3
+ */
+public class ImportLogs extends EchoBaseActionSupport {
+
+ private static final long serialVersionUID = 1L;
+
+ protected Map<String, String> voyages;
+
+ protected String voyageId;
+
+ public Map<String, String> getVoyages() {
+ return voyages;
+ }
+
+ public String getVoyageId() {
+ return voyageId;
+ }
+
+ public void setVoyageId(String voyageId) {
+ this.voyageId = voyageId;
+ }
+
+ @Override
+ public String execute() throws Exception {
+
+ voyages = loadSortAndDecorate(Voyage.class);
+
+ return SUCCESS;
+ }
+}
Property changes on: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/removeData/ImportLogs.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Modified: trunk/echobase-ui/src/main/resources/config/struts-removeData.xml
===================================================================
--- trunk/echobase-ui/src/main/resources/config/struts-removeData.xml 2012-09-20 10:19:24 UTC (rev 674)
+++ trunk/echobase-ui/src/main/resources/config/struts-removeData.xml 2012-09-20 16:03:59 UTC (rev 675)
@@ -57,9 +57,9 @@
</action>
<!-- Get importLogs -->
- <action name="importLogs"
- class="fr.ifremer.echobase.ui.actions.EchoBaseActionSupport">
- <result>/WEB-INF/jsp/removeData/dashboard.jsp</result>
+ <action name="importLogs" method="execute"
+ class="fr.ifremer.echobase.ui.actions.removeData.ImportLogs">
+ <result>/WEB-INF/jsp/removeData/importLogs.jsp</result>
</action>
<!-- Get import logs entries -->
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-20 10:19:24 UTC (rev 674)
+++ trunk/echobase-ui/src/main/resources/i18n/echobase-ui_en_GB.properties 2012-09-20 16:03:59 UTC (rev 675)
@@ -79,6 +79,7 @@
echobase.common.importDbFile=
echobase.common.importDbMode=Import db mode
echobase.common.importError=Error\:
+echobase.common.importLogToDelete=Voyage %s - Import type %s - Date %s
echobase.common.importNotes=Import notes
echobase.common.importResult=Import results
echobase.common.importText=import description
@@ -304,6 +305,7 @@
echobase.legend.importDb.resume=Results of database import
echobase.legend.libreOfficeQuery=Translate a SQL query from Libre Office
echobase.legend.removeData.resume=Results of Import removal
+echobase.legend.select.voyage=Voyage filter
echobase.legend.sqlQuery.configuration=Query definition
echobase.legend.sqlQuery.result=Query results
echobase.legend.workingDbConfiguration.create=Create a working database configuration
@@ -325,11 +327,14 @@
echobase.message.importData.result=Data import successful in %s \:\n%s
echobase.message.no.row.selected=No data selected
echobase.message.noEntrySelection=No field selected
+echobase.action.delete.selectedImport=Delete selected imports
echobase.message.removeData.result=Data import removalwas successful in %s\:\n%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.deleteImportLogs=Delete data
+echobase.confirm.delete.selected.importData=Delete selected imports
echobase.title.confirm.deleteQuery=Delete a query
echobase.title.confirm.deleteWorkingDbConfiguration=Delete a configuration
echobase.title.connectToDbInformations=Database connection information
@@ -364,3 +369,4 @@
echobase.tooltip.disconnectWorkingDb=Change working database
echobase.tooltip.logout=Logout
echobase.tooltip.selectWorkingDb=Select a working database
+echobase.warning.no.importLog.selected=No selected import
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-20 10:19:24 UTC (rev 674)
+++ trunk/echobase-ui/src/main/resources/i18n/echobase-ui_fr_FR.properties 2012-09-20 16:03:59 UTC (rev 675)
@@ -79,6 +79,7 @@
echobase.common.importDbFile=
echobase.common.importDbMode=Mode d'import
echobase.common.importError=Une erreur est survenue pendant l'import \:
+echobase.common.importLogToDelete=Campagne %s - Type d'import %s - Date %s
echobase.common.importNotes=Remarques sur l'import
echobase.common.importResult=Résultat de l'import
echobase.common.importText=Description
@@ -304,6 +305,7 @@
echobase.legend.importDb.resume=Résumé de l'import de base de données
echobase.legend.libreOfficeQuery=Traduire une requête SQL issue de Libre Office
echobase.legend.removeData.resume=Résumé de la suppression d'un import
+echobase.legend.select.voyage=Filtre Campagne
echobase.legend.sqlQuery.configuration=Définition de la requête
echobase.legend.sqlQuery.result=Résultats de la requête
echobase.legend.workingDbConfiguration.create=Création d'une configuration de base de travail
@@ -330,6 +332,9 @@
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.deleteImportLogs=Supprimer des données
+echobase.action.delete.selectedImport=Supprimer les imports sélectionnés
+echobase.confirm.delete.selected.importData=Confirmer la suppression des imports sélectionnés
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
@@ -364,3 +369,4 @@
echobase.tooltip.disconnectWorkingDb=Changer de base de travail
echobase.tooltip.logout=Se déconnecter
echobase.tooltip.selectWorkingDb=Sélectionner une base de travail
+echobase.warning.no.importLog.selected=Aucun import sélectionné
Modified: trunk/echobase-ui/src/main/webapp/WEB-INF/decorators.xml
===================================================================
--- trunk/echobase-ui/src/main/webapp/WEB-INF/decorators.xml 2012-09-20 10:19:24 UTC (rev 674)
+++ trunk/echobase-ui/src/main/webapp/WEB-INF/decorators.xml 2012-09-20 16:03:59 UTC (rev 675)
@@ -36,7 +36,7 @@
<pattern>/exportQuery/confirmDelete*</pattern>
<pattern>/importData/get*</pattern>
<pattern>/workingDb/confirmDelete*</pattern>
- <pattern>/removeData/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/removeData/confirmDelete.jsp
===================================================================
--- trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/removeData/confirmDelete.jsp 2012-09-20 10:19:24 UTC (rev 674)
+++ trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/removeData/confirmDelete.jsp 2012-09-20 16:03:59 UTC (rev 675)
@@ -23,63 +23,35 @@
<%@page contentType="text/html" pageEncoding="UTF-8" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
-<script type="text/javascript">
+<title><s:text name="echobase.title.confirm.deleteImportLogs"/></title>
-function cancel() {
-$('#confirmDeleteDialog').dialog('close');
-return false;
-}
-</script>
+<br/>
-<div class="dialogContainer ui-corner-all">
+<fieldset>
+ <legend>
+ <s:text name="echobase.confirm.delete.selected.importData"/>
+ </legend>
- <s:label key="echobase.confirm.delete.importData" theme="simple"/>
+ <ul class="">
+ <s:iterator value="importLogs">
+ <li>
+ <s:property/>
+ </li>
+ </s:iterator>
+ </ul>
- <fieldset class="ui-corner-all">
+ <s:form namespace="/removeData">
- <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.voyage' value=''/>
- <div class="clearBoth"/>
- <pre id='importVoyage' style="font-weight: bold;">
- <s:property value="%{voyage}"/>
- </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
+ <br/>
+ <ul class="toolbar floatRight">
+ <li>
+ <s:submit action="importLogs" theme="simple"
+ key="echobase.action.cancel"/>
+ </li>
+ <li>
+ <s:submit action="confirmDelete" theme="simple"
+ key="echobase.action.delete"/>
+ </li>
+ </ul>
+ </s:form>
+</fieldset>
Deleted: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/removeData/dashboard.jsp
===================================================================
--- trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/removeData/dashboard.jsp 2012-09-20 10:19:24 UTC (rev 674)
+++ trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/removeData/dashboard.jsp 2012-09-20 16:03:59 UTC (rev 675)
@@ -1,135 +0,0 @@
-<%--
-#%L
- EchoBase :: UI
- $Id$
- $HeadURL$
- %%
- Copyright (C) 2011 Ifremer, Codelutin
- %%
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
- #L%
---%>
-<%@page contentType="text/html" pageEncoding="UTF-8" %>
-<%@ taglib prefix="s" uri="/struts-tags" %>
-<%@ taglib prefix="sj" uri="/struts-jquery-tags" %>
-<%@ 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 voyage = $("tr[aria-selected=true] td[aria-describedby='datas_voyage']").text();
- $('#importLogVoyage').html(voyage);
- 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="voyage" sortable="true"
- title="%{getText('echobase.common.voyage')}"/>
- <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.voyage' value=''/>
- <div class="clearBoth"/>
- <pre id='importLogVoyage' 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
Copied: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/removeData/importLogs.jsp (from rev 674, trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/removeData/dashboard.jsp)
===================================================================
--- trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/removeData/importLogs.jsp (rev 0)
+++ trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/removeData/importLogs.jsp 2012-09-20 16:03:59 UTC (rev 675)
@@ -0,0 +1,161 @@
+<%--
+#%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>
+
+<script type="text/javascript">
+
+ function reloadPage(params) {
+ var url = "<s:url action='importLogs' namespace='/removeData'/>?";
+ window.location = url + $.param(params);
+ return false;
+ }
+
+ jQuery(document).ready(function () {
+
+ $('[name="voyageId"]').change(function (event) {
+ reloadPage({'voyageId':this.value});
+ });
+
+ $.addRowSelectTopic('importLogs', function () {
+
+ $('#extraInfos').show();
+ var text = $("tr[aria-selected=true] td[aria-describedby='importLogs_importText']").text();
+ $('#importLogText').html(text);
+ var voyage = $("tr[aria-selected=true] td[aria-describedby='importLogs_voyage']").text();
+ $('#importLogVoyage').html(voyage);
+ var user = $("tr[aria-selected=true] td[aria-describedby='importLogs_importUser']").text();
+ $('#importLogUser').html(user);
+ var date = $("tr[aria-selected=true] td[aria-describedby='importLogs_importDate']").text();
+ $('#importLogDate').html(date);
+ var importType = $("tr[aria-selected=true] td[aria-describedby='importLogs_importType']").text();
+ $('#importLogImportType').html(importType);
+
+ });
+
+ $.addClearSelectTopic('importLogs', function (event) {
+
+ $(':checkbox[name^="jqg"]').each(function () {
+ var elem = $(this);
+ var prefixLength = "jqg_importLogs_".length;
+ var newId = this.id.substring(prefixLength);
+ elem.attr("name", "model.importLogIds");
+ elem.attr("value", newId);
+ });
+ $('#extraInfos').hide();
+ });
+ $.addEvenAndOddClasses('importLogs');
+ });
+
+ function checkOneRowSelected() {
+ var checked = $(':checked[name="model.importLogIds"]');
+ var result = !!checked.length;
+ if (!result) {
+ alert('<s:text name="echobase.warning.no.importLog.selected"/>');
+ }
+ return result;
+ }
+
+</script>
+
+<title><s:text name="echobase.title.importLogs"/></title>
+
+<fieldset>
+ <legend><s:text name="echobase.legend.select.voyage"/></legend>
+ <s:select key="voyageId" cssStyle="font-size: 140%"
+ label="%{getText('echobase.common.voyage')}"
+ list="voyages" headerKey="" headerValue="" theme="simple"/>
+</fieldset>
+<s:form method="post" namespace="/removeData" action="confirmDelete">
+
+ <s:url id="loadUrl" action="getImportLogs" namespace="/removeData"
+ escapeAmp="false">
+ <s:param name="voyageId" value="%{voyageId}"/>
+ </s:url>
+ <sjg:grid id="importLogs" 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"
+ multiselect="true"
+ onSelectRowTopics='importLogs-rowSelect'
+ onCompleteTopics="importLogs-clearSelect,importLogs-CompleteTopics">
+
+ <sjg:gridColumn name="id" title="id" hidden="true"/>
+ <sjg:gridColumn name="importType" sortable="true"
+ title="%{getText('echobase.common.importType')}"/>
+ <sjg:gridColumn name="voyage" sortable="true"
+ title="%{getText('echobase.common.voyage')}"/>
+ <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.voyage' value=''/>
+ <div class="clearBoth"/>
+ <pre id='importLogVoyage' 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>
+
+ <br/>
+ <s:submit id='confirmDelete' action="confirmDelete" method="input"
+ onclick="return checkOneRowSelected();"
+ key="echobase.action.delete.selectedImport" />
+
+</s:form>
\ No newline at end of file
Property changes on: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/removeData/importLogs.jsp
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/src/doc/reunions/reunion-2012-09-20.txt
===================================================================
--- trunk/src/doc/reunions/reunion-2012-09-20.txt (rev 0)
+++ trunk/src/doc/reunions/reunion-2012-09-20.txt 2012-09-20 16:03:59 UTC (rev 675)
@@ -0,0 +1,93 @@
+========
+Echobase
+========
+
+Jeudi 20 septembre 2012 (Ifremer)
+
+Présents : Mathieu et Tony
+
+But
+===
+
+- Validation des suppressions d'import.
+- Lissage des données.
+
+Tableau de bord
+===============
+
+Ajout du tableau de bord
+
+- une ligne par campagne et une colonne par type d'import, on met dans chaque
+cellules les imports de ce type avec un lien pour afficher
+
+Exporter les données
+====================
+
+- corriger les readonly sur les query.name et query.description
+- corriger la pagination qui ne va pas (le nombre d'enregistrement = le nombre affiché à l'écran).
+
+Suppression des imports
+=======================
+
+Confifirmation les echotypes sont bien
+On rajoute un filtre par campagne (si pas sélectionner alors toutes les imports sont disponibles)
+
+- pouvoir supprimer plusieurs imports d'un coup (on affiche dans la fenetre de confirmation uniquement une ligne par import à supprimer)
+
+Import Voyage complêt
+---------------------
+
+Supprimer les Category + voyage
+
+Import Voyage/Transit/Transect
+------------------------------
+
+Supprimer les Category + voyage
+
+Import Transect
+---------------
+
+on supprime bien tous les résultats du voyage + Category
+
+Import Opération
+----------------
+
+Import Catches
+--------------
+
+Import Acoustic
+---------------
+
+on supprime bien tous les résultats du voyage + Category
+
+Import Résultat Voyage
+----------------------
+
+on supprime bien tous les résultats du voyage + Category
+
+Import Résultat Esdu
+--------------------
+
+Import Résultat Région
+----------------------
+
+Import Résultat Map
+-------------------
+
+A faire
+=======
+
+- Mathieu
+ -
+- Tony
+ - voir pour créer dynamiquement les bases
+ - faire pointer les docs uniquements sur les pages (sans les anchors pour pouvoir bien traduire)
+ - corriger le problème du NPE sur le filtre (transaction nulle)
+ - corriger le problème sur exporter les requetes (tout est en readonly)
+
+
+Prochaine réunion
+=================
+
+- Lundi 24 septembre 2012 à 10h00
+
Property changes on: trunk/src/doc/reunions/reunion-2012-09-20.txt
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
1
0
Author: tchemit
Date: 2012-09-20 12:19:24 +0200 (Thu, 20 Sep 2012)
New Revision: 674
Url: http://forge.codelutin.com/repositories/revision/echobase/674
Log:
>From scmwebeditor --
Modified:
trunk/src/site/rst/index.rst
Modified: trunk/src/site/rst/index.rst
===================================================================
--- trunk/src/site/rst/index.rst 2012-09-18 08:50:31 UTC (rev 673)
+++ trunk/src/site/rst/index.rst 2012-09-20 10:19:24 UTC (rev 674)
@@ -38,9 +38,13 @@
Ce site décrit la base de données Echobase. Si vous êtes intéressés par EchoR, rendez vous dans sa `forge Ifremer`_.
Les caractéristiques d'Echobase incluent :
+
- une interface basée accessible via un navigateur internet pour importer, éditer et extraire des données ;
+
- une grande capacité de stockage et un système de gestion de bases multiples ;
+
- une intégration facile avec des Systèmes d'Information Géographiques et ou des sites internet dynamiques ;
+
- une structure de métadonnées acoustiques en accord avec le format défini par le `groupe de travail CIEM WGFAST`_.
Les documents
1
0
r673 - trunk/echobase-domain/src/main/java/fr/ifremer/echobase/io
by tchemit@users.forge.codelutin.com 18 Sep '12
by tchemit@users.forge.codelutin.com 18 Sep '12
18 Sep '12
Author: tchemit
Date: 2012-09-18 10:50:31 +0200 (Tue, 18 Sep 2012)
New Revision: 673
Url: http://forge.codelutin.com/repositories/revision/echobase/673
Log:
czn use gz files for echobase distribution files
Modified:
trunk/echobase-domain/src/main/java/fr/ifremer/echobase/io/EchoBaseIOUtil.java
Modified: trunk/echobase-domain/src/main/java/fr/ifremer/echobase/io/EchoBaseIOUtil.java
===================================================================
--- trunk/echobase-domain/src/main/java/fr/ifremer/echobase/io/EchoBaseIOUtil.java 2012-09-18 08:42:47 UTC (rev 672)
+++ trunk/echobase-domain/src/main/java/fr/ifremer/echobase/io/EchoBaseIOUtil.java 2012-09-18 08:50:31 UTC (rev 673)
@@ -22,6 +22,7 @@
*/
package fr.ifremer.echobase.io;
+import com.google.common.base.Charsets;
import com.google.common.base.Preconditions;
import fr.ifremer.echobase.EchoBaseTechnicalException;
import org.apache.commons.collections.CollectionUtils;
@@ -34,13 +35,14 @@
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
-import java.io.FileReader;
+import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.LineNumberReader;
import java.util.Collection;
+import java.util.zip.GZIPInputStream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
@@ -95,7 +97,12 @@
try {
boolean firstLine = false;
for (File toMergeFile : fileToMerges) {
- BufferedReader reader = new BufferedReader(new FileReader(toMergeFile));
+ BufferedReader reader;
+ if (toMergeFile.getName().endsWith(".gz")) {
+ reader = new BufferedReader(new InputStreamReader(new GZIPInputStream(new FileInputStream(toMergeFile)), Charsets.UTF_8));
+ } else {
+ reader = new BufferedReader(new InputStreamReader(new FileInputStream(toMergeFile), Charsets.UTF_8));
+ }
try {
// pass the first line (header)
String line = reader.readLine();
1
0
Author: tchemit
Date: 2012-09-17 18:27:59 +0200 (Mon, 17 Sep 2012)
New Revision: 671
Url: http://forge.codelutin.com/repositories/revision/echobase/671
Log:
refs #1437: Suppression des imports (fix doc)
Modified:
trunk/src/site/rst/removeimports.rst
Modified: trunk/src/site/rst/removeimports.rst
===================================================================
--- trunk/src/site/rst/removeimports.rst 2012-09-17 08:58:15 UTC (rev 670)
+++ trunk/src/site/rst/removeimports.rst 2012-09-17 16:27:59 UTC (rev 671)
@@ -49,8 +49,9 @@
- category (utilise EchoType)
- echotype
-Imports à retirer
-~~~~~~~~~~~~~~~~~
+Question:
+ Les echotypes sont-ils uniquement lié au voyage ? Si oui on peut utiliser
+ une composition qui évitent de devoir supprimer à la main les echotypes.
Seront supprimés de la table des imports les imports suivants qui aurait pu
être effectué suite à cet import, à savoir :
@@ -106,13 +107,16 @@
Seront supprimés de la table des imports les imports suivants qui aurait pu
être effectué suite à cet import, à savoir :
-- import Operation
-- import Catches
-- import Acoustic
-- import Résultats Esdu
-- import Region
-- import Map
+- import Operation (*)
+- import Catches (*)
+- import Acoustic (*)
+- import Résultats Esdu (**)
+- import Region (**)
+- import Map (**)
+(*) tous ceux sur la branche du transect
+(**) tous ceux du voyage
+
Import Operation
----------------
@@ -128,8 +132,10 @@
Seront supprimés de la table des imports les imports suivants qui aurait pu
être effectué suite à cet import, à savoir :
-- import Catches
+- import Catches (*)
+(*) tous ceux sur la branche des opérations
+
Import Catches
--------------
@@ -159,10 +165,12 @@
Seront supprimés de la table des imports les imports suivants qui aurait pu
être effectué sur ce voyage, à savoir :
-- import Résultats Esdu
-- import Region
-- import Map
+- import Résultats Esdu (*)
+- import Region (*)
+- import Map (*)
+(*) tous ceux du voyage
+
Import Résultats voyage
-----------------------
@@ -183,10 +191,12 @@
Seront supprimés de la table des imports les imports suivants qui aurait pu
être effectué suite à cet import, à savoir :
-- import Résultats Esdu
-- import Region
-- import Map
+- import Résultats Esdu (*)
+- import Region (*)
+- import Map (*)
+(*) tous ceux du voyage
+
Immort Résultats Esdu
---------------------
1
0
r670 - in trunk/echobase-services/src: main/java/fr/ifremer/echobase/services/removedata/strategy test/java/fr/ifremer/echobase/ui/actions/removedata
by tchemit@users.forge.codelutin.com 17 Sep '12
by tchemit@users.forge.codelutin.com 17 Sep '12
17 Sep '12
Author: tchemit
Date: 2012-09-17 10:58:15 +0200 (Mon, 17 Sep 2012)
New Revision: 670
Url: http://forge.codelutin.com/repositories/revision/echobase/670
Log:
refs #1437: Suppression des imports (works fine but still need some clarifications)
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/AcousticRemoveDataStrategy.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/LegacyVoyageRemoveDataStrategy.java
trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/AbstractRemoveDataServiceTest.java
trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/AcousticRemoveDataServiceTest.java
trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/CommonTransectRemoveDataServiceTest.java
trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/ResultRegionRemoveDataServiceTest.java
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-16 13:56:31 UTC (rev 669)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/AbstractRemoveDataStrategy.java 2012-09-17 08:58:15 UTC (rev 670)
@@ -31,6 +31,8 @@
import fr.ifremer.echobase.entities.data.CategoryDAO;
import fr.ifremer.echobase.entities.data.Cell;
import fr.ifremer.echobase.entities.data.CellDAO;
+import fr.ifremer.echobase.entities.data.DataProcessing;
+import fr.ifremer.echobase.entities.data.DataProcessingDAO;
import fr.ifremer.echobase.entities.data.Echotype;
import fr.ifremer.echobase.entities.data.EchotypeDAO;
import fr.ifremer.echobase.entities.data.LengthAgeKey;
@@ -76,6 +78,8 @@
protected VoyageDAO voyageDao;
+ protected DataProcessingDAO dataProcessingDAO;
+
protected CellDAO cellDAO;
protected CategoryDAO categoryDAO;
@@ -92,6 +96,7 @@
public void setServiceContext(EchoBaseServiceContext serviceContext) {
super.setServiceContext(serviceContext);
+ dataProcessingDAO = getDAO(DataProcessing.class, DataProcessingDAO.class);
cellDAO = getDAO(Cell.class, CellDAO.class);
echotypeDAO = getDAO(Echotype.class, EchotypeDAO.class);
voyageDao = getDAO(Voyage.class, VoyageDAO.class);
@@ -138,12 +143,10 @@
}
protected void removePreDataInVoyage(Voyage voyage) throws TopiaException {
-
// by default nothing to remove
}
protected void removePostDataInVoyage(Voyage voyage) throws TopiaException {
-
// by default nothing to remove
}
@@ -191,16 +194,10 @@
protected void removeEchotype(Voyage entity,
Echotype echotype) throws TopiaException {
- // delete all category
+ // delete all categories using this echotype
List<Category> allByEchotype = categoryDAO.findAllByEchotype(echotype);
categoryDAO.deleteAll(allByEchotype);
-// if (entity != null) {
-//
-// // remove it from the voyage
-// entity.removeEchotype(echotype);
-// }
-
// delete echotype
echotypeDAO.delete(echotype);
@@ -298,4 +295,29 @@
}
}
}
+
+ protected void removeVoyageOrphanCells() throws TopiaException {
+ // 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 Cell c " +
+ "WHERE c.cell IS NULL AND c.dataprocessing IS NULL AND c.voyage IS NULL";
+ PreparedStatement result = connection.prepareStatement(hql);
+ return result;
+ }
+
+ @Override
+ protected String prepareResult(ResultSet set) throws SQLException {
+ return set.getString(1);
+ }
+ };
+
+ List<String> cellIds = query.findMultipleResult(
+ (TopiaContextImplementor) getTransaction());
+ for (String cellId : cellIds) {
+ Cell cell = cellDAO.findByTopiaId(cellId);
+ cellDAO.delete(cell);
+ }
+ }
}
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-16 13:56:31 UTC (rev 669)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/AcousticRemoveDataStrategy.java 2012-09-17 08:58:15 UTC (rev 670)
@@ -29,7 +29,6 @@
import fr.ifremer.echobase.entities.data.DataAcquisition;
import fr.ifremer.echobase.entities.data.DataAcquisitionDAO;
import fr.ifremer.echobase.entities.data.DataProcessing;
-import fr.ifremer.echobase.entities.data.DataProcessingDAO;
import fr.ifremer.echobase.entities.data.Transect;
import fr.ifremer.echobase.entities.data.TransectDAO;
import fr.ifremer.echobase.entities.data.Voyage;
@@ -54,7 +53,6 @@
private static final Log log =
LogFactory.getLog(AcousticRemoveDataStrategy.class);
- protected DataProcessingDAO dataProcessingDAO;
protected DataAcquisitionDAO dataAcquisitionDAO;
@@ -65,7 +63,6 @@
super.setServiceContext(serviceContext);
dataAcquisitionDAO = getDAO(DataAcquisition.class, DataAcquisitionDAO.class);
- dataProcessingDAO = getDAO(DataProcessing.class, DataProcessingDAO.class);
transectDAO = getDAO(Transect.class, TransectDAO.class);
}
@@ -77,6 +74,9 @@
// remove post cell from top voyage
removeVoyagePostCell(voyage);
+
+ // remove orphans cells
+ removeVoyageOrphanCells();
}
@Override
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-16 13:56:31 UTC (rev 669)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/CommonAllRemoveDataStrategy.java 2012-09-17 08:58:15 UTC (rev 670)
@@ -47,6 +47,13 @@
LogFactory.getLog(CommonAllRemoveDataStrategy.class);
@Override
+ protected void removePostDataInVoyage(Voyage voyage) throws TopiaException {
+
+ // remove orphans cells
+ removeVoyageOrphanCells();
+ }
+
+ @Override
protected void removeImportData(Voyage voyage, String id) throws TopiaException {
if (id.startsWith(Voyage.class.getName())) {
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-16 13:56:31 UTC (rev 669)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/CommonTransectRemoveDataStrategy.java 2012-09-17 08:58:15 UTC (rev 670)
@@ -71,6 +71,13 @@
}
@Override
+ protected void removePostDataInVoyage(Voyage voyage) throws TopiaException {
+
+ // remove orphans cells
+ removeVoyageOrphanCells();
+ }
+
+ @Override
protected void removeImportData(Voyage voyage, String id) throws TopiaException {
if (id.startsWith(Transect.class.getName())) {
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-16 13:56:31 UTC (rev 669)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/LegacyVoyageRemoveDataStrategy.java 2012-09-17 08:58:15 UTC (rev 670)
@@ -47,6 +47,13 @@
LogFactory.getLog(LegacyVoyageRemoveDataStrategy.class);
@Override
+ protected void removePostDataInVoyage(Voyage voyage) throws TopiaException {
+
+ // remove orphans cells
+ removeVoyageOrphanCells();
+ }
+
+ @Override
protected void removeImportData(Voyage voyage, String id) throws TopiaException {
if (id.startsWith(Voyage.class.getName())) {
Modified: trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/AbstractRemoveDataServiceTest.java
===================================================================
--- trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/AbstractRemoveDataServiceTest.java 2012-09-16 13:56:31 UTC (rev 669)
+++ trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/AbstractRemoveDataServiceTest.java 2012-09-17 08:58:15 UTC (rev 670)
@@ -287,7 +287,12 @@
for (String entityId : entityIds) {
if (entityId == null) continue;
E entity = getEntity(entityId);
- Assert.assertNull("Entity with id " + entityId + " should have been deleted, but is still in db :(", entity);
+ if (entity instanceof ImportLog) {
+
+ Assert.assertNull("ImporTLog with id " + entityId + " (" + ((ImportLog) entity).getImportType() + ") should have been deleted, but is still in db :(", entity);
+ } else {
+ Assert.assertNull("Entity with id " + entityId + " should have been deleted, but is still in db :(", entity);
+ }
}
}
@@ -295,7 +300,8 @@
for (String entityId : entityIds) {
if (entityId == null) continue;
E entity = getEntity(entityId);
- Assert.assertNotNull("Entity with id " + entityId + " should have not been deleted, but is deleted in db :(", entity);
+ Assert.assertNotNull("Entity with id " + entityId + " should NOT have been deleted, but is deleted in db :(", entity);
+
}
}
Modified: trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/AcousticRemoveDataServiceTest.java
===================================================================
--- trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/AcousticRemoveDataServiceTest.java 2012-09-16 13:56:31 UTC (rev 669)
+++ trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/AcousticRemoveDataServiceTest.java 2012-09-17 08:58:15 UTC (rev 670)
@@ -48,7 +48,6 @@
// and all his imports
assertEntityDeleted(importAcoustic1Id,
- importResultVoyage1Id,
importResultEsdu1Id,
importResultRegion1Id,
importResultMap1Id);
@@ -61,6 +60,7 @@
assertEntityExists(importCommonAll1Id,
importCommonTransect1Id,
importOperation1Id,
- importCatches1Id);
+ importCatches1Id,
+ importResultVoyage1Id);
}
}
Modified: trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/CommonTransectRemoveDataServiceTest.java
===================================================================
--- trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/CommonTransectRemoveDataServiceTest.java 2012-09-16 13:56:31 UTC (rev 669)
+++ trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/CommonTransectRemoveDataServiceTest.java 2012-09-17 08:58:15 UTC (rev 670)
@@ -58,9 +58,7 @@
importCatches1Id,
importAcoustic1Id,
importResultVoyage1Id,
- importResultEsdu1Id,
- importResultRegion1Id,
- importResultMap1Id);
+ importResultEsdu1Id);
// voyage 2 still in db
Modified: trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/ResultRegionRemoveDataServiceTest.java
===================================================================
--- trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/ResultRegionRemoveDataServiceTest.java 2012-09-16 13:56:31 UTC (rev 669)
+++ trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/ResultRegionRemoveDataServiceTest.java 2012-09-17 08:58:15 UTC (rev 670)
@@ -45,7 +45,7 @@
assertEntityDeleted(cellRegion1Id, resultRegion1Id);
// and all his imports
- assertEntityDeleted(importResultEsdu1Id);
+ assertEntityDeleted(importResultRegion1Id);
// voyage 1 other imports stay
assertEntityExists(voyage1Id, transect1Id, operation1Id,
1
0
r669 - in trunk: echobase-domain/src/main/xmi echobase-services/src/main/java/fr/ifremer/echobase/services/importdata echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata
by tchemit@users.forge.codelutin.com 16 Sep '12
by tchemit@users.forge.codelutin.com 16 Sep '12
16 Sep '12
Author: tchemit
Date: 2012-09-16 15:56:31 +0200 (Sun, 16 Sep 2012)
New Revision: 669
Url: http://forge.codelutin.com/repositories/revision/echobase/669
Log:
refs #1437: Suppression des imports (continue testing and fixing stuff)
Added:
trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/AbstractRemoveDataServiceTest.java
trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/AcousticRemoveDataServiceTest.java
trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/CatchesRemoveDataServiceTest.java
trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/CommonAllRemoveDataServiceTest.java
trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/CommonTransectRemoveDataServiceTest.java
trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/OperationRemoveDataServiceTest.java
trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/ResultEsduRemoveDataServiceTest.java
trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/ResultMapRemoveDataServiceTest.java
trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/ResultRegionRemoveDataServiceTest.java
trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/ResultVoyageRemoveDataServiceTest.java
Removed:
trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/AbstractRemoveDataServiceIT.java
trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/CommonAllRemoveDataServiceIT.java
trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/CommonTransectRemoveDataServiceIT.java
Modified:
trunk/echobase-domain/src/main/xmi/echobase.zargo
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/AbstractImportConfiguration.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/CommonImportConfiguration.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/ResultsImportConfiguration.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/LegacyVoyageRemoveDataStrategy.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
Modified: trunk/echobase-domain/src/main/xmi/echobase.zargo
===================================================================
(Binary files differ)
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/AbstractImportConfiguration.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/AbstractImportConfiguration.java 2012-09-16 09:39:45 UTC (rev 668)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/AbstractImportConfiguration.java 2012-09-16 13:56:31 UTC (rev 669)
@@ -94,6 +94,10 @@
return importType;
}
+ public final void setImportType(ImportType importType) {
+ this.importType = importType;
+ }
+
public List<EchoBaseCsvFileImportResult> getImportResults() {
return importResults;
}
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/CommonImportConfiguration.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/CommonImportConfiguration.java 2012-09-16 09:39:45 UTC (rev 668)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/CommonImportConfiguration.java 2012-09-16 13:56:31 UTC (rev 669)
@@ -23,7 +23,6 @@
*/
package fr.ifremer.echobase.services.importdata;
-import fr.ifremer.echobase.entities.ImportType;
import fr.ifremer.echobase.io.InputFile;
import java.util.Locale;
@@ -82,10 +81,6 @@
l_(locale, "echobase.common.transectFile"));
}
- public void setImportType(ImportType importType) {
- this.importType = importType;
- }
-
public String getMissionId() {
return missionId;
}
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/ResultsImportConfiguration.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/ResultsImportConfiguration.java 2012-09-16 09:39:45 UTC (rev 668)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/ResultsImportConfiguration.java 2012-09-16 13:56:31 UTC (rev 669)
@@ -23,7 +23,6 @@
*/
package fr.ifremer.echobase.services.importdata;
-import fr.ifremer.echobase.entities.ImportType;
import fr.ifremer.echobase.io.InputFile;
import java.util.Locale;
@@ -123,10 +122,6 @@
this.dataProcessingId = dataProcessingId;
}
- public void setImportType(ImportType importType) {
- this.importType = importType;
- }
-
public String getResultLabel() {
return resultLabel;
}
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-16 09:39:45 UTC (rev 668)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/AbstractRemoveDataStrategy.java 2012-09-16 13:56:31 UTC (rev 669)
@@ -37,6 +37,8 @@
import fr.ifremer.echobase.entities.data.LengthAgeKeyDAO;
import fr.ifremer.echobase.entities.data.LengthWeightKey;
import fr.ifremer.echobase.entities.data.LengthWeightKeyDAO;
+import fr.ifremer.echobase.entities.data.Result;
+import fr.ifremer.echobase.entities.data.ResultDAO;
import fr.ifremer.echobase.entities.data.Voyage;
import fr.ifremer.echobase.entities.data.VoyageDAO;
import fr.ifremer.echobase.services.EchoBaseServiceContext;
@@ -44,9 +46,16 @@
import fr.ifremer.echobase.services.removedata.RemoveDataConfiguration;
import org.apache.commons.collections.CollectionUtils;
import org.nuiton.topia.TopiaException;
+import org.nuiton.topia.framework.TopiaContextImplementor;
+import org.nuiton.topia.framework.TopiaSQLQuery;
import org.nuiton.topia.persistence.TopiaDAO;
import org.nuiton.topia.persistence.TopiaEntity;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Set;
@@ -77,6 +86,8 @@
protected LengthWeightKeyDAO lengthWeightKeyDAO;
+ protected ResultDAO resultDAO;
+
@Override
public void setServiceContext(EchoBaseServiceContext serviceContext) {
super.setServiceContext(serviceContext);
@@ -87,6 +98,7 @@
lengthAgeKeyDAO = getDAO(LengthAgeKey.class, LengthAgeKeyDAO.class);
lengthWeightKeyDAO = getDAO(LengthWeightKey.class, LengthWeightKeyDAO.class);
categoryDAO = getDAO(Category.class, CategoryDAO.class);
+ resultDAO = getDAO(Result.class, ResultDAO.class);
}
protected abstract void removeImportData(Voyage voyage,
@@ -98,7 +110,7 @@
Voyage voyage = voyageDao.findByTopiaId(importLog.getVoyageId());
- removeDataInVoyage(voyage);
+ removePreDataInVoyage(voyage);
int currentIndex = 0;
for (String importId : importLog.getImportId()) {
@@ -117,11 +129,24 @@
}
}
-// flushTransaction("Could not flush transaction");
+ flushTransaction("Could not flush transaction");
+
+ removePostDataInVoyage(voyage);
+
+
+ flushTransaction("Could not flush transaction");
}
- protected abstract void removeDataInVoyage(Voyage voyage) throws TopiaException;
+ protected void removePreDataInVoyage(Voyage voyage) throws TopiaException {
+ // by default nothing to remove
+ }
+
+ protected void removePostDataInVoyage(Voyage voyage) throws TopiaException {
+
+ // by default nothing to remove
+ }
+
protected <E extends TopiaEntity> E removeEntity(TopiaDAO<E> dao,
String id) throws TopiaException {
@@ -170,27 +195,28 @@
List<Category> allByEchotype = categoryDAO.findAllByEchotype(echotype);
categoryDAO.deleteAll(allByEchotype);
+// if (entity != null) {
+//
+// // remove it from the voyage
+// entity.removeEchotype(echotype);
+// }
+
// delete echotype
echotypeDAO.delete(echotype);
- if (entity != null) {
-
- // remove it from the voyage
- entity.removeEchotype(echotype);
- }
}
protected void removePostCell(Voyage entity,
Cell cell) throws TopiaException {
- // delete postcell
- cellDAO.delete(cell);
-
if (entity != null) {
// remove it from the voyage
entity.removePostCell(cell);
}
+
+ // delete postcell
+ cellDAO.delete(cell);
}
protected void removeVoyage(Voyage entity) throws TopiaException {
@@ -227,4 +253,49 @@
"Could not flush transaction after removing postCells");
}
}
+
+ protected void removeVoyageCellResults(final Voyage voyage) throws TopiaException {
+
+ // 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 Transit ta, " +
+ " Transect te, " +
+ " DataAcquisition da, " +
+ " DataProcessing dp, " +
+ " Cell 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
+
+ for (String cellId : cellIds) {
+ Cell cell = cellDAO.findByTopiaId(cellId);
+ if (cell != null && !cell.isResultEmpty()) {
+ Collection<Result> cellResult = cell.getResult();
+// for (Result result : cellResult) {
+// cell.removeResult(result);
+// }
+ resultDAO.deleteAll(cellResult);
+ cell.clearResult();
+ }
+ }
+ }
}
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-16 09:39:45 UTC (rev 668)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/AcousticRemoveDataStrategy.java 2012-09-16 13:56:31 UTC (rev 669)
@@ -28,6 +28,10 @@
import fr.ifremer.echobase.entities.data.Cell;
import fr.ifremer.echobase.entities.data.DataAcquisition;
import fr.ifremer.echobase.entities.data.DataAcquisitionDAO;
+import fr.ifremer.echobase.entities.data.DataProcessing;
+import fr.ifremer.echobase.entities.data.DataProcessingDAO;
+import fr.ifremer.echobase.entities.data.Transect;
+import fr.ifremer.echobase.entities.data.TransectDAO;
import fr.ifremer.echobase.entities.data.Voyage;
import fr.ifremer.echobase.services.EchoBaseServiceContext;
import org.apache.commons.logging.Log;
@@ -50,18 +54,27 @@
private static final Log log =
LogFactory.getLog(AcousticRemoveDataStrategy.class);
+ protected DataProcessingDAO dataProcessingDAO;
+
protected DataAcquisitionDAO dataAcquisitionDAO;
+ protected TransectDAO transectDAO;
+
@Override
public void setServiceContext(EchoBaseServiceContext serviceContext) {
super.setServiceContext(serviceContext);
dataAcquisitionDAO = getDAO(DataAcquisition.class, DataAcquisitionDAO.class);
+ dataProcessingDAO = getDAO(DataProcessing.class, DataProcessingDAO.class);
+ transectDAO = getDAO(Transect.class, TransectDAO.class);
}
@Override
- protected void removeDataInVoyage(Voyage voyage) throws TopiaException {
+ protected void removePostDataInVoyage(Voyage voyage) throws TopiaException {
+ // remove all cell results
+ removeVoyageCellResults(voyage);
+
// remove post cell from top voyage
removeVoyagePostCell(voyage);
}
@@ -71,17 +84,31 @@
if (id.startsWith(DataAcquisition.class.getName())) {
+ // get dataAcquisition
+ DataAcquisition dataAcquisition = dataAcquisitionDAO.findByTopiaId(id);
+
+ // remove it from cell
+ Transect transect = transectDAO.findContainsDataAcquisition(dataAcquisition);
+ transect.removeDataAcquisition(dataAcquisition);
+
// remove dataAcquisition
- DataAcquisition entity = removeEntity(dataAcquisitionDAO, id);
+ delete(dataAcquisitionDAO, dataAcquisition);
if (log.isInfoEnabled()) {
- log.info("DataAcquisition " + entity.getTopiaId() + " was removed");
+ log.info("DataAcquisition " + dataAcquisition.getTopiaId() + " was removed");
}
} else if (id.startsWith(Cell.class.getName())) {
+ // get cell
+ Cell cell = cellDAO.findByTopiaId(id);
+
+ // remove it from the dataAcquisition
+ DataProcessing dataProcessing = dataProcessingDAO.findContainsCell(cell);
+ dataProcessing.removeCell(cell);
+
// remove cell
- Cell entity = removeEntity(cellDAO, id);
+ delete(cellDAO, cell);
if (log.isInfoEnabled()) {
- log.info("Cell " + entity.getTopiaId() + " was removed");
+ log.info("Cell " + cell.getTopiaId() + " was removed");
}
} else {
canNotDealWithId(id);
@@ -90,7 +117,8 @@
@Override
public Set<ImportType> getPossibleSubImportType() {
- Set<ImportType> result = Sets.newHashSet(ImportType.RESULT_ESDU,
+ 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-16 09:39:45 UTC (rev 668)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/CatchesRemoveDataStrategy.java 2012-09-16 13:56:31 UTC (rev 669)
@@ -24,6 +24,8 @@
*/
import fr.ifremer.echobase.entities.ImportType;
+import fr.ifremer.echobase.entities.data.Operation;
+import fr.ifremer.echobase.entities.data.OperationDAO;
import fr.ifremer.echobase.entities.data.Sample;
import fr.ifremer.echobase.entities.data.SampleDAO;
import fr.ifremer.echobase.entities.data.Voyage;
@@ -51,26 +53,31 @@
protected SampleDAO sampleDAO;
+ protected OperationDAO operationDAO;
+
@Override
public void setServiceContext(EchoBaseServiceContext serviceContext) {
super.setServiceContext(serviceContext);
sampleDAO = getDAO(Sample.class, SampleDAO.class);
+ operationDAO = getDAO(Operation.class, OperationDAO.class);
}
@Override
- protected void removeDataInVoyage(Voyage voyage) throws TopiaException {
- // nothing to do on voyage level
- }
-
- @Override
protected void removeImportData(Voyage voyage, String id) throws TopiaException {
if (id.startsWith(Sample.class.getName())) {
+ // get sample
+ Sample sample = sampleDAO.findByTopiaId(id);
+
+ // remove it from operation
+ Operation operation = operationDAO.findContainsSample(sample);
+ operation.removeSample(sample);
+
// remove sample
- Sample entity = removeEntity(sampleDAO, id);
+ delete(sampleDAO, sample);
if (log.isInfoEnabled()) {
- log.info("Sample " + entity.getTopiaId() + " was removed");
+ log.info("Sample " + sample.getTopiaId() + " was removed");
}
} else {
canNotDealWithId(id);
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-16 09:39:45 UTC (rev 668)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/CommonAllRemoveDataStrategy.java 2012-09-16 13:56:31 UTC (rev 669)
@@ -47,16 +47,10 @@
LogFactory.getLog(CommonAllRemoveDataStrategy.class);
@Override
- protected void removeDataInVoyage(Voyage voyage) throws TopiaException {
- // nothing to do on voyage level (done by voyage id)...
- }
-
- @Override
protected void removeImportData(Voyage voyage, String id) throws TopiaException {
if (id.startsWith(Voyage.class.getName())) {
- // remove voyage
// get entity to delete
Voyage entity = voyageDao.findByTopiaId(id);
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-16 09:39:45 UTC (rev 668)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/CommonTransectRemoveDataStrategy.java 2012-09-16 13:56:31 UTC (rev 669)
@@ -64,7 +64,7 @@
}
@Override
- protected void removeDataInVoyage(Voyage voyage) throws TopiaException {
+ protected void removePreDataInVoyage(Voyage voyage) throws TopiaException {
// remove postCell from voyage
removeVoyagePostCell(voyage);
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-16 09:39:45 UTC (rev 668)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/LegacyVoyageRemoveDataStrategy.java 2012-09-16 13:56:31 UTC (rev 669)
@@ -47,11 +47,6 @@
LogFactory.getLog(LegacyVoyageRemoveDataStrategy.class);
@Override
- protected void removeDataInVoyage(Voyage voyage) throws TopiaException {
- // nothing to do on voyage level
- }
-
- @Override
protected void removeImportData(Voyage voyage, String id) throws TopiaException {
if (id.startsWith(Voyage.class.getName())) {
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-16 09:39:45 UTC (rev 668)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/OperationRemoveDataStrategy.java 2012-09-16 13:56:31 UTC (rev 669)
@@ -27,6 +27,8 @@
import fr.ifremer.echobase.entities.ImportType;
import fr.ifremer.echobase.entities.data.Operation;
import fr.ifremer.echobase.entities.data.OperationDAO;
+import fr.ifremer.echobase.entities.data.Transect;
+import fr.ifremer.echobase.entities.data.TransectDAO;
import fr.ifremer.echobase.entities.data.Voyage;
import fr.ifremer.echobase.services.EchoBaseServiceContext;
import org.apache.commons.logging.Log;
@@ -51,28 +53,33 @@
protected OperationDAO operationDAO;
+ protected TransectDAO transectDAO;
+
@Override
public void setServiceContext(EchoBaseServiceContext serviceContext) {
super.setServiceContext(serviceContext);
operationDAO = getDAO(Operation.class, OperationDAO.class);
+ transectDAO = getDAO(Transect.class, TransectDAO.class);
}
@Override
- protected void removeDataInVoyage(Voyage voyage) throws TopiaException {
- // nothing to do on voyage level
- }
-
- @Override
protected void removeImportData(Voyage voyage, String id) throws TopiaException {
if (id.startsWith(Operation.class.getName())) {
- // remove operation
- Operation entity = removeEntity(operationDAO, id);
+ // get operation
+ Operation operation = operationDAO.findByTopiaId(id);
+
+ // remove it from transect
+ Transect transect = transectDAO.findContainsOperation(operation);
+ transect.removeOperation(operation);
+
+ // remove it
+ delete(operationDAO, operation);
if (log.isInfoEnabled()) {
- log.info("Operation " + entity.getTopiaId() + " was removed");
+ log.info("Operation " + operation.getTopiaId() + " was removed");
}
} else {
canNotDealWithId(id);
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-16 09:39:45 UTC (rev 668)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/ResultEsduRemoveDataStrategy.java 2012-09-16 13:56:31 UTC (rev 669)
@@ -24,10 +24,9 @@
*/
import fr.ifremer.echobase.entities.ImportType;
+import fr.ifremer.echobase.entities.data.Cell;
import fr.ifremer.echobase.entities.data.Result;
-import fr.ifremer.echobase.entities.data.ResultDAO;
import fr.ifremer.echobase.entities.data.Voyage;
-import fr.ifremer.echobase.services.EchoBaseServiceContext;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.nuiton.topia.TopiaException;
@@ -49,29 +48,22 @@
private static final Log log =
LogFactory.getLog(ResultEsduRemoveDataStrategy.class);
- protected ResultDAO resultDAO;
-
@Override
- public void setServiceContext(EchoBaseServiceContext serviceContext) {
- super.setServiceContext(serviceContext);
-
- resultDAO = getDAO(Result.class, ResultDAO.class);
- }
-
- @Override
- protected void removeDataInVoyage(Voyage voyage) throws TopiaException {
- // nothing to do on voyage level
- }
-
- @Override
protected void removeImportData(Voyage voyage, String id) throws TopiaException {
if (id.startsWith(Result.class.getName())) {
+ // get result
+ Result result = resultDAO.findByTopiaId(id);
+
+ // remove it from cell
+ Cell cell = cellDAO.findContainsResult(result);
+ cell.removeResult(result);
+
// remove result
- Result entity = removeEntity(resultDAO, id);
+ delete(resultDAO, result);
if (log.isDebugEnabled()) {
- log.debug("Result " + entity.getTopiaId() + " was removed");
+ log.debug("Result " + result.getTopiaId() + " was removed");
}
} else {
canNotDealWithId(id);
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-16 09:39:45 UTC (rev 668)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/ResultMapRemoveDataStrategy.java 2012-09-16 13:56:31 UTC (rev 669)
@@ -48,19 +48,23 @@
LogFactory.getLog(ResultMapRemoveDataStrategy.class);
@Override
- protected void removeDataInVoyage(Voyage voyage) throws TopiaException {
- // nothing to do on voyage level
- }
-
- @Override
protected void removeImportData(Voyage voyage, String id) throws TopiaException {
if (id.startsWith(Cell.class.getName())) {
+ // get cell
+ Cell cell = cellDAO.findByTopiaId(id);
+
+ // dettach cell childs, we do not want to delete them from here ?
+ cell.clearChilds();
+
+ // remove it from voyage
+ voyage.removePostCell(cell);
+
// remove cell
- Cell entity = removeEntity(cellDAO, id);
+ delete(cellDAO, cell);
if (log.isInfoEnabled()) {
- log.info("Cell " + entity.getTopiaId() + " was removed");
+ log.info("Map Cell " + cell.getTopiaId() + " was removed");
}
} else {
canNotDealWithId(id);
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-16 09:39:45 UTC (rev 668)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/ResultRegionRemoveDataStrategy.java 2012-09-16 13:56:31 UTC (rev 669)
@@ -25,9 +25,7 @@
import fr.ifremer.echobase.entities.ImportType;
import fr.ifremer.echobase.entities.data.Cell;
-import fr.ifremer.echobase.entities.data.CellDAO;
import fr.ifremer.echobase.entities.data.Voyage;
-import fr.ifremer.echobase.services.EchoBaseServiceContext;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.nuiton.topia.TopiaException;
@@ -50,19 +48,23 @@
LogFactory.getLog(ResultRegionRemoveDataStrategy.class);
@Override
- protected void removeDataInVoyage(Voyage voyage) throws TopiaException {
- // nothing to do on voyage level
- }
-
- @Override
protected void removeImportData(Voyage voyage, String id) throws TopiaException {
if (id.startsWith(Cell.class.getName())) {
- // remove post cell
- Cell entity = removeEntity(cellDAO, id);
+ // get cell
+ Cell cell = cellDAO.findByTopiaId(id);
+
+ // dettach cell childs, we do not want to delete them from here ?
+ cell.clearChilds();
+
+ // remove it from voyage
+ voyage.removePostCell(cell);
+
+ // remove cell
+ delete(cellDAO, cell);
if (log.isInfoEnabled()) {
- log.info("Cell " + entity.getTopiaId() + " was removed");
+ log.info("Region Cell " + cell.getTopiaId() + " was removed");
}
} else {
canNotDealWithId(id);
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-16 09:39:45 UTC (rev 668)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/ResultVoyageRemoveDataStrategy.java 2012-09-16 13:56:31 UTC (rev 669)
@@ -25,26 +25,14 @@
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.ResultDAO;
import fr.ifremer.echobase.entities.data.Voyage;
-import fr.ifremer.echobase.services.EchoBaseServiceContext;
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 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;
/**
@@ -62,60 +50,13 @@
private static final Log log =
LogFactory.getLog(ResultVoyageRemoveDataStrategy.class);
-
- protected ResultDAO resultDAO;
-
@Override
- public void setServiceContext(EchoBaseServiceContext serviceContext) {
- super.setServiceContext(serviceContext);
+ protected void removePreDataInVoyage(final Voyage voyage) throws TopiaException {
- resultDAO = getDAO(Result.class, ResultDAO.class);
- }
-
- @Override
- protected void removeDataInVoyage(final Voyage voyage) throws TopiaException {
-
removeVoyagePostCell(voyage);
- // 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;
- }
+ removeVoyageCellResults(voyage);
- @Override
- protected String prepareResult(ResultSet set) throws SQLException {
- return set.getString(1);
- }
- };
-
- List<String> cellIds = query.findMultipleResult(
- (TopiaContextImplementor) getTransaction());
-
- // remove all result of cells
-
- for (String cellId : cellIds) {
- Cell cell = cellDAO.findByTopiaId(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");
}
Deleted: trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/AbstractRemoveDataServiceIT.java
===================================================================
--- trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/AbstractRemoveDataServiceIT.java 2012-09-16 09:39:45 UTC (rev 668)
+++ trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/AbstractRemoveDataServiceIT.java 2012-09-16 13:56:31 UTC (rev 669)
@@ -1,398 +0,0 @@
-package fr.ifremer.echobase.ui.actions.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.entities.EchoBaseUser;
-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.Cell;
-import fr.ifremer.echobase.entities.data.CellDAO;
-import fr.ifremer.echobase.entities.data.DataAcquisition;
-import fr.ifremer.echobase.entities.data.DataAcquisitionDAO;
-import fr.ifremer.echobase.entities.data.DataProcessing;
-import fr.ifremer.echobase.entities.data.DataProcessingDAO;
-import fr.ifremer.echobase.entities.data.Echotype;
-import fr.ifremer.echobase.entities.data.EchotypeDAO;
-import fr.ifremer.echobase.entities.data.LengthAgeKey;
-import fr.ifremer.echobase.entities.data.LengthAgeKeyDAO;
-import fr.ifremer.echobase.entities.data.LengthWeightKey;
-import fr.ifremer.echobase.entities.data.LengthWeightKeyDAO;
-import fr.ifremer.echobase.entities.data.Transect;
-import fr.ifremer.echobase.entities.data.TransectDAO;
-import fr.ifremer.echobase.entities.data.Transit;
-import fr.ifremer.echobase.entities.data.TransitDAO;
-import fr.ifremer.echobase.entities.data.Voyage;
-import fr.ifremer.echobase.entities.data.VoyageDAO;
-import fr.ifremer.echobase.entities.references.Mission;
-import fr.ifremer.echobase.entities.references.Vessel;
-import fr.ifremer.echobase.services.EchoBaseTestServiceSupport;
-import fr.ifremer.echobase.services.FakeEchoBaseServiceContext;
-import fr.ifremer.echobase.services.importdata.CommonAllImportService;
-import fr.ifremer.echobase.services.importdata.CommonImportConfiguration;
-import fr.ifremer.echobase.services.removedata.RemoveDataConfiguration;
-import fr.ifremer.echobase.services.removedata.RemoveDataService;
-import junit.framework.Assert;
-import org.apache.commons.collections.CollectionUtils;
-import org.junit.Before;
-import org.nuiton.topia.TopiaException;
-import org.nuiton.topia.persistence.TopiaDAO;
-import org.nuiton.topia.persistence.TopiaEntity;
-
-import java.util.List;
-
-/**
- * Abstract it form remove data feature.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.2
- */
-public abstract class AbstractRemoveDataServiceIT extends EchoBaseTestServiceSupport {
-
- protected String importCommonAll1Id;
-
- protected String importCommonTransect1Id;
-
- protected static final String voyage1Id = "fr.ifremer.echobase.entities.data.Voyage#1#1";
-
- protected static final String transit1Id = "fr.ifremer.echobase.entities.data.Transit#1#1";
-
- protected static final String transect1Id = "fr.ifremer.echobase.entities.data.Transect#1#1";
-
- protected static final String transect1_2Id = "fr.ifremer.echobase.entities.data.Transect#1#2";
-
- protected String importCommonAll2Id;
-
- protected String importCommonTransect2Id;
-
- protected static final String voyage2Id = "fr.ifremer.echobase.entities.data.Voyage#2#1";
-
- protected static final String transit2Id = "fr.ifremer.echobase.entities.data.Transit#2#1";
-
- protected static final String transect2Id = "fr.ifremer.echobase.entities.data.Transect#2#1";
-
- protected static final String transect2_2Id = "fr.ifremer.echobase.entities.data.Transect#2#2";
-
- protected VoyageDAO voyageDao;
-
- protected TransectDAO transectDAO;
-
- protected TransitDAO transitDAO;
-
- protected DataAcquisitionDAO dataAcquisitionDAO;
-
- protected DataProcessingDAO dataProcessingDAO;
-
- protected CellDAO cellDAO;
-
- protected CategoryDAO categoryDAO;
-
- protected EchotypeDAO echotypeDAO;
-
- protected LengthAgeKeyDAO lengthAgeKeyDAO;
-
- protected LengthWeightKeyDAO lengthWeightKeyDAO;
-
- @Override
- protected FakeEchoBaseServiceContext initContext() {
- return new FakeEchoBaseServiceContext(fixtures.IMPORT_DATA_ECHOBASE_NO_DATA());
- }
-
- @Override
- @Before
- public void setUp() throws Exception {
- super.setUp();
-
- voyageDao = getDAO(Voyage.class, VoyageDAO.class);
- transectDAO = getDAO(Transect.class, TransectDAO.class);
- transitDAO = getDAO(Transit.class, TransitDAO.class);
- dataAcquisitionDAO = getDAO(DataAcquisition.class, DataAcquisitionDAO.class);
- dataProcessingDAO = getDAO(DataProcessing.class, DataProcessingDAO.class);
-
- cellDAO = getDAO(Cell.class, CellDAO.class);
- echotypeDAO = getDAO(Echotype.class, EchotypeDAO.class);
- lengthAgeKeyDAO = getDAO(LengthAgeKey.class, LengthAgeKeyDAO.class);
- lengthWeightKeyDAO = getDAO(LengthWeightKey.class, LengthWeightKeyDAO.class);
- categoryDAO = getDAO(Category.class, CategoryDAO.class);
- }
-
- protected void removeImport(String importId) {
- RemoveDataConfiguration conf = new RemoveDataConfiguration();
- conf.setImportLogId(importId);
-
- RemoveDataService service = getService(RemoveDataService.class);
-
- EchoBaseUser fakeUser = createFakeUser();
-
- service.removeImport(conf, fakeUser);
- }
-
-
- protected <E extends TopiaEntity> void assertEntityDeleted(Class<E> entityType, String... entityIds) throws TopiaException {
- TopiaDAO<E> dao = getDAO(entityType);
- for (String entityId : entityIds) {
- E entity = dao.findByTopiaId(entityId);
- Assert.assertNull("Entity with id " + entityId + " should have been deleted, but is still in db :(", entity);
- }
- }
-
- protected <E extends TopiaEntity> void assertEntityExists(Class<E> entityType, String... entityIds) throws TopiaException {
- TopiaDAO<E> dao = getDAO(entityType);
- for (String entityId : entityIds) {
- E entity = dao.findByTopiaId(entityId);
- Assert.assertNotNull("Entity with id " + entityId + " should have not been deleted, but is deleted in db :(", entity);
- }
- }
-
- protected <E extends TopiaEntity> E getFirstEntity(Class<E> entityType) {
- List<E> entities = getEntities(entityType);
- Assert.assertTrue(CollectionUtils.isNotEmpty(entities));
- return entities.get(0);
- }
-
- protected void createCommonAllImportV1() {
-
- // create voyage
- Voyage voyage1 = create(voyageDao,
- TopiaEntity.TOPIA_ID, voyage1Id,
- Voyage.PROPERTY_MISSION, getFirstEntity(Mission.class),
- Voyage.PROPERTY_NAME, "voyage1",
- Voyage.PROPERTY_START_DATE, newDate(),
- Voyage.PROPERTY_END_DATE, newDate(),
- Voyage.PROPERTY_START_PORT, "voyage1StartPort",
- Voyage.PROPERTY_END_PORT, "voyage1EndPort",
- Voyage.PROPERTY_DESCRIPTION, "voyage1Description",
- Voyage.PROPERTY_DATUM, "voyage1Datum"
- );
-
- // create transit
- Transit transit1 = create(transitDAO,
- TopiaEntity.TOPIA_ID, transit1Id,
- Transit.PROPERTY_START_TIME, newDate(),
- Transit.PROPERTY_END_TIME, newDate(),
- Transit.PROPERTY_START_LOCALITY, "transit1tartLocality",
- Transit.PROPERTY_END_LOCALITY, "transit1EndLocality",
- Transit.PROPERTY_DESCRIPTION, "transit1Description",
- Transit.PROPERTY_RELATED_ACTIVITY, "transit1RelatedActivity"
- );
- voyage1.addTransit(transit1);
-
- // create transect
- Transect transect1 = create(transectDAO,
- TopiaEntity.TOPIA_ID, transect1Id,
- Transect.PROPERTY_TITLE, "transect1Title",
- Transect.PROPERTY_VESSEL, getFirstEntity(Vessel.class),
- Transect.PROPERTY_STRATUM, "transect1Stratum"
- );
- transit1.addTransect(transect1);
-
- commitTransaction("ImportError!");
-
- CommonImportConfiguration importConf =
- new CommonImportConfiguration(getLocale());
- importConf.setImportType(ImportType.COMMON_ALL);
- importConf.setImportNotes("Common/Voyage/Transit/Transect1");
- importConf.setVoyageId(voyage1.getTopiaId());
-
- CommonAllImportService importService =
- getService(CommonAllImportService.class);
-
- ImportLog importLog = importService.computeImportLogEntry(
- importConf, createFakeUser());
-
- importLog.addImportId(voyage1.getTopiaId());
-
- commitTransaction("ImportLogError!");
-
- importCommonAll1Id = importLog.getTopiaId();
- }
-
- protected void createCommonAllImportV2() {
-
- // create voyage
- Voyage voyage1 = create(voyageDao,
- TopiaEntity.TOPIA_ID, voyage2Id,
- Voyage.PROPERTY_MISSION, getFirstEntity(Mission.class),
- Voyage.PROPERTY_NAME, "voyage1",
- Voyage.PROPERTY_START_DATE, newDate(),
- Voyage.PROPERTY_END_DATE, newDate(),
- Voyage.PROPERTY_START_PORT, "voyage1StartPort",
- Voyage.PROPERTY_END_PORT, "voyage1EndPort",
- Voyage.PROPERTY_DESCRIPTION, "voyage1Description",
- Voyage.PROPERTY_DATUM, "voyage1Datum"
- );
-
- // create transit
- Transit transit1 = create(transitDAO,
- TopiaEntity.TOPIA_ID, transit2Id,
- Transit.PROPERTY_START_TIME, newDate(),
- Transit.PROPERTY_END_TIME, newDate(),
- Transit.PROPERTY_START_LOCALITY, "transit1tartLocality",
- Transit.PROPERTY_END_LOCALITY, "transit1EndLocality",
- Transit.PROPERTY_DESCRIPTION, "transit1Description",
- Transit.PROPERTY_RELATED_ACTIVITY, "transit1RelatedActivity"
- );
- voyage1.addTransit(transit1);
-
- // create transect
- Transect transect1 = create(transectDAO,
- TopiaEntity.TOPIA_ID, transect2Id,
- Transect.PROPERTY_TITLE, "transect1Title",
- Transect.PROPERTY_VESSEL, getFirstEntity(Vessel.class),
- Transect.PROPERTY_STRATUM, "transect1Stratum"
- );
- transit1.addTransect(transect1);
-
- commitTransaction("ImportError!");
-
- CommonImportConfiguration importConf =
- new CommonImportConfiguration(getLocale());
- importConf.setImportType(ImportType.COMMON_ALL);
- importConf.setImportNotes("Common/Voyage/Transit/Transect2");
- importConf.setVoyageId(voyage1.getTopiaId());
-
- CommonAllImportService importService =
- getService(CommonAllImportService.class);
-
- ImportLog importLog = importService.computeImportLogEntry(
- importConf, createFakeUser());
-
- importLog.addImportId(voyage1.getTopiaId());
-
- commitTransaction("ImportLogError!");
-
- importCommonAll2Id = importLog.getTopiaId();
- }
-
- protected void createCommonTransectImportV1() {
-
- Voyage voyage1 = getEntityById(Voyage.class, voyage1Id);
-
- // create transect
- Transect transect2 = create(transectDAO,
- TopiaEntity.TOPIA_ID, transect1_2Id,
- Transect.PROPERTY_TITLE, "transect2Title",
- Transect.PROPERTY_VESSEL, getFirstEntity(Vessel.class),
- Transect.PROPERTY_STRATUM, "transect2Stratum"
- );
- voyage1.getTransit().get(0).addTransect(transect2);
-
- commitTransaction("ImportError!");
-
- CommonImportConfiguration importConf =
- new CommonImportConfiguration(getLocale());
- importConf.setImportType(ImportType.COMMON_TRANSECT);
- importConf.setImportNotes("Common/Transect1");
- importConf.setVoyageId(voyage1Id);
-
- CommonAllImportService importService =
- getService(CommonAllImportService.class);
-
- ImportLog importLog = importService.computeImportLogEntry(
- importConf, createFakeUser());
-
- importLog.addImportId(transect2.getTopiaId());
-
- commitTransaction("ImportLogError!");
-
- importCommonTransect1Id = importLog.getTopiaId();
- }
-
- protected void createCommonTransectImportV2() {
-
- Voyage voyage1 = getEntityById(Voyage.class, voyage2Id);
-
- // create transect
- Transect transect2 = create(transectDAO,
- TopiaEntity.TOPIA_ID, transect2_2Id,
- Transect.PROPERTY_TITLE, "transect2Title",
- Transect.PROPERTY_VESSEL, getFirstEntity(Vessel.class),
- Transect.PROPERTY_STRATUM, "transect2Stratum"
- );
- voyage1.getTransit().get(0).addTransect(transect2);
-
- commitTransaction("ImportError!");
-
- CommonImportConfiguration importConf =
- new CommonImportConfiguration(getLocale());
- importConf.setImportType(ImportType.COMMON_TRANSECT);
- importConf.setImportNotes("Common/Transect2");
- importConf.setVoyageId(voyage2Id);
-
- CommonAllImportService importService =
- getService(CommonAllImportService.class);
-
- ImportLog importLog = importService.computeImportLogEntry(
- importConf, createFakeUser());
-
- importLog.addImportId(transect2.getTopiaId());
-
- commitTransaction("ImportLogError!");
-
- importCommonTransect2Id = importLog.getTopiaId();
- }
-
- protected void createOperationImport() {
-
- // create operation
- // create operationMetadata
- // create geartMetadata
- }
-
- protected void createCatchesImport() {
-
- // create totalSample
- // create subSample
- // create biometrySample
- }
-
- protected void createAcousticImport() {
-
- // create cell
- }
-
- protected void createResultVoyageImport() {
-
- // create echotype
- // create lengthAgeKey
- // create lengthWeightKey
- }
-
- protected void createResultEsduImport() {
-
- // create result (on ESDU)
- }
-
- protected void createResultRegionImport() {
-
- // create region
- // create result (on region)
- }
-
- protected void createResultMapImport() {
-
- // create map
- }
-}
Copied: trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/AbstractRemoveDataServiceTest.java (from rev 667, trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/AbstractRemoveDataServiceIT.java)
===================================================================
--- trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/AbstractRemoveDataServiceTest.java (rev 0)
+++ trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/AbstractRemoveDataServiceTest.java 2012-09-16 13:56:31 UTC (rev 669)
@@ -0,0 +1,772 @@
+package fr.ifremer.echobase.ui.actions.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.entities.EchoBaseUser;
+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.Cell;
+import fr.ifremer.echobase.entities.data.CellDAO;
+import fr.ifremer.echobase.entities.data.Data;
+import fr.ifremer.echobase.entities.data.DataAcquisition;
+import fr.ifremer.echobase.entities.data.DataAcquisitionDAO;
+import fr.ifremer.echobase.entities.data.DataDAO;
+import fr.ifremer.echobase.entities.data.DataProcessing;
+import fr.ifremer.echobase.entities.data.DataProcessingDAO;
+import fr.ifremer.echobase.entities.data.Echotype;
+import fr.ifremer.echobase.entities.data.EchotypeDAO;
+import fr.ifremer.echobase.entities.data.GearMetadataValue;
+import fr.ifremer.echobase.entities.data.GearMetadataValueDAO;
+import fr.ifremer.echobase.entities.data.LengthAgeKey;
+import fr.ifremer.echobase.entities.data.LengthAgeKeyDAO;
+import fr.ifremer.echobase.entities.data.LengthWeightKey;
+import fr.ifremer.echobase.entities.data.LengthWeightKeyDAO;
+import fr.ifremer.echobase.entities.data.Operation;
+import fr.ifremer.echobase.entities.data.OperationDAO;
+import fr.ifremer.echobase.entities.data.OperationMetadataValue;
+import fr.ifremer.echobase.entities.data.OperationMetadataValueDAO;
+import fr.ifremer.echobase.entities.data.Result;
+import fr.ifremer.echobase.entities.data.ResultDAO;
+import fr.ifremer.echobase.entities.data.Sample;
+import fr.ifremer.echobase.entities.data.SampleDAO;
+import fr.ifremer.echobase.entities.data.SampleData;
+import fr.ifremer.echobase.entities.data.SampleDataDAO;
+import fr.ifremer.echobase.entities.data.Transect;
+import fr.ifremer.echobase.entities.data.TransectDAO;
+import fr.ifremer.echobase.entities.data.Transit;
+import fr.ifremer.echobase.entities.data.TransitDAO;
+import fr.ifremer.echobase.entities.data.Voyage;
+import fr.ifremer.echobase.entities.data.VoyageDAO;
+import fr.ifremer.echobase.entities.references.AcousticInstrument;
+import fr.ifremer.echobase.entities.references.CellType;
+import fr.ifremer.echobase.entities.references.DataMetadata;
+import fr.ifremer.echobase.entities.references.Gear;
+import fr.ifremer.echobase.entities.references.GearMetadata;
+import fr.ifremer.echobase.entities.references.Mission;
+import fr.ifremer.echobase.entities.references.OperationMetadata;
+import fr.ifremer.echobase.entities.references.SampleDataType;
+import fr.ifremer.echobase.entities.references.SampleType;
+import fr.ifremer.echobase.entities.references.Species;
+import fr.ifremer.echobase.entities.references.SpeciesCategory;
+import fr.ifremer.echobase.entities.references.Strata;
+import fr.ifremer.echobase.entities.references.Vessel;
+import fr.ifremer.echobase.services.EchoBaseTestServiceSupport;
+import fr.ifremer.echobase.services.FakeEchoBaseServiceContext;
+import fr.ifremer.echobase.services.importdata.AbstractImportConfiguration;
+import fr.ifremer.echobase.services.importdata.AbstractImportDataService;
+import fr.ifremer.echobase.services.importdata.AcousticImportConfiguration;
+import fr.ifremer.echobase.services.importdata.AcousticImportService;
+import fr.ifremer.echobase.services.importdata.CatchesImportConfiguration;
+import fr.ifremer.echobase.services.importdata.CatchesImportService;
+import fr.ifremer.echobase.services.importdata.CommonAllImportService;
+import fr.ifremer.echobase.services.importdata.CommonImportConfiguration;
+import fr.ifremer.echobase.services.importdata.OperationImportConfiguration;
+import fr.ifremer.echobase.services.importdata.OperationImportService;
+import fr.ifremer.echobase.services.importdata.ResultsEsduCellImportService;
+import fr.ifremer.echobase.services.importdata.ResultsImportConfiguration;
+import fr.ifremer.echobase.services.importdata.ResultsMapCellImportService;
+import fr.ifremer.echobase.services.importdata.ResultsRegionCellImportService;
+import fr.ifremer.echobase.services.importdata.ResultsVoyageImportService;
+import fr.ifremer.echobase.services.removedata.RemoveDataConfiguration;
+import fr.ifremer.echobase.services.removedata.RemoveDataService;
+import junit.framework.Assert;
+import org.apache.commons.collections.CollectionUtils;
+import org.junit.Before;
+import org.nuiton.topia.TopiaException;
+import org.nuiton.topia.persistence.TopiaDAO;
+import org.nuiton.topia.persistence.TopiaEntity;
+import org.nuiton.topia.persistence.TopiaId;
+
+import java.util.List;
+
+/**
+ * Abstract test for remove data feature.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.2
+ */
+public abstract class AbstractRemoveDataServiceTest extends EchoBaseTestServiceSupport {
+
+ protected String importCommonAll1Id;
+
+ protected String importCommonTransect1Id;
+
+ protected String importOperation1Id;
+
+ protected String importCatches1Id;
+
+ protected String importAcoustic1Id;
+
+ protected String importResultVoyage1Id;
+
+ protected String importResultEsdu1Id;
+
+ protected String importResultRegion1Id;
+
+ protected String importResultMap1Id;
+
+ protected static final String voyage1Id = "fr.ifremer.echobase.entities.data.Voyage#1#1";
+
+ protected static final String transit1Id = "fr.ifremer.echobase.entities.data.Transit#1#1";
+
+ protected static final String transect1Id = "fr.ifremer.echobase.entities.data.Transect#1#1";
+
+ protected static final String transect1_2Id = "fr.ifremer.echobase.entities.data.Transect#1#2";
+
+ protected static final String operation1Id = "fr.ifremer.echobase.entities.data.Operation#1#1";
+
+ protected static final String totalSample1Id = "fr.ifremer.echobase.entities.data.Sample#1#total1";
+
+ protected static final String subSample1Id = "fr.ifremer.echobase.entities.data.Sample#1#sub1";
+
+ protected static final String biometrySample1Id = "fr.ifremer.echobase.entities.data.Sample#1#biometry1";
+
+ protected static final String dataAcquisition1Id = "fr.ifremer.echobase.entities.data.DataAcquisition#1";
+
+ protected static final String cellEsdu1Id = "fr.ifremer.echobase.entities.data.Cell#1#esdu1";
+
+ protected static final String cellMap1Id = "fr.ifremer.echobase.entities.data.Cell#1#map1";
+
+ protected static final String cellRegion1Id = "fr.ifremer.echobase.entities.data.Cell#1#region1";
+
+ protected static final String cellElementary1Id = "fr.ifremer.echobase.entities.data.Cell#1#elementary1";
+
+ protected static final String cellElementary1_2Id = "fr.ifremer.echobase.entities.data.Cell#1#elementary2";
+
+ protected static final String cellEsdu1_2Id = "fr.ifremer.echobase.entities.data.Cell#1#esdu2";
+
+ protected static final String resultEsdu1Id = "fr.ifremer.echobase.entities.data.Result#1#esdu1";
+
+ protected static final String resultMap1Id = "fr.ifremer.echobase.entities.data.Result#1#map1";
+
+ protected static final String resultRegion1Id = "fr.ifremer.echobase.entities.data.Result#1#region1";
+
+ protected static final String resultEsdu1_2Id = "fr.ifremer.echobase.entities.data.Result#1#esdu2";
+
+ protected static final String echotype1Id = "fr.ifremer.echobase.entities.data.Echotype#1#1";
+
+ protected static final String lengthAgeKey1Id = "fr.ifremer.echobase.entities.data.LengthAgeKey#1#1";
+
+ protected static final String lengthWeightKey1Id = "fr.ifremer.echobase.entities.data.LengthWeightKey#1#1";
+
+ protected String importCommonAll2Id;
+
+ protected String importCommonTransect2Id;
+
+ protected static final String voyage2Id = "fr.ifremer.echobase.entities.data.Voyage#2#1";
+
+ protected static final String transit2Id = "fr.ifremer.echobase.entities.data.Transit#2#1";
+
+ protected static final String transect2Id = "fr.ifremer.echobase.entities.data.Transect#2#1";
+
+ protected static final String transect2_2Id = "fr.ifremer.echobase.entities.data.Transect#2#2";
+
+ protected VoyageDAO voyageDao;
+
+ protected TransectDAO transectDAO;
+
+ protected TransitDAO transitDAO;
+
+ protected DataAcquisitionDAO dataAcquisitionDAO;
+
+ protected DataProcessingDAO dataProcessingDAO;
+
+ protected CellDAO cellDAO;
+
+ protected DataDAO dataDAO;
+
+ protected OperationDAO operationDAO;
+
+ protected OperationMetadataValueDAO operationMetadataValueDAO;
+
+ protected GearMetadataValueDAO gearMetadataValueDAO;
+
+ protected SampleDAO sampleDAO;
+
+ protected SampleDataDAO sampleDataDAO;
+
+ protected CategoryDAO categoryDAO;
+
+ protected EchotypeDAO echotypeDAO;
+
+ protected LengthAgeKeyDAO lengthAgeKeyDAO;
+
+ protected LengthWeightKeyDAO lengthWeightKeyDAO;
+
+ protected ResultDAO resultDAO;
+
+ @Override
+ protected FakeEchoBaseServiceContext initContext() {
+ return new FakeEchoBaseServiceContext(fixtures.IMPORT_DATA_ECHOBASE_NO_DATA());
+ }
+
+ @Override
+ @Before
+ public void setUp() throws Exception {
+ super.setUp();
+
+ voyageDao = getDAO(Voyage.class, VoyageDAO.class);
+ transectDAO = getDAO(Transect.class, TransectDAO.class);
+ transitDAO = getDAO(Transit.class, TransitDAO.class);
+ dataAcquisitionDAO = getDAO(DataAcquisition.class, DataAcquisitionDAO.class);
+ dataProcessingDAO = getDAO(DataProcessing.class, DataProcessingDAO.class);
+
+ cellDAO = getDAO(Cell.class, CellDAO.class);
+ dataDAO = getDAO(Data.class, DataDAO.class);
+ operationDAO = getDAO(Operation.class, OperationDAO.class);
+ operationMetadataValueDAO = getDAO(OperationMetadataValue.class, OperationMetadataValueDAO.class);
+ gearMetadataValueDAO = getDAO(GearMetadataValue.class, GearMetadataValueDAO.class);
+ sampleDAO = getDAO(Sample.class, SampleDAO.class);
+ sampleDataDAO = getDAO(SampleData.class, SampleDataDAO.class);
+
+ echotypeDAO = getDAO(Echotype.class, EchotypeDAO.class);
+ lengthAgeKeyDAO = getDAO(LengthAgeKey.class, LengthAgeKeyDAO.class);
+ lengthWeightKeyDAO = getDAO(LengthWeightKey.class, LengthWeightKeyDAO.class);
+ categoryDAO = getDAO(Category.class, CategoryDAO.class);
+ resultDAO = getDAO(Result.class, ResultDAO.class);
+
+ //create imports for voyage 1
+ createCommonAllImportV1();
+ createCommonTransectImportV1();
+ createOperationImportV1();
+ createCatchesImportV1();
+ createAcousticImportV1();
+ createResultVoyageImportV1();
+ createResultEsduImportV1();
+ createResultRegionImportV1();
+ createResultMapImportV1();
+
+ // create imports for voyage 2
+ createCommonAllImportV2();
+ createCommonTransectImportV2();
+// createOperationImportV2();
+// createCatchesImportV2();
+// createAcousticImportV2();
+// createResultVoyageImportV2();
+// createResultEsduImportV2();
+// createResultRegionImportV2();
+// createResultMapImportv2();
+ }
+
+ protected void removeImport(String importId) {
+ RemoveDataConfiguration conf = new RemoveDataConfiguration();
+ conf.setImportLogId(importId);
+
+ RemoveDataService service = getService(RemoveDataService.class);
+
+ EchoBaseUser fakeUser = createFakeUser();
+
+ service.removeImport(conf, fakeUser);
+ }
+
+
+ protected <E extends TopiaEntity> void assertEntityDeleted(String... entityIds) throws TopiaException {
+ for (String entityId : entityIds) {
+ if (entityId == null) continue;
+ E entity = getEntity(entityId);
+ Assert.assertNull("Entity with id " + entityId + " should have been deleted, but is still in db :(", entity);
+ }
+ }
+
+ protected <E extends TopiaEntity> void assertEntityExists(String... entityIds) throws TopiaException {
+ for (String entityId : entityIds) {
+ if (entityId == null) continue;
+ E entity = getEntity(entityId);
+ Assert.assertNotNull("Entity with id " + entityId + " should have not been deleted, but is deleted in db :(", entity);
+ }
+ }
+
+ private <E extends TopiaEntity> E getFirstEntity(Class<E> entityType) {
+ List<E> entities = getEntities(entityType);
+ Assert.assertTrue(CollectionUtils.isNotEmpty(entities));
+ return entities.get(0);
+ }
+
+ private <E extends TopiaEntity> E getEntity(String id) throws TopiaException {
+ Class entityType = TopiaId.getClassName(id);
+ TopiaDAO<E> dao = getDAO(entityType);
+ E entity = dao.findByTopiaId(id);
+ return entity;
+ }
+
+ private void createCommonAllImportV1() {
+
+ // create voyage
+ Voyage voyage = create(voyageDao,
+ TopiaEntity.TOPIA_ID, voyage1Id,
+ Voyage.PROPERTY_MISSION, getFirstEntity(Mission.class),
+ Voyage.PROPERTY_NAME, "voyage1",
+ Voyage.PROPERTY_START_DATE, newDate(),
+ Voyage.PROPERTY_END_DATE, newDate(),
+ Voyage.PROPERTY_START_PORT, "voyage1StartPort",
+ Voyage.PROPERTY_END_PORT, "voyage1EndPort",
+ Voyage.PROPERTY_DESCRIPTION, "voyage1Description",
+ Voyage.PROPERTY_DATUM, "voyage1Datum"
+ );
+
+ // create transit
+ Transit transit = create(transitDAO,
+ TopiaEntity.TOPIA_ID, transit1Id,
+ Transit.PROPERTY_START_TIME, newDate(),
+ Transit.PROPERTY_END_TIME, newDate(),
+ Transit.PROPERTY_START_LOCALITY, "transit1tartLocality",
+ Transit.PROPERTY_END_LOCALITY, "transit1EndLocality",
+ Transit.PROPERTY_DESCRIPTION, "transit1Description",
+ Transit.PROPERTY_RELATED_ACTIVITY, "transit1RelatedActivity"
+ );
+ voyage.addTransit(transit);
+
+ // create transect
+ Transect transect = create(transectDAO,
+ TopiaEntity.TOPIA_ID, transect1Id,
+ Transect.PROPERTY_TITLE, "transect1Title",
+ Transect.PROPERTY_VESSEL, getFirstEntity(Vessel.class),
+ Transect.PROPERTY_STRATUM, "transect1Stratum"
+ );
+ transit.addTransect(transect);
+
+ commitTransaction("ImportError!");
+
+ importCommonAll1Id = createImport(
+ CommonAllImportService.class,
+ new CommonImportConfiguration(getLocale()),
+ ImportType.COMMON_ALL,
+ "Common/Voyage/Transit/Transect1",
+ voyage1Id,
+ voyage);
+ }
+
+ private void createCommonAllImportV2() {
+
+ // create voyage
+ Voyage voyage = create(voyageDao,
+ TopiaEntity.TOPIA_ID, voyage2Id,
+ Voyage.PROPERTY_MISSION, getFirstEntity(Mission.class),
+ Voyage.PROPERTY_NAME, "voyage1",
+ Voyage.PROPERTY_START_DATE, newDate(),
+ Voyage.PROPERTY_END_DATE, newDate(),
+ Voyage.PROPERTY_START_PORT, "voyage1StartPort",
+ Voyage.PROPERTY_END_PORT, "voyage1EndPort",
+ Voyage.PROPERTY_DESCRIPTION, "voyage1Description",
+ Voyage.PROPERTY_DATUM, "voyage1Datum"
+ );
+
+ // create transit
+ Transit transit = create(transitDAO,
+ TopiaEntity.TOPIA_ID, transit2Id,
+ Transit.PROPERTY_START_TIME, newDate(),
+ Transit.PROPERTY_END_TIME, newDate(),
+ Transit.PROPERTY_START_LOCALITY, "transit1tartLocality",
+ Transit.PROPERTY_END_LOCALITY, "transit1EndLocality",
+ Transit.PROPERTY_DESCRIPTION, "transit1Description",
+ Transit.PROPERTY_RELATED_ACTIVITY, "transit1RelatedActivity"
+ );
+ voyage.addTransit(transit);
+
+ // create transect
+ Transect transect = create(transectDAO,
+ TopiaEntity.TOPIA_ID, transect2Id,
+ Transect.PROPERTY_TITLE, "transect1Title",
+ Transect.PROPERTY_VESSEL, getFirstEntity(Vessel.class),
+ Transect.PROPERTY_STRATUM, "transect1Stratum"
+ );
+ transit.addTransect(transect);
+
+ commitTransaction("ImportError!");
+
+ importCommonAll2Id = createImport(
+ CommonAllImportService.class,
+ new CommonImportConfiguration(getLocale()),
+ ImportType.COMMON_ALL,
+ "Common/Voyage/Transit/Transect2",
+ voyage2Id,
+ voyage);
+ }
+
+ private void createCommonTransectImportV1() throws TopiaException {
+
+ Voyage voyage = getEntity(voyage1Id);
+
+ // create transect
+ Transect transect = create(transectDAO,
+ TopiaEntity.TOPIA_ID, transect1_2Id,
+ Transect.PROPERTY_TITLE, "transect2Title",
+ Transect.PROPERTY_VESSEL, getFirstEntity(Vessel.class),
+ Transect.PROPERTY_STRATUM, "transect2Stratum"
+ );
+ voyage.getTransit().get(0).addTransect(transect);
+
+ commitTransaction("ImportError!");
+
+ importCommonTransect1Id = createImport(
+ CommonAllImportService.class,
+ new CommonImportConfiguration(getLocale()),
+ ImportType.COMMON_TRANSECT,
+ "Common/Transect1",
+ voyage1Id,
+ transect);
+ }
+
+ private void createCommonTransectImportV2() throws TopiaException {
+
+ Voyage voyage = getEntity(voyage2Id);
+
+ // create transect
+ Transect transect = create(transectDAO,
+ TopiaEntity.TOPIA_ID, transect2_2Id,
+ Transect.PROPERTY_TITLE, "transect2Title",
+ Transect.PROPERTY_VESSEL, getFirstEntity(Vessel.class),
+ Transect.PROPERTY_STRATUM, "transect2Stratum"
+ );
+ voyage.getTransit().get(0).addTransect(transect);
+
+ commitTransaction("ImportError!");
+
+ importCommonTransect2Id = createImport(
+ CommonAllImportService.class,
+ new CommonImportConfiguration(getLocale()),
+ ImportType.COMMON_TRANSECT,
+ "Common/Transect2",
+ voyage2Id,
+ transect);
+ }
+
+ private void createOperationImportV1() throws TopiaException {
+
+ Transect transect = getEntity(transect1Id);
+
+ // create operation
+ Operation operation = create(operationDAO,
+ TopiaEntity.TOPIA_ID, operation1Id,
+ Operation.PROPERTY_ID, "operationId",
+ Operation.PROPERTY_GEAR, getFirstEntity(Gear.class)
+ );
+
+ transect.addOperation(operation);
+
+ // create operationMetadata
+ OperationMetadataValue operationMetadataValue = create(
+ operationMetadataValueDAO,
+ OperationMetadataValue.PROPERTY_OPERATION_METADATA, getFirstEntity(OperationMetadata.class),
+ OperationMetadataValue.PROPERTY_DATA_VALUE, "dataValue"
+ );
+
+ operation.addOperationMetadataValue(operationMetadataValue);
+
+ // create geartMetadata
+ GearMetadataValue gearMetadataValue = create(
+ gearMetadataValueDAO,
+ GearMetadataValue.PROPERTY_GEAR, operation.getGear(),
+ GearMetadataValue.PROPERTY_GEAR_METADATA, getFirstEntity(GearMetadata.class),
+ GearMetadataValue.PROPERTY_DATA_VALUE, "gearDataValue"
+ );
+
+ operation.addGearMetadataValue(gearMetadataValue);
+
+ importOperation1Id = createImport(
+ OperationImportService.class,
+ new OperationImportConfiguration(getLocale()),
+ ImportType.OPERATION,
+ "Operation1",
+ voyage1Id,
+ operation);
+
+ }
+
+ private void createCatchesImportV1() throws TopiaException {
+
+ Operation operation = getEntity(operation1Id);
+
+ // create totalSample
+ Sample totalSample = create(sampleDAO,
+ TopiaEntity.TOPIA_ID, totalSample1Id,
+ Sample.PROPERTY_SAMPLE_TYPE, getFirstEntity(SampleType.class),
+ Sample.PROPERTY_SPECIES_CATEGORY, getFirstEntity(SpeciesCategory.class),
+ Sample.PROPERTY_NUMBER_SAMPLED, 10,
+ Sample.PROPERTY_SAMPLE_WEIGHT, 2.4f
+ );
+ operation.addSample(totalSample);
+
+ // add a data
+ SampleData totalSampleData = create(sampleDataDAO,
+ SampleData.PROPERTY_DATA_VALUE, 24.5f,
+ SampleData.PROPERTY_SAMPLE_DATA_TYPE, getFirstEntity(SampleDataType.class)
+ );
+ totalSample.addSampleData(totalSampleData);
+
+ // create subSample
+ Sample subSample = create(sampleDAO,
+ TopiaEntity.TOPIA_ID, subSample1Id,
+ Sample.PROPERTY_SAMPLE_TYPE, getFirstEntity(SampleType.class),
+ Sample.PROPERTY_SPECIES_CATEGORY, getFirstEntity(SpeciesCategory.class),
+ Sample.PROPERTY_NUMBER_SAMPLED, 10,
+ Sample.PROPERTY_SAMPLE_WEIGHT, 2.5f
+ );
+ operation.addSample(subSample);
+ // add a data
+ SampleData subSampleData = create(sampleDataDAO,
+ SampleData.PROPERTY_DATA_VALUE, 25.4f,
+ SampleData.PROPERTY_SAMPLE_DATA_TYPE, getFirstEntity(SampleDataType.class)
+ );
+ subSample.addSampleData(subSampleData);
+
+ // create biometrySample
+ Sample biometrySample = create(sampleDAO,
+ TopiaEntity.TOPIA_ID, biometrySample1Id,
+ Sample.PROPERTY_SAMPLE_TYPE, getFirstEntity(SampleType.class),
+ Sample.PROPERTY_SPECIES_CATEGORY, getFirstEntity(SpeciesCategory.class),
+ Sample.PROPERTY_NUMBER_SAMPLED, 10,
+ Sample.PROPERTY_SAMPLE_WEIGHT, 2.6f
+ );
+ operation.addSample(biometrySample);
+
+ // add a data
+ SampleData biometrySampleData = create(sampleDataDAO,
+ SampleData.PROPERTY_DATA_VALUE, 26.4f,
+ SampleData.PROPERTY_SAMPLE_DATA_TYPE, getFirstEntity(SampleDataType.class)
+ );
+ biometrySample.addSampleData(biometrySampleData);
+
+ importCatches1Id = createImport(
+ CatchesImportService.class,
+ new CatchesImportConfiguration(getLocale()),
+ ImportType.CATCHES,
+ "Catches1",
+ voyage1Id,
+ totalSample, subSample, biometrySample);
+ }
+
+ private void createAcousticImportV1() throws TopiaException {
+
+ Transect transect = getEntity(transect1Id);
+
+ // create data acquisition
+ DataAcquisition dataAcquisition = create(dataAcquisitionDAO,
+ TopiaEntity.TOPIA_ID, dataAcquisition1Id,
+ DataAcquisition.PROPERTY_ACOUSTIC_INSTRUMENT, getFirstEntity(AcousticInstrument.class));
+ transect.addDataAcquisition(dataAcquisition);
+
+ // create dataProcessing
+ DataProcessing dataProcessing = create(dataProcessingDAO,
+ DataProcessing.PROPERTY_ID, "id1",
+ DataProcessing.PROPERTY_PROCESSING_TEMPLATE, "processingTemplate");
+ dataAcquisition.addDataProcessing(dataProcessing);
+
+ // create esdu cell
+ Cell esduCell = create(cellDAO,
+ TopiaEntity.TOPIA_ID, cellEsdu1Id,
+ Cell.PROPERTY_CELL_TYPE, getFirstEntity(CellType.class),
+ Cell.PROPERTY_NAME, "cellEsdu1");
+ dataProcessing.addCell(esduCell);
+
+ // create cell data
+ Data esduData = create(dataDAO,
+ Data.PROPERTY_DATA_METADATA, getFirstEntity(DataMetadata.class),
+ Data.PROPERTY_DATA_VALUE, "esdu1Data");
+ esduCell.addData(esduData);
+
+ // create elementary cell
+ Cell elementaryCell = create(cellDAO,
+ TopiaEntity.TOPIA_ID, cellElementary1Id,
+ Cell.PROPERTY_CELL_TYPE, getFirstEntity(CellType.class),
+ Cell.PROPERTY_NAME, "cellElementary1");
+ esduCell.addChilds(elementaryCell);
+
+ // create cell data
+ Data elementaryData = create(dataDAO,
+ Data.PROPERTY_DATA_METADATA, getFirstEntity(DataMetadata.class),
+ Data.PROPERTY_DATA_VALUE, "elementary1Data");
+ elementaryCell.addData(elementaryData);
+
+ importAcoustic1Id = createImport(
+ AcousticImportService.class,
+ new AcousticImportConfiguration(getLocale()),
+ ImportType.ACOUSTIC,
+ "Acoustic1",
+ voyage1Id,
+ dataAcquisition);
+ }
+
+ private void createResultVoyageImportV1() throws TopiaException {
+
+ Voyage voyage = getEntity(voyage1Id);
+
+ // create echotype
+ Echotype echotype = create(echotypeDAO,
+ TopiaEntity.TOPIA_ID, echotype1Id,
+ Echotype.PROPERTY_NAME, "echotype1Name");
+ voyage.addEchotype(echotype);
+
+ // create lengthAgeKey
+ LengthAgeKey lengthAgeKey = create(lengthAgeKeyDAO,
+ TopiaEntity.TOPIA_ID, lengthAgeKey1Id,
+ LengthAgeKey.PROPERTY_AGE, 12,
+ LengthAgeKey.PROPERTY_LENGTH, 12.5f,
+ LengthAgeKey.PROPERTY_METADATA, "lengthAgeKeyMetadata1",
+ LengthAgeKey.PROPERTY_SPECIES, getFirstEntity(Species.class),
+ LengthAgeKey.PROPERTY_STRATA, getFirstEntity(Strata.class)
+ );
+ voyage.addLengthAgeKey(lengthAgeKey);
+
+ // create lengthWeightKey
+
+ LengthWeightKey lengthWeightKey = create(lengthWeightKeyDAO,
+ TopiaEntity.TOPIA_ID, lengthWeightKey1Id,
+ LengthWeightKey.PROPERTY_APARAMETER, 12.5f,
+ LengthWeightKey.PROPERTY_BPARAMETER, 0.2f,
+ LengthWeightKey.PROPERTY_METADATA, "lengthWeightMetadata1",
+ LengthWeightKey.PROPERTY_SPECIES_CATEGORY, getFirstEntity(SpeciesCategory.class),
+ LengthWeightKey.PROPERTY_STRATA, getFirstEntity(Strata.class)
+ );
+ voyage.addLengthWeightKey(lengthWeightKey);
+
+ importResultVoyage1Id = createImport(
+ ResultsVoyageImportService.class,
+ new ResultsImportConfiguration(getLocale()),
+ ImportType.RESULT_VOYAGE,
+ "ResultsVoyage1",
+ voyage1Id,
+ echotype, lengthAgeKey, lengthWeightKey);
+ }
+
+ private void createResultEsduImportV1() throws TopiaException {
+
+ // create result (on ESDU)
+
+ Category category = create(categoryDAO);
+
+ Result result = create(resultDAO,
+ TopiaEntity.TOPIA_ID, resultEsdu1Id,
+ Result.PROPERTY_CATEGORY, category,
+ Result.PROPERTY_DATA_METADATA, getFirstEntity(DataMetadata.class),
+ Result.PROPERTY_RESULT_VALUE, "resultValueEdsu1",
+ Result.PROPERTY_RESULT_LABEL, "resultLabelEdsu1"
+ );
+
+ Cell cell = getEntity(cellEsdu1Id);
+ cell.addResult(result);
+
+ importResultEsdu1Id = createImport(
+ ResultsEsduCellImportService.class,
+ new ResultsImportConfiguration(getLocale()),
+ ImportType.RESULT_ESDU,
+ "ResultsEsdu1",
+ voyage1Id,
+ result);
+ }
+
+ private void createResultRegionImportV1() throws TopiaException {
+
+ // create region
+ Cell region = create(cellDAO,
+ TopiaEntity.TOPIA_ID, cellRegion1Id,
+ Cell.PROPERTY_CELL_TYPE, getFirstEntity(CellType.class),
+ Cell.PROPERTY_NAME, "cellRegion1");
+
+ Voyage voyage = getEntity(voyage1Id);
+ voyage.addPostCell(region);
+
+ // add esdu cell on it
+ Cell esduCell = getEntity(cellEsdu1Id);
+ region.addChilds(esduCell);
+
+ // create result (on region)
+ Category category = create(categoryDAO);
+ Result result = create(resultDAO,
+ TopiaEntity.TOPIA_ID, resultRegion1Id,
+ Result.PROPERTY_CATEGORY, category,
+ Result.PROPERTY_DATA_METADATA, getFirstEntity(DataMetadata.class),
+ Result.PROPERTY_RESULT_VALUE, "resultValueRegion1",
+ Result.PROPERTY_RESULT_LABEL, "resultLabelRegion1"
+ );
+ region.addResult(result);
+
+ importResultRegion1Id = createImport(
+ ResultsRegionCellImportService.class,
+ new ResultsImportConfiguration(getLocale()),
+ ImportType.RESULT_REGION,
+ "ResultsRegion1",
+ voyage1Id,
+ region);
+ }
+
+ private void createResultMapImportV1() throws TopiaException {
+
+ // create map
+ Cell map = create(cellDAO,
+ TopiaEntity.TOPIA_ID, cellMap1Id,
+ Cell.PROPERTY_CELL_TYPE, getFirstEntity(CellType.class),
+ Cell.PROPERTY_NAME, "cellMap1");
+
+ Voyage voyage = getEntity(voyage1Id);
+ voyage.addPostCell(map);
+
+ // create result (on map)
+ Category category = create(categoryDAO);
+ Result result = create(resultDAO,
+ TopiaEntity.TOPIA_ID, resultMap1Id,
+ Result.PROPERTY_CATEGORY, category,
+ Result.PROPERTY_DATA_METADATA, getFirstEntity(DataMetadata.class),
+ Result.PROPERTY_RESULT_VALUE, "resultValueMap1",
+ Result.PROPERTY_RESULT_LABEL, "resultLabelMap1"
+ );
+ map.addResult(result);
+
+ importResultMap1Id = createImport(
+ ResultsMapCellImportService.class,
+ new ResultsImportConfiguration(getLocale()),
+ ImportType.RESULT_MAP,
+ "ResultsMap1",
+ voyage1Id,
+ map);
+ }
+
+ private <C extends AbstractImportConfiguration, S extends AbstractImportDataService<C>> String createImport(
+ Class<S> serviceType,
+ C importConf,
+ ImportType importType,
+ String importNote,
+ String voyageId,
+ TopiaEntity... importIds) {
+ importConf.setImportType(importType);
+ importConf.setImportNotes(importNote);
+ importConf.setVoyageId(voyageId);
+
+ S importService = getService(serviceType);
+
+ ImportLog importLog = importService.computeImportLogEntry(
+ importConf, createFakeUser());
+
+ for (TopiaEntity importId : importIds) {
+ importLog.addImportId(importId.getTopiaId());
+ }
+
+ commitTransaction("ImportLogError!");
+
+ String importId = importLog.getTopiaId();
+ return importId;
+ }
+}
Property changes on: trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/AbstractRemoveDataServiceTest.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/AcousticRemoveDataServiceTest.java
===================================================================
--- trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/AcousticRemoveDataServiceTest.java (rev 0)
+++ trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/AcousticRemoveDataServiceTest.java 2012-09-16 13:56:31 UTC (rev 669)
@@ -0,0 +1,66 @@
+package fr.ifremer.echobase.ui.actions.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.removedata.RemoveDataService;
+import fr.ifremer.echobase.services.removedata.strategy.AcousticRemoveDataStrategy;
+import org.junit.Test;
+import org.nuiton.topia.TopiaException;
+
+/**
+ * Test{@link RemoveDataService} with {@link AcousticRemoveDataStrategy}.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.3
+ */
+public class AcousticRemoveDataServiceTest extends AbstractRemoveDataServiceTest {
+
+ @Test
+ public void removeImport() throws TopiaException {
+
+ removeImport(importAcoustic1Id);
+
+ // dataAquisition 1 is deleted
+ assertEntityDeleted(dataAcquisition1Id, cellEsdu1Id, cellElementary1Id,
+ cellRegion1Id, cellMap1Id,
+ resultEsdu1Id, resultRegion1Id, resultMap1Id);
+
+ // and all his imports
+ assertEntityDeleted(importAcoustic1Id,
+ importResultVoyage1Id,
+ importResultEsdu1Id,
+ importResultRegion1Id,
+ importResultMap1Id);
+
+ // voyage 1 other imports stay
+ assertEntityExists(voyage1Id, transect1Id, operation1Id,
+ totalSample1Id, subSample1Id, biometrySample1Id);
+
+ // and all his imports
+ assertEntityExists(importCommonAll1Id,
+ importCommonTransect1Id,
+ importOperation1Id,
+ importCatches1Id);
+ }
+}
Property changes on: trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/AcousticRemoveDataServiceTest.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/CatchesRemoveDataServiceTest.java
===================================================================
--- trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/CatchesRemoveDataServiceTest.java (rev 0)
+++ trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/CatchesRemoveDataServiceTest.java 2012-09-16 13:56:31 UTC (rev 669)
@@ -0,0 +1,64 @@
+package fr.ifremer.echobase.ui.actions.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.removedata.RemoveDataService;
+import fr.ifremer.echobase.services.removedata.strategy.CatchesRemoveDataStrategy;
+import org.junit.Test;
+import org.nuiton.topia.TopiaException;
+
+/**
+ * Test{@link RemoveDataService} with {@link CatchesRemoveDataStrategy}.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.3
+ */
+public class CatchesRemoveDataServiceTest extends AbstractRemoveDataServiceTest {
+
+ @Test
+ public void removeImport() throws TopiaException {
+
+ removeImport(importCatches1Id);
+
+ // sample1 are deleted
+ assertEntityDeleted(totalSample1Id, subSample1Id, biometrySample1Id);
+
+ // and all his imports
+ assertEntityDeleted(importCatches1Id);
+
+ // voyage 1 other imports stay
+ assertEntityExists(voyage1Id, transect1Id, operation1Id,
+ cellEsdu1Id, cellElementary1Id);
+
+ // and all his imports
+ assertEntityExists(importCommonAll1Id,
+ importCommonTransect1Id,
+ importOperation1Id,
+ importAcoustic1Id,
+ importResultVoyage1Id,
+ importResultEsdu1Id,
+ importResultRegion1Id,
+ importResultMap1Id);
+ }
+}
Property changes on: trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/CatchesRemoveDataServiceTest.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Deleted: trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/CommonAllRemoveDataServiceIT.java
===================================================================
--- trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/CommonAllRemoveDataServiceIT.java 2012-09-16 09:39:45 UTC (rev 668)
+++ trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/CommonAllRemoveDataServiceIT.java 2012-09-16 13:56:31 UTC (rev 669)
@@ -1,100 +0,0 @@
-package fr.ifremer.echobase.ui.actions.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.entities.ImportLog;
-import fr.ifremer.echobase.entities.data.Transect;
-import fr.ifremer.echobase.entities.data.Voyage;
-import fr.ifremer.echobase.services.removedata.RemoveDataService;
-import fr.ifremer.echobase.services.removedata.strategy.CommonAllRemoveDataStrategy;
-import org.junit.Test;
-import org.nuiton.topia.TopiaException;
-
-/**
- * Test{@link RemoveDataService} with {@link CommonAllRemoveDataStrategy}.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.3
- */
-public class CommonAllRemoveDataServiceIT extends AbstractRemoveDataServiceIT {
-
- @Test
- public void removeImport1() throws TopiaException {
-
- createCommonAllImportV1();
- createCommonTransectImportV1();
-
- createCommonAllImportV2();
- createCommonTransectImportV2();
-
- removeImport(importCommonAll1Id);
-
- // voyage 1 is deleted
- assertEntityDeleted(Voyage.class, voyage1Id);
-
- // and all his imports
- assertEntityDeleted(ImportLog.class,
- importCommonAll1Id,
- importCommonTransect1Id);
-
- // voyage 2 still in db
- assertEntityExists(Voyage.class, voyage2Id);
- assertEntityExists(Transect.class, transect2Id);
-
- // and all his imports
- assertEntityExists(ImportLog.class,
- importCommonAll2Id,
- importCommonTransect2Id);
-
- }
-
- @Test
- public void removeImport2() throws TopiaException {
-
- createCommonAllImportV1();
- createCommonTransectImportV1();
-
- createCommonAllImportV2();
- createCommonTransectImportV2();
-
- removeImport(importCommonAll2Id);
-
- // voyage 2 is deleted
- assertEntityDeleted(Voyage.class, voyage2Id);
-
- // and all his imports
- assertEntityDeleted(ImportLog.class,
- importCommonAll2Id,
- importCommonTransect2Id);
-
- // voyage 1 still in db
- assertEntityExists(Voyage.class, voyage1Id);
- assertEntityExists(Transect.class, transect1Id);
-
- // and all his imports
- assertEntityExists(ImportLog.class,
- importCommonAll1Id,
- importCommonTransect1Id);
- }
-}
Copied: trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/CommonAllRemoveDataServiceTest.java (from rev 667, trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/CommonAllRemoveDataServiceIT.java)
===================================================================
--- trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/CommonAllRemoveDataServiceTest.java (rev 0)
+++ trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/CommonAllRemoveDataServiceTest.java 2012-09-16 13:56:31 UTC (rev 669)
@@ -0,0 +1,99 @@
+package fr.ifremer.echobase.ui.actions.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.removedata.RemoveDataService;
+import fr.ifremer.echobase.services.removedata.strategy.CommonAllRemoveDataStrategy;
+import org.junit.Test;
+import org.nuiton.topia.TopiaException;
+
+/**
+ * Test{@link RemoveDataService} with {@link CommonAllRemoveDataStrategy}.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.3
+ */
+public class CommonAllRemoveDataServiceTest extends AbstractRemoveDataServiceTest {
+
+ @Test
+ public void removeImport1() throws TopiaException {
+
+ removeImport(importCommonAll1Id);
+
+ // voyage 1 is deleted
+ assertEntityDeleted(voyage1Id, transect1Id, operation1Id,
+ totalSample1Id, subSample1Id, biometrySample1Id,
+ cellEsdu1Id, cellElementary1Id, resultEsdu1Id,
+ echotype1Id, lengthAgeKey1Id, lengthWeightKey1Id);
+
+ // and all his imports
+ assertEntityDeleted(importCommonAll1Id,
+ importCommonTransect1Id,
+ importOperation1Id,
+ importCatches1Id,
+ importAcoustic1Id,
+ importResultVoyage1Id,
+ importResultEsdu1Id,
+ importResultRegion1Id,
+ importResultMap1Id);
+
+ // voyage 2 still in db
+ assertEntityExists(voyage2Id, transect2Id);
+
+ // and all his imports
+ assertEntityExists(importCommonAll2Id,
+ importCommonTransect2Id);
+
+ }
+
+ @Test
+ public void removeImport2() throws TopiaException {
+
+ removeImport(importCommonAll2Id);
+
+ // voyage 2 is deleted
+ assertEntityDeleted(voyage2Id);
+
+ // and all his imports
+ assertEntityDeleted(importCommonAll2Id,
+ importCommonTransect2Id);
+
+ // voyage 1 still in db
+ assertEntityExists(voyage1Id, transect1Id, operation1Id,
+ totalSample1Id, subSample1Id, biometrySample1Id,
+ cellEsdu1Id, cellElementary1Id, resultEsdu1Id,
+ echotype1Id, lengthAgeKey1Id, lengthWeightKey1Id);
+
+ // and all his imports
+ assertEntityExists(importCommonAll1Id,
+ importCommonTransect1Id,
+ importOperation1Id,
+ importCatches1Id,
+ importAcoustic1Id,
+ importResultVoyage1Id,
+ importResultEsdu1Id,
+ importResultRegion1Id,
+ importResultMap1Id);
+ }
+}
Property changes on: trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/CommonAllRemoveDataServiceTest.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Deleted: trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/CommonTransectRemoveDataServiceIT.java
===================================================================
--- trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/CommonTransectRemoveDataServiceIT.java 2012-09-16 09:39:45 UTC (rev 668)
+++ trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/CommonTransectRemoveDataServiceIT.java 2012-09-16 13:56:31 UTC (rev 669)
@@ -1,117 +0,0 @@
-package fr.ifremer.echobase.ui.actions.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.entities.ImportLog;
-import fr.ifremer.echobase.entities.data.Transect;
-import fr.ifremer.echobase.entities.data.Voyage;
-import fr.ifremer.echobase.services.removedata.RemoveDataService;
-import fr.ifremer.echobase.services.removedata.strategy.CommonTransectRemoveDataStrategy;
-import org.junit.Test;
-import org.nuiton.topia.TopiaException;
-
-/**
- * Test{@link RemoveDataService} with {@link CommonTransectRemoveDataStrategy}.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.3
- */
-public class CommonTransectRemoveDataServiceIT extends AbstractRemoveDataServiceIT {
-
- @Test
- public void removeImport1() throws TopiaException {
-
- createCommonAllImportV1();
- createCommonTransectImportV1();
-
- createCommonAllImportV2();
- createCommonTransectImportV2();
-
- removeImport(importCommonTransect1Id);
-
- // transect 1 is deleted
- assertEntityDeleted(Transect.class, transect1_2Id);
-
- // and all his imports
- assertEntityDeleted(ImportLog.class,
- importCommonTransect1Id);
-
- // voyage 1 is still here
- assertEntityExists(Voyage.class, voyage1Id);
- assertEntityExists(Transect.class, transect1Id);
-
- // and all his imports
- assertEntityExists(ImportLog.class,
- importCommonAll1Id);
-
-
- // voyage 2 still in db
- assertEntityExists(Voyage.class, voyage2Id);
- assertEntityExists(Transect.class, transect2Id);
-
- // and all his imports
- assertEntityExists(ImportLog.class,
- importCommonAll2Id,
- importCommonTransect2Id);
- }
-
- @Test
- public void removeImport2() throws TopiaException {
-
-
- createCommonAllImportV1();
- createCommonTransectImportV1();
-
- createCommonAllImportV2();
- createCommonTransectImportV2();
-
- removeImport(importCommonTransect2Id);
-
- // transect 2 is deleted
- assertEntityDeleted(Transect.class, transect2_2Id);
-
- // and all his imports
- assertEntityDeleted(ImportLog.class,
- importCommonTransect2Id);
-
-
- // voyage 2 is still here
- assertEntityExists(Voyage.class, voyage2Id);
- assertEntityExists(Transect.class, transect2Id);
-
- // and all his imports
- assertEntityExists(ImportLog.class,
- importCommonAll2Id);
-
-
- // voyage 1 still in db
- assertEntityExists(Voyage.class, voyage1Id);
- assertEntityExists(Transect.class, transect1Id);
-
- // and all his imports
- assertEntityExists(ImportLog.class,
- importCommonAll1Id,
- importCommonTransect1Id);
- }
-}
Copied: trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/CommonTransectRemoveDataServiceTest.java (from rev 667, trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/CommonTransectRemoveDataServiceIT.java)
===================================================================
--- trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/CommonTransectRemoveDataServiceTest.java (rev 0)
+++ trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/CommonTransectRemoveDataServiceTest.java 2012-09-16 13:56:31 UTC (rev 669)
@@ -0,0 +1,110 @@
+package fr.ifremer.echobase.ui.actions.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.removedata.RemoveDataService;
+import fr.ifremer.echobase.services.removedata.strategy.CommonTransectRemoveDataStrategy;
+import org.junit.Test;
+import org.nuiton.topia.TopiaException;
+
+/**
+ * Test{@link RemoveDataService} with {@link CommonTransectRemoveDataStrategy}.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.3
+ */
+public class CommonTransectRemoveDataServiceTest extends AbstractRemoveDataServiceTest {
+
+ @Test
+ public void removeImport1() throws TopiaException {
+
+ removeImport(importCommonTransect1Id);
+
+ // transect 1 is deleted
+ assertEntityDeleted(transect1_2Id);
+
+ // and all his imports
+ assertEntityDeleted(importCommonTransect1Id);
+
+ // voyage 1 is still here
+ assertEntityExists(voyage1Id, transect1Id, operation1Id,
+ totalSample1Id, subSample1Id, biometrySample1Id,
+ cellEsdu1Id, cellElementary1Id, resultEsdu1Id);
+
+ // and all his imports (exception transect1 one)
+ assertEntityExists(importCommonAll1Id,
+ importOperation1Id,
+ importCatches1Id,
+ importAcoustic1Id,
+ importResultVoyage1Id,
+ importResultEsdu1Id,
+ importResultRegion1Id,
+ importResultMap1Id);
+
+
+ // voyage 2 still in db
+ assertEntityExists(voyage2Id, transect2Id);
+
+ // and all his imports
+ assertEntityExists(importCommonAll2Id,
+ importCommonTransect2Id);
+ }
+
+ @Test
+ public void removeImport2() throws TopiaException {
+
+ removeImport(importCommonTransect2Id);
+
+ // transect 2 is deleted
+ assertEntityDeleted(transect2_2Id);
+
+ // and all his imports
+ assertEntityDeleted(importCommonTransect2Id);
+
+
+ // voyage 2 is still here
+ assertEntityExists(voyage2Id, transect2Id);
+
+ // and all his imports
+ assertEntityExists(importCommonAll2Id);
+
+
+ // voyage 1 still in db
+ assertEntityExists(voyage1Id, transect1Id, operation1Id,
+ totalSample1Id, subSample1Id, biometrySample1Id,
+ cellEsdu1Id, cellElementary1Id, resultEsdu1Id,
+ echotype1Id, lengthAgeKey1Id,lengthWeightKey1Id);
+
+ // and all his imports
+ assertEntityExists(importCommonAll1Id,
+ importCommonTransect1Id,
+ importOperation1Id,
+ importCatches1Id,
+ importAcoustic1Id,
+ importResultVoyage1Id,
+ importResultEsdu1Id,
+ importResultRegion1Id,
+ importResultMap1Id);
+ }
+}
Property changes on: trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/CommonTransectRemoveDataServiceTest.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/OperationRemoveDataServiceTest.java
===================================================================
--- trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/OperationRemoveDataServiceTest.java (rev 0)
+++ trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/OperationRemoveDataServiceTest.java 2012-09-16 13:56:31 UTC (rev 669)
@@ -0,0 +1,64 @@
+package fr.ifremer.echobase.ui.actions.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.removedata.RemoveDataService;
+import fr.ifremer.echobase.services.removedata.strategy.OperationRemoveDataStrategy;
+import org.junit.Test;
+import org.nuiton.topia.TopiaException;
+
+/**
+ * Test{@link RemoveDataService} with {@link OperationRemoveDataStrategy}.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.3
+ */
+public class OperationRemoveDataServiceTest extends AbstractRemoveDataServiceTest {
+
+ @Test
+ public void removeImport() throws TopiaException {
+
+ removeImport(importOperation1Id);
+
+ // operation 1 is deleted
+ assertEntityDeleted(operation1Id);
+
+ // and all his imports
+ assertEntityDeleted(importOperation1Id);
+
+ // voyage 1 other imports stay
+ assertEntityExists(voyage1Id, transect1Id,
+ cellEsdu1Id, cellElementary1Id, resultEsdu1Id,
+ echotype1Id, lengthAgeKey1Id, lengthWeightKey1Id);
+
+ // and all his imports
+ assertEntityExists(importCommonAll1Id,
+ importCommonTransect1Id,
+ importAcoustic1Id,
+ importResultVoyage1Id,
+ importResultEsdu1Id,
+ importResultRegion1Id,
+ importResultMap1Id);
+ }
+}
Property changes on: trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/OperationRemoveDataServiceTest.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/ResultEsduRemoveDataServiceTest.java
===================================================================
--- trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/ResultEsduRemoveDataServiceTest.java (rev 0)
+++ trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/ResultEsduRemoveDataServiceTest.java 2012-09-16 13:56:31 UTC (rev 669)
@@ -0,0 +1,67 @@
+package fr.ifremer.echobase.ui.actions.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.removedata.RemoveDataService;
+import fr.ifremer.echobase.services.removedata.strategy.ResultEsduRemoveDataStrategy;
+import org.junit.Test;
+import org.nuiton.topia.TopiaException;
+
+/**
+ * Test{@link RemoveDataService} with {@link ResultEsduRemoveDataStrategy}.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.3
+ */
+public class ResultEsduRemoveDataServiceTest extends AbstractRemoveDataServiceTest {
+
+ @Test
+ public void removeImport() throws TopiaException {
+
+ removeImport(importResultEsdu1Id);
+
+ // esdu cell result are deleted
+ assertEntityDeleted(resultEsdu1Id);
+
+ // and all his imports
+ assertEntityDeleted(importResultEsdu1Id);
+
+ // voyage 1 other imports stay
+ assertEntityExists(voyage1Id, transect1Id, operation1Id,
+ totalSample1Id, subSample1Id, biometrySample1Id,
+ dataAcquisition1Id, cellEsdu1Id, cellElementary1Id,
+ echotype1Id, lengthAgeKey1Id, lengthWeightKey1Id);
+
+ // and all his imports
+ assertEntityExists(importCommonAll1Id,
+ importCommonTransect1Id,
+ importOperation1Id,
+ importCatches1Id,
+ importAcoustic1Id,
+ importResultVoyage1Id,
+ importResultRegion1Id,
+ importResultMap1Id);
+ }
+
+}
Property changes on: trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/ResultEsduRemoveDataServiceTest.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/ResultMapRemoveDataServiceTest.java
===================================================================
--- trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/ResultMapRemoveDataServiceTest.java (rev 0)
+++ trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/ResultMapRemoveDataServiceTest.java 2012-09-16 13:56:31 UTC (rev 669)
@@ -0,0 +1,45 @@
+package fr.ifremer.echobase.ui.actions.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.removedata.RemoveDataService;
+import fr.ifremer.echobase.services.removedata.strategy.ResultMapRemoveDataStrategy;
+import org.junit.Test;
+import org.nuiton.topia.TopiaException;
+
+/**
+ * Test{@link RemoveDataService} with {@link ResultMapRemoveDataStrategy}.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.3
+ */
+public class ResultMapRemoveDataServiceTest extends AbstractRemoveDataServiceTest {
+
+ @Test
+ public void removeImport() throws TopiaException {
+
+ removeImport(importResultMap1Id);
+
+ }
+}
Property changes on: trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/ResultMapRemoveDataServiceTest.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/ResultRegionRemoveDataServiceTest.java
===================================================================
--- trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/ResultRegionRemoveDataServiceTest.java (rev 0)
+++ trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/ResultRegionRemoveDataServiceTest.java 2012-09-16 13:56:31 UTC (rev 669)
@@ -0,0 +1,65 @@
+package fr.ifremer.echobase.ui.actions.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.removedata.RemoveDataService;
+import fr.ifremer.echobase.services.removedata.strategy.ResultRegionRemoveDataStrategy;
+import org.junit.Test;
+import org.nuiton.topia.TopiaException;
+
+/**
+ * Test{@link RemoveDataService} with {@link ResultRegionRemoveDataStrategy}.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.3
+ */
+public class ResultRegionRemoveDataServiceTest extends AbstractRemoveDataServiceTest {
+
+ @Test
+ public void removeImport() throws TopiaException {
+
+ removeImport(importResultRegion1Id);
+
+ // esdu cell result are deleted
+ assertEntityDeleted(cellRegion1Id, resultRegion1Id);
+
+ // and all his imports
+ assertEntityDeleted(importResultEsdu1Id);
+
+ // voyage 1 other imports stay
+ assertEntityExists(voyage1Id, transect1Id, operation1Id,
+ totalSample1Id, subSample1Id, biometrySample1Id,
+ dataAcquisition1Id, cellEsdu1Id, cellElementary1Id, resultEsdu1Id,
+ echotype1Id, lengthAgeKey1Id, lengthWeightKey1Id);
+
+ // and all his imports
+ assertEntityExists(importCommonAll1Id,
+ importCommonTransect1Id,
+ importOperation1Id,
+ importCatches1Id,
+ importAcoustic1Id,
+ importResultVoyage1Id,
+ importResultMap1Id);
+ }
+}
Property changes on: trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/ResultRegionRemoveDataServiceTest.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/ResultVoyageRemoveDataServiceTest.java
===================================================================
--- trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/ResultVoyageRemoveDataServiceTest.java (rev 0)
+++ trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/ResultVoyageRemoveDataServiceTest.java 2012-09-16 13:56:31 UTC (rev 669)
@@ -0,0 +1,67 @@
+package fr.ifremer.echobase.ui.actions.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.removedata.RemoveDataService;
+import fr.ifremer.echobase.services.removedata.strategy.ResultVoyageRemoveDataStrategy;
+import org.junit.Test;
+import org.nuiton.topia.TopiaException;
+
+/**
+ * Test{@link RemoveDataService} with {@link ResultVoyageRemoveDataStrategy}.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.3
+ */
+public class ResultVoyageRemoveDataServiceTest extends AbstractRemoveDataServiceTest {
+
+ @Test
+ public void removeImport() throws TopiaException {
+
+ removeImport(importResultVoyage1Id);
+
+ // voyage "results" are deleted
+ assertEntityDeleted(echotype1Id, lengthAgeKey1Id, lengthWeightKey1Id,
+ cellRegion1Id, cellMap1Id,
+ resultEsdu1Id, resultRegion1Id, resultMap1Id);
+
+ // and all his imports
+ assertEntityDeleted(importResultVoyage1Id,
+ importResultEsdu1Id,
+ importResultRegion1Id,
+ importResultMap1Id);
+
+ // voyage 1 other imports stay
+ assertEntityExists(voyage1Id, transect1Id, operation1Id,
+ totalSample1Id, subSample1Id, biometrySample1Id,
+ dataAcquisition1Id, cellEsdu1Id, cellElementary1Id);
+
+ // and all his imports
+ assertEntityExists(importCommonAll1Id,
+ importCommonTransect1Id,
+ importOperation1Id,
+ importCatches1Id,
+ importAcoustic1Id);
+ }
+}
Property changes on: trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/ResultVoyageRemoveDataServiceTest.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
1
0
16 Sep '12
Author: tchemit
Date: 2012-09-16 11:39:45 +0200 (Sun, 16 Sep 2012)
New Revision: 668
Url: http://forge.codelutin.com/repositories/revision/echobase/668
Log:
split natural id and not-null tag values
Modified:
trunk/echobase-domain/src/main/xmi/echobase.properties
Modified: trunk/echobase-domain/src/main/xmi/echobase.properties
===================================================================
--- trunk/echobase-domain/src/main/xmi/echobase.properties 2012-09-15 11:50:06 UTC (rev 667)
+++ trunk/echobase-domain/src/main/xmi/echobase.properties 2012-09-16 09:39:45 UTC (rev 668)
@@ -69,50 +69,35 @@
### Natural id for references ################################################
###############################################################################
-fr.ifremer.echobase.entities.EntityModificationLog.attribute.entityType.tagValue.notNull=true
-fr.ifremer.echobase.entities.EntityModificationLog.attribute.entityId.tagValue.notNull=true
-fr.ifremer.echobase.entities.EntityModificationLog.attribute.modificationText.tagValue.notNull=true
-fr.ifremer.echobase.entities.EntityModificationLog.attribute.modificationDate.tagValue.notNull=true
-fr.ifremer.echobase.entities.EntityModificationLog.attribute.modificationUser.tagValue.notNull=true
-
fr.ifremer.echobase.entities.references.AcousticInstrument.class.tagValue.naturalIdMutable=true
fr.ifremer.echobase.entities.references.AcousticInstrument.attribute.id.tagValue.naturalId=true
-fr.ifremer.echobase.entities.references.AcousticInstrument.attribute.id.tagValue.notNull=true
fr.ifremer.echobase.entities.references.AgeCategory.class.tagValue.naturalIdMutable=true
fr.ifremer.echobase.entities.references.AgeCategory.attribute.name.tagValue.naturalId=true
-fr.ifremer.echobase.entities.references.AgeCategory.attribute.name.tagValue.notNull=true
-fr.ifremer.echobase.entities.references.AgeCategory.attribute.meaning.tagValue.notNull=true
fr.ifremer.echobase.entities.references.AreaOfOperation.class.tagValue.naturalIdMutable=true
fr.ifremer.echobase.entities.references.AreaOfOperation.attribute.name.tagValue.naturalId=true
-fr.ifremer.echobase.entities.references.AreaOfOperation.attribute.name.tagValue.notNull=true
#fr.ifremer.echobase.entities.references.Calibration.class.tagValue.naturalIdMutable=true
#fr.ifremer.echobase.entities.references.Calibration.attribute.code.tagValue.naturalId=true
fr.ifremer.echobase.entities.references.CategoryMeaning.class.tagValue.naturalIdMutable=true
fr.ifremer.echobase.entities.references.CategoryMeaning.attribute.name.tagValue.naturalId=true
-fr.ifremer.echobase.entities.references.CategoryMeaning.attribute.name.tagValue.notNull=true
#fr.ifremer.echobase.entities.references.CategoryRef.class.tagValue.naturalIdMutable=true
#fr.ifremer.echobase.entities.references.CategoryRef.attribute.code.tagValue.naturalId=true
fr.ifremer.echobase.entities.references.CategoryType.class.tagValue.naturalIdMutable=true
fr.ifremer.echobase.entities.references.CategoryType.attribute.name.tagValue.naturalId=true
-fr.ifremer.echobase.entities.references.CategoryType.attribute.name.tagValue.notNull=true
fr.ifremer.echobase.entities.references.CellMethod.class.tagValue.naturalIdMutable=true
fr.ifremer.echobase.entities.references.CellMethod.attribute.name.tagValue.naturalId=true
-fr.ifremer.echobase.entities.references.CellMethod.attribute.name.tagValue.notNull=true
fr.ifremer.echobase.entities.references.CellType.class.tagValue.naturalIdMutable=true
fr.ifremer.echobase.entities.references.CellType.attribute.id.tagValue.naturalId=true
-fr.ifremer.echobase.entities.references.CellType.attribute.id.tagValue.notNull=true
fr.ifremer.echobase.entities.references.DataMetadata.class.tagValue.naturalIdMutable=true
fr.ifremer.echobase.entities.references.DataMetadata.attribute.name.tagValue.naturalId=true
-fr.ifremer.echobase.entities.references.DataMetadata.attribute.name.tagValue.notNull=true
#fr.ifremer.echobase.entities.references.DataProtocol.class.tagValue.naturalIdMutable=true
#fr.ifremer.echobase.entities.references.DataProtocol.attribute.code.tagValue.naturalId=true
@@ -122,111 +107,161 @@
fr.ifremer.echobase.entities.references.DataType.class.tagValue.naturalIdMutable=true
fr.ifremer.echobase.entities.references.DataType.attribute.name.tagValue.naturalId=true
-fr.ifremer.echobase.entities.references.DataType.attribute.name.tagValue.notNull=true
fr.ifremer.echobase.entities.references.DepthStratum.class.tagValue.naturalIdMutable=true
fr.ifremer.echobase.entities.references.DepthStratum.attribute.id.tagValue.naturalId=true
-fr.ifremer.echobase.entities.references.DepthStratum.attribute.id.tagValue.notNull=true
fr.ifremer.echobase.entities.references.EchotypeCategory.class.tagValue.naturalIdMutable=true
fr.ifremer.echobase.entities.references.EchotypeCategory.attribute.name.tagValue.naturalId=true
-fr.ifremer.echobase.entities.references.EchotypeCategory.attribute.name.tagValue.notNull=true
fr.ifremer.echobase.entities.references.Gear.class.tagValue.naturalIdMutable=true
fr.ifremer.echobase.entities.references.Gear.attribute.casinoGearName.tagValue.naturalId=true
-fr.ifremer.echobase.entities.references.Gear.attribute.casinoGearName.tagValue.notNull=true
fr.ifremer.echobase.entities.references.GearCharacteristic.class.tagValue.naturalIdMutable=true
fr.ifremer.echobase.entities.references.GearCharacteristic.attribute.name.tagValue.naturalId=true
-fr.ifremer.echobase.entities.references.GearCharacteristic.attribute.name.tagValue.notNull=true
#fr.ifremer.echobase.entities.references.GearCharacteristicValue.class.tagValue.naturalIdMutable=true
#fr.ifremer.echobase.entities.references.GearCharacteristicValue.attribute.code.tagValue.naturalId=true
fr.ifremer.echobase.entities.references.GearMetadata.class.tagValue.naturalIdMutable=true
fr.ifremer.echobase.entities.references.GearMetadata.attribute.name.tagValue.naturalId=true
-fr.ifremer.echobase.entities.references.GearMetadata.attribute.name.tagValue.notNull=true
#fr.ifremer.echobase.entities.references.Impacte.class.tagValue.naturalIdMutable=true
#fr.ifremer.echobase.entities.references.Impacte.attribute.code.tagValue.naturalId=true
fr.ifremer.echobase.entities.references.MeasurementMetadata.class.tagValue.naturalIdMutable=true
fr.ifremer.echobase.entities.references.MeasurementMetadata.attribute.name.tagValue.naturalId=true
-fr.ifremer.echobase.entities.references.MeasurementMetadata.attribute.name.tagValue.notNull=true
fr.ifremer.echobase.entities.references.MeasureType.class.tagValue.naturalIdMutable=true
fr.ifremer.echobase.entities.references.MeasureType.attribute.name.tagValue.naturalId=true
-fr.ifremer.echobase.entities.references.MeasureType.attribute.name.tagValue.notNull=true
fr.ifremer.echobase.entities.references.Mission.class.tagValue.naturalIdMutable=true
fr.ifremer.echobase.entities.references.Mission.attribute.name.tagValue.naturalId=true
-fr.ifremer.echobase.entities.references.Mission.attribute.name.tagValue.notNull=true
fr.ifremer.echobase.entities.references.OperationEvent.class.tagValue.naturalIdMutable=true
fr.ifremer.echobase.entities.references.OperationEvent.attribute.name.tagValue.naturalId=true
-fr.ifremer.echobase.entities.references.OperationEvent.attribute.name.tagValue.notNull=true
fr.ifremer.echobase.entities.references.OperationMetadata.class.tagValue.naturalIdMutable=true
fr.ifremer.echobase.entities.references.OperationMetadata.attribute.name.tagValue.naturalId=true
-fr.ifremer.echobase.entities.references.OperationMetadata.attribute.name.tagValue.notNull=true
fr.ifremer.echobase.entities.references.ReferenceDatum.class.tagValue.naturalIdMutable=true
fr.ifremer.echobase.entities.references.ReferenceDatum.attribute.id.tagValue.naturalId=true
-fr.ifremer.echobase.entities.references.ReferenceDatum.attribute.id.tagValue.notNull=true
fr.ifremer.echobase.entities.references.ReferenceDatumType.class.tagValue.naturalIdMutable=true
fr.ifremer.echobase.entities.references.ReferenceDatumType.attribute.name.tagValue.naturalId=true
-fr.ifremer.echobase.entities.references.ReferenceDatumType.attribute.name.tagValue.notNull=true
fr.ifremer.echobase.entities.references.ReferencingMethod.class.tagValue.naturalIdMutable=true
fr.ifremer.echobase.entities.references.ReferencingMethod.attribute.name.tagValue.naturalId=true
-fr.ifremer.echobase.entities.references.ReferencingMethod.attribute.name.tagValue.notNull=true
fr.ifremer.echobase.entities.references.SampleDataType.class.tagValue.naturalIdMutable=true
fr.ifremer.echobase.entities.references.SampleDataType.attribute.name.tagValue.naturalId=true
-fr.ifremer.echobase.entities.references.SampleDataType.attribute.name.tagValue.notNull=true
fr.ifremer.echobase.entities.references.SampleType.class.tagValue.naturalIdMutable=true
fr.ifremer.echobase.entities.references.SampleType.attribute.name.tagValue.naturalId=true
-fr.ifremer.echobase.entities.references.SampleType.attribute.name.tagValue.notNull=true
fr.ifremer.echobase.entities.references.SexCategory.class.tagValue.naturalIdMutable=true
fr.ifremer.echobase.entities.references.SexCategory.attribute.name.tagValue.naturalId=true
-fr.ifremer.echobase.entities.references.SexCategory.attribute.name.tagValue.notNull=true
-fr.ifremer.echobase.entities.references.SexCategory.attribute.meaning.tagValue.notNull=true
fr.ifremer.echobase.entities.references.SizeCategory.class.tagValue.naturalIdMutable=true
fr.ifremer.echobase.entities.references.SizeCategory.attribute.name.tagValue.naturalId=true
-fr.ifremer.echobase.entities.references.SizeCategory.attribute.name.tagValue.notNull=true
-fr.ifremer.echobase.entities.references.SizeCategory.attribute.meaning.tagValue.notNull=true
fr.ifremer.echobase.entities.references.Species.class.tagValue.naturalIdMutable=true
fr.ifremer.echobase.entities.references.Species.attribute.baracoudaCode.tagValue.naturalId=true
-fr.ifremer.echobase.entities.references.Species.attribute.baracoudaCode.tagValue.notNull=true
fr.ifremer.echobase.entities.references.SpeciesCategory.class.tagValue.naturalIdMutable=true
fr.ifremer.echobase.entities.references.SpeciesCategory.attribute.species.tagValue.naturalId=true
fr.ifremer.echobase.entities.references.SpeciesCategory.attribute.sizeCategory.tagValue.naturalId=true
fr.ifremer.echobase.entities.references.SpeciesCategory.attribute.ageCategory.tagValue.naturalId=true
fr.ifremer.echobase.entities.references.SpeciesCategory.attribute.sexCategory.tagValue.naturalId=true
-fr.ifremer.echobase.entities.references.SpeciesCategory.attribute.species.tagValue.notNull=true
-fr.ifremer.echobase.entities.references.SpeciesCategory.attribute.sizeCategory.tagValue.notNull=false
-fr.ifremer.echobase.entities.references.SpeciesCategory.attribute.ageCategory.tagValue.notNull=false
-fr.ifremer.echobase.entities.references.SpeciesCategory.attribute.sexCategory.tagValue.notNull=false
fr.ifremer.echobase.entities.references.Strata.class.tagValue.naturalIdMutable=true
fr.ifremer.echobase.entities.references.Strata.attribute.name.tagValue.naturalId=true
-fr.ifremer.echobase.entities.references.Strata.attribute.name.tagValue.notNull=true
#fr.ifremer.echobase.entities.references.TSParameters.class.tagValue.naturalIdMutable=true
#fr.ifremer.echobase.entities.references.TSParameters.attribute.code.tagValue.naturalId=true
fr.ifremer.echobase.entities.references.Vessel.class.tagValue.naturalIdMutable=true
fr.ifremer.echobase.entities.references.Vessel.attribute.name.tagValue.naturalId=true
-fr.ifremer.echobase.entities.references.Vessel.attribute.name.tagValue.notNull=true
fr.ifremer.echobase.entities.references.VesselType.class.tagValue.naturalIdMutable=true
fr.ifremer.echobase.entities.references.VesselType.attribute.name.tagValue.naturalId=true
+
+###############################################################################
+### Not null for references ###################################################
+###############################################################################
+
+fr.ifremer.echobase.entities.EntityModificationLog.attribute.entityType.tagValue.notNull=true
+fr.ifremer.echobase.entities.EntityModificationLog.attribute.entityId.tagValue.notNull=true
+fr.ifremer.echobase.entities.EntityModificationLog.attribute.modificationText.tagValue.notNull=true
+fr.ifremer.echobase.entities.EntityModificationLog.attribute.modificationDate.tagValue.notNull=true
+fr.ifremer.echobase.entities.EntityModificationLog.attribute.modificationUser.tagValue.notNull=true
+
+fr.ifremer.echobase.entities.references.AcousticInstrument.attribute.id.tagValue.notNull=true
+
+fr.ifremer.echobase.entities.references.AgeCategory.attribute.name.tagValue.notNull=true
+fr.ifremer.echobase.entities.references.AgeCategory.attribute.meaning.tagValue.notNull=true
+
+fr.ifremer.echobase.entities.references.AreaOfOperation.attribute.name.tagValue.notNull=true
+
+fr.ifremer.echobase.entities.references.CategoryMeaning.attribute.name.tagValue.notNull=true
+
+fr.ifremer.echobase.entities.references.CategoryType.attribute.name.tagValue.notNull=true
+
+fr.ifremer.echobase.entities.references.CellMethod.attribute.name.tagValue.notNull=true
+
+fr.ifremer.echobase.entities.references.CellType.attribute.id.tagValue.notNull=true
+
+fr.ifremer.echobase.entities.references.DataMetadata.attribute.name.tagValue.notNull=true
+
+fr.ifremer.echobase.entities.references.DataType.attribute.name.tagValue.notNull=true
+
+fr.ifremer.echobase.entities.references.DepthStratum.attribute.id.tagValue.notNull=true
+
+fr.ifremer.echobase.entities.references.EchotypeCategory.attribute.name.tagValue.notNull=true
+
+fr.ifremer.echobase.entities.references.Gear.attribute.casinoGearName.tagValue.notNull=true
+
+fr.ifremer.echobase.entities.references.GearCharacteristic.attribute.name.tagValue.notNull=true
+
+fr.ifremer.echobase.entities.references.GearMetadata.attribute.name.tagValue.notNull=true
+
+fr.ifremer.echobase.entities.references.MeasurementMetadata.attribute.name.tagValue.notNull=true
+
+fr.ifremer.echobase.entities.references.MeasureType.attribute.name.tagValue.notNull=true
+
+fr.ifremer.echobase.entities.references.Mission.attribute.name.tagValue.notNull=true
+
+fr.ifremer.echobase.entities.references.OperationEvent.attribute.name.tagValue.notNull=true
+
+fr.ifremer.echobase.entities.references.OperationMetadata.attribute.name.tagValue.notNull=true
+
+fr.ifremer.echobase.entities.references.ReferenceDatum.attribute.id.tagValue.notNull=true
+
+fr.ifremer.echobase.entities.references.ReferenceDatumType.attribute.name.tagValue.notNull=true
+
+fr.ifremer.echobase.entities.references.ReferencingMethod.attribute.name.tagValue.notNull=true
+
+fr.ifremer.echobase.entities.references.SampleDataType.attribute.name.tagValue.notNull=true
+
+fr.ifremer.echobase.entities.references.SampleType.attribute.name.tagValue.notNull=true
+
+fr.ifremer.echobase.entities.references.SexCategory.attribute.name.tagValue.notNull=true
+fr.ifremer.echobase.entities.references.SexCategory.attribute.meaning.tagValue.notNull=true
+
+fr.ifremer.echobase.entities.references.SizeCategory.attribute.name.tagValue.notNull=true
+fr.ifremer.echobase.entities.references.SizeCategory.attribute.meaning.tagValue.notNull=true
+
+fr.ifremer.echobase.entities.references.Species.attribute.baracoudaCode.tagValue.notNull=true
+
+fr.ifremer.echobase.entities.references.SpeciesCategory.attribute.species.tagValue.notNull=true
+fr.ifremer.echobase.entities.references.SpeciesCategory.attribute.sizeCategory.tagValue.notNull=false
+fr.ifremer.echobase.entities.references.SpeciesCategory.attribute.ageCategory.tagValue.notNull=false
+fr.ifremer.echobase.entities.references.SpeciesCategory.attribute.sexCategory.tagValue.notNull=false
+
+fr.ifremer.echobase.entities.references.Strata.attribute.name.tagValue.notNull=true
+
+fr.ifremer.echobase.entities.references.Vessel.attribute.name.tagValue.notNull=true
+
fr.ifremer.echobase.entities.references.VesselType.attribute.name.tagValue.notNull=true
###############################################################################
@@ -237,6 +272,14 @@
fr.ifremer.echobase.entities.data.Category.attribute.depthStratum.tagValue.naturalId=true
fr.ifremer.echobase.entities.data.Category.attribute.echotype.tagValue.naturalId=true
fr.ifremer.echobase.entities.data.Category.attribute.speciesCategory.tagValue.naturalId=true
+
+fr.ifremer.echobase.entities.data.Voyage.class.tagValue.naturalIdMutable=true
+fr.ifremer.echobase.entities.data.Voyage.attribute.name.tagValue.naturalId=true
+
+###############################################################################
+### Not null for data #########################################################
+###############################################################################
+
fr.ifremer.echobase.entities.data.Category.attribute.depthStratum.tagValue.notNull=false
fr.ifremer.echobase.entities.data.Category.attribute.echotype.tagValue.notNull=false
fr.ifremer.echobase.entities.data.Category.attribute.speciesCategory.tagValue.notNull=false
@@ -302,8 +345,6 @@
fr.ifremer.echobase.entities.data.Transit.attribute.description.tagValue.notNull=true
fr.ifremer.echobase.entities.data.Transit.attribute.relatedActivity.tagValue.notNull=true
-fr.ifremer.echobase.entities.data.Voyage.class.tagValue.naturalIdMutable=true
-fr.ifremer.echobase.entities.data.Voyage.attribute.name.tagValue.naturalId=true
fr.ifremer.echobase.entities.data.Voyage.attribute.name.tagValue.notNull=true
fr.ifremer.echobase.entities.data.Voyage.attribute.startDate.tagValue.notNull=true
fr.ifremer.echobase.entities.data.Voyage.attribute.endDate.tagValue.notNull=true
@@ -311,4 +352,4 @@
fr.ifremer.echobase.entities.data.Voyage.attribute.endPort.tagValue.notNull=true
fr.ifremer.echobase.entities.data.Voyage.attribute.description.tagValue.notNull=true
fr.ifremer.echobase.entities.data.Voyage.attribute.mission.tagValue.notNull=true
-fr.ifremer.echobase.entities.data.Voyage.attribute.datum.tagValue.notNull=true
+fr.ifremer.echobase.entities.data.Voyage.attribute.datum.tagValue.notNull=true
\ No newline at end of file
1
0
r667 - in trunk/echobase-services/src: main/java/fr/ifremer/echobase/services/importdata main/java/fr/ifremer/echobase/services/removedata main/java/fr/ifremer/echobase/services/removedata/strategy test/java/fr/ifremer/echobase/services test/java/fr/ifremer/echobase/ui/actions test/java/fr/ifremer/echobase/ui/actions/removedata test/resources/import-data
by tchemit@users.forge.codelutin.com 15 Sep '12
by tchemit@users.forge.codelutin.com 15 Sep '12
15 Sep '12
Author: tchemit
Date: 2012-09-15 13:50:06 +0200 (Sat, 15 Sep 2012)
New Revision: 667
Url: http://forge.codelutin.com/repositories/revision/echobase/667
Log:
refs #1437: Suppression des imports (debut des tests)
Added:
trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/
trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/AbstractRemoveDataServiceIT.java
trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/CommonAllRemoveDataServiceIT.java
trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/CommonTransectRemoveDataServiceIT.java
Removed:
trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removeData/
Modified:
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/AbstractImportDataService.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/CommonTransectRemoveDataStrategy.java
trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/EchoBaseServiceFixtures.java
trunk/echobase-services/src/test/resources/import-data/echobase-1.2-nodata.h2.db.gz
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-14 20:16:18 UTC (rev 666)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/AbstractImportDataService.java 2012-09-15 11:50:06 UTC (rev 667)
@@ -130,20 +130,36 @@
return new EchoBaseCsvFileImportResult(inputFile.getFileName());
}
- protected String computeResultAndLogBookEntry(M configuration,
- EchoBaseUser user) {
-
+ public ImportLog computeImportLogEntry(M configuration,
+ EchoBaseUser user) {
Date importDate = newDate();
String importUser = user.getEmail();
-
ImportLog importLog = create(getDAO(ImportLog.class),
ImportLog.PROPERTY_VOYAGE_ID, configuration.getVoyageId(),
ImportLog.PROPERTY_IMPORT_TYPE, configuration.getImportType(),
ImportLog.PROPERTY_IMPORT_USER, importUser,
ImportLog.PROPERTY_IMPORT_DATE, importDate,
ImportLog.PROPERTY_IMPORT_TEXT, configuration.getImportNotes());
+ return importLog;
+ }
+ protected String computeResultAndLogBookEntry(M configuration,
+ EchoBaseUser user) {
+
+ Date importDate = newDate();
+ String importUser = user.getEmail();
+
+ ImportLog importLog = computeImportLogEntry(configuration, user);
+//
+// ImportLog importLog = create(getDAO(ImportLog.class),
+// ImportLog.PROPERTY_VOYAGE_ID, configuration.getVoyageId(),
+// ImportLog.PROPERTY_IMPORT_TYPE, configuration.getImportType(),
+// ImportLog.PROPERTY_IMPORT_USER, importUser,
+// ImportLog.PROPERTY_IMPORT_DATE, importDate,
+// ImportLog.PROPERTY_IMPORT_TEXT, configuration.getImportNotes());
+//
+
String importType = getImportLabel(configuration);
StringBuilder buffer = new StringBuilder();
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-14 20:16:18 UTC (rev 666)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/RemoveDataService.java 2012-09-15 11:50:06 UTC (rev 667)
@@ -158,11 +158,17 @@
continue;
}
+ if (!importLog.getVoyageId().equals(logEntry.getVoyageId())) {
+
+ // not on same voyage, this importLog can not be obsoleted
+ 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();
+ String firstId = logEntry.getImportId().iterator().next();
if (!isIdExists(firstId)) {
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-14 20:16:18 UTC (rev 666)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/AbstractRemoveDataStrategy.java 2012-09-15 11:50:06 UTC (rev 667)
@@ -42,10 +42,12 @@
import fr.ifremer.echobase.services.EchoBaseServiceContext;
import fr.ifremer.echobase.services.EchoBaseServiceSupport;
import fr.ifremer.echobase.services.removedata.RemoveDataConfiguration;
+import org.apache.commons.collections.CollectionUtils;
import org.nuiton.topia.TopiaException;
import org.nuiton.topia.persistence.TopiaDAO;
import org.nuiton.topia.persistence.TopiaEntity;
+import java.util.Collections;
import java.util.List;
import java.util.Set;
@@ -94,7 +96,7 @@
public void doRemove(RemoveDataConfiguration model, ImportLog importLog) throws TopiaException {
- Voyage voyage = voyageDao.findByTopiaId(importLog.getTopiaId());
+ Voyage voyage = voyageDao.findByTopiaId(importLog.getVoyageId());
removeDataInVoyage(voyage);
@@ -114,6 +116,8 @@
throw new EchoBaseTechnicalException(e);
}
}
+
+// flushTransaction("Could not flush transaction");
}
protected abstract void removeDataInVoyage(Voyage voyage) throws TopiaException;
@@ -191,7 +195,9 @@
protected void removeVoyage(Voyage entity) throws TopiaException {
- Set<Echotype> echotypes = Sets.newHashSet(entity.getEchotype());
+ Set<Echotype> echotypes = CollectionUtils.isEmpty(entity.getEchotype()) ?
+ Collections.<Echotype>emptySet() :
+ Sets.newHashSet(entity.getEchotype());
// clean this data
entity.clearEchotype();
@@ -209,13 +215,16 @@
protected void removeVoyagePostCell(Voyage entity) throws TopiaException {
- for (Cell postCell : entity.getPostCell()) {
- removePostCell(null, postCell);
- }
+ if (CollectionUtils.isNotEmpty(entity.getPostCell())) {
+ for (Cell postCell : entity.getPostCell()) {
+ removePostCell(null, postCell);
+ }
- // clean this data
- entity.clearPostCell();
+ // clean this data
+ entity.clearPostCell();
- flushTransaction("Could not flush transaction after removing postCells");
+ flushTransaction(
+ "Could not flush transaction after removing postCells");
+ }
}
}
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-14 20:16:18 UTC (rev 666)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/CommonTransectRemoveDataStrategy.java 2012-09-15 11:50:06 UTC (rev 667)
@@ -27,6 +27,8 @@
import fr.ifremer.echobase.entities.ImportType;
import fr.ifremer.echobase.entities.data.Transect;
import fr.ifremer.echobase.entities.data.TransectDAO;
+import fr.ifremer.echobase.entities.data.Transit;
+import fr.ifremer.echobase.entities.data.TransitDAO;
import fr.ifremer.echobase.entities.data.Voyage;
import fr.ifremer.echobase.services.EchoBaseServiceContext;
import org.apache.commons.logging.Log;
@@ -51,11 +53,14 @@
protected TransectDAO transectDAO;
+ protected TransitDAO transitDAO;
+
@Override
public void setServiceContext(EchoBaseServiceContext serviceContext) {
super.setServiceContext(serviceContext);
transectDAO = getDAO(Transect.class, TransectDAO.class);
+ transitDAO = getDAO(Transit.class, TransitDAO.class);
}
@Override
@@ -71,19 +76,24 @@
if (id.startsWith(Transect.class.getName())) {
// remove transect
- removeTransect(id);
+ Transect transect = transectDAO.findByTopiaId(id);
+
+ // remove it from transit
+ Transit transit = transitDAO.findContainsTransect(transect);
+ transit.removeTransect(transect);
+
+ // delete it
+ delete(transectDAO, transect);
+
+ if (log.isInfoEnabled()) {
+ log.info("Transect " + transect.getTopiaId() + " was removed");
+ }
+
} else {
canNotDealWithId(id);
}
}
- protected void removeTransect(String id) throws TopiaException {
- Transect entity = removeEntity(transectDAO, id);
- if (log.isInfoEnabled()) {
- log.info("Transect " + entity.getTopiaId() + " was removed");
- }
- }
-
@Override
public Set<ImportType> getPossibleSubImportType() {
Set<ImportType> result = Sets.newHashSet(ImportType.OPERATION,
Modified: trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/EchoBaseServiceFixtures.java
===================================================================
--- trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/EchoBaseServiceFixtures.java 2012-09-14 20:16:18 UTC (rev 666)
+++ trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/EchoBaseServiceFixtures.java 2012-09-15 11:50:06 UTC (rev 667)
@@ -31,10 +31,6 @@
*/
public class EchoBaseServiceFixtures {
- public String completeDb2011() {
- return "/import-data/echobase-pelgas-2011.h2.db.gz";
- }
-
public String IMPORT_DATA_ECHOBASE_NO_DATA() {
return "/import-data/echobase-" + dbVersion() + "-nodata.h2.db.gz";
}
Copied: trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/AbstractRemoveDataServiceIT.java (from rev 666, trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removeData/AbstractRemoveDataServiceIT.java)
===================================================================
--- trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/AbstractRemoveDataServiceIT.java (rev 0)
+++ trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/AbstractRemoveDataServiceIT.java 2012-09-15 11:50:06 UTC (rev 667)
@@ -0,0 +1,398 @@
+package fr.ifremer.echobase.ui.actions.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.entities.EchoBaseUser;
+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.Cell;
+import fr.ifremer.echobase.entities.data.CellDAO;
+import fr.ifremer.echobase.entities.data.DataAcquisition;
+import fr.ifremer.echobase.entities.data.DataAcquisitionDAO;
+import fr.ifremer.echobase.entities.data.DataProcessing;
+import fr.ifremer.echobase.entities.data.DataProcessingDAO;
+import fr.ifremer.echobase.entities.data.Echotype;
+import fr.ifremer.echobase.entities.data.EchotypeDAO;
+import fr.ifremer.echobase.entities.data.LengthAgeKey;
+import fr.ifremer.echobase.entities.data.LengthAgeKeyDAO;
+import fr.ifremer.echobase.entities.data.LengthWeightKey;
+import fr.ifremer.echobase.entities.data.LengthWeightKeyDAO;
+import fr.ifremer.echobase.entities.data.Transect;
+import fr.ifremer.echobase.entities.data.TransectDAO;
+import fr.ifremer.echobase.entities.data.Transit;
+import fr.ifremer.echobase.entities.data.TransitDAO;
+import fr.ifremer.echobase.entities.data.Voyage;
+import fr.ifremer.echobase.entities.data.VoyageDAO;
+import fr.ifremer.echobase.entities.references.Mission;
+import fr.ifremer.echobase.entities.references.Vessel;
+import fr.ifremer.echobase.services.EchoBaseTestServiceSupport;
+import fr.ifremer.echobase.services.FakeEchoBaseServiceContext;
+import fr.ifremer.echobase.services.importdata.CommonAllImportService;
+import fr.ifremer.echobase.services.importdata.CommonImportConfiguration;
+import fr.ifremer.echobase.services.removedata.RemoveDataConfiguration;
+import fr.ifremer.echobase.services.removedata.RemoveDataService;
+import junit.framework.Assert;
+import org.apache.commons.collections.CollectionUtils;
+import org.junit.Before;
+import org.nuiton.topia.TopiaException;
+import org.nuiton.topia.persistence.TopiaDAO;
+import org.nuiton.topia.persistence.TopiaEntity;
+
+import java.util.List;
+
+/**
+ * Abstract it form remove data feature.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.2
+ */
+public abstract class AbstractRemoveDataServiceIT extends EchoBaseTestServiceSupport {
+
+ protected String importCommonAll1Id;
+
+ protected String importCommonTransect1Id;
+
+ protected static final String voyage1Id = "fr.ifremer.echobase.entities.data.Voyage#1#1";
+
+ protected static final String transit1Id = "fr.ifremer.echobase.entities.data.Transit#1#1";
+
+ protected static final String transect1Id = "fr.ifremer.echobase.entities.data.Transect#1#1";
+
+ protected static final String transect1_2Id = "fr.ifremer.echobase.entities.data.Transect#1#2";
+
+ protected String importCommonAll2Id;
+
+ protected String importCommonTransect2Id;
+
+ protected static final String voyage2Id = "fr.ifremer.echobase.entities.data.Voyage#2#1";
+
+ protected static final String transit2Id = "fr.ifremer.echobase.entities.data.Transit#2#1";
+
+ protected static final String transect2Id = "fr.ifremer.echobase.entities.data.Transect#2#1";
+
+ protected static final String transect2_2Id = "fr.ifremer.echobase.entities.data.Transect#2#2";
+
+ protected VoyageDAO voyageDao;
+
+ protected TransectDAO transectDAO;
+
+ protected TransitDAO transitDAO;
+
+ protected DataAcquisitionDAO dataAcquisitionDAO;
+
+ protected DataProcessingDAO dataProcessingDAO;
+
+ protected CellDAO cellDAO;
+
+ protected CategoryDAO categoryDAO;
+
+ protected EchotypeDAO echotypeDAO;
+
+ protected LengthAgeKeyDAO lengthAgeKeyDAO;
+
+ protected LengthWeightKeyDAO lengthWeightKeyDAO;
+
+ @Override
+ protected FakeEchoBaseServiceContext initContext() {
+ return new FakeEchoBaseServiceContext(fixtures.IMPORT_DATA_ECHOBASE_NO_DATA());
+ }
+
+ @Override
+ @Before
+ public void setUp() throws Exception {
+ super.setUp();
+
+ voyageDao = getDAO(Voyage.class, VoyageDAO.class);
+ transectDAO = getDAO(Transect.class, TransectDAO.class);
+ transitDAO = getDAO(Transit.class, TransitDAO.class);
+ dataAcquisitionDAO = getDAO(DataAcquisition.class, DataAcquisitionDAO.class);
+ dataProcessingDAO = getDAO(DataProcessing.class, DataProcessingDAO.class);
+
+ cellDAO = getDAO(Cell.class, CellDAO.class);
+ echotypeDAO = getDAO(Echotype.class, EchotypeDAO.class);
+ lengthAgeKeyDAO = getDAO(LengthAgeKey.class, LengthAgeKeyDAO.class);
+ lengthWeightKeyDAO = getDAO(LengthWeightKey.class, LengthWeightKeyDAO.class);
+ categoryDAO = getDAO(Category.class, CategoryDAO.class);
+ }
+
+ protected void removeImport(String importId) {
+ RemoveDataConfiguration conf = new RemoveDataConfiguration();
+ conf.setImportLogId(importId);
+
+ RemoveDataService service = getService(RemoveDataService.class);
+
+ EchoBaseUser fakeUser = createFakeUser();
+
+ service.removeImport(conf, fakeUser);
+ }
+
+
+ protected <E extends TopiaEntity> void assertEntityDeleted(Class<E> entityType, String... entityIds) throws TopiaException {
+ TopiaDAO<E> dao = getDAO(entityType);
+ for (String entityId : entityIds) {
+ E entity = dao.findByTopiaId(entityId);
+ Assert.assertNull("Entity with id " + entityId + " should have been deleted, but is still in db :(", entity);
+ }
+ }
+
+ protected <E extends TopiaEntity> void assertEntityExists(Class<E> entityType, String... entityIds) throws TopiaException {
+ TopiaDAO<E> dao = getDAO(entityType);
+ for (String entityId : entityIds) {
+ E entity = dao.findByTopiaId(entityId);
+ Assert.assertNotNull("Entity with id " + entityId + " should have not been deleted, but is deleted in db :(", entity);
+ }
+ }
+
+ protected <E extends TopiaEntity> E getFirstEntity(Class<E> entityType) {
+ List<E> entities = getEntities(entityType);
+ Assert.assertTrue(CollectionUtils.isNotEmpty(entities));
+ return entities.get(0);
+ }
+
+ protected void createCommonAllImportV1() {
+
+ // create voyage
+ Voyage voyage1 = create(voyageDao,
+ TopiaEntity.TOPIA_ID, voyage1Id,
+ Voyage.PROPERTY_MISSION, getFirstEntity(Mission.class),
+ Voyage.PROPERTY_NAME, "voyage1",
+ Voyage.PROPERTY_START_DATE, newDate(),
+ Voyage.PROPERTY_END_DATE, newDate(),
+ Voyage.PROPERTY_START_PORT, "voyage1StartPort",
+ Voyage.PROPERTY_END_PORT, "voyage1EndPort",
+ Voyage.PROPERTY_DESCRIPTION, "voyage1Description",
+ Voyage.PROPERTY_DATUM, "voyage1Datum"
+ );
+
+ // create transit
+ Transit transit1 = create(transitDAO,
+ TopiaEntity.TOPIA_ID, transit1Id,
+ Transit.PROPERTY_START_TIME, newDate(),
+ Transit.PROPERTY_END_TIME, newDate(),
+ Transit.PROPERTY_START_LOCALITY, "transit1tartLocality",
+ Transit.PROPERTY_END_LOCALITY, "transit1EndLocality",
+ Transit.PROPERTY_DESCRIPTION, "transit1Description",
+ Transit.PROPERTY_RELATED_ACTIVITY, "transit1RelatedActivity"
+ );
+ voyage1.addTransit(transit1);
+
+ // create transect
+ Transect transect1 = create(transectDAO,
+ TopiaEntity.TOPIA_ID, transect1Id,
+ Transect.PROPERTY_TITLE, "transect1Title",
+ Transect.PROPERTY_VESSEL, getFirstEntity(Vessel.class),
+ Transect.PROPERTY_STRATUM, "transect1Stratum"
+ );
+ transit1.addTransect(transect1);
+
+ commitTransaction("ImportError!");
+
+ CommonImportConfiguration importConf =
+ new CommonImportConfiguration(getLocale());
+ importConf.setImportType(ImportType.COMMON_ALL);
+ importConf.setImportNotes("Common/Voyage/Transit/Transect1");
+ importConf.setVoyageId(voyage1.getTopiaId());
+
+ CommonAllImportService importService =
+ getService(CommonAllImportService.class);
+
+ ImportLog importLog = importService.computeImportLogEntry(
+ importConf, createFakeUser());
+
+ importLog.addImportId(voyage1.getTopiaId());
+
+ commitTransaction("ImportLogError!");
+
+ importCommonAll1Id = importLog.getTopiaId();
+ }
+
+ protected void createCommonAllImportV2() {
+
+ // create voyage
+ Voyage voyage1 = create(voyageDao,
+ TopiaEntity.TOPIA_ID, voyage2Id,
+ Voyage.PROPERTY_MISSION, getFirstEntity(Mission.class),
+ Voyage.PROPERTY_NAME, "voyage1",
+ Voyage.PROPERTY_START_DATE, newDate(),
+ Voyage.PROPERTY_END_DATE, newDate(),
+ Voyage.PROPERTY_START_PORT, "voyage1StartPort",
+ Voyage.PROPERTY_END_PORT, "voyage1EndPort",
+ Voyage.PROPERTY_DESCRIPTION, "voyage1Description",
+ Voyage.PROPERTY_DATUM, "voyage1Datum"
+ );
+
+ // create transit
+ Transit transit1 = create(transitDAO,
+ TopiaEntity.TOPIA_ID, transit2Id,
+ Transit.PROPERTY_START_TIME, newDate(),
+ Transit.PROPERTY_END_TIME, newDate(),
+ Transit.PROPERTY_START_LOCALITY, "transit1tartLocality",
+ Transit.PROPERTY_END_LOCALITY, "transit1EndLocality",
+ Transit.PROPERTY_DESCRIPTION, "transit1Description",
+ Transit.PROPERTY_RELATED_ACTIVITY, "transit1RelatedActivity"
+ );
+ voyage1.addTransit(transit1);
+
+ // create transect
+ Transect transect1 = create(transectDAO,
+ TopiaEntity.TOPIA_ID, transect2Id,
+ Transect.PROPERTY_TITLE, "transect1Title",
+ Transect.PROPERTY_VESSEL, getFirstEntity(Vessel.class),
+ Transect.PROPERTY_STRATUM, "transect1Stratum"
+ );
+ transit1.addTransect(transect1);
+
+ commitTransaction("ImportError!");
+
+ CommonImportConfiguration importConf =
+ new CommonImportConfiguration(getLocale());
+ importConf.setImportType(ImportType.COMMON_ALL);
+ importConf.setImportNotes("Common/Voyage/Transit/Transect2");
+ importConf.setVoyageId(voyage1.getTopiaId());
+
+ CommonAllImportService importService =
+ getService(CommonAllImportService.class);
+
+ ImportLog importLog = importService.computeImportLogEntry(
+ importConf, createFakeUser());
+
+ importLog.addImportId(voyage1.getTopiaId());
+
+ commitTransaction("ImportLogError!");
+
+ importCommonAll2Id = importLog.getTopiaId();
+ }
+
+ protected void createCommonTransectImportV1() {
+
+ Voyage voyage1 = getEntityById(Voyage.class, voyage1Id);
+
+ // create transect
+ Transect transect2 = create(transectDAO,
+ TopiaEntity.TOPIA_ID, transect1_2Id,
+ Transect.PROPERTY_TITLE, "transect2Title",
+ Transect.PROPERTY_VESSEL, getFirstEntity(Vessel.class),
+ Transect.PROPERTY_STRATUM, "transect2Stratum"
+ );
+ voyage1.getTransit().get(0).addTransect(transect2);
+
+ commitTransaction("ImportError!");
+
+ CommonImportConfiguration importConf =
+ new CommonImportConfiguration(getLocale());
+ importConf.setImportType(ImportType.COMMON_TRANSECT);
+ importConf.setImportNotes("Common/Transect1");
+ importConf.setVoyageId(voyage1Id);
+
+ CommonAllImportService importService =
+ getService(CommonAllImportService.class);
+
+ ImportLog importLog = importService.computeImportLogEntry(
+ importConf, createFakeUser());
+
+ importLog.addImportId(transect2.getTopiaId());
+
+ commitTransaction("ImportLogError!");
+
+ importCommonTransect1Id = importLog.getTopiaId();
+ }
+
+ protected void createCommonTransectImportV2() {
+
+ Voyage voyage1 = getEntityById(Voyage.class, voyage2Id);
+
+ // create transect
+ Transect transect2 = create(transectDAO,
+ TopiaEntity.TOPIA_ID, transect2_2Id,
+ Transect.PROPERTY_TITLE, "transect2Title",
+ Transect.PROPERTY_VESSEL, getFirstEntity(Vessel.class),
+ Transect.PROPERTY_STRATUM, "transect2Stratum"
+ );
+ voyage1.getTransit().get(0).addTransect(transect2);
+
+ commitTransaction("ImportError!");
+
+ CommonImportConfiguration importConf =
+ new CommonImportConfiguration(getLocale());
+ importConf.setImportType(ImportType.COMMON_TRANSECT);
+ importConf.setImportNotes("Common/Transect2");
+ importConf.setVoyageId(voyage2Id);
+
+ CommonAllImportService importService =
+ getService(CommonAllImportService.class);
+
+ ImportLog importLog = importService.computeImportLogEntry(
+ importConf, createFakeUser());
+
+ importLog.addImportId(transect2.getTopiaId());
+
+ commitTransaction("ImportLogError!");
+
+ importCommonTransect2Id = importLog.getTopiaId();
+ }
+
+ protected void createOperationImport() {
+
+ // create operation
+ // create operationMetadata
+ // create geartMetadata
+ }
+
+ protected void createCatchesImport() {
+
+ // create totalSample
+ // create subSample
+ // create biometrySample
+ }
+
+ protected void createAcousticImport() {
+
+ // create cell
+ }
+
+ protected void createResultVoyageImport() {
+
+ // create echotype
+ // create lengthAgeKey
+ // create lengthWeightKey
+ }
+
+ protected void createResultEsduImport() {
+
+ // create result (on ESDU)
+ }
+
+ protected void createResultRegionImport() {
+
+ // create region
+ // create result (on region)
+ }
+
+ protected void createResultMapImport() {
+
+ // create map
+ }
+}
Property changes on: trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/AbstractRemoveDataServiceIT.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/CommonAllRemoveDataServiceIT.java
===================================================================
--- trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/CommonAllRemoveDataServiceIT.java (rev 0)
+++ trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/CommonAllRemoveDataServiceIT.java 2012-09-15 11:50:06 UTC (rev 667)
@@ -0,0 +1,100 @@
+package fr.ifremer.echobase.ui.actions.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.entities.ImportLog;
+import fr.ifremer.echobase.entities.data.Transect;
+import fr.ifremer.echobase.entities.data.Voyage;
+import fr.ifremer.echobase.services.removedata.RemoveDataService;
+import fr.ifremer.echobase.services.removedata.strategy.CommonAllRemoveDataStrategy;
+import org.junit.Test;
+import org.nuiton.topia.TopiaException;
+
+/**
+ * Test{@link RemoveDataService} with {@link CommonAllRemoveDataStrategy}.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.3
+ */
+public class CommonAllRemoveDataServiceIT extends AbstractRemoveDataServiceIT {
+
+ @Test
+ public void removeImport1() throws TopiaException {
+
+ createCommonAllImportV1();
+ createCommonTransectImportV1();
+
+ createCommonAllImportV2();
+ createCommonTransectImportV2();
+
+ removeImport(importCommonAll1Id);
+
+ // voyage 1 is deleted
+ assertEntityDeleted(Voyage.class, voyage1Id);
+
+ // and all his imports
+ assertEntityDeleted(ImportLog.class,
+ importCommonAll1Id,
+ importCommonTransect1Id);
+
+ // voyage 2 still in db
+ assertEntityExists(Voyage.class, voyage2Id);
+ assertEntityExists(Transect.class, transect2Id);
+
+ // and all his imports
+ assertEntityExists(ImportLog.class,
+ importCommonAll2Id,
+ importCommonTransect2Id);
+
+ }
+
+ @Test
+ public void removeImport2() throws TopiaException {
+
+ createCommonAllImportV1();
+ createCommonTransectImportV1();
+
+ createCommonAllImportV2();
+ createCommonTransectImportV2();
+
+ removeImport(importCommonAll2Id);
+
+ // voyage 2 is deleted
+ assertEntityDeleted(Voyage.class, voyage2Id);
+
+ // and all his imports
+ assertEntityDeleted(ImportLog.class,
+ importCommonAll2Id,
+ importCommonTransect2Id);
+
+ // voyage 1 still in db
+ assertEntityExists(Voyage.class, voyage1Id);
+ assertEntityExists(Transect.class, transect1Id);
+
+ // and all his imports
+ assertEntityExists(ImportLog.class,
+ importCommonAll1Id,
+ importCommonTransect1Id);
+ }
+}
Property changes on: trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/CommonAllRemoveDataServiceIT.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/CommonTransectRemoveDataServiceIT.java
===================================================================
--- trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/CommonTransectRemoveDataServiceIT.java (rev 0)
+++ trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/CommonTransectRemoveDataServiceIT.java 2012-09-15 11:50:06 UTC (rev 667)
@@ -0,0 +1,117 @@
+package fr.ifremer.echobase.ui.actions.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.entities.ImportLog;
+import fr.ifremer.echobase.entities.data.Transect;
+import fr.ifremer.echobase.entities.data.Voyage;
+import fr.ifremer.echobase.services.removedata.RemoveDataService;
+import fr.ifremer.echobase.services.removedata.strategy.CommonTransectRemoveDataStrategy;
+import org.junit.Test;
+import org.nuiton.topia.TopiaException;
+
+/**
+ * Test{@link RemoveDataService} with {@link CommonTransectRemoveDataStrategy}.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.3
+ */
+public class CommonTransectRemoveDataServiceIT extends AbstractRemoveDataServiceIT {
+
+ @Test
+ public void removeImport1() throws TopiaException {
+
+ createCommonAllImportV1();
+ createCommonTransectImportV1();
+
+ createCommonAllImportV2();
+ createCommonTransectImportV2();
+
+ removeImport(importCommonTransect1Id);
+
+ // transect 1 is deleted
+ assertEntityDeleted(Transect.class, transect1_2Id);
+
+ // and all his imports
+ assertEntityDeleted(ImportLog.class,
+ importCommonTransect1Id);
+
+ // voyage 1 is still here
+ assertEntityExists(Voyage.class, voyage1Id);
+ assertEntityExists(Transect.class, transect1Id);
+
+ // and all his imports
+ assertEntityExists(ImportLog.class,
+ importCommonAll1Id);
+
+
+ // voyage 2 still in db
+ assertEntityExists(Voyage.class, voyage2Id);
+ assertEntityExists(Transect.class, transect2Id);
+
+ // and all his imports
+ assertEntityExists(ImportLog.class,
+ importCommonAll2Id,
+ importCommonTransect2Id);
+ }
+
+ @Test
+ public void removeImport2() throws TopiaException {
+
+
+ createCommonAllImportV1();
+ createCommonTransectImportV1();
+
+ createCommonAllImportV2();
+ createCommonTransectImportV2();
+
+ removeImport(importCommonTransect2Id);
+
+ // transect 2 is deleted
+ assertEntityDeleted(Transect.class, transect2_2Id);
+
+ // and all his imports
+ assertEntityDeleted(ImportLog.class,
+ importCommonTransect2Id);
+
+
+ // voyage 2 is still here
+ assertEntityExists(Voyage.class, voyage2Id);
+ assertEntityExists(Transect.class, transect2Id);
+
+ // and all his imports
+ assertEntityExists(ImportLog.class,
+ importCommonAll2Id);
+
+
+ // voyage 1 still in db
+ assertEntityExists(Voyage.class, voyage1Id);
+ assertEntityExists(Transect.class, transect1Id);
+
+ // and all his imports
+ assertEntityExists(ImportLog.class,
+ importCommonAll1Id,
+ importCommonTransect1Id);
+ }
+}
Property changes on: trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removedata/CommonTransectRemoveDataServiceIT.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/echobase-services/src/test/resources/import-data/echobase-1.2-nodata.h2.db.gz
===================================================================
(Binary files differ)
1
0
r666 - trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removeData
by tchemit@users.forge.codelutin.com 14 Sep '12
by tchemit@users.forge.codelutin.com 14 Sep '12
14 Sep '12
Author: tchemit
Date: 2012-09-14 22:16:18 +0200 (Fri, 14 Sep 2012)
New Revision: 666
Url: http://forge.codelutin.com/repositories/revision/echobase/666
Log:
add missing svn properties + license header
Modified:
trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removeData/AbstractRemoveDataServiceIT.java
Modified: trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removeData/AbstractRemoveDataServiceIT.java
===================================================================
--- trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removeData/AbstractRemoveDataServiceIT.java 2012-09-14 20:15:44 UTC (rev 665)
+++ trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removeData/AbstractRemoveDataServiceIT.java 2012-09-14 20:16:18 UTC (rev 666)
@@ -1,5 +1,28 @@
package fr.ifremer.echobase.ui.actions.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.entities.EchoBaseUser;
import fr.ifremer.echobase.services.EchoBaseTestServiceSupport;
import fr.ifremer.echobase.services.FakeEchoBaseServiceContext;
Property changes on: trunk/echobase-services/src/test/java/fr/ifremer/echobase/ui/actions/removeData/AbstractRemoveDataServiceIT.java
___________________________________________________________________
Modified: svn:keywords
- Author Date Id Revision
+ Author Date Id Revision HeadURL
1
0
r665 - trunk/echobase-ui/src/main/env/prod/resources
by tchemit@users.forge.codelutin.com 14 Sep '12
by tchemit@users.forge.codelutin.com 14 Sep '12
14 Sep '12
Author: tchemit
Date: 2012-09-14 22:15:44 +0200 (Fri, 14 Sep 2012)
New Revision: 665
Url: http://forge.codelutin.com/repositories/revision/echobase/665
Log:
fix log file name
Modified:
trunk/echobase-ui/src/main/env/prod/resources/log4j.properties
Modified: trunk/echobase-ui/src/main/env/prod/resources/log4j.properties
===================================================================
--- trunk/echobase-ui/src/main/env/prod/resources/log4j.properties 2012-09-14 16:37:54 UTC (rev 664)
+++ trunk/echobase-ui/src/main/env/prod/resources/log4j.properties 2012-09-14 20:15:44 UTC (rev 665)
@@ -31,7 +31,7 @@
# file output...
log4j.appender.file=org.apache.log4j.RollingFileAppender
-log4j.appender.file.File=${echobase.log.dir}/t3.log
+log4j.appender.file.File=${echobase.log.dir}/echobase.log
log4j.appender.file.MaxFileSize=10MB
log4j.appender.file.MaxBackupIndex=4
log4j.appender.file.layout=org.apache.log4j.PatternLayout
1
0