Echobase-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- 1820 discussions
Author: mdoray
Date: 2012-09-10 10:59:53 +0200 (Mon, 10 Sep 2012)
New Revision: 639
Url: http://forge.codelutin.com/repositories/revision/echobase/639
Log:
>From scmwebeditor --
Modified:
trunk/src/site/en/rst/index.rst
Modified: trunk/src/site/en/rst/index.rst
===================================================================
--- trunk/src/site/en/rst/index.rst 2012-09-09 19:57:02 UTC (rev 638)
+++ trunk/src/site/en/rst/index.rst 2012-09-10 08:59:53 UTC (rev 639)
@@ -37,14 +37,14 @@
Echobase provide a web-browser interface for importing, editing and querying data,
large storage capacities, and an easy integration into Geographical Information Systems or dynamic websites.
-The Echobase acoustic metadata format follows the `ICES WGFAST`_.Topic Group on metadata standards recommendations.
+The Echobase acoustic metadata format follows the `ICES WGFAST`_ Topic Group on metadata standards recommendations.
Documentation
-------------
-- How to `install`_. Echobase.
+- How to `install`_ Echobase.
- The Echobase `model`_.
1
0
09 Sep '12
Author: tchemit
Date: 2012-09-09 21:57:02 +0200 (Sun, 09 Sep 2012)
New Revision: 638
Url: http://forge.codelutin.com/repositories/revision/echobase/638
Log:
refs #1437: Suppression des imports (add ui + implements strategies)
Added:
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/RemoveDataConfiguration.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/RemoveDataService.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/AbstractRemoveDataStrategy.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/AcousticRemoveDataStrategy.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/CatchesRemoveDataStrategy.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/CommonAllRemoveDataStrategy.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/CommonTransectRemoveDataStrategy.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/OperationRemoveDataStrategy.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/ResultEsduRemoveDataStrategy.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/ResultMapRemoveDataStrategy.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/ResultRegionRemoveDataStrategy.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/ResultVoyageRemoveDataStrategy.java
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/removeData/
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/removeData/ConfirmDelete.java
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/removeData/Delete.java
trunk/echobase-ui/src/main/resources/config/struts-removeData.xml
trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/removeData/
trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/removeData/confirmDelete.jsp
trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/removeData/dashboard.jsp
trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/removeData/deleteProgress.jsp
trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/removeData/deleteResult.jsp
trunk/echobase-ui/src/main/webapp/images/delete.png
trunk/src/site/rst/db.rst
trunk/src/site/rst/usage.rst
Removed:
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/AbstractRemoveDataService.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/AcousticRemoveDataService.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/CatchesRemoveDataService.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/CommonAllRemoveDataService.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/CommonTransectRemoveDataService.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/OperationRemoveDataService.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/ResultEsduRemoveDataService.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/ResultMapRemoveDataService.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/ResultRegionRemoveDataService.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/ResultVoyageRemoveDataService.java
Modified:
trunk/echobase-domain/src/main/java/fr/ifremer/echobase/services/EchoBaseServiceSupport.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/DbEditorService.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/AbstractImportDataService.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/AcousticImportService.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdb/ImportService.java
trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/GetEntities.java
trunk/echobase-ui/src/main/resources/config/struts-exportDb.xml
trunk/echobase-ui/src/main/resources/config/struts-user.xml
trunk/echobase-ui/src/main/resources/config/struts-workingDb.xml
trunk/echobase-ui/src/main/resources/i18n/echobase-ui_en_GB.properties
trunk/echobase-ui/src/main/resources/i18n/echobase-ui_fr_FR.properties
trunk/echobase-ui/src/main/resources/struts.xml
trunk/echobase-ui/src/main/webapp/WEB-INF/decorators.xml
trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/home.jsp
trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/importData/configureResultsImport.jsp
trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/importData/resultResultsImport.jsp
trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/importDb/result.jsp
trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/workingDb/modifications.jsp
trunk/echobase-ui/src/main/webapp/js/gridHelper.js
trunk/src/site/rst/embedded.rst
Modified: trunk/echobase-domain/src/main/java/fr/ifremer/echobase/services/EchoBaseServiceSupport.java
===================================================================
--- trunk/echobase-domain/src/main/java/fr/ifremer/echobase/services/EchoBaseServiceSupport.java 2012-09-08 11:23:33 UTC (rev 637)
+++ trunk/echobase-domain/src/main/java/fr/ifremer/echobase/services/EchoBaseServiceSupport.java 2012-09-09 19:57:02 UTC (rev 638)
@@ -32,9 +32,11 @@
import org.apache.commons.lang3.StringUtils;
import org.nuiton.topia.TopiaContext;
import org.nuiton.topia.TopiaException;
+import org.nuiton.topia.TopiaNotFoundException;
import org.nuiton.topia.framework.TopiaContextImplementor;
import org.nuiton.topia.persistence.TopiaDAO;
import org.nuiton.topia.persistence.TopiaEntity;
+import org.nuiton.topia.persistence.TopiaId;
import java.util.Date;
import java.util.List;
@@ -188,6 +190,17 @@
throw new EchoBaseTechnicalException("Could not obtain query db", e);
}
}
+
+ protected <E extends TopiaEntity> TopiaDAO<E> getDAOFromId(String id) {
+ try {
+ return getDAO(TopiaId.getClassName(id));
+ } catch (TopiaNotFoundException e) {
+
+ throw new EchoBaseTechnicalException(
+ "Could not find class from id: " + id, e);
+ }
+ }
+
protected final <E extends TopiaEntity, D extends TopiaDAO<E>> D getDAO(Class<E> entityType, Class<D> daoType) {
TopiaDAO<E> dao = getDAO(entityType);
Preconditions.checkState(daoType.isAssignableFrom(dao.getClass()));
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/DbEditorService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/DbEditorService.java 2012-09-08 11:23:33 UTC (rev 637)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/DbEditorService.java 2012-09-09 19:57:02 UTC (rev 638)
@@ -76,7 +76,7 @@
return getService(DecoratorService.class);
}
- public <E extends TopiaEntity> List<E> getForeignDatas(Class<E> entityType) {
+ public <E extends TopiaEntity> List<E> getForeignData(Class<E> entityType) {
Preconditions.checkNotNull(entityType);
try {
TopiaDAO<E> dao = getDAO(entityType);
@@ -95,10 +95,10 @@
}
//TODO Use an object to filter datas
- public Map<?, ?>[] getDatas(EchoBaseEntityEnum entityType,
- TopiaFilterPagerUtil.FilterPagerBean pager,
- String sidx,
- Boolean ascendantOrder) {
+ public Map<?, ?>[] getData(EchoBaseEntityEnum entityType,
+ TopiaFilterPagerUtil.FilterPagerBean pager,
+ String sidx,
+ Boolean ascendantOrder) {
TableMeta<EchoBaseEntityEnum> meta = getTableMeta(entityType);
@@ -294,7 +294,7 @@
TopiaDAO<E> dao = (TopiaDAO<E>) getDAO(tableMeta.getSource().getContract());
String hql = "FROM " +
- dao.getTopiaEntityEnum().getImplementationFQN()+" e";
+ dao.getTopiaEntityEnum().getImplementationFQN() + " e";
if (extraWhereQuery != null) {
hql += " WHERE " + extraWhereQuery;
}
@@ -551,7 +551,7 @@
if (columnMeta.isFK()) {
Class<TopiaEntity> entityType = (Class<TopiaEntity>) type;
- Collection<TopiaEntity> universe = getForeignDatas(entityType);
+ Collection<TopiaEntity> universe = getForeignData(entityType);
// translate foreign key to his id
model.addForeignKeyForImport(propertyName, entityType, universe);
@@ -607,6 +607,10 @@
model.addDefaultColumn(propertyName, type);
}
+ } else if ("importId".equals(propertyName) &&
+ Collection.class.equals(type)) {
+
+ // special case we do not want to deal with {@link ImportLog#importId}
} else {
model.addDefaultColumn(propertyName, type);
}
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/AbstractImportDataService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/AbstractImportDataService.java 2012-09-08 11:23:33 UTC (rev 637)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/AbstractImportDataService.java 2012-09-09 19:57:02 UTC (rev 638)
@@ -94,14 +94,9 @@
public static final TimeLog TIME_LOG =
new TimeLog(AbstractImportDataService.class);
- protected String importLabel;
-
public final String doImport(M configuration,
EchoBaseUser user) throws ImportException {
- Locale locale = getLocale();
- importLabel = l_(locale, configuration.getImportType().getI18nKey());
-
long s0 = TimeLog.getTime();
long nbSteps = configuration.computeNbSteps();
@@ -121,7 +116,7 @@
TimeLog.getTime() - s0);
// do commit
- commitTransaction("Could not execute import " + getImportLabel());
+ commitTransaction("Could not execute import " + getImportLabel(configuration));
return result;
} catch (EchoBaseTechnicalException e) {
throw new ImportException(e.getMessage(), e);
@@ -146,7 +141,7 @@
ImportLog.PROPERTY_IMPORT_TEXT, configuration.getImportNotes());
- String importType = getImportLabel();
+ String importType = getImportLabel(configuration);
StringBuilder buffer = new StringBuilder();
@@ -195,8 +190,10 @@
return result;
}
- protected final String getImportLabel() {
- return importLabel;
+ protected final String getImportLabel(M configuration) {
+ Locale locale = getLocale();
+ String result = l_(locale, configuration.getImportType().getI18nKey());
+ return result;
}
protected abstract void startImport(M configuration,
@@ -272,9 +269,9 @@
}
}
- protected String getImportMessage(InputFile inputFile) {
+ protected String getImportMessage(M configuration, InputFile inputFile) {
String message = l_(getLocale(), "echobase.importLabel.withFile",
- getImportLabel(), inputFile.getFileName());
+ getImportLabel(configuration), inputFile.getFileName());
return message;
}
@@ -284,7 +281,7 @@
configuration.incrementsProgression();
if (rowNumber % 1000 == 0) {
// flush each 1000 imported rows
- String message = getImportMessage(inputFile);
+ String message = getImportMessage(configuration, inputFile);
try {
long s0 = TimeLog.getTime();
flushTransaction();
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/AcousticImportService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/AcousticImportService.java 2012-09-08 11:23:33 UTC (rev 637)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/AcousticImportService.java 2012-09-09 19:57:02 UTC (rev 638)
@@ -142,7 +142,7 @@
InputFile inputFile = configuration.getMoviesFile();
if (log.isInfoEnabled()) {
- log.info("Starts " + getImportMessage(inputFile));
+ log.info("Starts " + getImportMessage(configuration, inputFile));
}
EchoBaseCsvFileImportResult importResult = newImportResult(inputFile);
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdb/ImportService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdb/ImportService.java 2012-09-08 11:23:33 UTC (rev 637)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdb/ImportService.java 2012-09-09 19:57:02 UTC (rev 638)
@@ -77,7 +77,7 @@
if (columnMeta.isFK()) {
Class<TopiaEntity> entityType = (Class<TopiaEntity>) type;
- Collection<TopiaEntity> universe = service.getForeignDatas(entityType);
+ Collection<TopiaEntity> universe = service.getForeignData(entityType);
model.addForeignKeyForImport(propertyName, entityType, universe);
} else {
model.addDefaultColumn(propertyName, type);
Deleted: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/AbstractRemoveDataService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/AbstractRemoveDataService.java 2012-09-08 11:23:33 UTC (rev 637)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/AbstractRemoveDataService.java 2012-09-09 19:57:02 UTC (rev 638)
@@ -1,239 +0,0 @@
-package fr.ifremer.echobase.services.removedata;
-
-/*
- * #%L
- * EchoBase :: Services
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2011 - 2012 Ifremer, Codelutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- * #L%
- */
-
-import com.google.common.collect.Lists;
-import fr.ifremer.echobase.EchoBaseTechnicalException;
-import fr.ifremer.echobase.entities.EchoBaseUser;
-import fr.ifremer.echobase.entities.EntityModificationLog;
-import fr.ifremer.echobase.entities.ImportLog;
-import fr.ifremer.echobase.entities.ImportType;
-import fr.ifremer.echobase.services.DecoratorService;
-import fr.ifremer.echobase.services.EchoBaseServiceSupport;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.nuiton.topia.TopiaException;
-import org.nuiton.topia.TopiaNotFoundException;
-import org.nuiton.topia.persistence.TopiaDAO;
-import org.nuiton.topia.persistence.TopiaEntity;
-import org.nuiton.topia.persistence.TopiaId;
-import org.nuiton.util.StringUtil;
-import org.nuiton.util.TimeLog;
-import org.nuiton.util.decorator.Decorator;
-
-import java.util.List;
-import java.util.Locale;
-import java.util.Set;
-
-import static org.nuiton.i18n.I18n.l_;
-
-/**
- * Abstract service to remove import data.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.2
- */
-public abstract class AbstractRemoveDataService extends EchoBaseServiceSupport {
-
- /** Logger. */
- private static final Log log =
- LogFactory.getLog(AbstractRemoveDataService.class);
-
- public static final TimeLog TIME_LOG =
- new TimeLog(AbstractRemoveDataService.class);
-
- protected static final String ID_REQUEST =
- "SELECT COUNT(*) FROM %s WHERE topiaid = :id";
-
- protected String importLabel;
-
- public String getImportLabel() {
- return importLabel;
- }
-
- protected abstract void removeData(String id);
-
- protected abstract Set<ImportType> getPossibleSubImportType();
-
- public String doRemove(ImportLog importLog, EchoBaseUser user) {
-
- Locale locale = getLocale();
- importLabel = l_(locale, importLog.getImportType().getI18nKey());
-
- long s0 = TimeLog.getTime();
-
- for (String importId : importLog.getImportId()) {
-
- removeData(importId);
- }
-
- s0 = TIME_LOG.log(s0, "removeData");
-
- List<ImportLog> removedImortLog = removeObsoleteImportLogs(importLog);
-
- s0 = TIME_LOG.log(s0, "removeObsoleteImportLogs");
-
- // add result in log book and compute resume to show in result
- String result = computeLogBookEntry(importLog,
- removedImortLog,
- user,
- TimeLog.getTime() - s0);
-
- // do commit
- commitTransaction("Could not remove import " + getImportLabel());
- return result;
- }
-
- protected List<ImportLog> removeObsoleteImportLogs(ImportLog importLog) {
-
- List<ImportLog> result = Lists.newArrayList();
-
- Set<ImportType> possibleSubImportType = getPossibleSubImportType();
-
- TopiaDAO<ImportLog> dao = getDAO(ImportLog.class);
-
- for (ImportLog logEntry : dao) {
-
- if (importLog.equals(logEntry)) {
-
- // for sure remove me
- // but do not add to result
- delete(dao, logEntry);
- continue;
- }
-
- if (possibleSubImportType.contains(logEntry.getImportType())) {
-
- // ok can try to remove this import log
- // try to find out if first id is still exists
- String firstId = importLog.getImportId().iterator().next();
-
- if (!isIdExists(firstId)) {
-
- // one of id does not exist, can safely remove importLog
-
- if (log.isInfoEnabled()) {
- log.info("Will remove obsolete importLog " +
- importLog.getTopiaId());
- }
-
- delete(dao, logEntry);
-
- // add it in result
- result.add(logEntry);
- }
- }
- }
- return result;
- }
-
- protected String computeLogBookEntry(ImportLog importLog,
- List<ImportLog> obsoleteImportLogs,
- EchoBaseUser user,
- long time) {
-
- Decorator<ImportLog> decorator = getService(DecoratorService.class).
- getDecorator(getLocale(), ImportLog.class, null);
-
- StringBuilder buffer = new StringBuilder();
- buffer.append("Suppression import ");
- buffer.append(decorator.toString(importLog));
- buffer.append("\nOpération réalisée en ");
- buffer.append(StringUtil.convertTime(time));
-
- for (ImportLog obsoleteImportLog : obsoleteImportLogs) {
-
- buffer.append("\n- Suppression en cascade de l'import ");
- buffer.append(decorator.toString(obsoleteImportLog));
- }
-
- String result = buffer.toString();
-
- if (log.isDebugEnabled()) {
- log.debug("Log text: " + result);
- }
- create(getDAO(EntityModificationLog.class),
- EntityModificationLog.PROPERTY_ENTITY_TYPE, "Remove Import",
- EntityModificationLog.PROPERTY_ENTITY_ID, importLog.getImportType(),
- EntityModificationLog.PROPERTY_MODIFICATION_USER, user.getEmail(),
- EntityModificationLog.PROPERTY_MODIFICATION_DATE, newDate(),
- EntityModificationLog.PROPERTY_MODIFICATION_TEXT, result
- );
- return result;
- }
-
- protected boolean isIdExists(String id) {
-
- try {
-
- boolean result = getDAOFromId(id).existByTopiaId(id);
- return result;
- } catch (TopiaException e) {
- throw new EchoBaseTechnicalException(
- "Could not find out if id " + id + " exists.", e);
- }
- }
-
- protected <E extends TopiaEntity> E findById(TopiaDAO<E> dao, String id) {
-
- try {
- E result = dao.findByTopiaId(id);
- return result;
- } catch (TopiaException e) {
- throw new EchoBaseTechnicalException("Could not find entity with id " + id, e);
- }
- }
-
- protected <E extends TopiaEntity> TopiaDAO<E> getDAOFromId(String id) {
- try {
- return getDAO(TopiaId.getClassName(id));
- } catch (TopiaNotFoundException e) {
-
- throw new EchoBaseTechnicalException(
- "Could not find class from id: " + id, e);
- }
- }
-
- protected <E extends TopiaEntity> E removeEntity(String id) {
-
- // get dao
- TopiaDAO<E> dao = getDAOFromId(id);
-
- // get entity to delete
- E entity = findById(dao, id);
-
- // delete it
- delete(dao, entity);
-
- return entity;
- }
-
-
- protected void canNotDealWithId(String id) {
- throw new IllegalStateException(
- "Can not deal with this type of id " + id +
- " from service " + this);
- }
-
-}
Deleted: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/AcousticRemoveDataService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/AcousticRemoveDataService.java 2012-09-08 11:23:33 UTC (rev 637)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/AcousticRemoveDataService.java 2012-09-09 19:57:02 UTC (rev 638)
@@ -1,90 +0,0 @@
-package fr.ifremer.echobase.services.removedata;
-
-/*
- * #%L
- * EchoBase :: Services
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2011 - 2012 Ifremer, Codelutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- * #L%
- */
-
-import com.google.common.collect.Sets;
-import fr.ifremer.echobase.entities.ImportType;
-import fr.ifremer.echobase.entities.data.Cell;
-import fr.ifremer.echobase.entities.data.DataAcquisition;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import java.util.HashSet;
-import java.util.Set;
-
-/**
- * Remove a {@link ImportType#ACOUSTIC} import.
- * <p/>
- * Can remove only {@link DataAcquisition} or {@link Cell}.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.2
- */
-public class AcousticRemoveDataService extends AbstractRemoveDataService {
-
- /** Logger. */
- private static final Log log =
- LogFactory.getLog(AcousticRemoveDataService.class);
-
- @Override
- protected void removeData(String id) {
-
- if (id.startsWith(DataAcquisition.class.getName())) {
-
- // remove dataAcquisition
- removeDataAcquisition(id);
- } else if (id.startsWith(Cell.class.getName())) {
-
- // remove cell
- removeCell(id);
- } else {
- canNotDealWithId(id);
- }
- }
-
- protected void removeDataAcquisition(String id) {
- DataAcquisition entity = removeEntity(id);
- if (log.isInfoEnabled()) {
- log.info("DataAcquisition " + entity.getTopiaId() + " was removed");
- }
- }
-
- protected void removeCell(String id) {
- Cell entity = removeEntity(id);
- if (log.isInfoEnabled()) {
- log.info("Cell " + entity.getTopiaId() + " was removed");
- }
- }
-
- @Override
- protected Set<ImportType> getPossibleSubImportType() {
- HashSet<ImportType> result = Sets.newHashSet(ImportType.values());
- result.remove(ImportType.COMMON_ALL);
- result.remove(ImportType.COMMON_TRANSECT);
- result.remove(ImportType.OPERATION);
- result.remove(ImportType.CATCHES);
- result.remove(ImportType.ACOUSTIC);
- return result;
- }
-}
Deleted: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/CatchesRemoveDataService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/CatchesRemoveDataService.java 2012-09-08 11:23:33 UTC (rev 637)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/CatchesRemoveDataService.java 2012-09-09 19:57:02 UTC (rev 638)
@@ -1,77 +0,0 @@
-package fr.ifremer.echobase.services.removedata;
-
-/*
- * #%L
- * EchoBase :: Services
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2011 - 2012 Ifremer, Codelutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- * #L%
- */
-
-import com.google.common.collect.Sets;
-import fr.ifremer.echobase.entities.ImportType;
-import fr.ifremer.echobase.entities.data.Sample;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import java.util.HashSet;
-import java.util.Set;
-
-/**
- * Remove a {@link ImportType#CATCHES} import.
- * <p/>
- * Can remove only {@link Sample}.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.2
- */
-public class CatchesRemoveDataService extends AbstractRemoveDataService {
-
- /** Logger. */
- private static final Log log =
- LogFactory.getLog(CatchesRemoveDataService.class);
-
- @Override
- protected void removeData(String id) {
-
- if (id.startsWith(Sample.class.getName())) {
-
- // remove sample
- removeSample(id);
- } else {
- canNotDealWithId(id);
- }
- }
-
- protected void removeSample(String id) {
- Sample entity = removeEntity(id);
- if (log.isInfoEnabled()) {
- log.info("Sample " + entity.getTopiaId() + " was removed");
- }
- }
-
- @Override
- protected Set<ImportType> getPossibleSubImportType() {
- HashSet<ImportType> result = Sets.newHashSet(ImportType.values());
- result.remove(ImportType.COMMON_ALL);
- result.remove(ImportType.COMMON_TRANSECT);
- result.remove(ImportType.OPERATION);
- result.remove(ImportType.CATCHES);
- return result;
- }
-}
Deleted: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/CommonAllRemoveDataService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/CommonAllRemoveDataService.java 2012-09-08 11:23:33 UTC (rev 637)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/CommonAllRemoveDataService.java 2012-09-09 19:57:02 UTC (rev 638)
@@ -1,75 +0,0 @@
-package fr.ifremer.echobase.services.removedata;
-
-/*
- * #%L
- * EchoBase :: Services
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2011 - 2012 Ifremer, Codelutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- * #L%
- */
-
-import com.google.common.collect.Sets;
-import fr.ifremer.echobase.entities.ImportType;
-import fr.ifremer.echobase.entities.data.Voyage;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import java.util.HashSet;
-import java.util.Set;
-
-/**
- * Remove a {@link ImportType#COMMON_ALL} import.
- * <p/>
- * Can remove only {@link Voyage}.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.2
- */
-public class CommonAllRemoveDataService extends AbstractRemoveDataService {
-
- /** Logger. */
- private static final Log log =
- LogFactory.getLog(CommonAllRemoveDataService.class);
-
- @Override
- protected void removeData(String id) {
-
- if (id.startsWith(Voyage.class.getName())) {
-
- // remove voyage
- removeVoyage(id);
- } else {
- canNotDealWithId(id);
- }
- }
-
- protected void removeVoyage(String id) {
- Voyage entity = removeEntity(id);
- if (log.isInfoEnabled()) {
- log.info("Voyage " + entity.getTopiaId() + " was removed");
- }
- }
-
- @Override
- protected Set<ImportType> getPossibleSubImportType() {
- HashSet<ImportType> result = Sets.newHashSet(ImportType.values());
- result.remove(ImportType.COMMON_ALL);
- result.remove(ImportType.COMMON_TRANSECT);
- return result;
- }
-}
Deleted: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/CommonTransectRemoveDataService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/CommonTransectRemoveDataService.java 2012-09-08 11:23:33 UTC (rev 637)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/CommonTransectRemoveDataService.java 2012-09-09 19:57:02 UTC (rev 638)
@@ -1,75 +0,0 @@
-package fr.ifremer.echobase.services.removedata;
-
-/*
- * #%L
- * EchoBase :: Services
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2011 - 2012 Ifremer, Codelutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- * #L%
- */
-
-import com.google.common.collect.Sets;
-import fr.ifremer.echobase.entities.ImportType;
-import fr.ifremer.echobase.entities.data.Transect;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import java.util.HashSet;
-import java.util.Set;
-
-/**
- * Remove a {@link ImportType#COMMON_TRANSECT} import.
- * <p/>
- * Can remove only {@link Transect}.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.2
- */
-public class CommonTransectRemoveDataService extends AbstractRemoveDataService {
-
- /** Logger. */
- private static final Log log =
- LogFactory.getLog(CommonTransectRemoveDataService.class);
-
- @Override
- protected void removeData(String id) {
-
- if (id.startsWith(Transect.class.getName())) {
-
- // remove transect
- removeTransect(id);
- } else {
- canNotDealWithId(id);
- }
- }
-
- protected void removeTransect(String id) {
- Transect entity = removeEntity(id);
- if (log.isInfoEnabled()) {
- log.info("Transect " + entity.getTopiaId() + " was removed");
- }
- }
-
- @Override
- protected Set<ImportType> getPossibleSubImportType() {
- HashSet<ImportType> result = Sets.newHashSet(ImportType.values());
- result.remove(ImportType.COMMON_ALL);
- result.remove(ImportType.COMMON_TRANSECT);
- return result;
- }
-}
Deleted: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/OperationRemoveDataService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/OperationRemoveDataService.java 2012-09-08 11:23:33 UTC (rev 637)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/OperationRemoveDataService.java 2012-09-09 19:57:02 UTC (rev 638)
@@ -1,76 +0,0 @@
-package fr.ifremer.echobase.services.removedata;
-
-/*
- * #%L
- * EchoBase :: Services
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2011 - 2012 Ifremer, Codelutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- * #L%
- */
-
-import com.google.common.collect.Sets;
-import fr.ifremer.echobase.entities.ImportType;
-import fr.ifremer.echobase.entities.data.Operation;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import java.util.HashSet;
-import java.util.Set;
-
-/**
- * Remove a {@link ImportType#OPERATION} import.
- * <p/>
- * Can remove only {@link Operation}.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.2
- */
-public class OperationRemoveDataService extends AbstractRemoveDataService {
-
- /** Logger. */
- private static final Log log =
- LogFactory.getLog(OperationRemoveDataService.class);
-
- @Override
- protected void removeData(String id) {
-
- if (id.startsWith(Operation.class.getName())) {
-
- // remove operation
- removeOperation(id);
- } else {
- canNotDealWithId(id);
- }
- }
-
- protected void removeOperation(String id) {
- Operation entity = removeEntity(id);
- if (log.isInfoEnabled()) {
- log.info("Operation " + entity.getTopiaId() + " was removed");
- }
- }
-
- @Override
- protected Set<ImportType> getPossibleSubImportType() {
- HashSet<ImportType> result = Sets.newHashSet(ImportType.values());
- result.remove(ImportType.COMMON_ALL);
- result.remove(ImportType.COMMON_TRANSECT);
- result.remove(ImportType.OPERATION);
- return result;
- }
-}
Added: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/RemoveDataConfiguration.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/RemoveDataConfiguration.java (rev 0)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/RemoveDataConfiguration.java 2012-09-09 19:57:02 UTC (rev 638)
@@ -0,0 +1,47 @@
+package fr.ifremer.echobase.services.removedata;
+
+/*
+ * #%L
+ * EchoBase :: Services
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 - 2012 Ifremer, Codelutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+
+import fr.ifremer.echobase.services.AbstractEchobaseActionConfiguration;
+
+/**
+ * Configuration for a remve data action.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.2
+ */
+public class RemoveDataConfiguration extends AbstractEchobaseActionConfiguration {
+
+ private static final long serialVersionUID = 1L;
+
+ private String importLogId;
+
+ public String getImportLogId() {
+ return importLogId;
+ }
+
+ public void setImportLogId(String importLogId) {
+ this.importLogId = importLogId;
+ }
+}
Property changes on: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/RemoveDataConfiguration.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/RemoveDataService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/RemoveDataService.java (rev 0)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/RemoveDataService.java 2012-09-09 19:57:02 UTC (rev 638)
@@ -0,0 +1,226 @@
+package fr.ifremer.echobase.services.removedata;
+
+/*
+ * #%L
+ * EchoBase :: Services
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 - 2012 Ifremer, Codelutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+
+import com.google.common.base.Preconditions;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import fr.ifremer.echobase.EchoBaseTechnicalException;
+import fr.ifremer.echobase.entities.EchoBaseUser;
+import fr.ifremer.echobase.entities.EntityModificationLog;
+import fr.ifremer.echobase.entities.ImportLog;
+import fr.ifremer.echobase.entities.ImportType;
+import fr.ifremer.echobase.services.DecoratorService;
+import fr.ifremer.echobase.services.EchoBaseServiceSupport;
+import fr.ifremer.echobase.services.removedata.strategy.AbstractRemoveDataStrategy;
+import fr.ifremer.echobase.services.removedata.strategy.AcousticRemoveDataStrategy;
+import fr.ifremer.echobase.services.removedata.strategy.CatchesRemoveDataStrategy;
+import fr.ifremer.echobase.services.removedata.strategy.CommonAllRemoveDataStrategy;
+import fr.ifremer.echobase.services.removedata.strategy.CommonTransectRemoveDataStrategy;
+import fr.ifremer.echobase.services.removedata.strategy.OperationRemoveDataStrategy;
+import fr.ifremer.echobase.services.removedata.strategy.ResultEsduRemoveDataStrategy;
+import fr.ifremer.echobase.services.removedata.strategy.ResultMapRemoveDataStrategy;
+import fr.ifremer.echobase.services.removedata.strategy.ResultRegionRemoveDataStrategy;
+import fr.ifremer.echobase.services.removedata.strategy.ResultVoyageRemoveDataStrategy;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.topia.TopiaException;
+import org.nuiton.topia.persistence.TopiaDAO;
+import org.nuiton.util.StringUtil;
+import org.nuiton.util.TimeLog;
+import org.nuiton.util.decorator.Decorator;
+
+import java.util.EnumMap;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * Service to remove an import data.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.2
+ */
+public class RemoveDataService extends EchoBaseServiceSupport {
+
+ /** Logger. */
+ private static final Log log = LogFactory.getLog(RemoveDataService.class);
+
+
+ public static final TimeLog TIME_LOG = new TimeLog(RemoveDataService.class);
+
+ protected static EnumMap<ImportType, Class<? extends AbstractRemoveDataStrategy>> strategies;
+
+ public static Class<? extends AbstractRemoveDataStrategy> getStrategy(ImportType importType) {
+ if (strategies == null) {
+ strategies = Maps.newEnumMap(ImportType.class);
+ strategies.put(ImportType.COMMON_ALL, CommonAllRemoveDataStrategy.class);
+ strategies.put(ImportType.COMMON_TRANSECT, CommonTransectRemoveDataStrategy.class);
+ strategies.put(ImportType.OPERATION, OperationRemoveDataStrategy.class);
+ strategies.put(ImportType.CATCHES, CatchesRemoveDataStrategy.class);
+ strategies.put(ImportType.ACOUSTIC, AcousticRemoveDataStrategy.class);
+ strategies.put(ImportType.RESULT_VOYAGE, ResultVoyageRemoveDataStrategy.class);
+ strategies.put(ImportType.RESULT_ESDU, ResultEsduRemoveDataStrategy.class);
+ strategies.put(ImportType.RESULT_MAP, ResultMapRemoveDataStrategy.class);
+ strategies.put(ImportType.RESULT_REGION, ResultRegionRemoveDataStrategy.class);
+ Preconditions.checkState(
+ ImportType.values().length == strategies.size(),
+ "It miss some remove data strategies...");
+ }
+ return strategies.get(importType);
+ }
+
+ public String removeImport(RemoveDataConfiguration model, EchoBaseUser user) {
+
+ String importLogId = model.getImportLogId();
+
+ ImportLog importLog = getEntityById(ImportLog.class, importLogId);
+
+ int nbSteps = importLog.getImportId().size() + 3;
+ model.setNbSteps(nbSteps);
+
+ ImportType importType = importLog.getImportType();
+
+ Class<? extends AbstractRemoveDataStrategy> strategyType =
+ getStrategy(importType);
+
+ long s0 = TimeLog.getTime();
+ AbstractRemoveDataStrategy strategy = getService(strategyType);
+
+ strategy.doRemove(model, importLog);
+
+ s0 = TIME_LOG.log(s0, "removeData");
+
+ List<ImportLog> removedImportLog = removeObsoleteImportLogs(strategy,
+ importLog);
+
+ model.incrementsProgression();
+ s0 = TIME_LOG.log(s0, "removeObsoleteImportLogs");
+
+ // add result in log book and compute resume to show in result
+ String result = computeLogBookEntry(importLog,
+ removedImportLog,
+ user,
+ TimeLog.getTime() - s0);
+
+ model.incrementsProgression();
+ // do commit
+ commitTransaction("Could not remove import " +
+ strategy.getImportLabel());
+
+ model.incrementsProgression();
+ return result;
+ }
+
+ protected List<ImportLog> removeObsoleteImportLogs(AbstractRemoveDataStrategy strategy,
+ ImportLog importLog) {
+
+ List<ImportLog> result = Lists.newArrayList();
+
+ Set<ImportType> possibleSubImportType =
+ strategy.getPossibleSubImportType();
+
+ TopiaDAO<ImportLog> dao = getDAO(ImportLog.class);
+
+ for (ImportLog logEntry : dao) {
+
+ if (importLog.equals(logEntry)) {
+
+ // for sure remove me
+ // but do not add to result
+ delete(dao, logEntry);
+ continue;
+ }
+
+ if (possibleSubImportType.contains(logEntry.getImportType())) {
+
+ // ok can try to remove this import log
+ // try to find out if first id is still exists
+ String firstId = importLog.getImportId().iterator().next();
+
+ if (!isIdExists(firstId)) {
+
+ // one of id does not exist, can safely remove importLog
+
+ if (log.isInfoEnabled()) {
+ log.info("Will remove obsolete importLog " +
+ importLog.getTopiaId());
+ }
+
+ delete(dao, logEntry);
+
+ // add it in result
+ result.add(logEntry);
+ }
+ }
+ }
+ return result;
+ }
+
+ protected String computeLogBookEntry(ImportLog importLog,
+ List<ImportLog> obsoleteImportLogs,
+ EchoBaseUser user,
+ long time) {
+
+ Decorator<ImportLog> decorator = getService(DecoratorService.class).
+ getDecorator(getLocale(), ImportLog.class, null);
+
+ StringBuilder buffer = new StringBuilder();
+ buffer.append("Suppression import ");
+ buffer.append(decorator.toString(importLog));
+ buffer.append("\nOpération réalisée en ");
+ buffer.append(StringUtil.convertTime(time));
+
+ for (ImportLog obsoleteImportLog : obsoleteImportLogs) {
+
+ buffer.append("\n- Suppression en cascade de l'import ");
+ buffer.append(decorator.toString(obsoleteImportLog));
+ }
+
+ String result = buffer.toString();
+
+ if (log.isDebugEnabled()) {
+ log.debug("Log text: " + result);
+ }
+ create(getDAO(EntityModificationLog.class),
+ EntityModificationLog.PROPERTY_ENTITY_TYPE, "Remove Import",
+ EntityModificationLog.PROPERTY_ENTITY_ID, decorator.toString(importLog),
+ EntityModificationLog.PROPERTY_MODIFICATION_USER, user.getEmail(),
+ EntityModificationLog.PROPERTY_MODIFICATION_DATE, newDate(),
+ EntityModificationLog.PROPERTY_MODIFICATION_TEXT, result
+ );
+ return result;
+ }
+
+ protected boolean isIdExists(String id) {
+
+ try {
+
+ boolean result = getDAOFromId(id).existByTopiaId(id);
+ return result;
+ } catch (TopiaException e) {
+ throw new EchoBaseTechnicalException(
+ "Could not find out if id " + id + " exists.", e);
+ }
+ }
+}
Property changes on: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/RemoveDataService.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Deleted: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/ResultEsduRemoveDataService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/ResultEsduRemoveDataService.java 2012-09-08 11:23:33 UTC (rev 637)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/ResultEsduRemoveDataService.java 2012-09-09 19:57:02 UTC (rev 638)
@@ -1,80 +0,0 @@
-package fr.ifremer.echobase.services.removedata;
-
-/*
- * #%L
- * EchoBase :: Services
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2011 - 2012 Ifremer, Codelutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- * #L%
- */
-
-import com.google.common.collect.Sets;
-import fr.ifremer.echobase.entities.ImportType;
-import fr.ifremer.echobase.entities.data.Result;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import java.util.HashSet;
-import java.util.Set;
-
-/**
- * Remove a {@link ImportType#RESULT_ESDU} import.
- * <p/>
- * Can remove only {@link Result}.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.2
- */
-public class ResultEsduRemoveDataService extends AbstractRemoveDataService {
-
- /** Logger. */
- private static final Log log =
- LogFactory.getLog(ResultEsduRemoveDataService.class);
-
- @Override
- protected void removeData(String id) {
-
- if (id.startsWith(Result.class.getName())) {
-
- // remove result
- removeResult(id);
- } else {
- canNotDealWithId(id);
- }
- }
-
- protected void removeResult(String id) {
- Result entity = removeEntity(id);
- if (log.isInfoEnabled()) {
- log.info("Result " + entity.getTopiaId() + " was removed");
- }
- }
-
- @Override
- protected Set<ImportType> getPossibleSubImportType() {
- HashSet<ImportType> result = Sets.newHashSet(ImportType.values());
- result.remove(ImportType.COMMON_ALL);
- result.remove(ImportType.COMMON_TRANSECT);
- result.remove(ImportType.OPERATION);
- result.remove(ImportType.CATCHES);
- result.remove(ImportType.ACOUSTIC);
- result.remove(ImportType.RESULT_VOYAGE);
- result.remove(ImportType.RESULT_ESDU);
- return result;
- }
-}
Deleted: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/ResultMapRemoveDataService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/ResultMapRemoveDataService.java 2012-09-08 11:23:33 UTC (rev 637)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/ResultMapRemoveDataService.java 2012-09-09 19:57:02 UTC (rev 638)
@@ -1,73 +0,0 @@
-package fr.ifremer.echobase.services.removedata;
-
-/*
- * #%L
- * EchoBase :: Services
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2011 - 2012 Ifremer, Codelutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- * #L%
- */
-
-import com.google.common.collect.Sets;
-import fr.ifremer.echobase.entities.ImportType;
-import fr.ifremer.echobase.entities.data.Cell;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import java.util.HashSet;
-import java.util.Set;
-
-/**
- * Remove a {@link ImportType#RESULT_MAP} import.
- * <p/>
- * Can remove only {@link Cell}.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.2
- */
-public class ResultMapRemoveDataService extends AbstractRemoveDataService {
-
- /** Logger. */
- private static final Log log =
- LogFactory.getLog(ResultMapRemoveDataService.class);
-
- @Override
- protected void removeData(String id) {
-
- if (id.startsWith(Cell.class.getName())) {
-
- // remove cell
- removeCell(id);
- } else {
- canNotDealWithId(id);
- }
- }
-
- protected void removeCell(String id) {
- Cell entity = removeEntity(id);
- if (log.isInfoEnabled()) {
- log.info("Cell " + entity.getTopiaId() + " was removed");
- }
- }
-
- @Override
- protected Set<ImportType> getPossibleSubImportType() {
- HashSet<ImportType> result = Sets.newHashSet();
- return result;
- }
-}
Deleted: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/ResultRegionRemoveDataService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/ResultRegionRemoveDataService.java 2012-09-08 11:23:33 UTC (rev 637)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/ResultRegionRemoveDataService.java 2012-09-09 19:57:02 UTC (rev 638)
@@ -1,81 +0,0 @@
-package fr.ifremer.echobase.services.removedata;
-
-/*
- * #%L
- * EchoBase :: Services
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2011 - 2012 Ifremer, Codelutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- * #L%
- */
-
-import com.google.common.collect.Sets;
-import fr.ifremer.echobase.entities.ImportType;
-import fr.ifremer.echobase.entities.data.Cell;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import java.util.HashSet;
-import java.util.Set;
-
-/**
- * Remove a {@link ImportType#RESULT_REGION} import.
- * <p/>
- * Can remove only {@link Cell}.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.2
- */
-public class ResultRegionRemoveDataService extends AbstractRemoveDataService {
-
- /** Logger. */
- private static final Log log =
- LogFactory.getLog(ResultRegionRemoveDataService.class);
-
- @Override
- protected void removeData(String id) {
-
- if (id.startsWith(Cell.class.getName())) {
-
- // remove echotype
- removeCell(id);
- } else {
- canNotDealWithId(id);
- }
- }
-
- protected void removeCell(String id) {
- Cell entity = removeEntity(id);
- if (log.isInfoEnabled()) {
- log.info("Cell " + entity.getTopiaId() + " was removed");
- }
- }
-
- @Override
- protected Set<ImportType> getPossibleSubImportType() {
- HashSet<ImportType> result = Sets.newHashSet(ImportType.values());
- result.remove(ImportType.COMMON_ALL);
- result.remove(ImportType.COMMON_TRANSECT);
- result.remove(ImportType.OPERATION);
- result.remove(ImportType.CATCHES);
- result.remove(ImportType.ACOUSTIC);
- result.remove(ImportType.RESULT_VOYAGE);
- result.remove(ImportType.RESULT_ESDU);
- result.remove(ImportType.RESULT_VOYAGE);
- return result;
- }
-}
Deleted: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/ResultVoyageRemoveDataService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/ResultVoyageRemoveDataService.java 2012-09-08 11:23:33 UTC (rev 637)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/ResultVoyageRemoveDataService.java 2012-09-09 19:57:02 UTC (rev 638)
@@ -1,104 +0,0 @@
-package fr.ifremer.echobase.services.removedata;
-
-/*
- * #%L
- * EchoBase :: Services
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2011 - 2012 Ifremer, Codelutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- * #L%
- */
-
-import com.google.common.collect.Sets;
-import fr.ifremer.echobase.entities.ImportType;
-import fr.ifremer.echobase.entities.data.Echotype;
-import fr.ifremer.echobase.entities.data.LengthAgeKey;
-import fr.ifremer.echobase.entities.data.LengthWeightKey;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import java.util.HashSet;
-import java.util.Set;
-
-/**
- * remove a {@link ImportType#OPERATION} import.
- * <p/>
- * Can remove only {@link Echotype}, {@link LengthAgeKey} or
- * {@link LengthWeightKey}.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.2
- */
-public class ResultVoyageRemoveDataService extends AbstractRemoveDataService {
-
- /** Logger. */
- private static final Log log =
- LogFactory.getLog(ResultVoyageRemoveDataService.class);
-
- @Override
- protected void removeData(String id) {
-
- if (id.startsWith(Echotype.class.getName())) {
-
- // remove echotype
- removeEchotype(id);
- } else if (id.startsWith(LengthAgeKey.class.getName())) {
-
- // remove lengthAgeKey
- removeLengthAgeKey(id);
- } else if (id.startsWith(LengthWeightKey.class.getName())) {
-
- // remove lengthAgeKey
- removeLengthWeightKey(id);
- } else {
- canNotDealWithId(id);
- }
- }
-
- protected void removeEchotype(String id) {
- Echotype entity = removeEntity(id);
- if (log.isInfoEnabled()) {
- log.info("Echotype " + entity.getTopiaId() + " was removed");
- }
- }
-
- protected void removeLengthAgeKey(String id) {
- LengthAgeKey entity = removeEntity(id);
- if (log.isInfoEnabled()) {
- log.info("LengthAgeKey " + entity.getTopiaId() + " was removed");
- }
- }
-
- protected void removeLengthWeightKey(String id) {
- LengthWeightKey entity = removeEntity(id);
- if (log.isInfoEnabled()) {
- log.info("LengthWeightKey " + entity.getTopiaId() + " was removed");
- }
- }
-
- @Override
- protected Set<ImportType> getPossibleSubImportType() {
- HashSet<ImportType> result = Sets.newHashSet(ImportType.values());
- result.remove(ImportType.COMMON_ALL);
- result.remove(ImportType.COMMON_TRANSECT);
- result.remove(ImportType.OPERATION);
- result.remove(ImportType.CATCHES);
- result.remove(ImportType.ACOUSTIC);
- result.remove(ImportType.RESULT_VOYAGE);
- return result;
- }
-}
Copied: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/AbstractRemoveDataStrategy.java (from rev 636, trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/AbstractRemoveDataService.java)
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/AbstractRemoveDataStrategy.java (rev 0)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/AbstractRemoveDataStrategy.java 2012-09-09 19:57:02 UTC (rev 638)
@@ -0,0 +1,106 @@
+package fr.ifremer.echobase.services.removedata.strategy;
+
+/*
+ * #%L
+ * EchoBase :: Services
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 - 2012 Ifremer, Codelutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+
+import fr.ifremer.echobase.EchoBaseTechnicalException;
+import fr.ifremer.echobase.entities.ImportLog;
+import fr.ifremer.echobase.entities.ImportType;
+import fr.ifremer.echobase.services.EchoBaseServiceSupport;
+import fr.ifremer.echobase.services.removedata.RemoveDataConfiguration;
+import org.nuiton.topia.TopiaException;
+import org.nuiton.topia.persistence.TopiaDAO;
+import org.nuiton.topia.persistence.TopiaEntity;
+
+import java.util.Set;
+
+/**
+ * Abstract service to remove import data.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.2
+ */
+public abstract class AbstractRemoveDataStrategy extends EchoBaseServiceSupport {
+
+ protected String importLabel;
+
+ public String getImportLabel() {
+ return importLabel;
+ }
+
+ protected abstract void removeData(String id);
+
+ public abstract Set<ImportType> getPossibleSubImportType();
+
+ public void doRemove(RemoveDataConfiguration model, ImportLog importLog) {
+
+ int currentIndex = 0;
+ for (String importId : importLog.getImportId()) {
+
+ currentIndex++;
+
+ if (currentIndex % 1000 == 0) {
+ try {
+ flushTransaction();
+ } catch (TopiaException e) {
+ throw new EchoBaseTechnicalException(
+ "Could not flush transaction", e);
+ }
+ }
+ model.incrementsProgression();
+
+ removeData(importId);
+ }
+ }
+
+ protected <E extends TopiaEntity> E findById(TopiaDAO<E> dao, String id) {
+
+ try {
+ E result = dao.findByTopiaId(id);
+ return result;
+ } catch (TopiaException e) {
+ throw new EchoBaseTechnicalException("Could not find entity with id " + id, e);
+ }
+ }
+
+ protected <E extends TopiaEntity> E removeEntity(String id) {
+
+ // get dao
+ TopiaDAO<E> dao = getDAOFromId(id);
+
+ // get entity to delete
+ E entity = findById(dao, id);
+
+ // delete it
+ delete(dao, entity);
+
+ return entity;
+ }
+
+ protected void canNotDealWithId(String id) {
+ throw new IllegalStateException(
+ "Can not deal with this type of id " + id +
+ " from service " + this);
+ }
+
+}
Property changes on: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/AbstractRemoveDataStrategy.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/AcousticRemoveDataStrategy.java (from rev 636, trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/AcousticRemoveDataService.java)
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/AcousticRemoveDataStrategy.java (rev 0)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/AcousticRemoveDataStrategy.java 2012-09-09 19:57:02 UTC (rev 638)
@@ -0,0 +1,90 @@
+package fr.ifremer.echobase.services.removedata.strategy;
+
+/*
+ * #%L
+ * EchoBase :: Services
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 - 2012 Ifremer, Codelutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+
+import com.google.common.collect.Sets;
+import fr.ifremer.echobase.entities.ImportType;
+import fr.ifremer.echobase.entities.data.Cell;
+import fr.ifremer.echobase.entities.data.DataAcquisition;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * Remove a {@link ImportType#ACOUSTIC} import.
+ * <p/>
+ * Can remove only {@link DataAcquisition} or {@link Cell}.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.2
+ */
+public class AcousticRemoveDataStrategy extends AbstractRemoveDataStrategy {
+
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(AcousticRemoveDataStrategy.class);
+
+ @Override
+ protected void removeData(String id) {
+
+ if (id.startsWith(DataAcquisition.class.getName())) {
+
+ // remove dataAcquisition
+ removeDataAcquisition(id);
+ } else if (id.startsWith(Cell.class.getName())) {
+
+ // remove cell
+ removeCell(id);
+ } else {
+ canNotDealWithId(id);
+ }
+ }
+
+ protected void removeDataAcquisition(String id) {
+ DataAcquisition entity = removeEntity(id);
+ if (log.isInfoEnabled()) {
+ log.info("DataAcquisition " + entity.getTopiaId() + " was removed");
+ }
+ }
+
+ protected void removeCell(String id) {
+ Cell entity = removeEntity(id);
+ if (log.isInfoEnabled()) {
+ log.info("Cell " + entity.getTopiaId() + " was removed");
+ }
+ }
+
+ @Override
+ public Set<ImportType> getPossibleSubImportType() {
+ HashSet<ImportType> result = Sets.newHashSet(ImportType.values());
+ result.remove(ImportType.COMMON_ALL);
+ result.remove(ImportType.COMMON_TRANSECT);
+ result.remove(ImportType.OPERATION);
+ result.remove(ImportType.CATCHES);
+ result.remove(ImportType.ACOUSTIC);
+ return result;
+ }
+}
Property changes on: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/AcousticRemoveDataStrategy.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/CatchesRemoveDataStrategy.java (from rev 636, trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/CatchesRemoveDataService.java)
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/CatchesRemoveDataStrategy.java (rev 0)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/CatchesRemoveDataStrategy.java 2012-09-09 19:57:02 UTC (rev 638)
@@ -0,0 +1,77 @@
+package fr.ifremer.echobase.services.removedata.strategy;
+
+/*
+ * #%L
+ * EchoBase :: Services
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 - 2012 Ifremer, Codelutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+
+import com.google.common.collect.Sets;
+import fr.ifremer.echobase.entities.ImportType;
+import fr.ifremer.echobase.entities.data.Sample;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * Remove a {@link ImportType#CATCHES} import.
+ * <p/>
+ * Can remove only {@link Sample}.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.2
+ */
+public class CatchesRemoveDataStrategy extends AbstractRemoveDataStrategy {
+
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(CatchesRemoveDataStrategy.class);
+
+ @Override
+ protected void removeData(String id) {
+
+ if (id.startsWith(Sample.class.getName())) {
+
+ // remove sample
+ removeSample(id);
+ } else {
+ canNotDealWithId(id);
+ }
+ }
+
+ protected void removeSample(String id) {
+ Sample entity = removeEntity(id);
+ if (log.isInfoEnabled()) {
+ log.info("Sample " + entity.getTopiaId() + " was removed");
+ }
+ }
+
+ @Override
+ public Set<ImportType> getPossibleSubImportType() {
+ HashSet<ImportType> result = Sets.newHashSet(ImportType.values());
+ result.remove(ImportType.COMMON_ALL);
+ result.remove(ImportType.COMMON_TRANSECT);
+ result.remove(ImportType.OPERATION);
+ result.remove(ImportType.CATCHES);
+ return result;
+ }
+}
Property changes on: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/CatchesRemoveDataStrategy.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/CommonAllRemoveDataStrategy.java (from rev 636, trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/CommonAllRemoveDataService.java)
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/CommonAllRemoveDataStrategy.java (rev 0)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/CommonAllRemoveDataStrategy.java 2012-09-09 19:57:02 UTC (rev 638)
@@ -0,0 +1,75 @@
+package fr.ifremer.echobase.services.removedata.strategy;
+
+/*
+ * #%L
+ * EchoBase :: Services
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 - 2012 Ifremer, Codelutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+
+import com.google.common.collect.Sets;
+import fr.ifremer.echobase.entities.ImportType;
+import fr.ifremer.echobase.entities.data.Voyage;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * Remove a {@link ImportType#COMMON_ALL} import.
+ * <p/>
+ * Can remove only {@link Voyage}.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.2
+ */
+public class CommonAllRemoveDataStrategy extends AbstractRemoveDataStrategy {
+
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(CommonAllRemoveDataStrategy.class);
+
+ @Override
+ protected void removeData(String id) {
+
+ if (id.startsWith(Voyage.class.getName())) {
+
+ // remove voyage
+ removeVoyage(id);
+ } else {
+ canNotDealWithId(id);
+ }
+ }
+
+ protected void removeVoyage(String id) {
+ Voyage entity = removeEntity(id);
+ if (log.isInfoEnabled()) {
+ log.info("Voyage " + entity.getTopiaId() + " was removed");
+ }
+ }
+
+ @Override
+ public Set<ImportType> getPossibleSubImportType() {
+ HashSet<ImportType> result = Sets.newHashSet(ImportType.values());
+ result.remove(ImportType.COMMON_ALL);
+ result.remove(ImportType.COMMON_TRANSECT);
+ return result;
+ }
+}
Property changes on: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/CommonAllRemoveDataStrategy.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/CommonTransectRemoveDataStrategy.java (from rev 636, trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/CommonTransectRemoveDataService.java)
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/CommonTransectRemoveDataStrategy.java (rev 0)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/CommonTransectRemoveDataStrategy.java 2012-09-09 19:57:02 UTC (rev 638)
@@ -0,0 +1,75 @@
+package fr.ifremer.echobase.services.removedata.strategy;
+
+/*
+ * #%L
+ * EchoBase :: Services
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 - 2012 Ifremer, Codelutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+
+import com.google.common.collect.Sets;
+import fr.ifremer.echobase.entities.ImportType;
+import fr.ifremer.echobase.entities.data.Transect;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * Remove a {@link ImportType#COMMON_TRANSECT} import.
+ * <p/>
+ * Can remove only {@link Transect}.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.2
+ */
+public class CommonTransectRemoveDataStrategy extends AbstractRemoveDataStrategy {
+
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(CommonTransectRemoveDataStrategy.class);
+
+ @Override
+ protected void removeData(String id) {
+
+ if (id.startsWith(Transect.class.getName())) {
+
+ // remove transect
+ removeTransect(id);
+ } else {
+ canNotDealWithId(id);
+ }
+ }
+
+ protected void removeTransect(String id) {
+ Transect entity = removeEntity(id);
+ if (log.isInfoEnabled()) {
+ log.info("Transect " + entity.getTopiaId() + " was removed");
+ }
+ }
+
+ @Override
+ public Set<ImportType> getPossibleSubImportType() {
+ HashSet<ImportType> result = Sets.newHashSet(ImportType.values());
+ result.remove(ImportType.COMMON_ALL);
+ result.remove(ImportType.COMMON_TRANSECT);
+ return result;
+ }
+}
Property changes on: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/CommonTransectRemoveDataStrategy.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/OperationRemoveDataStrategy.java (from rev 636, trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/OperationRemoveDataService.java)
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/OperationRemoveDataStrategy.java (rev 0)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/OperationRemoveDataStrategy.java 2012-09-09 19:57:02 UTC (rev 638)
@@ -0,0 +1,76 @@
+package fr.ifremer.echobase.services.removedata.strategy;
+
+/*
+ * #%L
+ * EchoBase :: Services
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 - 2012 Ifremer, Codelutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+
+import com.google.common.collect.Sets;
+import fr.ifremer.echobase.entities.ImportType;
+import fr.ifremer.echobase.entities.data.Operation;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * Remove a {@link ImportType#OPERATION} import.
+ * <p/>
+ * Can remove only {@link Operation}.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.2
+ */
+public class OperationRemoveDataStrategy extends AbstractRemoveDataStrategy {
+
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(OperationRemoveDataStrategy.class);
+
+ @Override
+ protected void removeData(String id) {
+
+ if (id.startsWith(Operation.class.getName())) {
+
+ // remove operation
+ removeOperation(id);
+ } else {
+ canNotDealWithId(id);
+ }
+ }
+
+ protected void removeOperation(String id) {
+ Operation entity = removeEntity(id);
+ if (log.isInfoEnabled()) {
+ log.info("Operation " + entity.getTopiaId() + " was removed");
+ }
+ }
+
+ @Override
+ public Set<ImportType> getPossibleSubImportType() {
+ HashSet<ImportType> result = Sets.newHashSet(ImportType.values());
+ result.remove(ImportType.COMMON_ALL);
+ result.remove(ImportType.COMMON_TRANSECT);
+ result.remove(ImportType.OPERATION);
+ return result;
+ }
+}
Property changes on: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/OperationRemoveDataStrategy.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/ResultEsduRemoveDataStrategy.java (from rev 636, trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/ResultEsduRemoveDataService.java)
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/ResultEsduRemoveDataStrategy.java (rev 0)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/ResultEsduRemoveDataStrategy.java 2012-09-09 19:57:02 UTC (rev 638)
@@ -0,0 +1,80 @@
+package fr.ifremer.echobase.services.removedata.strategy;
+
+/*
+ * #%L
+ * EchoBase :: Services
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 - 2012 Ifremer, Codelutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+
+import com.google.common.collect.Sets;
+import fr.ifremer.echobase.entities.ImportType;
+import fr.ifremer.echobase.entities.data.Result;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * Remove a {@link ImportType#RESULT_ESDU} import.
+ * <p/>
+ * Can remove only {@link Result}.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.2
+ */
+public class ResultEsduRemoveDataStrategy extends AbstractRemoveDataStrategy {
+
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(ResultEsduRemoveDataStrategy.class);
+
+ @Override
+ protected void removeData(String id) {
+
+ if (id.startsWith(Result.class.getName())) {
+
+ // remove result
+ removeResult(id);
+ } else {
+ canNotDealWithId(id);
+ }
+ }
+
+ protected void removeResult(String id) {
+ Result entity = removeEntity(id);
+ if (log.isDebugEnabled()) {
+ log.debug("Result " + entity.getTopiaId() + " was removed");
+ }
+ }
+
+ @Override
+ public Set<ImportType> getPossibleSubImportType() {
+ HashSet<ImportType> result = Sets.newHashSet(ImportType.values());
+ result.remove(ImportType.COMMON_ALL);
+ result.remove(ImportType.COMMON_TRANSECT);
+ result.remove(ImportType.OPERATION);
+ result.remove(ImportType.CATCHES);
+ result.remove(ImportType.ACOUSTIC);
+ result.remove(ImportType.RESULT_VOYAGE);
+ result.remove(ImportType.RESULT_ESDU);
+ return result;
+ }
+}
Property changes on: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/ResultEsduRemoveDataStrategy.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/ResultMapRemoveDataStrategy.java (from rev 636, trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/ResultMapRemoveDataService.java)
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/ResultMapRemoveDataStrategy.java (rev 0)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/ResultMapRemoveDataStrategy.java 2012-09-09 19:57:02 UTC (rev 638)
@@ -0,0 +1,73 @@
+package fr.ifremer.echobase.services.removedata.strategy;
+
+/*
+ * #%L
+ * EchoBase :: Services
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 - 2012 Ifremer, Codelutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+
+import com.google.common.collect.Sets;
+import fr.ifremer.echobase.entities.ImportType;
+import fr.ifremer.echobase.entities.data.Cell;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * Remove a {@link ImportType#RESULT_MAP} import.
+ * <p/>
+ * Can remove only {@link Cell}.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.2
+ */
+public class ResultMapRemoveDataStrategy extends AbstractRemoveDataStrategy {
+
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(ResultMapRemoveDataStrategy.class);
+
+ @Override
+ protected void removeData(String id) {
+
+ if (id.startsWith(Cell.class.getName())) {
+
+ // remove cell
+ removeCell(id);
+ } else {
+ canNotDealWithId(id);
+ }
+ }
+
+ protected void removeCell(String id) {
+ Cell entity = removeEntity(id);
+ if (log.isInfoEnabled()) {
+ log.info("Cell " + entity.getTopiaId() + " was removed");
+ }
+ }
+
+ @Override
+ public Set<ImportType> getPossibleSubImportType() {
+ HashSet<ImportType> result = Sets.newHashSet();
+ return result;
+ }
+}
Property changes on: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/ResultMapRemoveDataStrategy.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/ResultRegionRemoveDataStrategy.java (from rev 636, trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/ResultRegionRemoveDataService.java)
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/ResultRegionRemoveDataStrategy.java (rev 0)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/ResultRegionRemoveDataStrategy.java 2012-09-09 19:57:02 UTC (rev 638)
@@ -0,0 +1,81 @@
+package fr.ifremer.echobase.services.removedata.strategy;
+
+/*
+ * #%L
+ * EchoBase :: Services
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 - 2012 Ifremer, Codelutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+
+import com.google.common.collect.Sets;
+import fr.ifremer.echobase.entities.ImportType;
+import fr.ifremer.echobase.entities.data.Cell;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * Remove a {@link ImportType#RESULT_REGION} import.
+ * <p/>
+ * Can remove only {@link Cell}.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.2
+ */
+public class ResultRegionRemoveDataStrategy extends AbstractRemoveDataStrategy {
+
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(ResultRegionRemoveDataStrategy.class);
+
+ @Override
+ protected void removeData(String id) {
+
+ if (id.startsWith(Cell.class.getName())) {
+
+ // remove echotype
+ removeCell(id);
+ } else {
+ canNotDealWithId(id);
+ }
+ }
+
+ protected void removeCell(String id) {
+ Cell entity = removeEntity(id);
+ if (log.isInfoEnabled()) {
+ log.info("Cell " + entity.getTopiaId() + " was removed");
+ }
+ }
+
+ @Override
+ public Set<ImportType> getPossibleSubImportType() {
+ HashSet<ImportType> result = Sets.newHashSet(ImportType.values());
+ result.remove(ImportType.COMMON_ALL);
+ result.remove(ImportType.COMMON_TRANSECT);
+ result.remove(ImportType.OPERATION);
+ result.remove(ImportType.CATCHES);
+ result.remove(ImportType.ACOUSTIC);
+ result.remove(ImportType.RESULT_VOYAGE);
+ result.remove(ImportType.RESULT_ESDU);
+ result.remove(ImportType.RESULT_VOYAGE);
+ return result;
+ }
+}
Property changes on: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/ResultRegionRemoveDataStrategy.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/ResultVoyageRemoveDataStrategy.java (from rev 636, trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/ResultVoyageRemoveDataService.java)
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/ResultVoyageRemoveDataStrategy.java (rev 0)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/ResultVoyageRemoveDataStrategy.java 2012-09-09 19:57:02 UTC (rev 638)
@@ -0,0 +1,104 @@
+package fr.ifremer.echobase.services.removedata.strategy;
+
+/*
+ * #%L
+ * EchoBase :: Services
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 - 2012 Ifremer, Codelutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+
+import com.google.common.collect.Sets;
+import fr.ifremer.echobase.entities.ImportType;
+import fr.ifremer.echobase.entities.data.Echotype;
+import fr.ifremer.echobase.entities.data.LengthAgeKey;
+import fr.ifremer.echobase.entities.data.LengthWeightKey;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * remove a {@link ImportType#OPERATION} import.
+ * <p/>
+ * Can remove only {@link Echotype}, {@link LengthAgeKey} or
+ * {@link LengthWeightKey}.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.2
+ */
+public class ResultVoyageRemoveDataStrategy extends AbstractRemoveDataStrategy {
+
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(ResultVoyageRemoveDataStrategy.class);
+
+ @Override
+ protected void removeData(String id) {
+
+ if (id.startsWith(Echotype.class.getName())) {
+
+ // remove echotype
+ removeEchotype(id);
+ } else if (id.startsWith(LengthAgeKey.class.getName())) {
+
+ // remove lengthAgeKey
+ removeLengthAgeKey(id);
+ } else if (id.startsWith(LengthWeightKey.class.getName())) {
+
+ // remove lengthAgeKey
+ removeLengthWeightKey(id);
+ } else {
+ canNotDealWithId(id);
+ }
+ }
+
+ protected void removeEchotype(String id) {
+ Echotype entity = removeEntity(id);
+ if (log.isInfoEnabled()) {
+ log.info("Echotype " + entity.getTopiaId() + " was removed");
+ }
+ }
+
+ protected void removeLengthAgeKey(String id) {
+ LengthAgeKey entity = removeEntity(id);
+ if (log.isInfoEnabled()) {
+ log.info("LengthAgeKey " + entity.getTopiaId() + " was removed");
+ }
+ }
+
+ protected void removeLengthWeightKey(String id) {
+ LengthWeightKey entity = removeEntity(id);
+ if (log.isInfoEnabled()) {
+ log.info("LengthWeightKey " + entity.getTopiaId() + " was removed");
+ }
+ }
+
+ @Override
+ public Set<ImportType> getPossibleSubImportType() {
+ HashSet<ImportType> result = Sets.newHashSet(ImportType.values());
+ result.remove(ImportType.COMMON_ALL);
+ result.remove(ImportType.COMMON_TRANSECT);
+ result.remove(ImportType.OPERATION);
+ result.remove(ImportType.CATCHES);
+ result.remove(ImportType.ACOUSTIC);
+ result.remove(ImportType.RESULT_VOYAGE);
+ return result;
+ }
+}
Property changes on: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/strategy/ResultVoyageRemoveDataStrategy.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/GetEntities.java
===================================================================
--- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/GetEntities.java 2012-09-08 11:23:33 UTC (rev 637)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/dbeditor/GetEntities.java 2012-09-09 19:57:02 UTC (rev 638)
@@ -24,6 +24,7 @@
package fr.ifremer.echobase.ui.actions.dbeditor;
import fr.ifremer.echobase.entities.EchoBaseEntityEnum;
+import fr.ifremer.echobase.entities.ImportType;
import fr.ifremer.echobase.services.DbEditorService;
import fr.ifremer.echobase.ui.actions.AbstractJSONPaginedAction;
import org.apache.commons.logging.Log;
@@ -92,7 +93,7 @@
log.debug("sord = " + ascendantOrder);
}
- datas = getService(DbEditorService.class).getDatas(
+ datas = getService(DbEditorService.class).getData(
entityType,
pager,
sortColumn,
@@ -112,4 +113,19 @@
execute();
return SUCCESS;
}
+
+ public String entityImportLogs() throws Exception {
+ entityType = EchoBaseEntityEnum.ImportLog;
+ execute();
+ Map<String, String> importTypes = decorateEnums(ImportType.values());
+
+ for (Map row : datas) {
+
+ String importType = (String) row.get("importType");
+ String importTypeToString = importTypes.get(importType);
+ row.put("importType", importTypeToString);
+
+ }
+ return SUCCESS;
+ }
}
Added: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/removeData/ConfirmDelete.java
===================================================================
--- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/removeData/ConfirmDelete.java (rev 0)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/removeData/ConfirmDelete.java 2012-09-09 19:57:02 UTC (rev 638)
@@ -0,0 +1,94 @@
+package fr.ifremer.echobase.ui.actions.removeData;
+
+/*
+ * #%L
+ * EchoBase :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 - 2012 Ifremer, Codelutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+
+import com.google.common.base.Preconditions;
+import fr.ifremer.echobase.entities.ImportLog;
+import fr.ifremer.echobase.services.EchoBaseServiceSupport;
+import fr.ifremer.echobase.services.removedata.RemoveDataConfiguration;
+import fr.ifremer.echobase.ui.actions.AbstractConfigureAction;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.io.IOException;
+
+/**
+ * Confirm to delete a import log.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.2
+ */
+public class ConfirmDelete extends AbstractConfigureAction<RemoveDataConfiguration> {
+
+ private static final long serialVersionUID = 1L;
+
+ /** Logger. */
+ private static final Log log = LogFactory.getLog(ConfirmDelete.class);
+
+ protected ImportLog importLog;
+
+
+ protected String importType;
+
+ public ConfirmDelete() {
+ super(RemoveDataConfiguration.class);
+ }
+
+ public String getImportType() {
+ return importType;
+ }
+
+ public ImportLog getImportLog() {
+ return importLog;
+ }
+
+ @Override
+ protected RemoveDataConfiguration createModel() {
+ return new RemoveDataConfiguration();
+ }
+
+ @Override
+ protected void prepareExecuteAction(RemoveDataConfiguration model) throws IOException {
+
+ // nothing special to do here
+ }
+
+ protected void prepareInputAction(RemoveDataConfiguration model) {
+
+ String importLogId = model.getImportLogId();
+
+ Preconditions.checkArgument(StringUtils.isNotBlank(importLogId));
+
+ if (log.isInfoEnabled()) {
+ log.info("Load import log " + importLogId);
+ }
+ EchoBaseServiceSupport service =
+ getService(EchoBaseServiceSupport.class);
+ importLog = service.getEntityById(ImportLog.class, importLogId);
+
+ importType = decorateEnums(importLog.getImportType()).entrySet().iterator().next().getValue();
+ }
+
+}
\ No newline at end of file
Property changes on: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/removeData/ConfirmDelete.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/removeData/Delete.java
===================================================================
--- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/removeData/Delete.java (rev 0)
+++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/removeData/Delete.java 2012-09-09 19:57:02 UTC (rev 638)
@@ -0,0 +1,66 @@
+package fr.ifremer.echobase.ui.actions.removeData;
+
+/*
+ * #%L
+ * EchoBase :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 - 2012 Ifremer, Codelutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+
+import fr.ifremer.echobase.services.removedata.RemoveDataConfiguration;
+import fr.ifremer.echobase.services.removedata.RemoveDataService;
+import fr.ifremer.echobase.ui.actions.AbstractWaitAndExecAction;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Delete a selected import Log.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.2
+ */
+public class Delete extends AbstractWaitAndExecAction<RemoveDataConfiguration, RemoveDataService> {
+
+ private static final long serialVersionUID = 1L;
+
+ /** Logger. */
+ private static final Log log = LogFactory.getLog(Delete.class);
+
+ protected String result;
+
+ public Delete() {
+ super(RemoveDataConfiguration.class, RemoveDataService.class);
+ }
+
+ public String getResult() {
+ return result;
+ }
+
+ @Override
+ protected void startAction(RemoveDataService service,
+ RemoveDataConfiguration model) throws Exception {
+
+ if (log.isInfoEnabled()) {
+ log.info("Will remove importLog : " + model.getImportLogId());
+ }
+
+ result = service.removeImport(model, getEchoBaseSession().getUser());
+ }
+
+}
Property changes on: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/removeData/Delete.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/echobase-ui/src/main/resources/config/struts-exportDb.xml
===================================================================
--- trunk/echobase-ui/src/main/resources/config/struts-exportDb.xml 2012-09-08 11:23:33 UTC (rev 637)
+++ trunk/echobase-ui/src/main/resources/config/struts-exportDb.xml 2012-09-09 19:57:02 UTC (rev 638)
@@ -42,9 +42,8 @@
</action>
<!-- Build export -->
- <action name="export"
- class="fr.ifremer.echobase.ui.actions.exportDb.Export"
- method="execute">
+ <action name="export" method="execute"
+ class="fr.ifremer.echobase.ui.actions.exportDb.Export">
<interceptor-ref name="basicStackLoggued"/>
<interceptor-ref name="execAndWait"/>
<result name="wait">/WEB-INF/jsp/exportDb/progress.jsp</result>
Added: trunk/echobase-ui/src/main/resources/config/struts-removeData.xml
===================================================================
--- trunk/echobase-ui/src/main/resources/config/struts-removeData.xml (rev 0)
+++ trunk/echobase-ui/src/main/resources/config/struts-removeData.xml 2012-09-09 19:57:02 UTC (rev 638)
@@ -0,0 +1,63 @@
+<!--
+ #%L
+ EchoBase :: UI
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2011 - 2012 Ifremer, Codelutin
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+ #L%
+ -->
+<!DOCTYPE struts PUBLIC
+ "-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
+ "http://struts.apache.org/dtds/struts-2.3.dtd">
+
+<struts>
+
+ <package name="removeData" extends="loggued" namespace="/removeData">
+
+ <!-- Confirm to delete the importLog -->
+ <action name="confirmDelete"
+ class="fr.ifremer.echobase.ui.actions.removeData.ConfirmDelete">
+ <result name="input">/WEB-INF/jsp/removeData/confirmDelete.jsp</result>
+ <result type="redirectAction">
+ <param name="namespace">/removeData</param>
+ <param name="actionName">delete</param>
+ </result>
+ </action>
+
+ <!-- Delete the importLog -->
+ <action name="delete" method="execute"
+ class="fr.ifremer.echobase.ui.actions.removeData.Delete">
+ <interceptor-ref name="basicStackLoggued"/>
+ <interceptor-ref name="execAndWait"/>
+ <result name="wait">/WEB-INF/jsp/removeData/deleteProgress.jsp</result>
+ <result>/WEB-INF/jsp/removeData/deleteResult.jsp</result>
+ </action>
+
+ <!-- Get importLogs -->
+ <action name="importLogs"
+ class="fr.ifremer.echobase.ui.actions.EchoBaseActionSupport">
+ <result>/WEB-INF/jsp/removeData/dashboard.jsp</result>
+ </action>
+
+ <!-- Get import logs entries -->
+ <action name="getImportLogs" method="entityImportLogs"
+ class="fr.ifremer.echobase.ui.actions.dbeditor.GetEntities">
+ <result type="json"/>
+ </action>
+ </package>
+
+</struts>
Property changes on: trunk/echobase-ui/src/main/resources/config/struts-removeData.xml
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/echobase-ui/src/main/resources/config/struts-user.xml
===================================================================
--- trunk/echobase-ui/src/main/resources/config/struts-user.xml 2012-09-08 11:23:33 UTC (rev 637)
+++ trunk/echobase-ui/src/main/resources/config/struts-user.xml 2012-09-09 19:57:02 UTC (rev 638)
@@ -65,20 +65,12 @@
<result>/WEB-INF/jsp/user/userList.jsp</result>
</action>
-
-
<!-- Get list of users in database -->
<action name="getUsers"
class="fr.ifremer.echobase.ui.actions.user.GetUsers">
<result type="json"/>
</action>
- <!-- Get modification logs entries -->
- <action name="getEntityModificationLogs" method="entityModificationLogs"
- class="fr.ifremer.echobase.ui.actions.dbeditor.GetEntities">
- <result type="json"/>
- </action>
-
</package>
</struts>
Modified: trunk/echobase-ui/src/main/resources/config/struts-workingDb.xml
===================================================================
--- trunk/echobase-ui/src/main/resources/config/struts-workingDb.xml 2012-09-08 11:23:33 UTC (rev 637)
+++ trunk/echobase-ui/src/main/resources/config/struts-workingDb.xml 2012-09-09 19:57:02 UTC (rev 638)
@@ -127,6 +127,12 @@
</result>
</action>
+ <!-- Get modification logs entries -->
+ <action name="getEntityModificationLogs" method="entityModificationLogs"
+ class="fr.ifremer.echobase.ui.actions.dbeditor.GetEntities">
+ <result type="json"/>
+ </action>
+
</package>
</struts>
Modified: trunk/echobase-ui/src/main/resources/i18n/echobase-ui_en_GB.properties
===================================================================
--- trunk/echobase-ui/src/main/resources/i18n/echobase-ui_en_GB.properties 2012-09-08 11:23:33 UTC (rev 637)
+++ trunk/echobase-ui/src/main/resources/i18n/echobase-ui_en_GB.properties 2012-09-09 19:57:02 UTC (rev 638)
@@ -1,3 +1,4 @@
+echobase.action.backToImportLogs=Back to import logs
echobase.action.backToUserList=Back to users list
echobase.action.cancel=Cancel
echobase.action.clone=Clone
@@ -17,6 +18,7 @@
echobase.action.exportTable=Export
echobase.action.generateSqlQuery=Generate query
echobase.action.import=Import
+echobase.action.importLogDelete=Delete
echobase.action.importTable=Import
echobase.action.login=Connect
echobase.action.logout=Disconnect
@@ -30,6 +32,7 @@
echobase.action.saveSqlQuery=Update query
echobase.action.show.embedded.documentation=How to use a portable database
echobase.action.show.import.documentation=How to import data
+echobase.action.showImportLogs=Liste des imports\=Show import logs
echobase.action.toEnglish=English
echobase.action.toFrench=French
echobase.action.usingEnglish=English
@@ -68,17 +71,22 @@
echobase.common.esduBySpeciesAndSizeCategoryFile=
echobase.common.gearMetadataFile=
echobase.common.id=ID
+echobase.common.imortType=import type
echobase.common.importDataMode=Import type
+echobase.common.importDate=Import date
echobase.common.importDbFile=
echobase.common.importError=Error\:
+echobase.common.importLogActions=Actions
echobase.common.importNotes=Import notes
echobase.common.importResult=Import results
+echobase.common.importText=import description
echobase.common.importType=Import type
echobase.common.importType.acoustic=
echobase.common.importType.catches=
echobase.common.importType.common=Voyage / Transit / Transect data import
echobase.common.importType.operation=
echobase.common.importType.results=Results import
+echobase.common.importUser=Import user
echobase.common.inProgress=Processing...
echobase.common.institution=Institution
echobase.common.jdbcDriver=Jdbc driver name
@@ -132,6 +140,7 @@
echobase.common.voyage=Cruise
echobase.common.voyageDescription=Description
echobase.common.voyageFile=
+echobase.confirm.delete.importData=Delete import
echobase.confirm.delete.query=Delete query
echobase.confirm.delete.workingDbConfiguration=Delete working database configuration
echobase.error.bad.password=Invalid password
@@ -287,9 +296,11 @@
echobase.menu.viewData=Display data
echobase.message.no.row.selected=No data selected
echobase.message.noEntrySelection=No field selected
+echobase.message.removeData.result=data was successful removed in %s.
echobase.message.warnEmbeddedApplicationInProgress=Please do not close the window to access the new portable database file
echobase.message.warnExportInProgress=Please do not close the window to access the export file
echobase.message.warnImportInProgress=Please do not close the window to access the imported file
+echobase.message.warnRemoveDataInProgress=Please do not close the window to access remove data result
echobase.title.confirm.deleteQuery=Delete a query
echobase.title.confirm.deleteWorkingDbConfiguration=Delete a configuration
echobase.title.connectToDbInformations=Database connection information
@@ -297,6 +308,7 @@
echobase.title.createMission=Create a mission
echobase.title.dbEditor=Modify data
echobase.title.dbEditor.read=Data display
+echobase.title.delete.importLog=Delete a import
echobase.title.embeddedApplicationProgress=Creating the portable database
echobase.title.embeddedApplicationResult=Results of the portable database creation
echobase.title.entityModificationLogs=Change log
@@ -309,10 +321,14 @@
echobase.title.importDb=Complete database import
echobase.title.importDbProgress=Importing data
echobase.title.importDbResult=Data import results
+echobase.title.importLog.detail=Import detail
+echobase.title.importLogs=Import logs
echobase.title.importTable=Import a table
echobase.title.login=Connection
echobase.title.modification.detail=Modification details
echobase.title.newLibreOfficeQuery=Translate a SQL query from Libre Office
+echobase.title.removeDataProgress=Remove import data
+echobase.title.removeDataResult=Result of remove import data
echobase.title.users=Administrate users
echobase.title.welcome=Welcome to Echobase
echobase.title.workingDbConfiguration=Manage working database configurations
Modified: trunk/echobase-ui/src/main/resources/i18n/echobase-ui_fr_FR.properties
===================================================================
--- trunk/echobase-ui/src/main/resources/i18n/echobase-ui_fr_FR.properties 2012-09-08 11:23:33 UTC (rev 637)
+++ trunk/echobase-ui/src/main/resources/i18n/echobase-ui_fr_FR.properties 2012-09-09 19:57:02 UTC (rev 638)
@@ -1,3 +1,4 @@
+echobase.action.backToImportLogs=Retour à la liste des imports
echobase.action.backToUserList=Retour à la liste des utilisateurs
echobase.action.cancel=Annuler
echobase.action.clone=Cloner
@@ -17,6 +18,7 @@
echobase.action.exportTable=Exporter
echobase.action.generateSqlQuery=Générer la requête
echobase.action.import=Importer
+echobase.action.importLogDelete=Supprimer
echobase.action.importTable=Importer
echobase.action.login=Connexion
echobase.action.logout=Déconnexion
@@ -30,6 +32,7 @@
echobase.action.saveSqlQuery=Mettre à jour
echobase.action.show.embedded.documentation=Comment utiliser une application embarquée
echobase.action.show.import.documentation=Comment importer des données
+echobase.action.showImportLogs=Liste des imports
echobase.action.toEnglish=En anglais
echobase.action.toFrench=En français
echobase.action.usingEnglish=Version anglaise
@@ -68,17 +71,22 @@
echobase.common.esduBySpeciesAndSizeCategoryFile=
echobase.common.gearMetadataFile=
echobase.common.id=Identifiant
+echobase.common.imortType=Type d'import
echobase.common.importDataMode=Type d'import
+echobase.common.importDate=Date de l'import
echobase.common.importDbFile=
echobase.common.importError=Une erreur est survenue pendant l'import \:
+echobase.common.importLogActions=Actions
echobase.common.importNotes=Remarques sur l'import
echobase.common.importResult=Résultat de l'import
+echobase.common.importText=Description
echobase.common.importType=Type d'import
echobase.common.importType.acoustic=
echobase.common.importType.catches=
echobase.common.importType.common=Import des données de Voyage / Transit / Transect
echobase.common.importType.operation=
echobase.common.importType.results=Import des résultats
+echobase.common.importUser=Utilisateur
echobase.common.inProgress=En cours...
echobase.common.institution=Institution
echobase.common.jdbcDriver=Nom du pilote jdbc
@@ -132,6 +140,7 @@
echobase.common.voyage=Campagne
echobase.common.voyageDescription=Description
echobase.common.voyageFile=
+echobase.confirm.delete.importData=Confirmer la suppression de l'import
echobase.confirm.delete.query=Confirmer la suppression de la requête
echobase.confirm.delete.workingDbConfiguration=Confirmer la suppression de la configuration suivante
echobase.error.bad.password=Mot de passe incorrect
@@ -287,9 +296,11 @@
echobase.menu.viewData=Visualiser les données
echobase.message.no.row.selected=Aucune donnée sélectionnée
echobase.message.noEntrySelection=Pas de champ sélectionné
+echobase.message.removeData.result=Résultat de la suppression de l'import %s
echobase.message.warnEmbeddedApplicationInProgress=Merci de ne pas fermer la fenêtre pour pouvoir accéder aux résultats de la création de l'application embarquée
echobase.message.warnExportInProgress=Merci de ne pas fermer la fenêtre pour pouvoir accéder aux résultats de l'export
echobase.message.warnImportInProgress=Merci de ne pas fermer la fenêtre pour pouvoir accéder aux résultats de l'import
+echobase.message.warnRemoveDataInProgress=Merci de ne pas fermer la fenètre pour pouvoir accéder aux résultats de la suppression de l'import
echobase.title.confirm.deleteQuery=Supprimer une requête
echobase.title.confirm.deleteWorkingDbConfiguration=Supprimer la configuration
echobase.title.connectToDbInformations=Informations de connexion à la base de données
@@ -297,6 +308,7 @@
echobase.title.createMission=Créer une mission
echobase.title.dbEditor=Modification des données
echobase.title.dbEditor.read=Visualisation des données
+echobase.title.delete.importLog=Confirmer la suppression d'un import
echobase.title.embeddedApplicationProgress=Création de l'application embarquée en cours
echobase.title.embeddedApplicationResult=Résultat de la création de l'application embarquée
echobase.title.entityModificationLogs=Journal des modifications
@@ -309,13 +321,18 @@
echobase.title.importDb=Import d'une base complète
echobase.title.importDbProgress=Import de données en cours
echobase.title.importDbResult=Résultats de l'import de données
+echobase.title.importLog.detail=Détil d'un import
+echobase.title.importLogs=Liste des imports
echobase.title.importTable=Importer une table
echobase.title.login=Connexion
echobase.title.modification.detail=Détails de la modification
echobase.title.newLibreOfficeQuery=Traduire une requête SQL issue de Libre Office
+echobase.title.removeDataProgress=Suppression d'un import en cours...
+echobase.title.removeDataResult=Résultat de la suppression d'un import
echobase.title.users=Administration des utilisateurs
echobase.title.welcome=Bienvenue dans EchoBase
echobase.title.workingDbConfiguration=Administration des configurations de base de travail
echobase.tooltip.disconnectWorkingDb=Changer de base de travail
echobase.tooltip.logout=Se déconnecter
echobase.tooltip.selectWorkingDb=Sélectionner une base de travail
+ehobase.message.removeData.result=Import supprimé avec succès en %s
Modified: trunk/echobase-ui/src/main/resources/struts.xml
===================================================================
--- trunk/echobase-ui/src/main/resources/struts.xml 2012-09-08 11:23:33 UTC (rev 637)
+++ trunk/echobase-ui/src/main/resources/struts.xml 2012-09-09 19:57:02 UTC (rev 638)
@@ -158,6 +158,7 @@
<include file="config/struts-importDb.xml"/>
<include file="config/struts-exportDb.xml"/>
+ <include file="config/struts-removeData.xml"/>
</struts>
Modified: trunk/echobase-ui/src/main/webapp/WEB-INF/decorators.xml
===================================================================
--- trunk/echobase-ui/src/main/webapp/WEB-INF/decorators.xml 2012-09-08 11:23:33 UTC (rev 637)
+++ trunk/echobase-ui/src/main/webapp/WEB-INF/decorators.xml 2012-09-09 19:57:02 UTC (rev 638)
@@ -36,6 +36,7 @@
<pattern>/exportQuery/confirmDelete*</pattern>
<pattern>/importData/get*</pattern>
<pattern>/workingDb/confirmDelete*</pattern>
+ <pattern>/removeData/confirmDelete*</pattern>
</excludes>
<decorator name="layout-default" page="layout-default.jsp">
Modified: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/home.jsp
===================================================================
--- trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/home.jsp 2012-09-08 11:23:33 UTC (rev 637)
+++ trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/home.jsp 2012-09-09 19:57:02 UTC (rev 638)
@@ -61,4 +61,14 @@
</li>
</ul>
</s:form>
-</s:if>
\ No newline at end of file
+</s:if>
+<s:else>
+ <s:form namespace="/removeData" action="importLogs">
+ <ul class="toolbar floatLeft">
+ <li>
+ <s:submit theme="simple" action="importLogs"
+ key="echobase.action.showImportLogs"/>
+ </li>
+ </ul>
+ </s:form>
+</s:else>
\ No newline at end of file
Modified: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/importData/configureResultsImport.jsp
===================================================================
--- trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/importData/configureResultsImport.jsp 2012-09-08 11:23:33 UTC (rev 637)
+++ trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/importData/configureResultsImport.jsp 2012-09-09 19:57:02 UTC (rev 638)
@@ -37,7 +37,7 @@
// to change form when mode is changed
$('[name="model.importType"]').change(function (event) {
- $('[class~="importMode"]').hide();
+ $('[class~="importType"]').hide();
$('#' + this.value).show();
$('#' + this.value + ' .errorMessage').hide();
});
@@ -61,7 +61,7 @@
label='%{getText("echobase.common.importType")}' />
<s:form id="RESULT_VOYAGE" namespace="/importData" method="POST"
- enctype="multipart/form-data" cssClass="hidden importMode">
+ enctype="multipart/form-data" cssClass="hidden importType">
<fieldset>
<legend>
@@ -102,7 +102,7 @@
</s:form>
<s:form id="RESULT_ESDU" namespace="/importData" method="POST"
- enctype="multipart/form-data" cssClass="hidden importMode">
+ enctype="multipart/form-data" cssClass="hidden importType">
<fieldset>
<legend>
@@ -153,7 +153,7 @@
</s:form>
<s:form id="RESULT_REGION" namespace="/importData" method="POST"
- enctype="multipart/form-data" cssClass="hidden importMode">
+ enctype="multipart/form-data" cssClass="hidden importType">
<fieldset>
<legend>
@@ -193,7 +193,7 @@
</s:form>
<s:form id="RESULT_MAP" namespace="/importData" method="POST"
- enctype="multipart/form-data" cssClass="hidden importMode">
+ enctype="multipart/form-data" cssClass="hidden importType">
<fieldset>
<legend>
Modified: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/importData/resultResultsImport.jsp
===================================================================
--- trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/importData/resultResultsImport.jsp 2012-09-08 11:23:33 UTC (rev 637)
+++ trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/importData/resultResultsImport.jsp 2012-09-09 19:57:02 UTC (rev 638)
@@ -30,7 +30,7 @@
<h4>
<s:text name="echobase.common.importType.results"/>
- ( <s:property value="%{getText(model.importMode.i18nKey)}"/> )
+ ( <s:property value="%{getText(model.importType.i18nKey)}"/> )
</h4>
<%@ include file="/WEB-INF/includes/importDataResults.jsp" %>
Modified: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/importDb/result.jsp
===================================================================
--- trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/importDb/result.jsp 2012-09-08 11:23:33 UTC (rev 637)
+++ trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/importDb/result.jsp 2012-09-09 19:57:02 UTC (rev 638)
@@ -27,8 +27,7 @@
<title><s:text name="echobase.title.importDbResult"/></title>
<div>
- L'import de la base complête a réussi en <s:property
- value="model.actionTime"/>.
+ L'import de la base complête a réussi en <s:property value="model.actionTime"/>.
</div>
<div>
EchoBase possède désormais un référentiel et les campagnes contenues dans
Added: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/removeData/confirmDelete.jsp
===================================================================
--- trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/removeData/confirmDelete.jsp (rev 0)
+++ trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/removeData/confirmDelete.jsp 2012-09-09 19:57:02 UTC (rev 638)
@@ -0,0 +1,79 @@
+<%--
+ #%L
+ EchoBase :: UI
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2011 - 2012 Ifremer, Codelutin
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+ #L%
+ --%>
+<%@page contentType="text/html" pageEncoding="UTF-8" %>
+<%@ taglib prefix="s" uri="/struts-tags" %>
+
+<script type="text/javascript">
+
+function cancel() {
+$('#confirmDeleteDialog').dialog('close');
+return false;
+}
+</script>
+
+<div class="dialogContainer ui-corner-all">
+
+ <s:label key="echobase.confirm.delete.importData" theme="simple"/>
+
+ <fieldset class="ui-corner-all">
+
+ <s:label key='echobase.common.importType' value=''/>
+ <div class="clearBoth"/>
+ <pre id='importLogImportType' style="font-weight: bold;">
+ <s:property value="%{importType}"/>
+ </pre>
+
+ <s:label key='echobase.common.importDate' value=''/>
+ <div class="clearBoth"/>
+ <pre id='importLogDate' style="font-weight: bold;">
+ <s:property value="%{importLog.importDate}"/>
+ </pre>
+
+ <s:label key='echobase.common.importText' value=''/>
+ <div class="clearBoth"/>
+ <pre id='importLogText' style="font-weight: bold;">
+ <s:property value="%{importLog.importText}"/>
+ </pre>
+
+ <s:label key='echobase.common.importUser' value=''/>
+ <div class="clearBoth"/>
+ <pre id='importLogUser' style="font-weight: bold;">
+ <s:property value="%{importLog.importUser}"/>
+ </pre>
+
+ <s:form namespace="/removeData">
+
+ <s:hidden key="model.importLogId" label=''/>
+ <ul class="toolbar floatRight">
+ <li>
+ <s:submit onclick="return cancel();" theme="simple"
+ key="echobase.action.cancel"/>
+ </li>
+ <li>
+ <s:submit action="confirmDelete" theme="simple"
+ key="echobase.action.delete"/>
+ </li>
+ </ul>
+ </s:form>
+ </fieldset>
+</div>
\ No newline at end of file
Property changes on: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/removeData/confirmDelete.jsp
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/removeData/dashboard.jsp
===================================================================
--- trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/removeData/dashboard.jsp (rev 0)
+++ trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/removeData/dashboard.jsp 2012-09-09 19:57:02 UTC (rev 638)
@@ -0,0 +1,126 @@
+<%--
+#%L
+ EchoBase :: UI
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2011 Ifremer, Codelutin
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+ #L%
+--%>
+<%@page contentType="text/html" pageEncoding="UTF-8" %>
+<%@ taglib prefix="s" uri="/struts-tags" %>
+<%@ taglib prefix="sj" uri="/struts-jquery-tags" %>
+<%@ taglib prefix="sjg" uri="/struts-jquery-grid-tags" %>
+<script type="text/javascript"
+ src="<s:url value='/js/gridHelper.js' />"></script>
+<s:set var="emptySelection">
+ <s:text name="echobase.message.noEntrySelection"/>
+</s:set>
+
+<s:url id='deleteImg' value='/images/delete.png'/>
+<s:set id='deleteTitle'><s:text name="echobase.action.importLogDelete"/></s:set>
+<s:url id='delUrl' action="confirmDelete" namespace="/removeData" method="input"
+ escapeAmp="false"/>
+<script type="text/javascript">
+
+ function confirmDelete(id) {
+ var dialog = $("#confirmDeleteDialog");
+ dialog.html('');
+ var url = "${delUrl}";
+ url += '?' + $.param({'model.importLogId':id});
+ dialog.load(url);
+ dialog.dialog('open');
+ return false;
+ }
+
+ jQuery(document).ready(function () {
+ $.addRowSelectTopic('datas', function (event) {
+ $('#extraInfos').show();
+ var text = $("tr[aria-selected=true] td[aria-describedby='datas_importText']").text();
+ $('#importLogText').html(text);
+ var user = $("tr[aria-selected=true] td[aria-describedby='datas_importUser']").text();
+ $('#importLogUser').html(user);
+ var date = $("tr[aria-selected=true] td[aria-describedby='datas_importDate']").text();
+ $('#importLogDate').html(date);
+ var importType = $("tr[aria-selected=true] td[aria-describedby='datas_importType']").text();
+ $('#importLogImportType').html(importType);
+
+ });
+ $.addClearSelectTopic('datas', function (event) {
+ $('#extraInfos').hide();
+ });
+ $.addSingleRowTopic2('datas', 'Delete', function (event, id) {
+ return confirmDelete(id);
+ });
+ $.addEvenAndOddClasses('datas');
+ });
+</script>
+
+<title><s:text name="echobase.title.importLogs"/></title>
+<s:url id="loadUrl" action="getImportLogs" namespace="/removeData"
+ escapeAmp="false"/>
+
+<sjg:grid id="datas" dataType="json" href="%{loadUrl}" gridModel="datas"
+ pager="true" pagerButtons="true" pagerInput="true" navigator="true"
+ autowidth="true" rownumbers="false" viewrecords="true"
+ navigatorEdit="false" navigatorSearch="false"
+ navigatorDelete="false" navigatorAdd="false"
+ rowList="10,15,20,50,100,250,500" rowNum="10"
+ onSelectRowTopics='datas-rowSelect'
+ onCompleteTopics="datas-clearSelect,datas-CompleteTopics"
+ navigatorExtraButtons="{
+ delete: { title : 'Supprimer', icon: 'ui-icon-trash', topic: 'datas-rowDelete' }
+ }"
+ >
+
+ <sjg:gridColumn name="id" title="id" hidden="true"/>
+ <sjg:gridColumn name="importType" sortable="true"
+ title="%{getText('echobase.common.importType')}"/>
+ <sjg:gridColumn name="importDate" sortable="true"
+ title="%{getText('echobase.common.importDate')}"/>
+ <sjg:gridColumn name="importText" sortable="true"
+ title="%{getText('echobase.common.importText')}"/>
+ <sjg:gridColumn name="importUser" sortable="true"
+ title="%{getText('echobase.common.importUser')}"/>
+</sjg:grid>
+<br/>
+<fieldset>
+ <legend><s:text name="echobase.title.importLog.detail"/></legend>
+ <div id="extraInfos">
+
+ <s:label key='echobase.common.importType' value=''/>
+ <div class="clearBoth"/>
+ <pre id='importLogImportType' style="font-weight: bold;"></pre>
+ <br/>
+
+ <s:label key='echobase.common.importDate' value=''/>
+ <div class="clearBoth"/>
+ <pre id='importLogDate' style="font-weight: bold;"></pre>
+ <br/>
+
+ <s:label key='echobase.common.importText' value=''/>
+ <div class="clearBoth"/>
+ <pre id='importLogText' style="font-weight: bold;"></pre>
+ <br/>
+
+ <s:label key='echobase.common.importUser' value=''/>
+ <div class="clearBoth"/>
+ <pre id='importLogUser' style="font-weight: bold;"></pre>
+ </div>
+</fieldset>
+
+<sj:dialog id="confirmDeleteDialog" autoOpen="false" modal="true" width="780"
+ title='%{getText("echobase.title.delete.importLog")}'/>
\ No newline at end of file
Property changes on: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/removeData/dashboard.jsp
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/removeData/deleteProgress.jsp
===================================================================
--- trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/removeData/deleteProgress.jsp (rev 0)
+++ trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/removeData/deleteProgress.jsp 2012-09-09 19:57:02 UTC (rev 638)
@@ -0,0 +1,40 @@
+<%--
+ #%L
+ EchoBase :: UI
+
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2011 Ifremer, Codelutin
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+ #L%
+ --%>
+<%@page contentType="text/html" pageEncoding="UTF-8" %>
+<%@ taglib prefix="s" uri="/struts-tags" %>
+<%@ taglib prefix="sj" uri="/struts-jquery-tags" %>
+
+<meta http-equiv="refresh"
+ content='5;url=<s:url action="delete" namespace="/removeData"/>'/>
+
+<title><s:text name="echobase.title.removeDataProgress"/></title>
+
+<%-- TODO letellier 20111104 : Add warn icon --%>
+<p><s:text name="echobase.message.warnRemoveDataInProgress"/></p>
+
+<br/>
+
+<div>
+ <sj:progressbar value="%{model.progression}"/>
+</div>
\ No newline at end of file
Property changes on: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/removeData/deleteProgress.jsp
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/removeData/deleteResult.jsp
===================================================================
--- trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/removeData/deleteResult.jsp (rev 0)
+++ trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/removeData/deleteResult.jsp 2012-09-09 19:57:02 UTC (rev 638)
@@ -0,0 +1,46 @@
+<%--
+ #%L
+ EchoBase :: UI
+
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2011 Ifremer, Codelutin
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+ #L%
+ --%>
+<%@page contentType="text/html" pageEncoding="UTF-8" %>
+<%@ taglib prefix="s" uri="/struts-tags" %>
+
+<title><s:text name="echobase.title.removeDataResult"/></title>
+
+<div>
+ <s:text name="echobase.message.removeData.result">
+ <s:param><s:property value="model.actionTime"/></s:param>
+ </s:text>
+ <pre>
+ <s:property value="result"/>
+ </pre>
+</div>
+
+<s:form id="createForm" namespace="/removeData">
+ <ul class="toolbar floatLeft">
+ <li>
+ <s:submit theme="simple" action="importLogs"
+ key="echobase.action.backToImportLogs"/>
+ </li>
+ </ul>
+</s:form>
+
Property changes on: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/removeData/deleteResult.jsp
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/workingDb/modifications.jsp
===================================================================
--- trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/workingDb/modifications.jsp 2012-09-08 11:23:33 UTC (rev 637)
+++ trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/workingDb/modifications.jsp 2012-09-09 19:57:02 UTC (rev 638)
@@ -49,7 +49,7 @@
</script>
<title><s:text name="echobase.title.entityModificationLogs"/></title>
-<s:url id="loadUrl" action="getEntityModificationLogs" namespace="/user"
+<s:url id="loadUrl" action="getEntityModificationLogs" namespace="/workingDb"
escapeAmp="false"/>
<sjg:grid id="datas" dataType="json" href="%{loadUrl}" gridModel="datas"
Added: trunk/echobase-ui/src/main/webapp/images/delete.png
===================================================================
(Binary files differ)
Property changes on: trunk/echobase-ui/src/main/webapp/images/delete.png
___________________________________________________________________
Added: svn:mime-type
+ image/png
Added: svn:keywords
+ Author Date Id Revision HeadURL
Modified: trunk/echobase-ui/src/main/webapp/js/gridHelper.js
===================================================================
--- trunk/echobase-ui/src/main/webapp/js/gridHelper.js 2012-09-08 11:23:33 UTC (rev 637)
+++ trunk/echobase-ui/src/main/webapp/js/gridHelper.js 2012-09-09 19:57:02 UTC (rev 638)
@@ -74,6 +74,19 @@
}, {id:gridId, url:url, parameterName:parameterName});
},
+ addSingleRowTopic2:function (gridId, action, callback) {
+ $.subscribe(gridId + '-row' + action, function (event) {
+
+
+ var gridId = event.data.id;
+ var opts = jQuery.struts2_jquery[gridId];
+ var selectedId = opts['selectedRow'];
+ if (selectedId) {
+ event.data.callback(event, selectedId);
+ }
+ }, {id:gridId, callback:callback});
+ },
+
addMultiRowTopic:function (gridId, action, target, checkboxName, callback) {
$.subscribe(gridId + '-row' + action, function (event) {
var gridId = event.data.id;
@@ -247,6 +260,10 @@
return $(document).addSingleRowTopic(gridId, action, url, parameterName);
},
+ addSingleRowTopic2:function (gridId, action, callback) {
+ return $(document).addSingleRowTopic2(gridId, action, callback);
+ },
+
addMultiRowTopic:function (gridId, action, target, checkboxName, calbback) {
return $(document).addMultiRowTopic(gridId, action, target, checkboxName, calbback);
},
Added: trunk/src/site/rst/db.rst
===================================================================
--- trunk/src/site/rst/db.rst (rev 0)
+++ trunk/src/site/rst/db.rst 2012-09-09 19:57:02 UTC (rev 638)
@@ -0,0 +1,121 @@
+.. -
+.. * #%L
+.. * EchoBase
+.. * $Id$
+.. * $HeadURL$
+.. * %%
+.. * Copyright (C) 2011 - 2012 Ifremer, Codelutin
+.. * %%
+.. * This program is free software: you can redistribute it and/or modify
+.. * it under the terms of the GNU Affero General Public License as published by
+.. * the Free Software Foundation, either version 3 of the License, or
+.. * (at your option) any later version.
+.. *
+.. * This program is distributed in the hope that it will be useful,
+.. * but WITHOUT ANY WARRANTY; without even the implied warranty of
+.. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+.. * GNU General Public License for more details.
+.. *
+.. * You should have received a copy of the GNU Affero General Public License
+.. * along with this program. If not, see <http://www.gnu.org/licenses/>.
+.. * #L%
+.. -
+==========================
+Echobase - Base de données
+==========================
+
+.. contents:: Table des matières
+ :depth: 2
+
+.. sectnum::
+ :start: 1
+ :depth: 2
+
+Les bases de données dans EchoBase
+----------------------------------
+
+*EchoBase* permet l'utilisation de plusieurs bases de données que nous appelons
+*bases de travail*.
+
+Il est nécessaire de se connecter à une telle base de travail avant tout
+import/consultation/... de données dans l'application.
+
+Il est possible de gérer les paramètres de connexion à une base de travail.
+
+On distinque deux types de base :
+
+- les bases de données de type *H2*
+- les bases de données de type *Postgresql*
+
+Utilisation d'une base H2
+-------------------------
+
+L'avantage de ce type base est de pouvoir les créer facilement sans aucune
+maintenance (la base est stockée dans un simple fichier). Par contre elles sont
+moins performantes et perenne que les bases de type *Postgresql*.
+
+Pour utiliser une telle base, il suffit de créer une configuration de type *H2*
+en spécifiant une url de type :
+
+::
+ jdbc:h2:file:/cheminVersLaBase/nomDeLaBase
+
+Vous pouvez ensuite utiliser cette base qui va être crée automatiquement à
+l'endroit spécifié.
+
+Il est recommandé de fournir un mot de passe bien que cela ne soit pas
+obligatoire (mais cela peut être requis par certains outils externes).
+
+Par convention, nous utilisons les identifiants suivants :
+
+::
+ login: sa
+ password: sa
+
+Utilisation d'une base Postgres
+-------------------------------
+
+C'est ce genre de base que l'on doit utiliser sur un serveur pour conserver de
+manière perenne les données.
+
+Pour utiliser une telle base il faut configurer le serveur postgres comme
+indiqué dans la section suivante.
+
+Une fois la base créée sur le serveur, il suffit de créer une configuration de
+base de travail dans *EchoBase* de type *Postgresql* avec une url de type :
+
+::
+ jdbc:postgresql://adresseDuServeur/nomDeLaBase
+
+Les identifiants vous sont fournit par l'administrateur qui a installé la base
+postgresql sur le serveur.
+
+Création d'une base postgresql
+------------------------------
+
+Pré-requis :
+ - **postgres** doit être installé sur la machine (exemple pour un système
+ Debian : **sudo apt-get install postgresql**)
+ - être connecté avec l'utilisateur (postgres par défaut) qui a les droits
+ d'administrer cette base de donnée dans une console shell.
+
+1. Création de l'utilisateur Postgres
+
+::
+
+ createuser -U postgres -sdRP echobase
+
+2. Création de la base de donnée "echobase"
+
+::
+
+ createdb -U postgres -E UTF-8 -O echobase echobase
+
+3. Donner les droits d'acces à l'utilisateur echobase (cela varie d'un système
+ à l'autre, donc se référer à la documentation du système). Cela fonctionne
+ lorsqu'on peut accéder à la base via cette commande :
+
+::
+
+ psql -h localhost -U echobase echobase
+
Property changes on: trunk/src/site/rst/db.rst
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/src/site/rst/embedded.rst
===================================================================
--- trunk/src/site/rst/embedded.rst 2012-09-08 11:23:33 UTC (rev 637)
+++ trunk/src/site/rst/embedded.rst 2012-09-09 19:57:02 UTC (rev 638)
@@ -51,118 +51,13 @@
données), elle est téléchargeable depuis une page de résultat de l'opération
(normalement l'archive se met toute seule en téléchargement).
-Architecture de l'application embarquée
+Utilisation d'une application embarquée
=======================================
-L'archive une fois décompressé à la forme suivante :
+L'application embarquée est en fait une version *mode autonome* d'EchoBase
+avec en plus un jeu de données.
-::
+Consultez la `page d'utilisation`_ pour les détails d'utilisation et
+configuration d'EchoBase.
- echobase-embedded-0.6-pelgas2010
- ├── db (1) contient la base de données au format h2.
- │ └── echobase.h2.db
- ├── drivers (2) contient les drivers jdbc à utiliser dans LibreOffice
- │ ├── h2-1.3.165.jar
- │ └── postgresql-9.1-901-1.jdbc4.jar
- ├── echobase.properties (3) Fichier de configuration de l'application embarquée
- ├── echobase-ui-0.6.war (4) Application embarquée (war auto-exécutable)
- ├── logs (5) contient les logs de l'application
- │ └── echobase.log
- ├── README.txt
- ├── startEchobase.bat (6) Script de démarrage (windows)
- └── startEchobase.sh (7) Script de démarrage (linux)
-
-Utilisateurs
-============
-
-Deux utilisateurs sont fournis dans la base embarquée :
-
-- admin / admin (avec des droits d'administration)
-- user / user (pour la consultation)
-
-
-Utilisation de l'application embarquée (windows)
-------------------------------------------------
-
-Pré-requis
-==========
-
-Installer un environnement java de développement (une JDK) et pas une JRE
-qui ne suffit pas.
-
-`Page de téléchargement Oracle`_
-
-Une fois la JDK téléchargée et installée, ajouter la variable d'environnement
-**JDK_HOME** qui est le chemin vers où a été installé Java.
-
-::
-
- JDK_HOME -> C:/Program Files/Java/jdk1.7.0_03
-
-Installation d'echobase
-=======================
-
-- Dézipper l'archive précédemment téléchargée du site central.
-
-- Ouvrir une console (Touche Windows + R , taper *cmd* , Touche Entrée)
-- Se placer dans le répertoire où a été dézippée l'archive
-
-::
- cd Chemin vers l'archive dézippée
-
-- Enfin lancer le script
-
-::
- startEchobase.bat
-
-- Dans la console on doit voir l'application démarré et produire des logs
-- Lorsque l'application est prête, un navigateur s'ouvre sur la page
- de login.
-
-Utilisation de l'application embarquée (linux)
-----------------------------------------------
-
-Pré-requis
-==========
-
-Installer un environnement java de développement (une JDK) et pas une JRE
-qui ne suffit pas.
-
-`Page de téléchargement Oracle`_
-
-Une fois la JDK téléchargée et installée, ajouter dans les variables
-d'environnement :
-
-::
-
- JDK_HOME -> chemin vers où a été installé la JDK
-
- Pour ajouter une variable d'environnement, écrire dans ton fichier /home/Utilisateur/.bashrc la ligne :
-
-export JDK_HOME=/path/vers/jdk
-
-Installation d'echobase
-=======================
-
-- Dézipper l'archive précédemment téléchargée du site central.
-- Ouvrir une console
-- Se placer dans le répertoire où a été dézippée l'archive
-
-::
- cd Chemin vers l'archive dézippée
-
-- Rendre le script de démarrage exécutable
-
-::
- chmod +x startEchobase.sh
-
-- Enfin lancer le script
-
-::
- ./startEchobase.sh
-
-- Dans la console on doit voir l'application démarré et produire des logs
-- Lorsque l'application est prête, un navigateur s'ouvre sur la page
- de login.
-
-.. _Page de téléchargement Oracle: http://www.oracle.com/technetwork/java/javase/downloads/index.html
+.. _page d'utilisation: ./usage.html#utiliser-la-version-mode-portable
Added: trunk/src/site/rst/usage.rst
===================================================================
--- trunk/src/site/rst/usage.rst (rev 0)
+++ trunk/src/site/rst/usage.rst 2012-09-09 19:57:02 UTC (rev 638)
@@ -0,0 +1,189 @@
+.. -
+.. * #%L
+.. * EchoBase
+.. * $Id$
+.. * $HeadURL$
+.. * %%
+.. * Copyright (C) 2011 - 2012 Ifremer, Codelutin
+.. * %%
+.. * This program is free software: you can redistribute it and/or modify
+.. * it under the terms of the GNU Affero General Public License as published by
+.. * the Free Software Foundation, either version 3 of the License, or
+.. * (at your option) any later version.
+.. *
+.. * This program is distributed in the hope that it will be useful,
+.. * but WITHOUT ANY WARRANTY; without even the implied warranty of
+.. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+.. * GNU General Public License for more details.
+.. *
+.. * You should have received a copy of the GNU Affero General Public License
+.. * along with this program. If not, see <http://www.gnu.org/licenses/>.
+.. * #L%
+.. -
+======================
+EchoBase - Utilisation
+======================
+
+.. contents:: Table des matières
+ :depth: 2
+
+.. sectnum::
+ :start: 1
+ :depth: 2
+
+Comment utiliser EchoBase
+-------------------------
+
+L'application est fournit sous deux modes:
+
+- une version en *mode portable* qui ne nécessite pas de serveur
+- une version en *mode serveur* qui nécessite l'installation d'*EchoBase* dans
+ un serveur web de type *tomcat* ou *jetty*.
+
+Nous détaillons dans les sections suivantes comment utiliser les différentes
+versions.
+
+Utiliser la version mode portable
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+En mode portable, pas besoin de serveur, il faut juste avoir java d'installer
+sur la machine avec la varaible d'environnement *JDK_HOME* de bien positionner
+sur le repertoire où est installer Java.
+
+Pré-requis pour utilisation sous Windows
+________________________________________
+
+Installer un environnement java de développement (une JDK) et pas une JRE
+qui ne suffit pas.
+
+`Page de téléchargement Oracle`_
+
+Une fois la JDK téléchargée et installée, ajouter la variable d'environnement
+**JDK_HOME** qui est le chemin vers où a été installé Java.
+
+::
+
+ JDK_HOME -> C:/Program Files/Java/jdk1.7.0_03
+
+Pré-requis pour utilisation sous Linux
+______________________________________
+
+Installer un environnement java de développement (une JDK) et pas une JRE
+qui ne suffit pas.
+
+`Page de téléchargement Oracle`_
+
+Une fois la JDK téléchargée et installée, ajouter dans les variables
+d'environnement :
+
+::
+
+ JDK_HOME -> chemin vers où a été installé la JDK
+
+ Pour ajouter une variable d'environnement, écrire dans ton fichier /home/Utilisateur/.bashrc la ligne :
+
+export JDK_HOME=/path/vers/jdk
+
+Procédure d'installation
+________________________
+
+Une fois les pré-requis remplis, c'est très simple :
+
+- Récupérer l'archive zip `echobase-${project.version}-embedded.zip`_.
+
+- Décompresser l'archive, vous obtenez une arborescence de ce type:
+
+::
+
+ echobase-ui-1.1-embedded
+ ├── echobase.properties (1) Fichier de configuration de l'application embarquée
+ ├── echobase-ui-1.1-embedded.war
+ ├── LICENSE.txt
+ ├── README.txt
+ ├── startEchobase.bat (2) Script de démarrage (windows)
+ ├── startEchobase.sh (3) Script de démarrage (linux)
+ └── THIRD-PARTY.txt
+
+- Lancer le script *startEchobase.sh* (linux) ou *startEchobase.bat* (windows).
+
+L'application va démarrer et est accessible à l'adresse suivante:
+
+::
+ http://localhost:8888
+
+Procédure détaillée (sous windows)
+__________________________________
+
+- Dézipper l'archive précédemment téléchargée du site central.
+
+- Ouvrir une console (Touche Windows + R , taper *cmd* , Touche Entrée)
+- Se placer dans le répertoire où a été dézippée l'archive
+
+::
+ cd Chemin vers l'archive dézippée
+
+- Enfin lancer le script
+
+::
+ startEchobase.bat
+
+- Dans la console on doit voir l'application démarré et produire des logs
+- Lorsque l'application est prête, un navigateur s'ouvre sur la page
+ de login.
+
+Procédure détaillée (sous linux)
+________________________________
+
+- Dézipper l'archive précédemment téléchargée du site central.
+- Ouvrir une console
+- Se placer dans le répertoire où a été dézippée l'archive
+
+::
+ cd Chemin vers l'archive dézippée
+
+- Rendre le script de démarrage exécutable
+
+::
+ chmod +x startEchobase.sh
+
+- Enfin lancer le script
+
+::
+ ./startEchobase.sh
+
+- Dans la console on doit voir l'application démarré et produire des logs
+- Lorsque l'application est prête, un navigateur s'ouvre sur la page
+ de login.
+
+Utilisateurs
+____________
+
+Par défaut, deux utilisateurs sont fournis dans la base embarquée :
+
+- admin / admin (avec des droits d'administration)
+- user / user (pour la consultation)
+
+Configuration base de travail
+_____________________________
+
+Une configuration de base de travail est aussi crée automatiquement vers une
+base de type *H2* stoquée dans le répertoire *db* avec les identifiants suivants :
+
+- login: *sa*
+- mot de passe: *sa*
+
+Utiliser la version mode serveur
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Il faut que l'application est au préalable installée sur un serveur web.
+
+Demandez à votre administrateur l'url de connexion, et les identifiants.
+
+Si vous voulez installer EchoBase sur un serveur, veuillez consulter la
+`page installation`_.
+
+.. _echobase-${project.version}-embedded.zip: http://forge.codelutin.com/projects/echobase/files
+.. _page installation: ./install.html
+.. _Page de téléchargement Oracle: http://www.oracle.com/technetwork/java/javase/downloads/index.html
+
+
Property changes on: trunk/src/site/rst/usage.rst
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
1
0
Author: tchemit
Date: 2012-09-08 13:23:33 +0200 (Sat, 08 Sep 2012)
New Revision: 637
Url: http://forge.codelutin.com/repositories/revision/echobase/637
Log:
>From scmwebeditor -- fix documentation
Modified:
trunk/src/site/rst/index.rst
Modified: trunk/src/site/rst/index.rst
===================================================================
--- trunk/src/site/rst/index.rst 2012-09-07 20:58:54 UTC (rev 636)
+++ trunk/src/site/rst/index.rst 2012-09-08 11:23:33 UTC (rev 637)
@@ -55,8 +55,8 @@
- Comment créer une `application embarquée`_.
-.. _Ifremer forge: https://forge.ifremer.fr/www/echor
-.. _ICES WGFAST: http://www.acoustics.washington.edu/FAST
+.. _forge Ifremer: https://forge.ifremer.fr/www/echor
+.. _groupe de travail CIEM WGFAST: http://www.acoustics.washington.edu/FAST
.. _installation: ./install.html
.. _modèle: ./model.html
.. _imports: ./imports.html
1
0
r636 - in trunk: echobase-domain/src/main/java/fr/ifremer/echobase/services echobase-services/src/main/java/fr/ifremer/echobase/services echobase-services/src/main/java/fr/ifremer/echobase/services/importdata echobase-services/src/main/java/fr/ifremer/echobase/services/removedata
by tchemit@users.forge.codelutin.com 07 Sep '12
by tchemit@users.forge.codelutin.com 07 Sep '12
07 Sep '12
Author: tchemit
Date: 2012-09-07 22:58:54 +0200 (Fri, 07 Sep 2012)
New Revision: 636
Url: http://forge.codelutin.com/repositories/revision/echobase/636
Log:
refs #1437: Suppression des imports (add remove basic service)
Added:
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/AbstractRemoveDataService.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/AcousticRemoveDataService.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/CatchesRemoveDataService.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/CommonAllRemoveDataService.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/CommonTransectRemoveDataService.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/OperationRemoveDataService.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/ResultEsduRemoveDataService.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/ResultMapRemoveDataService.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/ResultRegionRemoveDataService.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/ResultVoyageRemoveDataService.java
Modified:
trunk/echobase-domain/src/main/java/fr/ifremer/echobase/services/EchoBaseServiceSupport.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/DecoratorService.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/AbstractImportDataService.java
Modified: trunk/echobase-domain/src/main/java/fr/ifremer/echobase/services/EchoBaseServiceSupport.java
===================================================================
--- trunk/echobase-domain/src/main/java/fr/ifremer/echobase/services/EchoBaseServiceSupport.java 2012-09-07 16:34:49 UTC (rev 635)
+++ trunk/echobase-domain/src/main/java/fr/ifremer/echobase/services/EchoBaseServiceSupport.java 2012-09-07 20:58:54 UTC (rev 636)
@@ -157,6 +157,37 @@
}
}
+ protected <E extends TopiaEntity> E create(TopiaDAO<E> dao,
+ Object... properties) {
+ try {
+ E result = dao.create(properties);
+ return result;
+ } catch (TopiaException e) {
+ throw new EchoBaseTechnicalException("Could not create entity", e);
+ }
+ }
+
+ protected final <E extends TopiaEntity> void delete(TopiaDAO<E> dao, E entity) {
+
+ try {
+ dao.delete(entity);
+ } catch (TopiaException e) {
+
+ throw new EchoBaseTechnicalException("Could not delete entity " + entity, e);
+ }
+ }
+
+ protected <E extends TopiaEntity> E findByProperties(TopiaDAO<E> dao,
+ String propertyName,
+ Object value,
+ Object... others) {
+ try {
+ E result = dao.findByProperties(propertyName, value, others);
+ return result;
+ } catch (TopiaException e) {
+ throw new EchoBaseTechnicalException("Could not obtain query db", e);
+ }
+ }
protected final <E extends TopiaEntity, D extends TopiaDAO<E>> D getDAO(Class<E> entityType, Class<D> daoType) {
TopiaDAO<E> dao = getDAO(entityType);
Preconditions.checkState(daoType.isAssignableFrom(dao.getClass()));
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/DecoratorService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/DecoratorService.java 2012-09-07 16:34:49 UTC (rev 635)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/DecoratorService.java 2012-09-07 20:58:54 UTC (rev 636)
@@ -28,6 +28,7 @@
import com.google.common.collect.Maps;
import fr.ifremer.echobase.entities.EchoBaseUser;
import fr.ifremer.echobase.entities.ExportQuery;
+import fr.ifremer.echobase.entities.ImportLog;
import fr.ifremer.echobase.entities.WorkingDbConfiguration;
import fr.ifremer.echobase.entities.data.Category;
import fr.ifremer.echobase.entities.data.Cell;
@@ -179,6 +180,10 @@
// ExportQuery decorator
registerJXPathDecorator(locale, ExportQuery.class, "${name}$s - ${description}$s");
+ // ImportLog decorator
+ registerJXPathDecorator(locale, ImportLog.class, "${importType}$s - ${importDate}$s - ${importText}$s");
+
+
// WorkingDbConfiguration decorator
registerJXPathDecorator(locale, WorkingDbConfiguration.class, "${url}$s - ${login}$s (${description}$s)");
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/AbstractImportDataService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/AbstractImportDataService.java 2012-09-07 16:34:49 UTC (rev 635)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/AbstractImportDataService.java 2012-09-07 20:58:54 UTC (rev 636)
@@ -136,7 +136,6 @@
EchoBaseUser user,
long time) {
-
Date importDate = newDate();
String importUser = user.getEmail();
@@ -261,16 +260,6 @@
}
}
- protected <E extends TopiaEntity> E create(TopiaDAO<E> dao,
- Object... properties) {
- try {
- E result = dao.create(properties);
- return result;
- } catch (TopiaException e) {
- throw new EchoBaseTechnicalException("Could not create entity", e);
- }
- }
-
protected <E extends TopiaEntity> E findByProperties(TopiaDAO<E> dao,
String propertyName,
Object value,
Added: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/AbstractRemoveDataService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/AbstractRemoveDataService.java (rev 0)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/AbstractRemoveDataService.java 2012-09-07 20:58:54 UTC (rev 636)
@@ -0,0 +1,239 @@
+package fr.ifremer.echobase.services.removedata;
+
+/*
+ * #%L
+ * EchoBase :: Services
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 - 2012 Ifremer, Codelutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+
+import com.google.common.collect.Lists;
+import fr.ifremer.echobase.EchoBaseTechnicalException;
+import fr.ifremer.echobase.entities.EchoBaseUser;
+import fr.ifremer.echobase.entities.EntityModificationLog;
+import fr.ifremer.echobase.entities.ImportLog;
+import fr.ifremer.echobase.entities.ImportType;
+import fr.ifremer.echobase.services.DecoratorService;
+import fr.ifremer.echobase.services.EchoBaseServiceSupport;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.topia.TopiaException;
+import org.nuiton.topia.TopiaNotFoundException;
+import org.nuiton.topia.persistence.TopiaDAO;
+import org.nuiton.topia.persistence.TopiaEntity;
+import org.nuiton.topia.persistence.TopiaId;
+import org.nuiton.util.StringUtil;
+import org.nuiton.util.TimeLog;
+import org.nuiton.util.decorator.Decorator;
+
+import java.util.List;
+import java.util.Locale;
+import java.util.Set;
+
+import static org.nuiton.i18n.I18n.l_;
+
+/**
+ * Abstract service to remove import data.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.2
+ */
+public abstract class AbstractRemoveDataService extends EchoBaseServiceSupport {
+
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(AbstractRemoveDataService.class);
+
+ public static final TimeLog TIME_LOG =
+ new TimeLog(AbstractRemoveDataService.class);
+
+ protected static final String ID_REQUEST =
+ "SELECT COUNT(*) FROM %s WHERE topiaid = :id";
+
+ protected String importLabel;
+
+ public String getImportLabel() {
+ return importLabel;
+ }
+
+ protected abstract void removeData(String id);
+
+ protected abstract Set<ImportType> getPossibleSubImportType();
+
+ public String doRemove(ImportLog importLog, EchoBaseUser user) {
+
+ Locale locale = getLocale();
+ importLabel = l_(locale, importLog.getImportType().getI18nKey());
+
+ long s0 = TimeLog.getTime();
+
+ for (String importId : importLog.getImportId()) {
+
+ removeData(importId);
+ }
+
+ s0 = TIME_LOG.log(s0, "removeData");
+
+ List<ImportLog> removedImortLog = removeObsoleteImportLogs(importLog);
+
+ s0 = TIME_LOG.log(s0, "removeObsoleteImportLogs");
+
+ // add result in log book and compute resume to show in result
+ String result = computeLogBookEntry(importLog,
+ removedImortLog,
+ user,
+ TimeLog.getTime() - s0);
+
+ // do commit
+ commitTransaction("Could not remove import " + getImportLabel());
+ return result;
+ }
+
+ protected List<ImportLog> removeObsoleteImportLogs(ImportLog importLog) {
+
+ List<ImportLog> result = Lists.newArrayList();
+
+ Set<ImportType> possibleSubImportType = getPossibleSubImportType();
+
+ TopiaDAO<ImportLog> dao = getDAO(ImportLog.class);
+
+ for (ImportLog logEntry : dao) {
+
+ if (importLog.equals(logEntry)) {
+
+ // for sure remove me
+ // but do not add to result
+ delete(dao, logEntry);
+ continue;
+ }
+
+ if (possibleSubImportType.contains(logEntry.getImportType())) {
+
+ // ok can try to remove this import log
+ // try to find out if first id is still exists
+ String firstId = importLog.getImportId().iterator().next();
+
+ if (!isIdExists(firstId)) {
+
+ // one of id does not exist, can safely remove importLog
+
+ if (log.isInfoEnabled()) {
+ log.info("Will remove obsolete importLog " +
+ importLog.getTopiaId());
+ }
+
+ delete(dao, logEntry);
+
+ // add it in result
+ result.add(logEntry);
+ }
+ }
+ }
+ return result;
+ }
+
+ protected String computeLogBookEntry(ImportLog importLog,
+ List<ImportLog> obsoleteImportLogs,
+ EchoBaseUser user,
+ long time) {
+
+ Decorator<ImportLog> decorator = getService(DecoratorService.class).
+ getDecorator(getLocale(), ImportLog.class, null);
+
+ StringBuilder buffer = new StringBuilder();
+ buffer.append("Suppression import ");
+ buffer.append(decorator.toString(importLog));
+ buffer.append("\nOpération réalisée en ");
+ buffer.append(StringUtil.convertTime(time));
+
+ for (ImportLog obsoleteImportLog : obsoleteImportLogs) {
+
+ buffer.append("\n- Suppression en cascade de l'import ");
+ buffer.append(decorator.toString(obsoleteImportLog));
+ }
+
+ String result = buffer.toString();
+
+ if (log.isDebugEnabled()) {
+ log.debug("Log text: " + result);
+ }
+ create(getDAO(EntityModificationLog.class),
+ EntityModificationLog.PROPERTY_ENTITY_TYPE, "Remove Import",
+ EntityModificationLog.PROPERTY_ENTITY_ID, importLog.getImportType(),
+ EntityModificationLog.PROPERTY_MODIFICATION_USER, user.getEmail(),
+ EntityModificationLog.PROPERTY_MODIFICATION_DATE, newDate(),
+ EntityModificationLog.PROPERTY_MODIFICATION_TEXT, result
+ );
+ return result;
+ }
+
+ protected boolean isIdExists(String id) {
+
+ try {
+
+ boolean result = getDAOFromId(id).existByTopiaId(id);
+ return result;
+ } catch (TopiaException e) {
+ throw new EchoBaseTechnicalException(
+ "Could not find out if id " + id + " exists.", e);
+ }
+ }
+
+ protected <E extends TopiaEntity> E findById(TopiaDAO<E> dao, String id) {
+
+ try {
+ E result = dao.findByTopiaId(id);
+ return result;
+ } catch (TopiaException e) {
+ throw new EchoBaseTechnicalException("Could not find entity with id " + id, e);
+ }
+ }
+
+ protected <E extends TopiaEntity> TopiaDAO<E> getDAOFromId(String id) {
+ try {
+ return getDAO(TopiaId.getClassName(id));
+ } catch (TopiaNotFoundException e) {
+
+ throw new EchoBaseTechnicalException(
+ "Could not find class from id: " + id, e);
+ }
+ }
+
+ protected <E extends TopiaEntity> E removeEntity(String id) {
+
+ // get dao
+ TopiaDAO<E> dao = getDAOFromId(id);
+
+ // get entity to delete
+ E entity = findById(dao, id);
+
+ // delete it
+ delete(dao, entity);
+
+ return entity;
+ }
+
+
+ protected void canNotDealWithId(String id) {
+ throw new IllegalStateException(
+ "Can not deal with this type of id " + id +
+ " from service " + this);
+ }
+
+}
Property changes on: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/AbstractRemoveDataService.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/AcousticRemoveDataService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/AcousticRemoveDataService.java (rev 0)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/AcousticRemoveDataService.java 2012-09-07 20:58:54 UTC (rev 636)
@@ -0,0 +1,90 @@
+package fr.ifremer.echobase.services.removedata;
+
+/*
+ * #%L
+ * EchoBase :: Services
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 - 2012 Ifremer, Codelutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+
+import com.google.common.collect.Sets;
+import fr.ifremer.echobase.entities.ImportType;
+import fr.ifremer.echobase.entities.data.Cell;
+import fr.ifremer.echobase.entities.data.DataAcquisition;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * Remove a {@link ImportType#ACOUSTIC} import.
+ * <p/>
+ * Can remove only {@link DataAcquisition} or {@link Cell}.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.2
+ */
+public class AcousticRemoveDataService extends AbstractRemoveDataService {
+
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(AcousticRemoveDataService.class);
+
+ @Override
+ protected void removeData(String id) {
+
+ if (id.startsWith(DataAcquisition.class.getName())) {
+
+ // remove dataAcquisition
+ removeDataAcquisition(id);
+ } else if (id.startsWith(Cell.class.getName())) {
+
+ // remove cell
+ removeCell(id);
+ } else {
+ canNotDealWithId(id);
+ }
+ }
+
+ protected void removeDataAcquisition(String id) {
+ DataAcquisition entity = removeEntity(id);
+ if (log.isInfoEnabled()) {
+ log.info("DataAcquisition " + entity.getTopiaId() + " was removed");
+ }
+ }
+
+ protected void removeCell(String id) {
+ Cell entity = removeEntity(id);
+ if (log.isInfoEnabled()) {
+ log.info("Cell " + entity.getTopiaId() + " was removed");
+ }
+ }
+
+ @Override
+ protected Set<ImportType> getPossibleSubImportType() {
+ HashSet<ImportType> result = Sets.newHashSet(ImportType.values());
+ result.remove(ImportType.COMMON_ALL);
+ result.remove(ImportType.COMMON_TRANSECT);
+ result.remove(ImportType.OPERATION);
+ result.remove(ImportType.CATCHES);
+ result.remove(ImportType.ACOUSTIC);
+ return result;
+ }
+}
Property changes on: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/AcousticRemoveDataService.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/CatchesRemoveDataService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/CatchesRemoveDataService.java (rev 0)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/CatchesRemoveDataService.java 2012-09-07 20:58:54 UTC (rev 636)
@@ -0,0 +1,77 @@
+package fr.ifremer.echobase.services.removedata;
+
+/*
+ * #%L
+ * EchoBase :: Services
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 - 2012 Ifremer, Codelutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+
+import com.google.common.collect.Sets;
+import fr.ifremer.echobase.entities.ImportType;
+import fr.ifremer.echobase.entities.data.Sample;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * Remove a {@link ImportType#CATCHES} import.
+ * <p/>
+ * Can remove only {@link Sample}.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.2
+ */
+public class CatchesRemoveDataService extends AbstractRemoveDataService {
+
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(CatchesRemoveDataService.class);
+
+ @Override
+ protected void removeData(String id) {
+
+ if (id.startsWith(Sample.class.getName())) {
+
+ // remove sample
+ removeSample(id);
+ } else {
+ canNotDealWithId(id);
+ }
+ }
+
+ protected void removeSample(String id) {
+ Sample entity = removeEntity(id);
+ if (log.isInfoEnabled()) {
+ log.info("Sample " + entity.getTopiaId() + " was removed");
+ }
+ }
+
+ @Override
+ protected Set<ImportType> getPossibleSubImportType() {
+ HashSet<ImportType> result = Sets.newHashSet(ImportType.values());
+ result.remove(ImportType.COMMON_ALL);
+ result.remove(ImportType.COMMON_TRANSECT);
+ result.remove(ImportType.OPERATION);
+ result.remove(ImportType.CATCHES);
+ return result;
+ }
+}
Property changes on: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/CatchesRemoveDataService.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/CommonAllRemoveDataService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/CommonAllRemoveDataService.java (rev 0)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/CommonAllRemoveDataService.java 2012-09-07 20:58:54 UTC (rev 636)
@@ -0,0 +1,75 @@
+package fr.ifremer.echobase.services.removedata;
+
+/*
+ * #%L
+ * EchoBase :: Services
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 - 2012 Ifremer, Codelutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+
+import com.google.common.collect.Sets;
+import fr.ifremer.echobase.entities.ImportType;
+import fr.ifremer.echobase.entities.data.Voyage;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * Remove a {@link ImportType#COMMON_ALL} import.
+ * <p/>
+ * Can remove only {@link Voyage}.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.2
+ */
+public class CommonAllRemoveDataService extends AbstractRemoveDataService {
+
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(CommonAllRemoveDataService.class);
+
+ @Override
+ protected void removeData(String id) {
+
+ if (id.startsWith(Voyage.class.getName())) {
+
+ // remove voyage
+ removeVoyage(id);
+ } else {
+ canNotDealWithId(id);
+ }
+ }
+
+ protected void removeVoyage(String id) {
+ Voyage entity = removeEntity(id);
+ if (log.isInfoEnabled()) {
+ log.info("Voyage " + entity.getTopiaId() + " was removed");
+ }
+ }
+
+ @Override
+ protected Set<ImportType> getPossibleSubImportType() {
+ HashSet<ImportType> result = Sets.newHashSet(ImportType.values());
+ result.remove(ImportType.COMMON_ALL);
+ result.remove(ImportType.COMMON_TRANSECT);
+ return result;
+ }
+}
Property changes on: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/CommonAllRemoveDataService.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/CommonTransectRemoveDataService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/CommonTransectRemoveDataService.java (rev 0)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/CommonTransectRemoveDataService.java 2012-09-07 20:58:54 UTC (rev 636)
@@ -0,0 +1,75 @@
+package fr.ifremer.echobase.services.removedata;
+
+/*
+ * #%L
+ * EchoBase :: Services
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 - 2012 Ifremer, Codelutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+
+import com.google.common.collect.Sets;
+import fr.ifremer.echobase.entities.ImportType;
+import fr.ifremer.echobase.entities.data.Transect;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * Remove a {@link ImportType#COMMON_TRANSECT} import.
+ * <p/>
+ * Can remove only {@link Transect}.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.2
+ */
+public class CommonTransectRemoveDataService extends AbstractRemoveDataService {
+
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(CommonTransectRemoveDataService.class);
+
+ @Override
+ protected void removeData(String id) {
+
+ if (id.startsWith(Transect.class.getName())) {
+
+ // remove transect
+ removeTransect(id);
+ } else {
+ canNotDealWithId(id);
+ }
+ }
+
+ protected void removeTransect(String id) {
+ Transect entity = removeEntity(id);
+ if (log.isInfoEnabled()) {
+ log.info("Transect " + entity.getTopiaId() + " was removed");
+ }
+ }
+
+ @Override
+ protected Set<ImportType> getPossibleSubImportType() {
+ HashSet<ImportType> result = Sets.newHashSet(ImportType.values());
+ result.remove(ImportType.COMMON_ALL);
+ result.remove(ImportType.COMMON_TRANSECT);
+ return result;
+ }
+}
Property changes on: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/CommonTransectRemoveDataService.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/OperationRemoveDataService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/OperationRemoveDataService.java (rev 0)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/OperationRemoveDataService.java 2012-09-07 20:58:54 UTC (rev 636)
@@ -0,0 +1,76 @@
+package fr.ifremer.echobase.services.removedata;
+
+/*
+ * #%L
+ * EchoBase :: Services
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 - 2012 Ifremer, Codelutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+
+import com.google.common.collect.Sets;
+import fr.ifremer.echobase.entities.ImportType;
+import fr.ifremer.echobase.entities.data.Operation;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * Remove a {@link ImportType#OPERATION} import.
+ * <p/>
+ * Can remove only {@link Operation}.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.2
+ */
+public class OperationRemoveDataService extends AbstractRemoveDataService {
+
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(OperationRemoveDataService.class);
+
+ @Override
+ protected void removeData(String id) {
+
+ if (id.startsWith(Operation.class.getName())) {
+
+ // remove operation
+ removeOperation(id);
+ } else {
+ canNotDealWithId(id);
+ }
+ }
+
+ protected void removeOperation(String id) {
+ Operation entity = removeEntity(id);
+ if (log.isInfoEnabled()) {
+ log.info("Operation " + entity.getTopiaId() + " was removed");
+ }
+ }
+
+ @Override
+ protected Set<ImportType> getPossibleSubImportType() {
+ HashSet<ImportType> result = Sets.newHashSet(ImportType.values());
+ result.remove(ImportType.COMMON_ALL);
+ result.remove(ImportType.COMMON_TRANSECT);
+ result.remove(ImportType.OPERATION);
+ return result;
+ }
+}
Property changes on: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/OperationRemoveDataService.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/ResultEsduRemoveDataService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/ResultEsduRemoveDataService.java (rev 0)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/ResultEsduRemoveDataService.java 2012-09-07 20:58:54 UTC (rev 636)
@@ -0,0 +1,80 @@
+package fr.ifremer.echobase.services.removedata;
+
+/*
+ * #%L
+ * EchoBase :: Services
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 - 2012 Ifremer, Codelutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+
+import com.google.common.collect.Sets;
+import fr.ifremer.echobase.entities.ImportType;
+import fr.ifremer.echobase.entities.data.Result;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * Remove a {@link ImportType#RESULT_ESDU} import.
+ * <p/>
+ * Can remove only {@link Result}.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.2
+ */
+public class ResultEsduRemoveDataService extends AbstractRemoveDataService {
+
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(ResultEsduRemoveDataService.class);
+
+ @Override
+ protected void removeData(String id) {
+
+ if (id.startsWith(Result.class.getName())) {
+
+ // remove result
+ removeResult(id);
+ } else {
+ canNotDealWithId(id);
+ }
+ }
+
+ protected void removeResult(String id) {
+ Result entity = removeEntity(id);
+ if (log.isInfoEnabled()) {
+ log.info("Result " + entity.getTopiaId() + " was removed");
+ }
+ }
+
+ @Override
+ protected Set<ImportType> getPossibleSubImportType() {
+ HashSet<ImportType> result = Sets.newHashSet(ImportType.values());
+ result.remove(ImportType.COMMON_ALL);
+ result.remove(ImportType.COMMON_TRANSECT);
+ result.remove(ImportType.OPERATION);
+ result.remove(ImportType.CATCHES);
+ result.remove(ImportType.ACOUSTIC);
+ result.remove(ImportType.RESULT_VOYAGE);
+ result.remove(ImportType.RESULT_ESDU);
+ return result;
+ }
+}
Property changes on: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/ResultEsduRemoveDataService.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/ResultMapRemoveDataService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/ResultMapRemoveDataService.java (rev 0)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/ResultMapRemoveDataService.java 2012-09-07 20:58:54 UTC (rev 636)
@@ -0,0 +1,73 @@
+package fr.ifremer.echobase.services.removedata;
+
+/*
+ * #%L
+ * EchoBase :: Services
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 - 2012 Ifremer, Codelutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+
+import com.google.common.collect.Sets;
+import fr.ifremer.echobase.entities.ImportType;
+import fr.ifremer.echobase.entities.data.Cell;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * Remove a {@link ImportType#RESULT_MAP} import.
+ * <p/>
+ * Can remove only {@link Cell}.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.2
+ */
+public class ResultMapRemoveDataService extends AbstractRemoveDataService {
+
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(ResultMapRemoveDataService.class);
+
+ @Override
+ protected void removeData(String id) {
+
+ if (id.startsWith(Cell.class.getName())) {
+
+ // remove cell
+ removeCell(id);
+ } else {
+ canNotDealWithId(id);
+ }
+ }
+
+ protected void removeCell(String id) {
+ Cell entity = removeEntity(id);
+ if (log.isInfoEnabled()) {
+ log.info("Cell " + entity.getTopiaId() + " was removed");
+ }
+ }
+
+ @Override
+ protected Set<ImportType> getPossibleSubImportType() {
+ HashSet<ImportType> result = Sets.newHashSet();
+ return result;
+ }
+}
Property changes on: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/ResultMapRemoveDataService.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/ResultRegionRemoveDataService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/ResultRegionRemoveDataService.java (rev 0)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/ResultRegionRemoveDataService.java 2012-09-07 20:58:54 UTC (rev 636)
@@ -0,0 +1,81 @@
+package fr.ifremer.echobase.services.removedata;
+
+/*
+ * #%L
+ * EchoBase :: Services
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 - 2012 Ifremer, Codelutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+
+import com.google.common.collect.Sets;
+import fr.ifremer.echobase.entities.ImportType;
+import fr.ifremer.echobase.entities.data.Cell;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * Remove a {@link ImportType#RESULT_REGION} import.
+ * <p/>
+ * Can remove only {@link Cell}.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.2
+ */
+public class ResultRegionRemoveDataService extends AbstractRemoveDataService {
+
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(ResultRegionRemoveDataService.class);
+
+ @Override
+ protected void removeData(String id) {
+
+ if (id.startsWith(Cell.class.getName())) {
+
+ // remove echotype
+ removeCell(id);
+ } else {
+ canNotDealWithId(id);
+ }
+ }
+
+ protected void removeCell(String id) {
+ Cell entity = removeEntity(id);
+ if (log.isInfoEnabled()) {
+ log.info("Cell " + entity.getTopiaId() + " was removed");
+ }
+ }
+
+ @Override
+ protected Set<ImportType> getPossibleSubImportType() {
+ HashSet<ImportType> result = Sets.newHashSet(ImportType.values());
+ result.remove(ImportType.COMMON_ALL);
+ result.remove(ImportType.COMMON_TRANSECT);
+ result.remove(ImportType.OPERATION);
+ result.remove(ImportType.CATCHES);
+ result.remove(ImportType.ACOUSTIC);
+ result.remove(ImportType.RESULT_VOYAGE);
+ result.remove(ImportType.RESULT_ESDU);
+ result.remove(ImportType.RESULT_VOYAGE);
+ return result;
+ }
+}
Property changes on: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/ResultRegionRemoveDataService.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/ResultVoyageRemoveDataService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/ResultVoyageRemoveDataService.java (rev 0)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/ResultVoyageRemoveDataService.java 2012-09-07 20:58:54 UTC (rev 636)
@@ -0,0 +1,104 @@
+package fr.ifremer.echobase.services.removedata;
+
+/*
+ * #%L
+ * EchoBase :: Services
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 - 2012 Ifremer, Codelutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+
+import com.google.common.collect.Sets;
+import fr.ifremer.echobase.entities.ImportType;
+import fr.ifremer.echobase.entities.data.Echotype;
+import fr.ifremer.echobase.entities.data.LengthAgeKey;
+import fr.ifremer.echobase.entities.data.LengthWeightKey;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * remove a {@link ImportType#OPERATION} import.
+ * <p/>
+ * Can remove only {@link Echotype}, {@link LengthAgeKey} or
+ * {@link LengthWeightKey}.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.2
+ */
+public class ResultVoyageRemoveDataService extends AbstractRemoveDataService {
+
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(ResultVoyageRemoveDataService.class);
+
+ @Override
+ protected void removeData(String id) {
+
+ if (id.startsWith(Echotype.class.getName())) {
+
+ // remove echotype
+ removeEchotype(id);
+ } else if (id.startsWith(LengthAgeKey.class.getName())) {
+
+ // remove lengthAgeKey
+ removeLengthAgeKey(id);
+ } else if (id.startsWith(LengthWeightKey.class.getName())) {
+
+ // remove lengthAgeKey
+ removeLengthWeightKey(id);
+ } else {
+ canNotDealWithId(id);
+ }
+ }
+
+ protected void removeEchotype(String id) {
+ Echotype entity = removeEntity(id);
+ if (log.isInfoEnabled()) {
+ log.info("Echotype " + entity.getTopiaId() + " was removed");
+ }
+ }
+
+ protected void removeLengthAgeKey(String id) {
+ LengthAgeKey entity = removeEntity(id);
+ if (log.isInfoEnabled()) {
+ log.info("LengthAgeKey " + entity.getTopiaId() + " was removed");
+ }
+ }
+
+ protected void removeLengthWeightKey(String id) {
+ LengthWeightKey entity = removeEntity(id);
+ if (log.isInfoEnabled()) {
+ log.info("LengthWeightKey " + entity.getTopiaId() + " was removed");
+ }
+ }
+
+ @Override
+ protected Set<ImportType> getPossibleSubImportType() {
+ HashSet<ImportType> result = Sets.newHashSet(ImportType.values());
+ result.remove(ImportType.COMMON_ALL);
+ result.remove(ImportType.COMMON_TRANSECT);
+ result.remove(ImportType.OPERATION);
+ result.remove(ImportType.CATCHES);
+ result.remove(ImportType.ACOUSTIC);
+ result.remove(ImportType.RESULT_VOYAGE);
+ return result;
+ }
+}
Property changes on: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/removedata/ResultVoyageRemoveDataService.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
1
0
07 Sep '12
Author: tchemit
Date: 2012-09-07 18:34:49 +0200 (Fri, 07 Sep 2012)
New Revision: 635
Url: http://forge.codelutin.com/repositories/revision/echobase/635
Log:
remove migraiont 0.9 (was only ther for test purpose)
make import test works again (migrate them to version 1.2)
make test use the working db as in real life
refs #1437: Suppression des imports (test ImportResult ids and it works!)
Added:
trunk/echobase-services/src/test/resources/echobase-1.2-importDb-referentiel.zip
trunk/echobase-services/src/test/resources/import-data/echobase-1.2-catches-and-voyage-result.h2.db.gz
trunk/echobase-services/src/test/resources/import-data/echobase-1.2-catches.h2.db.gz
trunk/echobase-services/src/test/resources/import-data/echobase-1.2-commonData.h2.db.gz
trunk/echobase-services/src/test/resources/import-data/echobase-1.2-nodata.h2.db.gz
trunk/echobase-services/src/test/resources/import-data/echobase-1.2-operation.h2.db.gz
Removed:
trunk/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/migration/workingDb/MigrationCallbackV0_9.java
trunk/echobase-services/src/test/resources/echobase-0.3-importDb-referentiel.zip
trunk/echobase-services/src/test/resources/import-data/echobase-0.3-catches-and-voyage-result.h2.db.gz
trunk/echobase-services/src/test/resources/import-data/echobase-0.3-catches.h2.db.gz
trunk/echobase-services/src/test/resources/import-data/echobase-0.3-commonData.h2.db.gz
trunk/echobase-services/src/test/resources/import-data/echobase-0.3-nodata.h2.db.gz
trunk/echobase-services/src/test/resources/import-data/echobase-0.3-operation.h2.db.gz
Modified:
trunk/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/EchobaseTopiaContexts.java
trunk/echobase-domain/src/main/resources/META-INF/services/fr.ifremer.echobase.persistence.migration.workingDb.MigrationCallBackForVersion
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/ResultsVoyageImportService.java
trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/EchoBaseTestServiceSupport.java
trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/FakeEchoBaseServiceContext.java
trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/ImportDbServiceTest.java
trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/AbstractImportDataServiceIT.java
trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/AcousticImportServiceIT.java
trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/CatchesImportServiceIT.java
trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/CommonAllImportServiceIT.java
trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/CommonTransectImportServiceIT.java
trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/OperationImportServiceIT.java
trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/ResultsEsduCellImportServiceIT.java
trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/ResultsMapCellImportServiceIT.java
trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/ResultsRegionCellImportServiceIT.java
trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/ResultsVoyageImportServiceIT.java
trunk/echobase-services/src/test/resources/import-data/common/transect.csv.gz
trunk/echobase-services/src/test/resources/import-data/common/transit.csv.gz
trunk/echobase-services/src/test/resources/import-data/common/voyage.csv.gz
trunk/echobase-services/src/test/resources/import-data/operation/operation.csv.gz
trunk/echobase-services/src/test/resources/import-data/result/voyage/lengthWeightKey.csv.gz
trunk/echobase-services/update-import-data-db.sh
Modified: trunk/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/EchobaseTopiaContexts.java
===================================================================
--- trunk/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/EchobaseTopiaContexts.java 2012-09-07 14:02:07 UTC (rev 634)
+++ trunk/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/EchobaseTopiaContexts.java 2012-09-07 16:34:49 UTC (rev 635)
@@ -187,7 +187,7 @@
* @param configuration topia configuration
* @return the new fresh root context
*/
- public static TopiaContext newDb(Properties configuration) {
+ private static TopiaContext newDb(Properties configuration) {
try {
if (log.isInfoEnabled()) {
log.info("Starts a db at : " +
Deleted: trunk/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/migration/workingDb/MigrationCallbackV0_9.java
===================================================================
--- trunk/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/migration/workingDb/MigrationCallbackV0_9.java 2012-09-07 14:02:07 UTC (rev 634)
+++ trunk/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/migration/workingDb/MigrationCallbackV0_9.java 2012-09-07 16:34:49 UTC (rev 635)
@@ -1,113 +0,0 @@
-package fr.ifremer.echobase.persistence.migration.workingDb;
-
-/*
- * #%L
- * EchoBase :: Domain
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2011 - 2012 Ifremer, Codelutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- * #L%
- */
-
-import org.hibernate.dialect.Dialect;
-import org.hibernate.dialect.H2Dialect;
-import org.hibernate.dialect.PostgreSQLDialect;
-import org.nuiton.topia.TopiaException;
-import org.nuiton.topia.TopiaNotFoundException;
-import org.nuiton.topia.framework.TopiaContextImplementor;
-import org.nuiton.util.Version;
-import org.nuiton.util.VersionUtil;
-
-import java.util.List;
-
-/**
- * Migration for version {@code 0.9}.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.2
- */
-public class MigrationCallbackV0_9 extends MigrationCallBackForVersion {
-
- @Override
- public Version getVersion() {
- return VersionUtil.valueOf("0.9");
- }
-
- @Override
- protected void prepareMigrationScript(TopiaContextImplementor tx,
- List<String> queries,
- boolean showSql,
- boolean showProgression) throws TopiaException {
-
-
- // add strata column on lengthweightkey table
- addStrataToLengthWeightKeyTable(tx, queries);
-
-// createSexCategoryTable(tx,queries);
- }
-
- protected void addStrataToLengthWeightKeyTable(TopiaContextImplementor tx,
- List<String> queries) throws TopiaNotFoundException {
- Dialect dialect =
- Dialect.getDialect(tx.getHibernateConfiguration().getProperties());
-
- if (dialect instanceof PostgreSQLDialect) {
-
- queries.add("ALTER TABLE lengthweightkey ADD COLUMN strata character varying(255);");
-
- queries.add("ALTER TABLE lengthweightkey ADD CONSTRAINT FK1687F88192874545_INDEX_E FOREIGN KEY(strata) REFERENCES strata(topiaid);");
-
- } else if (dialect instanceof H2Dialect) {
-
- queries.add("ALTER TABLE lengthweightkey ADD COLUMN strata VARCHAR(255);");
-
- queries.add("ALTER TABLE lengthweightkey ADD CONSTRAINT FK1687F88192874545_INDEX_E FOREIGN KEY(strata) REFERENCES strata(topiaid);");
- }
- }
-
-//
-// protected void createSexCategoryTable(TopiaContextImplementor tx,
-// List<String> queries) throws TopiaNotFoundException {
-// Dialect dialect =
-// Dialect.getDialect(tx.getHibernateConfiguration().getProperties());
-//
-// if (dialect instanceof PostgreSQLDialect) {
-// queries.add("CREATE TABLE sexcategory (\n" +
-// "topiaid character varying(255) NOT NULL,\n" +
-// "topiaversion bigint NOT NULL,\n" +
-// "topiacreatedate date,\n" +
-// "name character varying(1024),\n" +
-// "meaning character varying(255)\n" +
-// ");");
-// queries.add("ALTER TABLE sexcategory ADD CONSTRAINT PRIMARY_KEY_472 PRIMARY KEY(topiaid);");
-// queries.add("ALTER TABLE sexcategory ADD CONSTRAINT CONSTRAINT_INDEX_472 UNIQUE KEY(name);");
-//
-// } else if (dialect instanceof H2Dialect) {
-//
-// queries.add("CREATE TABLE sexcategory (\n" +
-// "topiaid VARCHAR(255) NOT NULL,\n" +
-// "topiaversion BIGINT NOT NULL,\n" +
-// "topiacreatedate DATE,\n" +
-// "name VARCHAR(1024),\n" +
-// "meaning VARCHAR(255)\n" +
-// ");");
-//
-// queries.add("ALTER TABLE sexcategory ADD CONSTRAINT PRIMARY_KEY_472 PRIMARY KEY(topiaid);");
-// queries.add("ALTER TABLE sexcategory ADD CONSTRAINT CONSTRAINT_INDEX_472 UNIQUE KEY(topiaid);");
-// }
-// }
-}
Modified: trunk/echobase-domain/src/main/resources/META-INF/services/fr.ifremer.echobase.persistence.migration.workingDb.MigrationCallBackForVersion
===================================================================
--- trunk/echobase-domain/src/main/resources/META-INF/services/fr.ifremer.echobase.persistence.migration.workingDb.MigrationCallBackForVersion 2012-09-07 14:02:07 UTC (rev 634)
+++ trunk/echobase-domain/src/main/resources/META-INF/services/fr.ifremer.echobase.persistence.migration.workingDb.MigrationCallBackForVersion 2012-09-07 16:34:49 UTC (rev 635)
@@ -1,3 +1,2 @@
-fr.ifremer.echobase.persistence.migration.workingDb.MigrationCallbackV0_9
fr.ifremer.echobase.persistence.migration.workingDb.MigrationCallbackV1_1
fr.ifremer.echobase.persistence.migration.workingDb.MigrationCallbackV1_2
\ No newline at end of file
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/ResultsVoyageImportService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/ResultsVoyageImportService.java 2012-09-07 14:02:07 UTC (rev 634)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/ResultsVoyageImportService.java 2012-09-07 16:34:49 UTC (rev 635)
@@ -199,7 +199,9 @@
// attach it to voyage
voyage.addLengthWeightKey(lengthWeightKey);
- importResult.incrementsNumberCreated(EchoBaseEntityEnum.LengthWeightKey);
+ // collect ids
+ importResult.addId(EchoBaseEntityEnum.LengthWeightKey,
+ lengthWeightKey);
}
return importResult;
Modified: trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/EchoBaseTestServiceSupport.java
===================================================================
--- trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/EchoBaseTestServiceSupport.java 2012-09-07 14:02:07 UTC (rev 634)
+++ trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/EchoBaseTestServiceSupport.java 2012-09-07 16:34:49 UTC (rev 635)
@@ -138,29 +138,25 @@
protected <E extends TopiaEntity> void assertCsvImportResult(EchoBaseCsvFileImportResult actual,
Class<E> entityType,
- int numberCreated,
- int nbIds) throws TopiaException {
+ int numberCreated) throws TopiaException {
assertCsvImportResult(actual,
entityType,
numberCreated,
0,
- numberCreated,
- nbIds);
+ numberCreated);
}
protected <E extends TopiaEntity> void assertCsvImportResult(List<EchoBaseCsvFileImportResult> actual,
int pos,
Class<E> entityType,
- int numberCreated,
- int nbIds) throws TopiaException {
+ int numberCreated) throws TopiaException {
Assert.assertTrue(actual.size() >= pos);
assertCsvImportResult(actual.get(pos),
entityType,
numberCreated,
0,
- numberCreated,
- nbIds);
+ numberCreated);
}
@@ -168,8 +164,7 @@
Class<E> entityType,
int numberCreated,
int numberUpdated,
- int nbCount,
- int nbIds) throws TopiaException {
+ int nbCount) throws TopiaException {
Assert.assertNotNull(actual);
Set<EchoBaseEntityEnum> entityTypes = actual.getEntityTypes();
EchoBaseEntityEnum expectedEntityType = EchoBaseEntityEnum.valueOf(entityType);
@@ -177,7 +172,6 @@
Assert.assertEquals(numberCreated, actual.getNumberCreated(expectedEntityType));
Assert.assertEquals(numberUpdated, actual.getNumberUpdated(expectedEntityType));
assertNbEntities(entityType, nbCount);
- Assert.assertEquals(nbIds, actual.getIds().size());
}
protected <E extends TopiaEntity> void assertCsvImportResult(List<EchoBaseCsvFileImportResult> results,
@@ -185,8 +179,7 @@
Class<E> entityType,
int numberCreated,
int numberUpdated,
- int nbCount,
- int nbIds) throws TopiaException {
+ int nbCount) throws TopiaException {
Assert.assertTrue(results.size() >= pos);
EchoBaseCsvFileImportResult actual = results.get(pos);
Assert.assertNotNull(actual);
@@ -196,6 +189,14 @@
Assert.assertEquals(numberCreated, actual.getNumberCreated(expectedEntityType));
Assert.assertEquals(numberUpdated, actual.getNumberUpdated(expectedEntityType));
assertNbEntities(entityType, nbCount);
+ }
+
+ protected <E extends TopiaEntity> void assertNbIDs(List<EchoBaseCsvFileImportResult> results,
+ int pos,
+ int nbIds) throws TopiaException {
+ Assert.assertTrue(results.size() >= pos);
+ EchoBaseCsvFileImportResult actual = results.get(pos);
+ Assert.assertNotNull(actual);
Assert.assertEquals(nbIds, actual.getIds().size());
}
Modified: trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/FakeEchoBaseServiceContext.java
===================================================================
--- trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/FakeEchoBaseServiceContext.java 2012-09-07 14:02:07 UTC (rev 634)
+++ trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/FakeEchoBaseServiceContext.java 2012-09-07 16:34:49 UTC (rev 635)
@@ -149,11 +149,7 @@
configuration = new EchoBaseConfiguration(defaultProps);
JdbcConfiguration dbConf = JdbcConfiguration.newEmbeddedConfig(testDir);
- Properties properties = EchobaseTopiaContexts.loadWorkingDbConfiguration(dbConf);
-
- //FIXME should never try to update db, tests db should always be uptodate...
- //properties.put("hibernate.hbm2ddl.auto", "update");
- rootContext = EchobaseTopiaContexts.newDb(properties);
+ rootContext = EchobaseTopiaContexts.newWorkingDb(dbConf);
}
@Override
Modified: trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/ImportDbServiceTest.java
===================================================================
--- trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/ImportDbServiceTest.java 2012-09-07 14:02:07 UTC (rev 634)
+++ trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/ImportDbServiceTest.java 2012-09-07 16:34:49 UTC (rev 635)
@@ -43,6 +43,8 @@
*/
public class ImportDbServiceTest extends EchoBaseTestServiceSupport {
+ public static final String DB_VERSION = "1.2";
+
@Override
protected FakeEchoBaseServiceContext initContext() {
return new FakeEchoBaseServiceContext(null);
@@ -51,8 +53,6 @@
@Test
public void importDb() throws IOException, TopiaException {
- serviceContext.getTransaction().updateSchema();
-
ImportDbService service = getService(ImportDbService.class);
ImportDbConfiguration conf = new ImportDbConfiguration(getLocale());
@@ -61,7 +61,7 @@
FileUtil.createDirectoryIfNecessary(workingDirectory);
conf.setWorkingDirectory(workingDirectory);
- prepareInputFile(conf.getInput(), "/echobase-0.3-importDb-referentiel.zip");
+ prepareInputFile(conf.getInput(), "/echobase-" + DB_VERSION + "-importDb-referentiel.zip");
EchoBaseUser user = new EchoBaseUserImpl();
user.setEmail("testUser(a)fake.fr");
Modified: trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/AbstractImportDataServiceIT.java
===================================================================
--- trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/AbstractImportDataServiceIT.java 2012-09-07 14:02:07 UTC (rev 634)
+++ trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/AbstractImportDataServiceIT.java 2012-09-07 16:34:49 UTC (rev 635)
@@ -50,6 +50,7 @@
import fr.ifremer.echobase.entities.references.CellType;
import fr.ifremer.echobase.io.InputFile;
import fr.ifremer.echobase.services.EchoBaseTestServiceSupport;
+import fr.ifremer.echobase.services.ImportDbServiceTest;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.junit.Assert;
@@ -81,19 +82,19 @@
public static final TimeLog TIME_LOG = new TimeLog(AbstractImportDataServiceIT.class);
- public static final String IMPORT_DATA_ECHOBASE_NO_DATA = "/import-data/echobase-0.3-nodata.h2.db.gz";
+ public static final String IMPORT_DATA_ECHOBASE_NO_DATA = "/import-data/echobase-" + ImportDbServiceTest.DB_VERSION + "-nodata.h2.db.gz";
- public static final String IMPORT_DATA_ECHOBASE_COMMON_DATA = "/import-data/echobase-0.3-commonData.h2.db.gz";
+ public static final String IMPORT_DATA_ECHOBASE_COMMON_DATA = "/import-data/echobase-" + ImportDbServiceTest.DB_VERSION + "-commonData.h2.db.gz";
- public static final String IMPORT_DATA_ECHOBASE_OPERATION = "/import-data/echobase-0.3-operation.h2.db.gz";
+ public static final String IMPORT_DATA_ECHOBASE_OPERATION = "/import-data/echobase-" + ImportDbServiceTest.DB_VERSION + "-operation.h2.db.gz";
- public static final String IMPORT_DATA_ECHOBASE_CATCHES = "/import-data/echobase-0.3-catches.h2.db.gz";
+ public static final String IMPORT_DATA_ECHOBASE_CATCHES = "/import-data/echobase-" + ImportDbServiceTest.DB_VERSION + "-catches.h2.db.gz";
- public static final String IMPORT_DATA_ECHOBASE_CATCHES_AND_VOYAGE_RESULT = "/import-data/echobase-0.3-catches-and-voyage-result.h2.db.gz";
+ public static final String IMPORT_DATA_ECHOBASE_CATCHES_AND_VOYAGE_RESULT = "/import-data/echobase-" + ImportDbServiceTest.DB_VERSION + "-catches-and-voyage-result.h2.db.gz";
-// public static final String IMPORT_DATA_ECHOBASE_CATCHES_AND_ACOUSTIC = "/import-data/echobase-0.3-catches-and-acoustic.h2.db.gz";
+// public static final String IMPORT_DATA_ECHOBASE_CATCHES_AND_ACOUSTIC = "/import-data/echobase-" + ImportDbServiceTest.DB_VERSION + "-catches-and-acoustic.h2.db.gz";
-// public static final String IMPORT_DATA_ECHOBASE_CATCHES_AND_ACOUSTIC_AND_VOYAGE_RESULT = "/import-data/echobase-0.3-catches-and-acoustic-and-voyage-result.h2.db.gz";
+// public static final String IMPORT_DATA_ECHOBASE_CATCHES_AND_ACOUSTIC_AND_VOYAGE_RESULT = "/import-data/echobase-" + ImportDbServiceTest.DB_VERSION + "-catches-and-acoustic-and-voyage-result.h2.db.gz";
public static final String VESSEL_ID = "fr.ifremer.echobase.entities.references.Vessel#1323196672049#0.9790502711645855";
Modified: trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/AcousticImportServiceIT.java
===================================================================
--- trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/AcousticImportServiceIT.java 2012-09-07 14:02:07 UTC (rev 634)
+++ trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/AcousticImportServiceIT.java 2012-09-07 16:34:49 UTC (rev 635)
@@ -85,11 +85,13 @@
List<EchoBaseCsvFileImportResult> result;
result = doImport(conf, AcousticImportService.class, 1);
- assertCsvImportResult(result, 0, DataAcquisition.class, NB_DATA_ACQUISITION,NB_DATA_ACQUISITION);
- assertCsvImportResult(result, 0, DataProcessing.class, NB_DATA_PROCESSING,0);
- assertCsvImportResult(result, 0, Cell.class, NB_CELL,0);
- assertCsvImportResult(result, 0, Data.class, NB_DATA,0);
+ assertNbIDs(result, 0, NB_CELL);
+ assertCsvImportResult(result, 0, DataAcquisition.class, NB_DATA_ACQUISITION);
+ assertCsvImportResult(result, 0, DataProcessing.class, NB_DATA_PROCESSING);
+ assertCsvImportResult(result, 0, Cell.class, NB_CELL);
+ assertCsvImportResult(result, 0, Data.class, NB_DATA);
+
assertImportAcousticDatas();
}
Modified: trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/CatchesImportServiceIT.java
===================================================================
--- trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/CatchesImportServiceIT.java 2012-09-07 14:02:07 UTC (rev 634)
+++ trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/CatchesImportServiceIT.java 2012-09-07 16:34:49 UTC (rev 635)
@@ -70,17 +70,21 @@
List<EchoBaseCsvFileImportResult> result;
result = doImport(conf, CatchesImportService.class, 3);
- assertCsvImportResult(result, 0, Sample.class, NB_SAMPLE_TOTAL, 0, NB_SAMPLE, NB_SAMPLE_TOTAL);
- assertCsvImportResult(result, 0, SampleData.class, NB_SAMPLE_DATA_TOTAL, 0, NB_SAMPLE_DATA, 0);
- assertCsvImportResult(result, 0, SpeciesCategory.class, 4, 0, 456, 0);
+ assertNbIDs(result, 0, NB_SAMPLE_TOTAL);
- assertCsvImportResult(result, 1, Sample.class, NB_SAMPLE_UNSORTED, 0, NB_SAMPLE, NB_SAMPLE_UNSORTED);
- assertCsvImportResult(result, 1, SampleData.class, NB_SAMPLE_DATA_UNSORTED, 0, NB_SAMPLE_DATA, 0);
- assertCsvImportResult(result, 1, SpeciesCategory.class, 9, 0, 456, 0);
+ assertCsvImportResult(result, 0, Sample.class, NB_SAMPLE_TOTAL, 0, NB_SAMPLE);
+ assertCsvImportResult(result, 0, SampleData.class, NB_SAMPLE_DATA_TOTAL, 0, NB_SAMPLE_DATA);
+ assertCsvImportResult(result, 0, SpeciesCategory.class, 4, 0, 456);
- assertCsvImportResult(result, 2, Sample.class, NB_SAMPLE_BIOMETRY, 0, NB_SAMPLE, NB_SAMPLE_BIOMETRY);
- assertCsvImportResult(result, 2, SampleData.class, NB_SAMPLE_DATA_BIOMETRY, 0, NB_SAMPLE_DATA, 0);
+ assertNbIDs(result, 1, NB_SAMPLE_UNSORTED);
+ assertCsvImportResult(result, 1, Sample.class, NB_SAMPLE_UNSORTED, 0, NB_SAMPLE);
+ assertCsvImportResult(result, 1, SampleData.class, NB_SAMPLE_DATA_UNSORTED, 0, NB_SAMPLE_DATA);
+ assertCsvImportResult(result, 1, SpeciesCategory.class, 9, 0, 456);
+ assertNbIDs(result, 2, NB_SAMPLE_BIOMETRY);
+ assertCsvImportResult(result, 2, Sample.class, NB_SAMPLE_BIOMETRY, 0, NB_SAMPLE);
+ assertCsvImportResult(result, 2, SampleData.class, NB_SAMPLE_DATA_BIOMETRY, 0, NB_SAMPLE_DATA);
+
assertImportSampleDatas();
}
@@ -103,8 +107,9 @@
List<EchoBaseCsvFileImportResult> result;
result = doImport(conf, CatchesImportService.class, 1);
- assertCsvImportResult(result, 0, Sample.class, NB_SAMPLE_TOTAL, NB_SAMPLE_TOTAL);
- assertCsvImportResult(result, 0, SampleData.class, NB_SAMPLE_DATA_TOTAL, 0);
+ assertNbIDs(result, 0, NB_SAMPLE_TOTAL);
+ assertCsvImportResult(result, 0, Sample.class, NB_SAMPLE_TOTAL);
+ assertCsvImportResult(result, 0, SampleData.class, NB_SAMPLE_DATA_TOTAL);
}
@Ignore
@@ -126,8 +131,9 @@
List<EchoBaseCsvFileImportResult> result;
result = doImport(conf, CatchesImportService.class, 1);
- assertCsvImportResult(result, 0, Sample.class, NB_SAMPLE_UNSORTED, NB_SAMPLE_UNSORTED);
- assertCsvImportResult(result, 0, SampleData.class, NB_SAMPLE_DATA_UNSORTED, 0);
+ assertNbIDs(result, 0, NB_SAMPLE_UNSORTED);
+ assertCsvImportResult(result, 0, Sample.class, NB_SAMPLE_UNSORTED);
+ assertCsvImportResult(result, 0, SampleData.class, NB_SAMPLE_DATA_UNSORTED);
}
@Ignore
@@ -148,8 +154,10 @@
List<EchoBaseCsvFileImportResult> result;
result = doImport(conf, CatchesImportService.class, 1);
- assertCsvImportResult(result, 0, Sample.class, NB_SAMPLE_BIOMETRY, NB_SAMPLE_BIOMETRY);
- assertCsvImportResult(result, 0, SampleData.class, NB_SAMPLE_DATA_BIOMETRY, 0);
+
+ assertNbIDs(result, 0, NB_SAMPLE_BIOMETRY);
+ assertCsvImportResult(result, 0, Sample.class, NB_SAMPLE_BIOMETRY);
+ assertCsvImportResult(result, 0, SampleData.class, NB_SAMPLE_DATA_BIOMETRY);
}
}
Modified: trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/CommonAllImportServiceIT.java
===================================================================
--- trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/CommonAllImportServiceIT.java 2012-09-07 14:02:07 UTC (rev 634)
+++ trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/CommonAllImportServiceIT.java 2012-09-07 16:34:49 UTC (rev 635)
@@ -80,10 +80,15 @@
List<EchoBaseCsvFileImportResult> result;
result = doImport(conf, CommonAllImportService.class, 3);
- assertCsvImportResult(result, 0, Voyage.class, NB_VOYAGE,NB_VOYAGE);
- assertCsvImportResult(result, 1, Transit.class, NB_TRANSIT,0);
- assertCsvImportResult(result, 2, Transect.class, NB_TRANSECT,0);
+ assertNbIDs(result, 0, NB_VOYAGE);
+ assertCsvImportResult(result, 0, Voyage.class, NB_VOYAGE);
+ assertNbIDs(result, 1, 0);
+ assertCsvImportResult(result, 1, Transit.class, NB_TRANSIT);
+
+ assertNbIDs(result, 2, 0);
+ assertCsvImportResult(result, 2, Transect.class, NB_TRANSECT);
+
assertImportCommonData();
}
Modified: trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/CommonTransectImportServiceIT.java
===================================================================
--- trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/CommonTransectImportServiceIT.java 2012-09-07 14:02:07 UTC (rev 634)
+++ trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/CommonTransectImportServiceIT.java 2012-09-07 16:34:49 UTC (rev 635)
@@ -76,7 +76,8 @@
List<EchoBaseCsvFileImportResult> result;
result = doImport(conf, CommonTransectImportService.class, 1);
- assertCsvImportResult(result, 0, Transect.class, NB_TRANSECT,NB_TRANSECT);
+ assertNbIDs(result, 0, NB_TRANSECT);
+ assertCsvImportResult(result, 0, Transect.class, NB_TRANSECT);
assertImportCommonData();
}
Modified: trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/OperationImportServiceIT.java
===================================================================
--- trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/OperationImportServiceIT.java 2012-09-07 14:02:07 UTC (rev 634)
+++ trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/OperationImportServiceIT.java 2012-09-07 16:34:49 UTC (rev 635)
@@ -71,10 +71,15 @@
List<EchoBaseCsvFileImportResult> result;
result = doImport(conf, OperationImportService.class, 3);
- assertCsvImportResult(result, 0, Operation.class, NB_OPERATION,NB_OPERATION);
- assertCsvImportResult(result, 1, OperationMetadataValue.class, NB_OPERATION_METADATAVALUE,0);
- assertCsvImportResult(result, 2, GearMetadataValue.class, NB_GEAR_METADATAVALUE,0);
+ assertNbIDs(result, 0, NB_OPERATION);
+ assertCsvImportResult(result, 0, Operation.class, NB_OPERATION);
+ assertNbIDs(result, 1, 0);
+ assertCsvImportResult(result, 1, OperationMetadataValue.class, NB_OPERATION_METADATAVALUE);
+
+ assertNbIDs(result, 2, 0);
+ assertCsvImportResult(result, 2, GearMetadataValue.class, NB_GEAR_METADATAVALUE);
+
assertImportOperations();
}
}
Modified: trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/ResultsEsduCellImportServiceIT.java
===================================================================
--- trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/ResultsEsduCellImportServiceIT.java 2012-09-07 14:02:07 UTC (rev 634)
+++ trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/ResultsEsduCellImportServiceIT.java 2012-09-07 16:34:49 UTC (rev 635)
@@ -80,8 +80,10 @@
List<EchoBaseCsvFileImportResult> result;
result = doImport(conf, ResultsEsduCellImportService.class, 1);
- assertCsvImportResult(result, 0, Result.class, 43533,43533);
- assertCsvImportResult(result, 0, Category.class, 7,0);
+ assertNbIDs(result, 0, 43533);
+
+ assertCsvImportResult(result, 0, Result.class, 43533);
+ assertCsvImportResult(result, 0, Category.class, 7);
}
@Test
@@ -112,9 +114,11 @@
List<EchoBaseCsvFileImportResult> result;
result = doImport(conf, ResultsEsduCellImportService.class, 1);
- assertCsvImportResult(result, 0, Result.class, 357291,357291);
- assertCsvImportResult(result, 0, Category.class, 27,0);
- assertCsvImportResult(result, 0, SpeciesCategory.class, 1, 0, 457,0);
+ assertNbIDs(result, 0, 357291);
+
+ assertCsvImportResult(result, 0, Result.class, 357291);
+ assertCsvImportResult(result, 0, Category.class, 27);
+ assertCsvImportResult(result, 0, SpeciesCategory.class, 1, 0, 457);
}
@Test
@@ -145,10 +149,11 @@
List<EchoBaseCsvFileImportResult> result;
result = doImport(conf, ResultsEsduCellImportService.class, 1);
- assertCsvImportResult(result, 0, Result.class, 68108,68108);
- assertCsvImportResult(result, 0, Category.class, 129,0);
- assertCsvImportResult(result, 0, SpeciesCategory.class, 129, 0, 585,0);
- assertCsvImportResult(result, 0, SizeCategory.class, 62, 0, 69,0);
+ assertNbIDs(result, 0, 68108);
+ assertCsvImportResult(result, 0, Result.class, 68108);
+ assertCsvImportResult(result, 0, Category.class, 129);
+ assertCsvImportResult(result, 0, SpeciesCategory.class, 129, 0, 585);
+ assertCsvImportResult(result, 0, SizeCategory.class, 62, 0, 69);
}
@Test
@@ -179,10 +184,11 @@
List<EchoBaseCsvFileImportResult> result;
result = doImport(conf, ResultsEsduCellImportService.class, 1);
- assertCsvImportResult(result, 0, Category.class, 14,0);
- assertCsvImportResult(result, 0, Result.class, 10021,10021);
- assertCsvImportResult(result, 0, AgeCategory.class, 6, 0, 10,0);
- assertCsvImportResult(result, 0, SpeciesCategory.class, 14, 0, 470,0);
+ assertNbIDs(result, 0, 10021);
+ assertCsvImportResult(result, 0, Category.class, 14);
+ assertCsvImportResult(result, 0, Result.class, 10021);
+ assertCsvImportResult(result, 0, AgeCategory.class, 6, 0, 10);
+ assertCsvImportResult(result, 0, SpeciesCategory.class, 14, 0, 470);
}
}
\ No newline at end of file
Modified: trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/ResultsMapCellImportServiceIT.java
===================================================================
--- trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/ResultsMapCellImportServiceIT.java 2012-09-07 14:02:07 UTC (rev 634)
+++ trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/ResultsMapCellImportServiceIT.java 2012-09-07 16:34:49 UTC (rev 635)
@@ -72,10 +72,12 @@
List<EchoBaseCsvFileImportResult> result;
result = doImport(conf, ResultsMapCellImportService.class, 1);
- assertCsvImportResult(result, 0, Cell.class, 380, 380);
- assertCsvImportResult(result, 0, Data.class, 2280, 0);
- assertCsvImportResult(result, 0, Result.class, 380, 0);
- assertCsvImportResult(result, 0, Category.class, 1, 0);
+ assertNbIDs(result,0,380);
+
+ assertCsvImportResult(result, 0, Cell.class, 380);
+ assertCsvImportResult(result, 0, Data.class, 2280);
+ assertCsvImportResult(result, 0, Result.class, 380);
+ assertCsvImportResult(result, 0, Category.class, 1);
}
}
\ No newline at end of file
Modified: trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/ResultsRegionCellImportServiceIT.java
===================================================================
--- trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/ResultsRegionCellImportServiceIT.java 2012-09-07 14:02:07 UTC (rev 634)
+++ trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/ResultsRegionCellImportServiceIT.java 2012-09-07 16:34:49 UTC (rev 635)
@@ -82,12 +82,14 @@
List<EchoBaseCsvFileImportResult> result;
result = doImport(conf, ResultsRegionCellImportService.class, 3);
- assertCsvImportResult(result, 0, Cell.class, 10, 0, 2083,10);
- assertCsvImportResult(result, 0, Data.class, 238,0);
- assertCsvImportResult(result, 1, Cell.class, 0, 4146, 2083,0);
- assertCsvImportResult(result, 2, Result.class, 2128,0);
- assertCsvImportResult(result, 2, Category.class, 27,0);
- assertCsvImportResult(result, 2, SpeciesCategory.class, 1, 0, 457,0);
+ assertNbIDs(result, 0, 10);
+
+ assertCsvImportResult(result, 0, Cell.class, 10, 0, 2083);
+ assertCsvImportResult(result, 0, Data.class, 238);
+ assertCsvImportResult(result, 1, Cell.class, 0, 4146, 2083);
+ assertCsvImportResult(result, 2, Result.class, 2128);
+ assertCsvImportResult(result, 2, Category.class, 27);
+ assertCsvImportResult(result, 2, SpeciesCategory.class, 1, 0, 457);
}
}
\ No newline at end of file
Modified: trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/ResultsVoyageImportServiceIT.java
===================================================================
--- trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/ResultsVoyageImportServiceIT.java 2012-09-07 14:02:07 UTC (rev 634)
+++ trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/ResultsVoyageImportServiceIT.java 2012-09-07 16:34:49 UTC (rev 635)
@@ -75,9 +75,14 @@
List<EchoBaseCsvFileImportResult> result;
result = doImport(conf, ResultsVoyageImportService.class, 3);
- assertCsvImportResult(result, 0, LengthAgeKey.class, NB_LENGTH_AGE_KEY, NB_LENGTH_AGE_KEY);
- assertCsvImportResult(result, 1, LengthWeightKey.class, NB_LENGTH_WEIGHT_KEY, NB_LENGTH_WEIGHT_KEY);
- assertCsvImportResult(result, 2, Echotype.class, NB_ECHOTYPE, NB_ECHOTYPE);
+ assertNbIDs(result, 0, NB_LENGTH_AGE_KEY);
+ assertCsvImportResult(result, 0, LengthAgeKey.class, NB_LENGTH_AGE_KEY);
+
+ assertNbIDs(result, 1, NB_LENGTH_WEIGHT_KEY);
+ assertCsvImportResult(result, 1, LengthWeightKey.class, NB_LENGTH_WEIGHT_KEY);
+
+ assertNbIDs(result, 2, NB_ECHOTYPE);
+ assertCsvImportResult(result, 2, Echotype.class, NB_ECHOTYPE);
}
@Ignore
@@ -102,7 +107,8 @@
List<EchoBaseCsvFileImportResult> result;
result = doImport(conf, ResultsVoyageImportService.class, 1);
- assertCsvImportResult(result, 0, LengthAgeKey.class, NB_LENGTH_AGE_KEY, NB_LENGTH_AGE_KEY);
+ assertNbIDs(result, 0, NB_LENGTH_AGE_KEY);
+ assertCsvImportResult(result, 0, LengthAgeKey.class, NB_LENGTH_AGE_KEY);
}
@Ignore
@@ -127,7 +133,8 @@
List<EchoBaseCsvFileImportResult> result;
result = doImport(conf, ResultsVoyageImportService.class, 1);
- assertCsvImportResult(result, 0, LengthWeightKey.class, NB_LENGTH_WEIGHT_KEY, NB_LENGTH_WEIGHT_KEY);
+ assertNbIDs(result, 0, NB_LENGTH_WEIGHT_KEY);
+ assertCsvImportResult(result, 0, LengthWeightKey.class, NB_LENGTH_WEIGHT_KEY);
}
@Ignore
@@ -151,7 +158,8 @@
List<EchoBaseCsvFileImportResult> result;
result = doImport(conf, ResultsVoyageImportService.class, 1);
- assertCsvImportResult(result, 0, Echotype.class, NB_ECHOTYPE, NB_ECHOTYPE);
+ assertNbIDs(result, 0, NB_ECHOTYPE);
+ assertCsvImportResult(result, 0, Echotype.class, NB_ECHOTYPE);
}
}
\ No newline at end of file
Deleted: trunk/echobase-services/src/test/resources/echobase-0.3-importDb-referentiel.zip
===================================================================
(Binary files differ)
Copied: trunk/echobase-services/src/test/resources/echobase-1.2-importDb-referentiel.zip (from rev 622, trunk/echobase-services/src/test/resources/echobase-0.3-importDb-referentiel.zip)
===================================================================
(Binary files differ)
Property changes on: trunk/echobase-services/src/test/resources/echobase-1.2-importDb-referentiel.zip
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: svn:keywords
+ Author Date Id Revision HeadURL
Modified: trunk/echobase-services/src/test/resources/import-data/common/transect.csv.gz
===================================================================
(Binary files differ)
Modified: trunk/echobase-services/src/test/resources/import-data/common/transit.csv.gz
===================================================================
(Binary files differ)
Modified: trunk/echobase-services/src/test/resources/import-data/common/voyage.csv.gz
===================================================================
(Binary files differ)
Deleted: trunk/echobase-services/src/test/resources/import-data/echobase-0.3-catches-and-voyage-result.h2.db.gz
===================================================================
(Binary files differ)
Deleted: trunk/echobase-services/src/test/resources/import-data/echobase-0.3-catches.h2.db.gz
===================================================================
(Binary files differ)
Deleted: trunk/echobase-services/src/test/resources/import-data/echobase-0.3-commonData.h2.db.gz
===================================================================
(Binary files differ)
Deleted: trunk/echobase-services/src/test/resources/import-data/echobase-0.3-nodata.h2.db.gz
===================================================================
(Binary files differ)
Deleted: trunk/echobase-services/src/test/resources/import-data/echobase-0.3-operation.h2.db.gz
===================================================================
(Binary files differ)
Copied: trunk/echobase-services/src/test/resources/import-data/echobase-1.2-catches-and-voyage-result.h2.db.gz (from rev 622, trunk/echobase-services/src/test/resources/import-data/echobase-0.3-catches-and-voyage-result.h2.db.gz)
===================================================================
(Binary files differ)
Copied: trunk/echobase-services/src/test/resources/import-data/echobase-1.2-catches.h2.db.gz (from rev 622, trunk/echobase-services/src/test/resources/import-data/echobase-0.3-catches.h2.db.gz)
===================================================================
(Binary files differ)
Copied: trunk/echobase-services/src/test/resources/import-data/echobase-1.2-commonData.h2.db.gz (from rev 622, trunk/echobase-services/src/test/resources/import-data/echobase-0.3-commonData.h2.db.gz)
===================================================================
(Binary files differ)
Copied: trunk/echobase-services/src/test/resources/import-data/echobase-1.2-nodata.h2.db.gz (from rev 622, trunk/echobase-services/src/test/resources/import-data/echobase-0.3-nodata.h2.db.gz)
===================================================================
(Binary files differ)
Copied: trunk/echobase-services/src/test/resources/import-data/echobase-1.2-operation.h2.db.gz (from rev 622, trunk/echobase-services/src/test/resources/import-data/echobase-0.3-operation.h2.db.gz)
===================================================================
(Binary files differ)
Modified: trunk/echobase-services/src/test/resources/import-data/operation/operation.csv.gz
===================================================================
(Binary files differ)
Modified: trunk/echobase-services/src/test/resources/import-data/result/voyage/lengthWeightKey.csv.gz
===================================================================
(Binary files differ)
Modified: trunk/echobase-services/update-import-data-db.sh
===================================================================
--- trunk/echobase-services/update-import-data-db.sh 2012-09-07 14:02:07 UTC (rev 634)
+++ trunk/echobase-services/update-import-data-db.sh 2012-09-07 16:34:49 UTC (rev 635)
@@ -8,7 +8,7 @@
exit
fi
-dbnameprefix="echobase-0.3"
+dbnameprefix="echobase-1.2"
dbDir=src/test/resources/import-data
@@ -16,7 +16,7 @@
testId=$1
dbdst=$2
echo "execute mvn test -Dtest=$testId ..."
- mvn test -Dtest=$testId &>/tmp/maven-$testId.log
+ mvn test -Dtest=$testId -Dmaven.surefire.debug &>/tmp/maven-$testId.log
if [ $? -eq 1 ]; then
echo "Error with test $testId, see /tmp/maven-$testId.log"
exit 1
1
0
Author: tchemit
Date: 2012-09-07 16:02:07 +0200 (Fri, 07 Sep 2012)
New Revision: 634
Url: http://forge.codelutin.com/repositories/revision/echobase/634
Log:
check i18n only at release time
Modified:
trunk/echobase-ui/pom.xml
trunk/pom.xml
Modified: trunk/echobase-ui/pom.xml
===================================================================
--- trunk/echobase-ui/pom.xml 2012-09-07 10:57:12 UTC (rev 633)
+++ trunk/echobase-ui/pom.xml 2012-09-07 14:02:07 UTC (rev 634)
@@ -1,6 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
@@ -89,7 +91,6 @@
<userRulesFiles>
<file>${basedir}/src/main/validationRules.txt</file>
</userRulesFiles>
- <keepGetters>true</keepGetters>
</configuration>
</execution>
<execution>
@@ -340,9 +341,12 @@
</activation>
<properties>
<env>prod</env>
+
+ <!-- make sure i18n is fully complete -->
+ <i18n.failsIfWarning>true</i18n.failsIfWarning>
</properties>
</profile>
-
+
<profile>
<id>assembly</id>
<activation>
@@ -368,7 +372,7 @@
<phase>generate-resources</phase>
<configuration>
<target>
- <mkdir dir="${embeddedWarDir}/WEB-INF/classes" />
+ <mkdir dir="${embeddedWarDir}/WEB-INF/classes"/>
</target>
</configuration>
<goals>
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2012-09-07 10:57:12 UTC (rev 633)
+++ trunk/pom.xml 2012-09-07 14:02:07 UTC (rev 634)
@@ -159,7 +159,6 @@
<i18n.bundles>fr_FR,en_GB</i18n.bundles>
<i18n.silent>true</i18n.silent>
<echobaseI18nBundle>echobase-i18n</echobaseI18nBundle>
- <i18n.failsIfWarning>true</i18n.failsIfWarning>
<!--Site configuration -->
<locales>fr,en</locales>
1
0
r633 - in trunk/echobase-services/src: main/java/fr/ifremer/echobase/services/importdata test/java/fr/ifremer/echobase/services test/java/fr/ifremer/echobase/services/importdata
by tchemit@users.forge.codelutin.com 07 Sep '12
by tchemit@users.forge.codelutin.com 07 Sep '12
07 Sep '12
Author: tchemit
Date: 2012-09-07 12:57:12 +0200 (Fri, 07 Sep 2012)
New Revision: 633
Url: http://forge.codelutin.com/repositories/revision/echobase/633
Log:
refs #1437: Suppression des imports (marquage des ids de l'import)
Added:
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/CommonAllImportService.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/CommonTransectImportService.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/EchoBaseCsvFileImportResult.java
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/AbstractImportDataService.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/AcousticImportService.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/CatchesImportService.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/CommonImportService.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/OperationImportService.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/ResultsEsduCellImportService.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/ResultsImportService.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/ResultsMapCellImportService.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/ResultsRegionCellImportService.java
trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/ResultsVoyageImportService.java
trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/EchoBaseTestServiceSupport.java
trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/AbstractImportDataServiceIT.java
trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/AcousticImportServiceIT.java
trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/CatchesImportServiceIT.java
trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/CommonAllImportServiceIT.java
trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/CommonTransectImportServiceIT.java
trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/OperationImportServiceIT.java
trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/ResultsEsduCellImportServiceIT.java
trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/ResultsMapCellImportServiceIT.java
trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/ResultsRegionCellImportServiceIT.java
trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/ResultsVoyageImportServiceIT.java
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-07 10:19:04 UTC (rev 632)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/AbstractImportConfiguration.java 2012-09-07 10:57:12 UTC (rev 633)
@@ -29,7 +29,6 @@
import fr.ifremer.echobase.io.EchoBaseIOUtil;
import fr.ifremer.echobase.io.InputFile;
import fr.ifremer.echobase.services.AbstractEchobaseActionConfiguration;
-import org.nuiton.topia.persistence.csv.in.CsvFileImportResult;
import java.io.File;
import java.util.List;
@@ -61,7 +60,7 @@
protected ImportType importType;
/** Result stats for each file imported. (mainly kept for testing purpose). */
- protected final List<CsvFileImportResult<EchoBaseEntityEnum>> importResults =
+ protected final List<EchoBaseCsvFileImportResult> importResults =
Lists.newArrayList();
public File getWorkingDirectory() {
@@ -84,7 +83,7 @@
return importType;
}
- public List<CsvFileImportResult<EchoBaseEntityEnum>> getImportResults() {
+ public List<EchoBaseCsvFileImportResult> getImportResults() {
return importResults;
}
@@ -106,7 +105,7 @@
return result;
}
- public void addResult(CsvFileImportResult<EchoBaseEntityEnum> fileResult) {
+ public void addResult(EchoBaseCsvFileImportResult fileResult) {
Set<EchoBaseEntityEnum> entityTypes = fileResult.getEntityTypes();
if (!entityTypes.isEmpty()) {
importResults.add(fileResult);
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/AbstractImportDataService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/AbstractImportDataService.java 2012-09-07 10:19:04 UTC (rev 632)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/AbstractImportDataService.java 2012-09-07 10:57:12 UTC (rev 633)
@@ -28,11 +28,11 @@
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import fr.ifremer.echobase.EchoBaseTechnicalException;
-import fr.ifremer.echobase.io.InputFile;
import fr.ifremer.echobase.csv.EchoBaseCsvUtil;
import fr.ifremer.echobase.entities.EchoBaseEntityEnum;
import fr.ifremer.echobase.entities.EchoBaseUser;
import fr.ifremer.echobase.entities.EntityModificationLog;
+import fr.ifremer.echobase.entities.ImportLog;
import fr.ifremer.echobase.entities.data.Category;
import fr.ifremer.echobase.entities.data.CategoryDAO;
import fr.ifremer.echobase.entities.data.Cell;
@@ -49,6 +49,7 @@
import fr.ifremer.echobase.entities.references.Species;
import fr.ifremer.echobase.entities.references.SpeciesCategory;
import fr.ifremer.echobase.entities.references.SpeciesCategoryDAO;
+import fr.ifremer.echobase.io.InputFile;
import fr.ifremer.echobase.services.EchoBaseServiceSupport;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
@@ -56,7 +57,6 @@
import org.nuiton.topia.TopiaException;
import org.nuiton.topia.persistence.TopiaDAO;
import org.nuiton.topia.persistence.TopiaEntity;
-import org.nuiton.topia.persistence.csv.in.CsvFileImportResult;
import org.nuiton.util.StringUtil;
import org.nuiton.util.TimeLog;
import org.nuiton.util.csv.ImportRuntimeException;
@@ -67,6 +67,7 @@
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;
+import java.util.Date;
import java.util.List;
import java.util.Locale;
import java.util.Map;
@@ -98,7 +99,8 @@
public final String doImport(M configuration,
EchoBaseUser user) throws ImportException {
- importLabel = computeImportLabel(configuration);
+ Locale locale = getLocale();
+ importLabel = l_(locale, configuration.getImportType().getI18nKey());
long s0 = TimeLog.getTime();
@@ -126,13 +128,25 @@
}
}
- protected abstract String computeImportLabel(M configuration);
+ protected EchoBaseCsvFileImportResult newImportResult(InputFile inputFile) {
+ return new EchoBaseCsvFileImportResult(inputFile.getFileName());
+ }
-
protected String computeResultAndLogBookEntry(M configuration,
EchoBaseUser user,
long time) {
+
+ Date importDate = newDate();
+ String importUser = user.getEmail();
+
+ ImportLog importLog = create(getDAO(ImportLog.class),
+ 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();
StringBuilder buffer = new StringBuilder();
@@ -145,8 +159,10 @@
buffer.append("Import réalisé en ");
buffer.append(StringUtil.convertTime(time));
- for (CsvFileImportResult<EchoBaseEntityEnum> importResult : configuration.getImportResults()) {
+ for (EchoBaseCsvFileImportResult importResult : configuration.getImportResults()) {
+ importLog.addAllImportId(importResult.getIds());
+
StringBuilder description = new StringBuilder();
description.append("Depuis Fichier ").append(importResult.getImportFileName());
@@ -173,8 +189,8 @@
create(getDAO(EntityModificationLog.class),
EntityModificationLog.PROPERTY_ENTITY_TYPE, "Import",
EntityModificationLog.PROPERTY_ENTITY_ID, importType,
- EntityModificationLog.PROPERTY_MODIFICATION_USER, user.getEmail(),
- EntityModificationLog.PROPERTY_MODIFICATION_DATE, newDate(),
+ EntityModificationLog.PROPERTY_MODIFICATION_USER, importUser,
+ EntityModificationLog.PROPERTY_MODIFICATION_DATE, importDate,
EntityModificationLog.PROPERTY_MODIFICATION_TEXT, result
);
return result;
@@ -182,7 +198,7 @@
protected final String getImportLabel() {
return importLabel;
- };
+ }
protected abstract void startImport(M configuration,
EchoBaseUser user) throws ImportException;
@@ -273,7 +289,10 @@
return message;
}
- protected final void doFlushTransaction(int rowNumber, InputFile inputFile) {
+ protected final void doFlushTransaction(int rowNumber,
+ InputFile inputFile,
+ M configuration) {
+ configuration.incrementsProgression();
if (rowNumber % 1000 == 0) {
// flush each 1000 imported rows
String message = getImportMessage(inputFile);
@@ -296,7 +315,7 @@
SizeCategory sizeCategory,
AgeCategory ageCategory,
SexCategory sexCategory,
- CsvFileImportResult<EchoBaseEntityEnum> importResult) {
+ EchoBaseCsvFileImportResult importResult) {
String key = species == null ? "" : species.getBaracoudaCode();
key += "#" + (ageCategory == null ? "" : ageCategory.getName());
@@ -344,7 +363,7 @@
Species species,
SizeCategory sizeCategory,
AgeCategory ageCategory,
- CsvFileImportResult<EchoBaseEntityEnum> importResult) {
+ EchoBaseCsvFileImportResult importResult) {
// get species categorie first
@@ -367,7 +386,7 @@
CategoryDAO categoryDAO,
Echotype echotype,
SpeciesCategory speciesCategory,
- CsvFileImportResult<EchoBaseEntityEnum> importResult) {
+ EchoBaseCsvFileImportResult importResult) {
String key = speciesCategory == null ? "" : speciesCategory.getTopiaId();
key += "#" + (echotype == null ? "" : echotype.getName());
@@ -439,7 +458,7 @@
DataMetadata dataMetaData,
String dataValue,
DataQuality dataQuality,
- CsvFileImportResult<EchoBaseEntityEnum> importResult) {
+ EchoBaseCsvFileImportResult importResult) {
Data data = create(dao,
Data.PROPERTY_DATA_METADATA, dataMetaData,
@@ -455,7 +474,8 @@
Category category,
String resultLabel,
ResultDAO dao,
- CsvFileImportResult<EchoBaseEntityEnum> importResult) {
+ EchoBaseCsvFileImportResult importResult,
+ boolean collecIds) {
List<Result> results = row.getResult();
for (Result result : results) {
@@ -466,7 +486,15 @@
Result resultCreated = create(dao, result);
cell.addResult(resultCreated);
- importResult.incrementsNumberCreated(EchoBaseEntityEnum.Result);
+
+ if (collecIds) {
+
+ // collect ids
+ importResult.addId(EchoBaseEntityEnum.Result, resultCreated);
+ } else {
+
+ importResult.incrementsNumberCreated(EchoBaseEntityEnum.Result);
+ }
}
}
}
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/AcousticImportService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/AcousticImportService.java 2012-09-07 10:19:04 UTC (rev 632)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/AcousticImportService.java 2012-09-07 10:57:12 UTC (rev 633)
@@ -27,8 +27,6 @@
import com.google.common.collect.Lists;
import fr.ifremer.echobase.EchoBaseFunctions;
import fr.ifremer.echobase.EchoBasePredicates;
-import fr.ifremer.echobase.entities.ImportType;
-import fr.ifremer.echobase.io.InputFile;
import fr.ifremer.echobase.csv.EchoBaseCsvUtil;
import fr.ifremer.echobase.entities.EchoBaseEntityEnum;
import fr.ifremer.echobase.entities.EchoBaseUser;
@@ -48,12 +46,12 @@
import fr.ifremer.echobase.entities.references.DataMetadata;
import fr.ifremer.echobase.entities.references.DataQuality;
import fr.ifremer.echobase.entities.references.Vessel;
+import fr.ifremer.echobase.io.InputFile;
import fr.ifremer.echobase.services.importdata.csv.AcousticImportModel;
import fr.ifremer.echobase.services.importdata.csv.AcousticImportRow;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.nuiton.topia.persistence.csv.in.CsvFileImportResult;
import org.nuiton.util.csv.Import;
import org.nuiton.util.csv.ImportRuntimeException;
@@ -80,11 +78,6 @@
LogFactory.getLog(AcousticImportService.class);
@Override
- protected String computeImportLabel(AcousticImportConfiguration configuration) {
- return l_(getLocale(), ImportType.ACOUSTIC.getI18nKey());
- }
-
- @Override
protected void startImport(
AcousticImportConfiguration configuration,
EchoBaseUser user) throws ImportException {
@@ -105,11 +98,11 @@
CellType.class, CellType.PROPERTY_ID, "Elementary");
Preconditions.checkNotNull(elementaryCellType);
- CsvFileImportResult importResult = importMoviesFile(configuration,
- voyage,
- vessel,
- esduCellType,
- elementaryCellType);
+ EchoBaseCsvFileImportResult importResult = importMoviesFile(configuration,
+ voyage,
+ vessel,
+ esduCellType,
+ elementaryCellType);
configuration.addResult(importResult);
}
@@ -139,11 +132,11 @@
return result;
}
- private CsvFileImportResult importMoviesFile(AcousticImportConfiguration configuration,
- Voyage voyage,
- Vessel vessel,
- CellType esduCellType,
- CellType elementaryCellType
+ private EchoBaseCsvFileImportResult importMoviesFile(AcousticImportConfiguration configuration,
+ Voyage voyage,
+ Vessel vessel,
+ CellType esduCellType,
+ CellType elementaryCellType
) throws ImportException {
InputFile inputFile = configuration.getMoviesFile();
@@ -152,8 +145,7 @@
log.info("Starts " + getImportMessage(inputFile));
}
- CsvFileImportResult<EchoBaseEntityEnum> importResult = CsvFileImportResult.newResult(
- inputFile.getFileName(), EchoBaseEntityEnum.values());
+ EchoBaseCsvFileImportResult importResult = newImportResult(inputFile);
Map<String, AcousticInstrument> instrumentsById =
getEntitiesMap(AcousticInstrument.class,
@@ -197,10 +189,8 @@
configuration.incrementsProgression();
for (AcousticImportRow row : importer) {
- doFlushTransaction(++rowNumber, inputFile);
+ doFlushTransaction(++rowNumber, inputFile, configuration);
- configuration.incrementsProgression();
-
if (dataProcessingId == null) {
// compute once for all the common dataprocessing id used
@@ -240,6 +230,8 @@
boolean isME70 =
EchoBasePredicates.IS_ACOUSTIC_INSTRUMENT_ME70.apply(instrument);
+ boolean collectCellIds = true;
+
if (dataAcquisition == null ||
!instrument.equals(dataAcquisition.getAcousticInstrument())) {
@@ -288,13 +280,17 @@
dataAcquisitionDAO
);
+ // collect id of the import
+ importResult.addId(EchoBaseEntityEnum.DataAcquisition,
+ dataAcquisition);
+
+ // as the dataAcquisition is collected, then no need
+ // to collect cells ids
+ collectCellIds = false;
+
// add dataAcquisition to transect
transect.addDataAcquisition(dataAcquisition);
- // count creation in result
- importResult.incrementsNumberCreated(
- EchoBaseEntityEnum.DataAcquisition);
-
if (log.isDebugEnabled()) {
log.debug("[row " + rowNumber +
"] New dataAquisition to use (number: " +
@@ -364,8 +360,16 @@
// clear elementary cells
elementaryCells.clear();
- importResult.incrementsNumberCreated(EchoBaseEntityEnum.Cell);
+ if (collectCellIds) {
+
+ // collect ids (dataProcessing already exists)
+ importResult.addId(EchoBaseEntityEnum.Cell, esduCell);
+ } else {
+
+ importResult.incrementsNumberCreated(EchoBaseEntityEnum.Cell);
+ }
+
// add it to data processing
dataProcessing.addCell(esduCell);
@@ -430,7 +434,7 @@
AcousticImportRow row,
DataQuality dataQuality,
DataDAO dao,
- CsvFileImportResult<EchoBaseEntityEnum> importResult) {
+ EchoBaseCsvFileImportResult importResult) {
String dataValue;
@@ -499,7 +503,7 @@
AcousticImportRow row,
DataQuality dataQuality,
DataDAO dao,
- CsvFileImportResult importResult) {
+ EchoBaseCsvFileImportResult importResult) {
String dataValue;
String startMeta;
@@ -710,7 +714,7 @@
String metadataName,
String dataValue,
DataQuality dataQuality,
- CsvFileImportResult<EchoBaseEntityEnum> importResult) {
+ EchoBaseCsvFileImportResult importResult) {
createCellData(
dao,
cell,
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/CatchesImportService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/CatchesImportService.java 2012-09-07 10:19:04 UTC (rev 632)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/CatchesImportService.java 2012-09-07 10:57:12 UTC (rev 633)
@@ -27,8 +27,6 @@
import com.google.common.collect.Maps;
import fr.ifremer.echobase.EchoBaseFunctions;
import fr.ifremer.echobase.EchoBasePredicates;
-import fr.ifremer.echobase.entities.ImportType;
-import fr.ifremer.echobase.io.InputFile;
import fr.ifremer.echobase.entities.EchoBaseEntityEnum;
import fr.ifremer.echobase.entities.EchoBaseUser;
import fr.ifremer.echobase.entities.data.Operation;
@@ -46,6 +44,7 @@
import fr.ifremer.echobase.entities.references.Species;
import fr.ifremer.echobase.entities.references.SpeciesCategory;
import fr.ifremer.echobase.entities.references.SpeciesCategoryDAO;
+import fr.ifremer.echobase.io.InputFile;
import fr.ifremer.echobase.services.importdata.csv.BiometrySampleImportModel;
import fr.ifremer.echobase.services.importdata.csv.BiometrySampleImportRow;
import fr.ifremer.echobase.services.importdata.csv.SubSampleImportModel;
@@ -54,7 +53,6 @@
import fr.ifremer.echobase.services.importdata.csv.TotalSampleImportRow;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.nuiton.topia.persistence.csv.in.CsvFileImportResult;
import org.nuiton.util.csv.Import;
import org.nuiton.util.csv.ImportRuntimeException;
@@ -78,11 +76,6 @@
LogFactory.getLog(CatchesImportService.class);
@Override
- protected String computeImportLabel(CatchesImportConfiguration configuration) {
- return l_(getLocale(), ImportType.CATCHES.getI18nKey());
- }
-
- @Override
protected void startImport(CatchesImportConfiguration configuration,
EchoBaseUser user) throws ImportException {
@@ -106,7 +99,7 @@
InputFile inputFile;
- CsvFileImportResult<EchoBaseEntityEnum> importResult;
+ EchoBaseCsvFileImportResult importResult;
inputFile = configuration.getTotalSampleFile();
if (inputFile.hasFile()) {
@@ -146,7 +139,7 @@
}
}
- private CsvFileImportResult<EchoBaseEntityEnum> importTotalSampleFile(
+ private EchoBaseCsvFileImportResult importTotalSampleFile(
CatchesImportConfiguration configuration,
InputFile inputFile,
Map<String, Operation> operationMap,
@@ -158,8 +151,7 @@
inputFile.getFileName());
}
- CsvFileImportResult<EchoBaseEntityEnum> importResult = CsvFileImportResult.newResult(
- inputFile.getFileName(), EchoBaseEntityEnum.values());
+ EchoBaseCsvFileImportResult importResult = newImportResult(inputFile);
TotalSampleImportModel csvModel = new TotalSampleImportModel(getCsvSeparator(),
operationMap,
@@ -197,8 +189,7 @@
configuration.incrementsProgression();
for (TotalSampleImportRow row : importer) {
- doFlushTransaction(++rowNumber, inputFile);
- configuration.incrementsProgression();
+ doFlushTransaction(++rowNumber, inputFile, configuration);
Operation operation = row.getOperation();
Species species = row.getSpecies();
@@ -250,8 +241,6 @@
operation,
sample,
importResult);
- } else {
- sample = sample;
}
// create datas
@@ -294,12 +283,11 @@
createdSortedSample.setSampleWeight(row.getSortedWeight());
// create sorted sample
- addSample(sampleDAO,
- operation,
- createdSortedSample,
- importResult);
+ createdSortedSample = addSample(sampleDAO,
+ operation,
+ createdSortedSample,
+ importResult);
-
}
return importResult;
@@ -310,7 +298,7 @@
}
}
- private CsvFileImportResult<EchoBaseEntityEnum> importSubSampleFile(
+ private EchoBaseCsvFileImportResult importSubSampleFile(
CatchesImportConfiguration configuration,
InputFile inputFile,
Map<String, Operation> operationMap,
@@ -328,8 +316,7 @@
EchoBaseFunctions.SEX_CATEGORY_NAME);
- CsvFileImportResult<EchoBaseEntityEnum> importResult = CsvFileImportResult.newResult(
- inputFile.getFileName(), EchoBaseEntityEnum.values());
+ EchoBaseCsvFileImportResult importResult = newImportResult(inputFile);
SubSampleImportModel csvModel = new SubSampleImportModel(
getCsvSeparator(),
@@ -365,8 +352,7 @@
int rowNumber = 0;
for (SubSampleImportRow row : importer) {
- doFlushTransaction(++rowNumber, inputFile);
- configuration.incrementsProgression();
+ doFlushTransaction(++rowNumber, inputFile, configuration);
Operation operation = row.getOperation();
Species species = row.getSpecies();
@@ -439,7 +425,7 @@
}
}
- private CsvFileImportResult<EchoBaseEntityEnum> importBiometrySampleFile(
+ private EchoBaseCsvFileImportResult importBiometrySampleFile(
CatchesImportConfiguration configuration,
InputFile inputFile,
Map<String, Operation> operationMap,
@@ -455,8 +441,7 @@
SampleDataType.class,
EchoBaseFunctions.SAMPLE_DATA_TYPE_NAME);
- CsvFileImportResult<EchoBaseEntityEnum> importResult = CsvFileImportResult.newResult(
- inputFile.getFileName(), EchoBaseEntityEnum.values());
+ EchoBaseCsvFileImportResult importResult = newImportResult(inputFile);
BiometrySampleImportModel csvModel =
new BiometrySampleImportModel(getCsvSeparator(),
@@ -483,15 +468,15 @@
int rowNumber = 0;
for (BiometrySampleImportRow row : importer) {
- doFlushTransaction(++rowNumber, inputFile);
- configuration.incrementsProgression();
+ doFlushTransaction(++rowNumber, inputFile, configuration);
Operation operation = row.getOperation();
Species species = row.getSpecies();
int numFish = row.getNumFish();
- String sampleKey = operation.getId() + "_" + species.getBaracoudaCode() + "_" + numFish;
+ String sampleKey = operation.getId() + "_" +
+ species.getBaracoudaCode() + "_" + numFish;
Sample sample = samples.get(sampleKey);
@@ -539,12 +524,14 @@
private Sample addSample(SampleDAO dao,
Operation operation,
Sample sample,
- CsvFileImportResult<EchoBaseEntityEnum> importResult) {
+ EchoBaseCsvFileImportResult importResult) {
Preconditions.checkNotNull(operation);
Preconditions.checkNotNull(sample);
Sample result = create(dao, sample);
operation.addSample(result);
- importResult.incrementsNumberCreated(EchoBaseEntityEnum.Sample);
+
+ // collect ids
+ importResult.addId(EchoBaseEntityEnum.Sample, sample);
return result;
}
@@ -553,7 +540,7 @@
String label,
float value,
Sample sample,
- CsvFileImportResult<EchoBaseEntityEnum> importResult) {
+ EchoBaseCsvFileImportResult importResult) {
SampleData sampleData = create(
dao,
SampleData.PROPERTY_SAMPLE_DATA_TYPE, sampleDataType,
Copied: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/CommonAllImportService.java (from rev 625, trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/CommonImportService.java)
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/CommonAllImportService.java (rev 0)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/CommonAllImportService.java 2012-09-07 10:57:12 UTC (rev 633)
@@ -0,0 +1,213 @@
+/*
+ * #%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%
+ */
+package fr.ifremer.echobase.services.importdata;
+
+import com.google.common.collect.Maps;
+import fr.ifremer.echobase.EchoBaseFunctions;
+import fr.ifremer.echobase.entities.EchoBaseEntityEnum;
+import fr.ifremer.echobase.entities.EchoBaseUser;
+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.AreaOfOperation;
+import fr.ifremer.echobase.entities.references.Mission;
+import fr.ifremer.echobase.entities.references.Vessel;
+import fr.ifremer.echobase.io.InputFile;
+import fr.ifremer.echobase.services.importdata.csv.TransitImportModel;
+import fr.ifremer.echobase.services.importdata.csv.TransitImportRow;
+import fr.ifremer.echobase.services.importdata.csv.VoyageImportModel;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.util.csv.Import;
+import org.nuiton.util.csv.ImportModel;
+import org.nuiton.util.csv.ImportRuntimeException;
+
+import java.io.Reader;
+import java.util.Arrays;
+import java.util.Locale;
+import java.util.Map;
+
+import static org.nuiton.i18n.I18n.l_;
+
+/**
+ * Service to launch a "common all data" import.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.3
+ */
+public class CommonAllImportService extends AbstractImportDataService<CommonImportConfiguration> {
+
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(CommonAllImportService.class);
+
+ @Override
+ protected void startImport(CommonImportConfiguration configuration,
+ EchoBaseUser user) throws ImportException {
+
+ // get usable vessels
+ Map<String, Vessel> vesselMap = getEntitiesMap(
+ Vessel.class, EchoBaseFunctions.VESSEL_NAME);
+
+ EchoBaseCsvFileImportResult importResult;
+
+ importResult = importVoyageFile(configuration);
+ configuration.addResult(importResult);
+
+ importResult = importTransitFile(configuration);
+ configuration.addResult(importResult);
+
+ CommonImportService service = getService(CommonImportService.class);
+
+ importResult = service.importTransectFile(vesselMap, configuration, false);
+ configuration.addResult(importResult);
+ }
+
+ protected EchoBaseCsvFileImportResult importVoyageFile(
+ CommonImportConfiguration configuration) throws ImportException {
+
+ InputFile inputFile = configuration.getVoyageFile();
+
+ if (log.isInfoEnabled()) {
+ log.info("Starts import of voyages from file " +
+ inputFile.getFileName());
+ }
+
+ Mission mission = getEntityById(Mission.class,
+ configuration.getMissionId());
+ AreaOfOperation areaOfOperation =
+ getEntityById(AreaOfOperation.class,
+ configuration.getAreaOfOperationId());
+
+ EchoBaseCsvFileImportResult result = newImportResult(inputFile);
+
+ String voyageDescription = configuration.getVoyageDescription();
+ String datum = configuration.getDatum();
+
+ VoyageDAO dao = getDAO(Voyage.class, VoyageDAO.class);
+
+ ImportModel<Voyage> csvModel = new VoyageImportModel(getCsvSeparator());
+
+ Voyage newVoyage = null;
+ Locale locale = getLocale();
+ Reader reader = getInputFileReader(inputFile);
+ try {
+ Import<Voyage> importer = Import.newImport(csvModel, reader);
+
+ configuration.incrementsProgression();
+ for (Voyage voyage : importer) {
+
+ configuration.incrementsProgression();
+
+ voyage.setMission(mission);
+ voyage.setAreaOfOperation(areaOfOperation);
+ voyage.setDescription(voyageDescription);
+ voyage.setDatum(datum);
+
+ Voyage createdVoyage = create(dao, voyage);
+ if (newVoyage == null) {
+ newVoyage = createdVoyage;
+ } else {
+ // this means a voyage file with more than one row not possible...
+
+ throw new ImportException(
+ l_(locale, "echobase.importError.can.only.import.one.voyage.atime"));
+ }
+
+ // collect id of the import
+ result.addId(EchoBaseEntityEnum.Voyage, voyage);
+ }
+
+ if (newVoyage == null) {
+ throw new ImportException(
+ l_(locale, "echobase.importError.no.voyage.imported"));
+ }
+
+ // push back to id of the voyage in configuration for next imports
+ configuration.setVoyageId(newVoyage.getTopiaId());
+
+ return result;
+ } catch (ImportRuntimeException e) {
+ throw new ImportException(locale, inputFile, e);
+ } finally {
+ closeReader(reader, inputFile);
+ }
+ }
+
+ protected EchoBaseCsvFileImportResult importTransitFile(
+ CommonImportConfiguration configuration) throws ImportException {
+
+ InputFile inputFile = configuration.getTransitFile();
+
+ if (log.isInfoEnabled()) {
+ log.info("Starts import of transits from file " +
+ inputFile.getFileName());
+ }
+ EchoBaseCsvFileImportResult importResult = newImportResult(inputFile);
+
+ // get voyage
+ Voyage voyage = getEntityById(Voyage.class,
+ configuration.getVoyageId());
+
+ // restrict voyage to use to this voyage
+ Map<String, Voyage> voyageMap = Maps.uniqueIndex(
+ Arrays.asList(voyage), EchoBaseFunctions.VOYAGE_NAME);
+
+ String relatedActivity = configuration.getTransitRelatedActivity();
+
+ TransitImportModel csvModel =
+ new TransitImportModel(getCsvSeparator(), voyageMap);
+
+ TransitDAO dao = getDAO(Transit.class, TransitDAO.class);
+
+ Reader reader = getInputFileReader(inputFile);
+ try {
+ Import<TransitImportRow> importer =
+ Import.newImport(csvModel, reader);
+
+ configuration.incrementsProgression();
+ for (TransitImportRow row : importer) {
+
+ configuration.incrementsProgression();
+ Transit transit = row.getTransit();
+
+ transit.setRelatedActivity(relatedActivity);
+
+ Transit createdTransit = create(dao, transit);
+
+ voyage.addTransit(createdTransit);
+
+ importResult.incrementsNumberCreated(EchoBaseEntityEnum.Transit);
+ }
+ return importResult;
+ } catch (ImportRuntimeException e) {
+ throw new ImportException(getLocale(), inputFile, e);
+ } finally {
+ closeReader(reader, inputFile);
+ }
+ }
+
+
+}
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/CommonImportService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/CommonImportService.java 2012-09-07 10:19:04 UTC (rev 632)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/CommonImportService.java 2012-09-07 10:57:12 UTC (rev 633)
@@ -29,34 +29,26 @@
import fr.ifremer.echobase.EchoBaseTechnicalException;
import fr.ifremer.echobase.entities.EchoBaseEntityEnum;
import fr.ifremer.echobase.entities.EchoBaseUser;
+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.entities.data.VoyageDAO;
-import fr.ifremer.echobase.entities.references.AreaOfOperation;
import fr.ifremer.echobase.entities.references.Mission;
import fr.ifremer.echobase.entities.references.MissionDAO;
import fr.ifremer.echobase.entities.references.Vessel;
import fr.ifremer.echobase.io.InputFile;
import fr.ifremer.echobase.services.importdata.csv.TransectImportModel;
import fr.ifremer.echobase.services.importdata.csv.TransectImportRow;
-import fr.ifremer.echobase.services.importdata.csv.TransitImportModel;
-import fr.ifremer.echobase.services.importdata.csv.TransitImportRow;
-import fr.ifremer.echobase.services.importdata.csv.VoyageImportModel;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.nuiton.topia.TopiaException;
-import org.nuiton.topia.persistence.csv.in.CsvFileImportResult;
import org.nuiton.util.csv.Import;
-import org.nuiton.util.csv.ImportModel;
import org.nuiton.util.csv.ImportRuntimeException;
import java.io.Reader;
import java.util.Arrays;
import java.util.Date;
-import java.util.Locale;
import java.util.Map;
import static org.nuiton.i18n.I18n.l_;
@@ -73,49 +65,31 @@
private static final Log log = LogFactory.getLog(CommonImportService.class);
@Override
- protected String computeImportLabel(CommonImportConfiguration configuration) {
- String result = l_(getLocale(),
- configuration.getImportType().getI18nKey());
- return result;
- }
+ public void startImport(CommonImportConfiguration configuration,
+ EchoBaseUser user) throws ImportException {
- @Override
- protected void startImport(
- CommonImportConfiguration configuration,
- EchoBaseUser user) throws ImportException {
+ ImportType importMode = configuration.getImportType();
- // get usable vessels
- Map<String, Vessel> vesselMap = getEntitiesMap(
- Vessel.class, EchoBaseFunctions.VESSEL_NAME);
+ AbstractImportDataService<CommonImportConfiguration> service;
- switch (configuration.getImportType()) {
+ switch (importMode) {
- case COMMON_ALL: {
+ case COMMON_ALL:
+ service = getService(CommonAllImportService.class);
+ break;
- CsvFileImportResult<EchoBaseEntityEnum> importResult;
+ case COMMON_TRANSECT:
- importResult = importVoyageFile(configuration);
- configuration.addResult(importResult);
+ service = getService(CommonTransectImportService.class);
+ break;
- importResult = importTransitFile(configuration);
- configuration.addResult(importResult);
-
- importResult = importTransectFile(vesselMap, configuration);
- configuration.addResult(importResult);
- }
- break;
- case COMMON_TRANSECT: {
-
- CsvFileImportResult<EchoBaseEntityEnum> importResult;
-
- importResult = importTransectFile(vesselMap, configuration);
- configuration.addResult(importResult);
- }
- break;
+ default:
+ throw new EchoBaseTechnicalException(
+ "Can not treate import result of type " + importMode);
}
+ service.startImport(configuration, user);
}
-
public Mission createMission(Mission mission) throws MissionNameAlreadyExistException {
Preconditions.checkNotNull(mission);
@@ -138,134 +112,10 @@
}
}
- protected CsvFileImportResult<EchoBaseEntityEnum> importVoyageFile(
- CommonImportConfiguration configuration) throws ImportException {
-
- InputFile inputFile = configuration.getVoyageFile();
-
- if (log.isInfoEnabled()) {
- log.info("Starts import of voyages from file " +
- inputFile.getFileName());
- }
-
- Mission mission = getEntityById(Mission.class,
- configuration.getMissionId());
- AreaOfOperation areaOfOperation =
- getEntityById(AreaOfOperation.class,
- configuration.getAreaOfOperationId());
-
- CsvFileImportResult<EchoBaseEntityEnum> importResult = CsvFileImportResult.newResult(
- inputFile.getFileName(), EchoBaseEntityEnum.values());
-
- String voyageDescription = configuration.getVoyageDescription();
- String datum = configuration.getDatum();
-
- VoyageDAO dao = getDAO(Voyage.class, VoyageDAO.class);
-
- ImportModel<Voyage> csvModel = new VoyageImportModel(getCsvSeparator());
-
- Voyage newVoyage = null;
- Locale locale = getLocale();
- Reader reader = getInputFileReader(inputFile);
- try {
- Import<Voyage> importer = Import.newImport(csvModel, reader);
-
- configuration.incrementsProgression();
- for (Voyage voyage : importer) {
-
- configuration.incrementsProgression();
-
- voyage.setMission(mission);
- voyage.setAreaOfOperation(areaOfOperation);
- voyage.setDescription(voyageDescription);
- voyage.setDatum(datum);
-
- Voyage createdVoyage = create(dao, voyage);
- if (newVoyage == null) {
- newVoyage = createdVoyage;
- } else {
- // this means a voyage file with more than one row not possible...
-
- throw new ImportException(
- l_(locale, "echobase.importError.can.only.import.one.voyage.atime"));
- }
-
- importResult.incrementsNumberCreated(EchoBaseEntityEnum.Voyage);
- }
-
- if (newVoyage == null) {
- throw new ImportException(
- l_(locale, "echobase.importError.no.voyage.imported"));
- }
-
- // push back to id of the voyage in configuration for next imports
- configuration.setVoyageId(newVoyage.getTopiaId());
-
- return importResult;
- } catch (ImportRuntimeException e) {
- throw new ImportException(locale, inputFile, e);
- } finally {
- closeReader(reader, inputFile);
- }
- }
-
- protected CsvFileImportResult<EchoBaseEntityEnum> importTransitFile(
- CommonImportConfiguration configuration) throws ImportException {
-
- InputFile inputFile = configuration.getTransitFile();
-
- if (log.isInfoEnabled()) {
- log.info("Starts import of transits from file " +
- inputFile.getFileName());
- }
- CsvFileImportResult<EchoBaseEntityEnum> importResult = CsvFileImportResult.newResult(
- inputFile.getFileName(), EchoBaseEntityEnum.values());
-
- // get voyage
- Voyage voyage = getEntityById(Voyage.class,
- configuration.getVoyageId());
-
- // restrict voyage to use to this voyage
- Map<String, Voyage> voyageMap = Maps.uniqueIndex(
- Arrays.asList(voyage), EchoBaseFunctions.VOYAGE_NAME);
-
- String relatedActivity = configuration.getTransitRelatedActivity();
-
- TransitImportModel csvModel =
- new TransitImportModel(getCsvSeparator(), voyageMap);
-
- TransitDAO dao = getDAO(Transit.class, TransitDAO.class);
-
- Reader reader = getInputFileReader(inputFile);
- try {
- Import<TransitImportRow> importer =
- Import.newImport(csvModel, reader);
-
- configuration.incrementsProgression();
- for (TransitImportRow row : importer) {
-
- configuration.incrementsProgression();
- Transit transit = row.getTransit();
-
- transit.setRelatedActivity(relatedActivity);
-
- Transit createdTransit = create(dao, transit);
-
- voyage.addTransit(createdTransit);
-
- importResult.incrementsNumberCreated(EchoBaseEntityEnum.Transit);
- }
- return importResult;
- } catch (ImportRuntimeException e) {
- throw new ImportException(getLocale(), inputFile, e);
- } finally {
- closeReader(reader, inputFile);
- }
- }
-
- private CsvFileImportResult<EchoBaseEntityEnum> importTransectFile(
+ protected EchoBaseCsvFileImportResult importTransectFile(
Map<String, Vessel> vesselMap,
- CommonImportConfiguration configuration) throws ImportException {
+ CommonImportConfiguration configuration,
+ boolean collectIds) throws ImportException {
InputFile inputFile = configuration.getTransectFile();
@@ -274,8 +124,7 @@
inputFile.getFileName());
}
- CsvFileImportResult<EchoBaseEntityEnum> importResult = CsvFileImportResult.newResult(
- inputFile.getFileName(), EchoBaseEntityEnum.values());
+ EchoBaseCsvFileImportResult importResult = newImportResult(inputFile);
// get voyage
Voyage voyage = getEntityById(Voyage.class,
@@ -329,7 +178,16 @@
Transect createdTransect = create(dao, transect);
transit.addTransect(createdTransect);
- importResult.incrementsNumberCreated(EchoBaseEntityEnum.Transect);
+
+ if (collectIds) {
+
+ // collect id of the import
+ importResult.addId(EchoBaseEntityEnum.Transect,
+ createdTransect);
+ } else {
+
+ importResult.incrementsNumberCreated(EchoBaseEntityEnum.Transect);
+ }
}
return importResult;
Added: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/CommonTransectImportService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/CommonTransectImportService.java (rev 0)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/CommonTransectImportService.java 2012-09-07 10:57:12 UTC (rev 633)
@@ -0,0 +1,57 @@
+/*
+ * #%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%
+ */
+package fr.ifremer.echobase.services.importdata;
+
+import fr.ifremer.echobase.EchoBaseFunctions;
+import fr.ifremer.echobase.entities.EchoBaseUser;
+import fr.ifremer.echobase.entities.references.Vessel;
+
+import java.util.Map;
+
+/**
+ * Service to launch a "common transect data" import.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.3
+ */
+public class CommonTransectImportService extends AbstractImportDataService<CommonImportConfiguration> {
+
+
+ @Override
+ protected void startImport(
+ CommonImportConfiguration configuration,
+ EchoBaseUser user) throws ImportException {
+
+ // get usable vessels
+ Map<String, Vessel> vesselMap = getEntitiesMap(
+ Vessel.class, EchoBaseFunctions.VESSEL_NAME);
+
+ EchoBaseCsvFileImportResult importResult;
+
+ CommonImportService service = getService(CommonImportService.class);
+
+ importResult = service.importTransectFile(vesselMap, configuration, true);
+ configuration.addResult(importResult);
+ }
+}
Property changes on: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/CommonTransectImportService.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/EchoBaseCsvFileImportResult.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/EchoBaseCsvFileImportResult.java (rev 0)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/EchoBaseCsvFileImportResult.java 2012-09-07 10:57:12 UTC (rev 633)
@@ -0,0 +1,62 @@
+package fr.ifremer.echobase.services.importdata;
+
+/*
+ * #%L
+ * EchoBase :: Services
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 - 2012 Ifremer, Codelutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+
+import com.google.common.collect.Lists;
+import fr.ifremer.echobase.entities.EchoBaseEntityEnum;
+import fr.ifremer.echobase.entities.ImportLog;
+import org.nuiton.topia.persistence.TopiaEntity;
+import org.nuiton.topia.persistence.csv.in.CsvFileImportResult;
+
+import java.util.List;
+
+/**
+ * {@link CsvFileImportResult} with support for ids to keep in the
+ * {@link ImportLog#getImportId()}.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.2
+ */
+public class EchoBaseCsvFileImportResult extends CsvFileImportResult<EchoBaseEntityEnum> {
+
+ private static final long serialVersionUID = 1L;
+
+ protected final List<String> ids;
+
+ public EchoBaseCsvFileImportResult(String importFileName) {
+ super(importFileName, EchoBaseEntityEnum.values());
+ ids = Lists.newArrayList();
+ }
+
+ public <E extends TopiaEntity> void addId(EchoBaseEntityEnum entityEnum, E... entities) {
+ for (E entity : entities) {
+ this.ids.add(entity.getTopiaId());
+ incrementsNumberCreated(entityEnum);
+ }
+ }
+
+ public List<String> getIds() {
+ return ids;
+ }
+}
Property changes on: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/EchoBaseCsvFileImportResult.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/OperationImportService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/OperationImportService.java 2012-09-07 10:19:04 UTC (rev 632)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/OperationImportService.java 2012-09-07 10:57:12 UTC (rev 633)
@@ -27,7 +27,6 @@
import fr.ifremer.echobase.EchoBaseFunctions;
import fr.ifremer.echobase.entities.EchoBaseEntityEnum;
import fr.ifremer.echobase.entities.EchoBaseUser;
-import fr.ifremer.echobase.entities.ImportType;
import fr.ifremer.echobase.entities.data.GearMetadataValue;
import fr.ifremer.echobase.entities.data.GearMetadataValueDAO;
import fr.ifremer.echobase.entities.data.Operation;
@@ -51,7 +50,6 @@
import fr.ifremer.echobase.services.importdata.csv.OperationMetadataValueImportRow;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.nuiton.topia.persistence.csv.in.CsvFileImportResult;
import org.nuiton.util.csv.Import;
import org.nuiton.util.csv.ImportRuntimeException;
@@ -60,8 +58,6 @@
import java.util.Date;
import java.util.Map;
-import static org.nuiton.i18n.I18n.l_;
-
/**
* Service to launch a "operations" import.
*
@@ -75,11 +71,6 @@
LogFactory.getLog(OperationImportService.class);
@Override
- protected String computeImportLabel(OperationImportConfiguration configuration) {
- return l_(getLocale(), ImportType.OPERATION.getI18nKey());
- }
-
- @Override
protected void startImport(
OperationImportConfiguration configuration,
EchoBaseUser user) throws ImportException {
@@ -96,13 +87,12 @@
Map<String, Gear> gearMap = getEntitiesMap(
Gear.class, EchoBaseFunctions.GEAR_CASINO_GEAR_NAME);
- CsvFileImportResult<EchoBaseEntityEnum> importResult;
+ EchoBaseCsvFileImportResult importResult;
- importResult = importOperationFile(
- configuration,
- voyage,
- vesselMap,
- gearMap);
+ importResult = importOperationFile(configuration,
+ voyage,
+ vesselMap,
+ gearMap);
configuration.addResult(importResult);
// get all operation for this voyage and this vessel
@@ -112,21 +102,19 @@
Map<String, Operation> operationMap = Maps.uniqueIndex(
operations, EchoBaseFunctions.OPERATION_ID);
- importResult = importOperationMetadataFile(
- configuration,
- vesselMap,
- operationMap);
+ importResult = importOperationMetadataFile(configuration,
+ vesselMap,
+ operationMap);
configuration.addResult(importResult);
- importResult = importGearMetadataFile(
- configuration,
- vesselMap,
- gearMap,
- operationMap);
+ importResult = importGearMetadataFile(configuration,
+ vesselMap,
+ gearMap,
+ operationMap);
configuration.addResult(importResult);
}
- protected CsvFileImportResult<EchoBaseEntityEnum> importOperationFile(
+ protected EchoBaseCsvFileImportResult importOperationFile(
OperationImportConfiguration configuration,
Voyage voyage,
Map<String, Vessel> vesselMap,
@@ -140,8 +128,7 @@
inputFile.getFileName());
}
- CsvFileImportResult<EchoBaseEntityEnum> importResult = CsvFileImportResult.newResult(
- inputFile.getFileName(), EchoBaseEntityEnum.values());
+ EchoBaseCsvFileImportResult importResult = newImportResult(inputFile);
Map<String, DepthStratum> depthStratumMap = getEntitiesMap(
DepthStratum.class, EchoBaseFunctions.DEPTH_STRATUM_ID);
@@ -163,8 +150,7 @@
int rowNumber = 0;
for (OperationImportRow row : importer) {
- configuration.incrementsProgression();
- doFlushTransaction(++rowNumber, inputFile);
+ doFlushTransaction(++rowNumber, inputFile, configuration);
Vessel vessel = row.getVessel();
Operation operation = row.getOperation();
@@ -178,9 +164,11 @@
Operation createdOperation = create(dao, operation);
- transect.addOperation(createdOperation);
+ // collect ids
+ importResult.addId(EchoBaseEntityEnum.Operation,
+ createdOperation);
- importResult.incrementsNumberCreated(EchoBaseEntityEnum.Operation);
+ transect.addOperation(createdOperation);
}
return importResult;
@@ -191,7 +179,7 @@
}
}
- protected CsvFileImportResult<EchoBaseEntityEnum> importOperationMetadataFile(
+ protected EchoBaseCsvFileImportResult importOperationMetadataFile(
OperationImportConfiguration configuration,
Map<String, Vessel> vesselMap,
Map<String, Operation> operationMap) throws ImportException {
@@ -203,8 +191,7 @@
inputFile.getFileName());
}
- CsvFileImportResult<EchoBaseEntityEnum> importResult = CsvFileImportResult.newResult(
- inputFile.getFileName(), EchoBaseEntityEnum.values());
+ EchoBaseCsvFileImportResult importResult = newImportResult(inputFile);
Map<String, OperationMetadata> operationMetadatasByName =
getEntitiesMap(OperationMetadata.class,
@@ -229,8 +216,7 @@
configuration.incrementsProgression();
for (OperationMetadataValueImportRow row : importer) {
- doFlushTransaction(++rowNumber, inputFile);
- configuration.incrementsProgression();
+ doFlushTransaction(++rowNumber, inputFile, configuration);
Operation operation = row.getOperation();
OperationMetadataValue operationMetadataValueToCreate =
@@ -249,7 +235,7 @@
}
}
- protected CsvFileImportResult<EchoBaseEntityEnum> importGearMetadataFile(
+ protected EchoBaseCsvFileImportResult importGearMetadataFile(
OperationImportConfiguration configuration,
Map<String, Vessel> vesselMap,
Map<String, Gear> gearMap,
@@ -262,8 +248,7 @@
inputFile.getFileName());
}
- CsvFileImportResult<EchoBaseEntityEnum> importResult = CsvFileImportResult.newResult(
- inputFile.getFileName(), EchoBaseEntityEnum.values());
+ EchoBaseCsvFileImportResult importResult = newImportResult(inputFile);
Map<String, GearMetadata> gearMetadatasByType =
getEntitiesMap(GearMetadata.class,
@@ -288,8 +273,7 @@
configuration.incrementsProgression();
for (GearMetadataValueImportRow row : importer) {
- doFlushTransaction(++rowNumber, inputFile);
- configuration.incrementsProgression();
+ doFlushTransaction(++rowNumber, inputFile, configuration);
Operation operation = row.getOperation();
GearMetadataValue gearMetadataValuetoCreate =
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/ResultsEsduCellImportService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/ResultsEsduCellImportService.java 2012-09-07 10:19:04 UTC (rev 632)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/ResultsEsduCellImportService.java 2012-09-07 10:57:12 UTC (rev 633)
@@ -25,8 +25,6 @@
import com.google.common.collect.Maps;
import fr.ifremer.echobase.EchoBaseFunctions;
-import fr.ifremer.echobase.entities.ImportType;
-import fr.ifremer.echobase.io.InputFile;
import fr.ifremer.echobase.entities.EchoBaseEntityEnum;
import fr.ifremer.echobase.entities.EchoBaseUser;
import fr.ifremer.echobase.entities.data.Category;
@@ -46,6 +44,7 @@
import fr.ifremer.echobase.entities.references.Species;
import fr.ifremer.echobase.entities.references.SpeciesCategory;
import fr.ifremer.echobase.entities.references.SpeciesCategoryDAO;
+import fr.ifremer.echobase.io.InputFile;
import fr.ifremer.echobase.services.importdata.csv.EsduResultByEchotypeAndSpeciesCategoryImportModel;
import fr.ifremer.echobase.services.importdata.csv.EsduResultByEchotypeAndSpeciesCategoryImportRow;
import fr.ifremer.echobase.services.importdata.csv.EsduResultByEchotypeImportModel;
@@ -56,7 +55,6 @@
import fr.ifremer.echobase.services.importdata.csv.EsduResultBySpeciesAndSizeCategoryImportRow;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.nuiton.topia.persistence.csv.in.CsvFileImportResult;
import org.nuiton.util.csv.Import;
import org.nuiton.util.csv.ImportRuntimeException;
import org.nuiton.util.csv.ext.CsvReaders;
@@ -66,8 +64,6 @@
import java.util.List;
import java.util.Map;
-import static org.nuiton.i18n.I18n.l_;
-
/**
* To import results attached to a voyage (but not cells).
*
@@ -81,11 +77,6 @@
LogFactory.getLog(ResultsEsduCellImportService.class);
@Override
- protected String computeImportLabel(ResultsImportConfiguration configuration) {
- return l_(getLocale(), ImportType.RESULT_ESDU.getI18nKey());
- }
-
- @Override
public void startImport(
ResultsImportConfiguration configuration,
EchoBaseUser user) throws ImportException {
@@ -130,20 +121,19 @@
voyage.getEchotype(), EchoBaseFunctions.ECHOTYPE_NAME);
InputFile inputFile;
- CsvFileImportResult<EchoBaseEntityEnum> importResult;
+ EchoBaseCsvFileImportResult importResult;
inputFile = configuration.getEsduByEchotypeFile();
if (inputFile.hasFile()) {
- importResult = importByEchotypeFile(
- configuration,
- inputFile,
- voyage,
- voyageMap,
- echotypeMap,
- dataMetadataMap,
- esduCellMap,
- dataQualityMap);
+ importResult = importByEchotypeFile(configuration,
+ inputFile,
+ voyage,
+ voyageMap,
+ echotypeMap,
+ dataMetadataMap,
+ esduCellMap,
+ dataQualityMap);
configuration.addResult(importResult);
}
@@ -195,7 +185,7 @@
}
}
- private CsvFileImportResult<EchoBaseEntityEnum> importByEchotypeFile(
+ private EchoBaseCsvFileImportResult importByEchotypeFile(
ResultsImportConfiguration configuration,
InputFile inputFile,
Voyage voyage,
@@ -214,8 +204,7 @@
String[] header = CsvReaders.getHeader(inputFile.getFile(),
getCsvSeparator());
- CsvFileImportResult<EchoBaseEntityEnum> importResult = CsvFileImportResult.newResult(
- inputFile.getFileName(), EchoBaseEntityEnum.values());
+ EchoBaseCsvFileImportResult importResult = newImportResult(inputFile);
List<DataMetadata> metas = getMetas(
EsduResultByEchotypeImportModel.COLUMN_NAMES_TO_EXCLUDE,
@@ -246,8 +235,7 @@
for (EsduResultByEchotypeImportRow row : importer) {
- doFlushTransaction(++rowNumber, inputFile);
- configuration.incrementsProgression();
+ doFlushTransaction(++rowNumber, inputFile, configuration);
Cell cell = row.getCell();
@@ -256,7 +244,7 @@
null,
importResult);
- addResults(row, cell, category, resultLabel, dao, importResult);
+ addResults(row, cell, category, resultLabel, dao, importResult, true);
}
return importResult;
} catch (ImportRuntimeException e) {
@@ -266,7 +254,7 @@
}
}
- private CsvFileImportResult<EchoBaseEntityEnum> importByEchotypeAndSpeciesCategoryFile(
+ private EchoBaseCsvFileImportResult importByEchotypeAndSpeciesCategoryFile(
ResultsImportConfiguration configuration,
InputFile inputFile,
Voyage voyage,
@@ -288,8 +276,7 @@
String[] header = CsvReaders.getHeader(inputFile.getFile(),
getCsvSeparator());
- CsvFileImportResult<EchoBaseEntityEnum> importResult = CsvFileImportResult.newResult(
- inputFile.getFileName(), EchoBaseEntityEnum.values());
+ EchoBaseCsvFileImportResult importResult = newImportResult(inputFile);
List<DataMetadata> metas =
getMetas(
@@ -326,8 +313,7 @@
int rowNumber = 0;
for (EsduResultByEchotypeAndSpeciesCategoryImportRow row : importer) {
- doFlushTransaction(++rowNumber, inputFile);
- configuration.incrementsProgression();
+ doFlushTransaction(++rowNumber, inputFile, configuration);
Cell cell = row.getCell();
@@ -339,7 +325,7 @@
null,
importResult);
- addResults(row, cell, category, resultLabel, dao, importResult);
+ addResults(row, cell, category, resultLabel, dao, importResult, true);
}
return importResult;
@@ -350,7 +336,7 @@
}
}
- private CsvFileImportResult<EchoBaseEntityEnum> importBySpeciesAndSizeCategoryFile(
+ private EchoBaseCsvFileImportResult importBySpeciesAndSizeCategoryFile(
ResultsImportConfiguration configuration, InputFile inputFile,
Voyage voyage,
Map<String, Voyage> voyageMap,
@@ -370,8 +356,7 @@
getCsvSeparator());
- CsvFileImportResult<EchoBaseEntityEnum> importResult = CsvFileImportResult.newResult(
- inputFile.getFileName(), EchoBaseEntityEnum.values());
+ EchoBaseCsvFileImportResult importResult = newImportResult(inputFile);
List<DataMetadata> metas =
getMetas(
@@ -409,8 +394,7 @@
int rowNumber = 0;
for (EsduResultBySpeciesAndSizeCategoryImportRow row : importer) {
- doFlushTransaction(++rowNumber, inputFile);
- configuration.incrementsProgression();
+ doFlushTransaction(++rowNumber, inputFile, configuration);
Cell cell = row.getCell();
@@ -443,7 +427,7 @@
null,
importResult);
- addResults(row, cell, category, resultLabel, dao, importResult);
+ addResults(row, cell, category, resultLabel, dao, importResult, true);
}
return importResult;
@@ -454,7 +438,7 @@
}
}
- private CsvFileImportResult<EchoBaseEntityEnum> importBySpeciesAndAgeCategoryFile(
+ private EchoBaseCsvFileImportResult importBySpeciesAndAgeCategoryFile(
ResultsImportConfiguration configuration,
InputFile inputFile,
Voyage voyage,
@@ -475,8 +459,7 @@
getCsvSeparator());
- CsvFileImportResult<EchoBaseEntityEnum> importResult = CsvFileImportResult.newResult(
- inputFile.getFileName(), EchoBaseEntityEnum.values());
+ EchoBaseCsvFileImportResult importResult = newImportResult(inputFile);
List<DataMetadata> metas =
getMetas(
@@ -512,8 +495,7 @@
int rowNumber = 0;
for (EsduResultBySpeciesAndAgeCategoryImportRow row : importer) {
- doFlushTransaction(++rowNumber, inputFile);
- configuration.incrementsProgression();
+ doFlushTransaction(++rowNumber, inputFile, configuration);
Cell cell = row.getCell();
@@ -546,7 +528,7 @@
ageCategory,
importResult);
- addResults(row, cell, category, resultLabel, dao, importResult);
+ addResults(row, cell, category, resultLabel, dao, importResult, true);
}
return importResult;
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/ResultsImportService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/ResultsImportService.java 2012-09-07 10:19:04 UTC (rev 632)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/ResultsImportService.java 2012-09-07 10:57:12 UTC (rev 633)
@@ -46,27 +46,11 @@
public class ResultsImportService extends AbstractImportDataService<ResultsImportConfiguration> {
@Override
- protected String computeImportLabel(ResultsImportConfiguration configuration) {
-
- AbstractImportDataService<ResultsImportConfiguration> service =
- getService(configuration.getImportType());
-
- String result = service.computeImportLabel(configuration);
- return result;
- }
-
- @Override
public void startImport(ResultsImportConfiguration configuration,
EchoBaseUser user) throws ImportException {
ImportType importMode = configuration.getImportType();
- AbstractImportDataService<ResultsImportConfiguration> service = getService(importMode);
-
- service.startImport(configuration, user);
- }
-
- private AbstractImportDataService<ResultsImportConfiguration> getService(ImportType importMode) {
AbstractImportDataService<ResultsImportConfiguration> service;
switch (importMode) {
@@ -93,7 +77,7 @@
throw new EchoBaseTechnicalException(
"Can not treate import result of type " + importMode);
}
- return service;
+ service.startImport(configuration, user);
}
public Map<String, String> getDataProcessings(Voyage voyage) {
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/ResultsMapCellImportService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/ResultsMapCellImportService.java 2012-09-07 10:19:04 UTC (rev 632)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/ResultsMapCellImportService.java 2012-09-07 10:57:12 UTC (rev 633)
@@ -26,8 +26,6 @@
import com.google.common.base.Preconditions;
import com.google.common.collect.Maps;
import fr.ifremer.echobase.EchoBaseFunctions;
-import fr.ifremer.echobase.entities.ImportType;
-import fr.ifremer.echobase.io.InputFile;
import fr.ifremer.echobase.entities.EchoBaseEntityEnum;
import fr.ifremer.echobase.entities.EchoBaseUser;
import fr.ifremer.echobase.entities.data.Category;
@@ -47,11 +45,11 @@
import fr.ifremer.echobase.entities.references.Species;
import fr.ifremer.echobase.entities.references.SpeciesCategory;
import fr.ifremer.echobase.entities.references.SpeciesCategoryDAO;
+import fr.ifremer.echobase.io.InputFile;
import fr.ifremer.echobase.services.importdata.csv.MapCellImportModel;
import fr.ifremer.echobase.services.importdata.csv.MapCellImportRow;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.nuiton.topia.persistence.csv.in.CsvFileImportResult;
import org.nuiton.util.csv.Import;
import org.nuiton.util.csv.ImportRuntimeException;
import org.nuiton.util.csv.ext.CsvReaders;
@@ -61,8 +59,6 @@
import java.util.List;
import java.util.Map;
-import static org.nuiton.i18n.I18n.l_;
-
/**
* To import map results attached to a voyage.
*
@@ -76,11 +72,6 @@
LogFactory.getLog(ResultsMapCellImportService.class);
@Override
- protected String computeImportLabel(ResultsImportConfiguration configuration) {
- return l_(getLocale(), ImportType.RESULT_MAP.getI18nKey());
- }
-
- @Override
public void startImport(
ResultsImportConfiguration configuration,
EchoBaseUser user) throws ImportException {
@@ -89,12 +80,12 @@
Voyage voyage = getEntityById(Voyage.class,
configuration.getVoyageId());
- CsvFileImportResult<EchoBaseEntityEnum> importResult;
+ EchoBaseCsvFileImportResult importResult;
importResult = importMapFile(configuration, voyage);
configuration.addResult(importResult);
}
- protected CsvFileImportResult<EchoBaseEntityEnum> importMapFile(
+ protected EchoBaseCsvFileImportResult importMapFile(
ResultsImportConfiguration configuration,
Voyage voyage) throws ImportException {
@@ -175,8 +166,7 @@
metas,
dataQualityMap);
- CsvFileImportResult<EchoBaseEntityEnum> importResult = CsvFileImportResult.newResult(
- inputFile.getFileName(), EchoBaseEntityEnum.values());
+ EchoBaseCsvFileImportResult importResult = newImportResult(inputFile);
CellDAO dao = getDAO(Cell.class, CellDAO.class);
DataDAO dataDao = getDAO(Data.class, DataDAO.class);
@@ -195,13 +185,14 @@
int rowNumber = 0;
for (MapCellImportRow row : importer) {
- doFlushTransaction(++rowNumber, inputFile);
- configuration.incrementsProgression();
+ doFlushTransaction(++rowNumber, inputFile, configuration);
Cell cell = create(dao, row.getCell());
voyage.addPostCell(cell);
- importResult.incrementsNumberCreated(EchoBaseEntityEnum.Cell);
+ // collect ids
+ importResult.addId(EchoBaseEntityEnum.Cell, cell);
+
DataQuality dataQuality = row.getDataQuality();
// add gridCellLongitude data
@@ -266,7 +257,7 @@
row.getAgeCategory(),
importResult);
- addResults(row, cell, category, resultLabel, resultDao, importResult);
+ addResults(row, cell, category, resultLabel, resultDao, importResult, false);
}
return importResult;
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/ResultsRegionCellImportService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/ResultsRegionCellImportService.java 2012-09-07 10:19:04 UTC (rev 632)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/ResultsRegionCellImportService.java 2012-09-07 10:57:12 UTC (rev 633)
@@ -26,8 +26,6 @@
import com.google.common.base.Preconditions;
import com.google.common.collect.Maps;
import fr.ifremer.echobase.EchoBaseFunctions;
-import fr.ifremer.echobase.entities.ImportType;
-import fr.ifremer.echobase.io.InputFile;
import fr.ifremer.echobase.entities.EchoBaseEntityEnum;
import fr.ifremer.echobase.entities.EchoBaseUser;
import fr.ifremer.echobase.entities.data.Category;
@@ -47,6 +45,7 @@
import fr.ifremer.echobase.entities.references.Species;
import fr.ifremer.echobase.entities.references.SpeciesCategory;
import fr.ifremer.echobase.entities.references.SpeciesCategoryDAO;
+import fr.ifremer.echobase.io.InputFile;
import fr.ifremer.echobase.services.importdata.csv.RegionCellAssociationImportModel;
import fr.ifremer.echobase.services.importdata.csv.RegionCellAssociationImportRow;
import fr.ifremer.echobase.services.importdata.csv.RegionCellImportModel;
@@ -55,7 +54,6 @@
import fr.ifremer.echobase.services.importdata.csv.RegionCellResultImportRow;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.nuiton.topia.persistence.csv.in.CsvFileImportResult;
import org.nuiton.util.csv.Import;
import org.nuiton.util.csv.ImportRuntimeException;
import org.nuiton.util.csv.ext.CsvReaders;
@@ -65,8 +63,6 @@
import java.util.List;
import java.util.Map;
-import static org.nuiton.i18n.I18n.l_;
-
/**
* To import regions results attached to a voyage.
*
@@ -80,11 +76,6 @@
LogFactory.getLog(ResultsRegionCellImportService.class);
@Override
- protected String computeImportLabel(ResultsImportConfiguration configuration) {
- return l_(getLocale(), ImportType.RESULT_VOYAGE.getI18nKey());
- }
-
- @Override
public void startImport(
ResultsImportConfiguration configuration,
EchoBaseUser user) throws ImportException {
@@ -96,7 +87,7 @@
Map<String, DataQuality> dataQualityMap = getEntitiesMap(
DataQuality.class, EchoBaseFunctions.DATA_QUALITY_NAME);
- CsvFileImportResult<EchoBaseEntityEnum> importResult;
+ EchoBaseCsvFileImportResult importResult;
importResult = importRegionFile(configuration, voyage, dataQualityMap);
configuration.addResult(importResult);
@@ -108,7 +99,7 @@
configuration.addResult(importResult);
}
- protected CsvFileImportResult<EchoBaseEntityEnum> importRegionFile(
+ protected EchoBaseCsvFileImportResult importRegionFile(
ResultsImportConfiguration configuration,
Voyage voyage,
Map<String, DataQuality> dataQualityMap) throws ImportException {
@@ -153,8 +144,7 @@
inputFile.getFileName());
}
- CsvFileImportResult<EchoBaseEntityEnum> importResult = CsvFileImportResult.newResult(
- inputFile.getFileName(), EchoBaseEntityEnum.values());
+ EchoBaseCsvFileImportResult importResult = newImportResult(inputFile);
CellDAO dao = getDAO(Cell.class, CellDAO.class);
DataDAO dataDao = getDAO(Data.class, DataDAO.class);
@@ -169,11 +159,8 @@
configuration.incrementsProgression();
int rowNumber = 0;
for (RegionCellImportRow row : importer) {
- configuration.incrementsProgression();
- rowNumber++;
- doFlushTransaction(rowNumber, inputFile);
-
+ doFlushTransaction(++rowNumber, inputFile, configuration);
if (cell == null || !row.getName().equals(cell.getName())) {
cell = create(dao,
@@ -181,8 +168,10 @@
Cell.PROPERTY_NAME, row.getName()
);
voyage.addPostCell(cell);
- importResult.incrementsNumberCreated(EchoBaseEntityEnum.Cell);
+ // collect ids
+ importResult.addId(EchoBaseEntityEnum.Cell, cell);
+
// add surface data
createCellData(dataDao,
cell,
@@ -211,7 +200,7 @@
}
}
- protected CsvFileImportResult<EchoBaseEntityEnum> importRegionAssociationFile(
+ protected EchoBaseCsvFileImportResult importRegionAssociationFile(
ResultsImportConfiguration configuration,
Voyage voyage) throws ImportException {
@@ -236,8 +225,7 @@
regionsMap,
getDAO(Cell.class, CellDAO.class));
- CsvFileImportResult<EchoBaseEntityEnum> importResult = CsvFileImportResult.newResult(
- inputFile.getFileName(), EchoBaseEntityEnum.values());
+ EchoBaseCsvFileImportResult importResult = newImportResult(inputFile);
Reader reader = getInputFileReader(inputFile);
try {
@@ -248,9 +236,7 @@
int rowNumber = 0;
for (RegionCellAssociationImportRow row : importer) {
- rowNumber++;
- doFlushTransaction(rowNumber, inputFile);
- configuration.incrementsProgression();
+ doFlushTransaction(++rowNumber, inputFile, configuration);
Cell regionCell = row.getRegionCell();
Cell esduCell = row.getEsduCell();
@@ -266,7 +252,7 @@
}
}
- protected CsvFileImportResult<EchoBaseEntityEnum> importRegionResultFile(
+ protected EchoBaseCsvFileImportResult importRegionResultFile(
ResultsImportConfiguration configuration,
Voyage voyage,
Map<String, DataQuality> dataQualityMap) throws ImportException {
@@ -304,7 +290,6 @@
String[] header = CsvReaders.getHeader(inputFile.getFile(),
getCsvSeparator());
-
List<DataMetadata> metas = getMetas(
RegionCellResultImportModel.COLUMN_NAMES_TO_EXCLUDE,
dataMetadataMap,
@@ -322,8 +307,7 @@
String resultLabel = configuration.getResultLabel();
- CsvFileImportResult<EchoBaseEntityEnum> importResult = CsvFileImportResult.newResult(
- inputFile.getFileName(), EchoBaseEntityEnum.values());
+ EchoBaseCsvFileImportResult importResult = newImportResult(inputFile);
SpeciesCategoryDAO speciesCategoryDAO =
getDAO(SpeciesCategory.class, SpeciesCategoryDAO.class);
@@ -339,9 +323,7 @@
int rowNumber = 0;
for (RegionCellResultImportRow row : importer) {
- rowNumber++;
- doFlushTransaction(rowNumber, inputFile);
- configuration.incrementsProgression();
+ doFlushTransaction(++rowNumber, inputFile, configuration);
Cell cell = row.getCell();
@@ -353,7 +335,7 @@
null,
importResult);
- addResults(row, cell, category, resultLabel, dao, importResult);
+ addResults(row, cell, category, resultLabel, dao, importResult, false);
}
return importResult;
Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/ResultsVoyageImportService.java
===================================================================
--- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/ResultsVoyageImportService.java 2012-09-07 10:19:04 UTC (rev 632)
+++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/importdata/ResultsVoyageImportService.java 2012-09-07 10:57:12 UTC (rev 633)
@@ -28,8 +28,6 @@
import com.google.common.collect.Maps;
import fr.ifremer.echobase.EchoBaseFunctions;
import fr.ifremer.echobase.EchoBasePredicates;
-import fr.ifremer.echobase.entities.ImportType;
-import fr.ifremer.echobase.io.InputFile;
import fr.ifremer.echobase.entities.EchoBaseEntityEnum;
import fr.ifremer.echobase.entities.EchoBaseUser;
import fr.ifremer.echobase.entities.data.Echotype;
@@ -43,6 +41,7 @@
import fr.ifremer.echobase.entities.references.SpeciesCategory;
import fr.ifremer.echobase.entities.references.SpeciesCategoryDAO;
import fr.ifremer.echobase.entities.references.Strata;
+import fr.ifremer.echobase.io.InputFile;
import fr.ifremer.echobase.services.importdata.csv.EchotypeImportModel;
import fr.ifremer.echobase.services.importdata.csv.EchotypeImportRow;
import fr.ifremer.echobase.services.importdata.csv.LengthAgeKeyImportModel;
@@ -52,7 +51,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.nuiton.topia.persistence.TopiaDAO;
-import org.nuiton.topia.persistence.csv.in.CsvFileImportResult;
import org.nuiton.util.csv.Import;
import org.nuiton.util.csv.ImportRuntimeException;
@@ -61,8 +59,6 @@
import java.util.Collection;
import java.util.Map;
-import static org.nuiton.i18n.I18n.l_;
-
/**
* To import results attached to a voyage (but not cells).
*
@@ -76,11 +72,6 @@
LogFactory.getLog(ResultsVoyageImportService.class);
@Override
- protected String computeImportLabel(ResultsImportConfiguration configuration) {
- return l_(getLocale(), ImportType.RESULT_VOYAGE.getI18nKey());
- }
-
- @Override
public void startImport(ResultsImportConfiguration configuration,
EchoBaseUser user) throws ImportException {
@@ -101,7 +92,7 @@
InputFile inputFile;
- CsvFileImportResult<EchoBaseEntityEnum> importResult;
+ EchoBaseCsvFileImportResult importResult;
inputFile = configuration.getLengthAgeKeyFile();
if (inputFile.hasFile()) {
@@ -142,7 +133,7 @@
}
}
- protected CsvFileImportResult<EchoBaseEntityEnum> importLenghtWeightKey(
+ protected EchoBaseCsvFileImportResult importLenghtWeightKey(
ResultsImportConfiguration configuration,
InputFile inputFile,
Map<String, Voyage> voyageMap,
@@ -154,8 +145,8 @@
inputFile.getFileName());
}
- CsvFileImportResult<EchoBaseEntityEnum> importResult = CsvFileImportResult.newResult(
- inputFile.getFileName(), EchoBaseEntityEnum.values());
+ EchoBaseCsvFileImportResult importResult = new EchoBaseCsvFileImportResult(
+ inputFile.getFileName());
Map<String, SizeCategory> sizeCategoryMap = getEntitiesMap(
SizeCategory.class,
@@ -184,8 +175,7 @@
int rowNumber = 0;
for (LengthWeightKeyImportRow row : importer) {
- doFlushTransaction(++rowNumber, inputFile);
- configuration.incrementsProgression();
+ doFlushTransaction(++rowNumber, inputFile, configuration);
Voyage voyage = row.getVoyage();
// find speciesCategory
@@ -220,7 +210,7 @@
}
}
- protected CsvFileImportResult<EchoBaseEntityEnum> importLenthAgeKey(
+ protected EchoBaseCsvFileImportResult importLenthAgeKey(
ResultsImportConfiguration configuration,
InputFile inputFile,
Map<String, Voyage> voyageMap,
@@ -232,8 +222,7 @@
inputFile.getFileName());
}
- CsvFileImportResult<EchoBaseEntityEnum> importResult = CsvFileImportResult.newResult(
- inputFile.getFileName(), EchoBaseEntityEnum.values());
+ EchoBaseCsvFileImportResult importResult = newImportResult(inputFile);
LengthAgeKeyImportModel csvModel = new LengthAgeKeyImportModel(
serviceContext.getConfiguration().getCsvSeparator(),
@@ -253,8 +242,7 @@
int rowNumber = 0;
for (LengthAgeKeyImportRow row : importer) {
- doFlushTransaction(++rowNumber, inputFile);
- configuration.incrementsProgression();
+ doFlushTransaction(++rowNumber, inputFile, configuration);
Voyage voyage = row.getVoyage();
@@ -264,7 +252,9 @@
// attach it to voyage
voyage.addLengthAgeKey(lengthAgeKey);
- importResult.incrementsNumberCreated(EchoBaseEntityEnum.LengthAgeKey);
+ // collect ids
+ importResult.addId(EchoBaseEntityEnum.LengthAgeKey,
+ lengthAgeKey);
}
return importResult;
} catch (ImportRuntimeException e) {
@@ -274,7 +264,7 @@
}
}
- private CsvFileImportResult<EchoBaseEntityEnum> importEchotypeFile(
+ private EchoBaseCsvFileImportResult importEchotypeFile(
ResultsImportConfiguration configuration,
InputFile inputFile,
Map<String, Voyage> voyageMap,
@@ -285,8 +275,7 @@
inputFile.getFileName());
}
- CsvFileImportResult<EchoBaseEntityEnum> importResult = CsvFileImportResult.newResult(
- inputFile.getFileName(), EchoBaseEntityEnum.values());
+ EchoBaseCsvFileImportResult importResult = newImportResult(inputFile);
Map<String, DepthStratum> depthStratumMap = getEntitiesMap(
DepthStratum.class,
@@ -310,8 +299,7 @@
int rowNumber = 0;
for (EchotypeImportRow row : importer) {
- doFlushTransaction(++rowNumber, inputFile);
- configuration.incrementsProgression();
+ doFlushTransaction(++rowNumber, inputFile, configuration);
Voyage voyage = row.getVoyage();
@@ -340,7 +328,8 @@
// attach it to voyage
voyage.addEchotype(echotype);
- importResult.incrementsNumberCreated(EchoBaseEntityEnum.Echotype);
+ // collect ids
+ importResult.addId(EchoBaseEntityEnum.Echotype, echotype);
} else {
Modified: trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/EchoBaseTestServiceSupport.java
===================================================================
--- trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/EchoBaseTestServiceSupport.java 2012-09-07 10:19:04 UTC (rev 632)
+++ trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/EchoBaseTestServiceSupport.java 2012-09-07 10:57:12 UTC (rev 633)
@@ -24,12 +24,13 @@
package fr.ifremer.echobase.services;
import com.google.common.base.Preconditions;
-import fr.ifremer.echobase.io.InputFile;
import fr.ifremer.echobase.entities.EchoBaseEntityEnum;
import fr.ifremer.echobase.entities.EchoBaseUser;
import fr.ifremer.echobase.entities.EchoBaseUserImpl;
import fr.ifremer.echobase.entities.data.DataProcessing;
import fr.ifremer.echobase.entities.data.Voyage;
+import fr.ifremer.echobase.io.InputFile;
+import fr.ifremer.echobase.services.importdata.EchoBaseCsvFileImportResult;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import org.apache.commons.logging.Log;
@@ -39,7 +40,6 @@
import org.junit.Rule;
import org.nuiton.topia.TopiaException;
import org.nuiton.topia.persistence.TopiaEntity;
-import org.nuiton.topia.persistence.csv.in.CsvFileImportResult;
import org.nuiton.util.StringUtil;
import java.io.File;
@@ -136,35 +136,40 @@
}
}
- protected <E extends TopiaEntity> void assertCsvImportResult(CsvFileImportResult<EchoBaseEntityEnum> actual,
+ protected <E extends TopiaEntity> void assertCsvImportResult(EchoBaseCsvFileImportResult actual,
Class<E> entityType,
- int numberCreated) throws TopiaException {
+ int numberCreated,
+ int nbIds) throws TopiaException {
assertCsvImportResult(actual,
entityType,
numberCreated,
0,
- numberCreated);
+ numberCreated,
+ nbIds);
}
- protected <E extends TopiaEntity> void assertCsvImportResult(List<CsvFileImportResult<EchoBaseEntityEnum>> actual,
+ protected <E extends TopiaEntity> void assertCsvImportResult(List<EchoBaseCsvFileImportResult> actual,
int pos,
Class<E> entityType,
- int numberCreated) throws TopiaException {
+ int numberCreated,
+ int nbIds) throws TopiaException {
Assert.assertTrue(actual.size() >= pos);
assertCsvImportResult(actual.get(pos),
entityType,
numberCreated,
0,
- numberCreated);
+ numberCreated,
+ nbIds);
}
- protected <E extends TopiaEntity> void assertCsvImportResult(CsvFileImportResult<EchoBaseEntityEnum> actual,
+ protected <E extends TopiaEntity> void assertCsvImportResult(EchoBaseCsvFileImportResult actual,
Class<E> entityType,
int numberCreated,
int numberUpdated,
- int nbCount) throws TopiaException {
+ int nbCount,
+ int nbIds) throws TopiaException {
Assert.assertNotNull(actual);
Set<EchoBaseEntityEnum> entityTypes = actual.getEntityTypes();
EchoBaseEntityEnum expectedEntityType = EchoBaseEntityEnum.valueOf(entityType);
@@ -172,16 +177,18 @@
Assert.assertEquals(numberCreated, actual.getNumberCreated(expectedEntityType));
Assert.assertEquals(numberUpdated, actual.getNumberUpdated(expectedEntityType));
assertNbEntities(entityType, nbCount);
+ Assert.assertEquals(nbIds, actual.getIds().size());
}
- protected <E extends TopiaEntity> void assertCsvImportResult(List<CsvFileImportResult<EchoBaseEntityEnum>> results,
+ protected <E extends TopiaEntity> void assertCsvImportResult(List<EchoBaseCsvFileImportResult> results,
int pos,
Class<E> entityType,
int numberCreated,
int numberUpdated,
- int nbCount) throws TopiaException {
+ int nbCount,
+ int nbIds) throws TopiaException {
Assert.assertTrue(results.size() >= pos);
- CsvFileImportResult actual = results.get(pos);
+ EchoBaseCsvFileImportResult actual = results.get(pos);
Assert.assertNotNull(actual);
Set<EchoBaseEntityEnum> entityTypes = actual.getEntityTypes();
EchoBaseEntityEnum expectedEntityType = EchoBaseEntityEnum.valueOf(entityType);
@@ -189,6 +196,7 @@
Assert.assertEquals(numberCreated, actual.getNumberCreated(expectedEntityType));
Assert.assertEquals(numberUpdated, actual.getNumberUpdated(expectedEntityType));
assertNbEntities(entityType, nbCount);
+ Assert.assertEquals(nbIds, actual.getIds().size());
}
protected <E extends TopiaEntity> void assertNbEntities(Class<E> entityType,
Modified: trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/AbstractImportDataServiceIT.java
===================================================================
--- trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/AbstractImportDataServiceIT.java 2012-09-07 10:19:04 UTC (rev 632)
+++ trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/AbstractImportDataServiceIT.java 2012-09-07 10:57:12 UTC (rev 633)
@@ -29,7 +29,6 @@
import fr.ifremer.echobase.EchoBaseFunctions;
import fr.ifremer.echobase.EchoBaseTechnicalException;
import fr.ifremer.echobase.csv.EchoBaseCsvUtil;
-import fr.ifremer.echobase.entities.EchoBaseEntityEnum;
import fr.ifremer.echobase.entities.EchoBaseUser;
import fr.ifremer.echobase.entities.data.Cell;
import fr.ifremer.echobase.entities.data.CellDAO;
@@ -58,7 +57,6 @@
import org.nuiton.topia.persistence.TopiaDAO;
import org.nuiton.topia.persistence.TopiaEntity;
import org.nuiton.topia.persistence.csv.in.AbstractImportModel;
-import org.nuiton.topia.persistence.csv.in.CsvFileImportResult;
import org.nuiton.util.TimeLog;
import org.nuiton.util.csv.Import;
import org.nuiton.util.csv.ext.CsvReaders;
@@ -176,9 +174,9 @@
}
protected <M extends AbstractImportConfiguration, S extends AbstractImportDataService<M>>
- List<CsvFileImportResult<EchoBaseEntityEnum>> doImport(M conf,
- Class<S> serviceType,
- int nbResults) throws ImportException {
+ List<EchoBaseCsvFileImportResult> doImport(M conf,
+ Class<S> serviceType,
+ int nbResults) throws ImportException {
S service = getService(serviceType);
@@ -190,7 +188,7 @@
TIME_LOG.log(s0, "doImport");
- List<CsvFileImportResult<EchoBaseEntityEnum>> result = conf.getImportResults();
+ List<EchoBaseCsvFileImportResult> result = conf.getImportResults();
Assert.assertNotNull(result);
Assert.assertEquals(nbResults, result.size());
Modified: trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/AcousticImportServiceIT.java
===================================================================
--- trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/AcousticImportServiceIT.java 2012-09-07 10:19:04 UTC (rev 632)
+++ trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/AcousticImportServiceIT.java 2012-09-07 10:57:12 UTC (rev 633)
@@ -23,8 +23,6 @@
*/
package fr.ifremer.echobase.services.importdata;
-import fr.ifremer.echobase.entities.EchoBaseEntityEnum;
-import org.nuiton.topia.persistence.csv.in.CsvFileImportResult;
import fr.ifremer.echobase.entities.data.Cell;
import fr.ifremer.echobase.entities.data.Data;
import fr.ifremer.echobase.entities.data.DataAcquisition;
@@ -84,13 +82,13 @@
prepareInputFile(conf.getMoviesFile(), getImportPath("movies.csv.gz"));
- List<CsvFileImportResult<EchoBaseEntityEnum>> result;
+ List<EchoBaseCsvFileImportResult> result;
result = doImport(conf, AcousticImportService.class, 1);
- assertCsvImportResult(result, 0, DataAcquisition.class, NB_DATA_ACQUISITION);
- assertCsvImportResult(result, 0, DataProcessing.class, NB_DATA_PROCESSING);
- assertCsvImportResult(result, 0, Cell.class, NB_CELL);
- assertCsvImportResult(result, 0, Data.class, NB_DATA);
+ assertCsvImportResult(result, 0, DataAcquisition.class, NB_DATA_ACQUISITION,NB_DATA_ACQUISITION);
+ assertCsvImportResult(result, 0, DataProcessing.class, NB_DATA_PROCESSING,0);
+ assertCsvImportResult(result, 0, Cell.class, NB_CELL,0);
+ assertCsvImportResult(result, 0, Data.class, NB_DATA,0);
assertImportAcousticDatas();
}
Modified: trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/CatchesImportServiceIT.java
===================================================================
--- trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/CatchesImportServiceIT.java 2012-09-07 10:19:04 UTC (rev 632)
+++ trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/CatchesImportServiceIT.java 2012-09-07 10:57:12 UTC (rev 633)
@@ -23,8 +23,6 @@
*/
package fr.ifremer.echobase.services.importdata;
-import fr.ifremer.echobase.entities.EchoBaseEntityEnum;
-import org.nuiton.topia.persistence.csv.in.CsvFileImportResult;
import fr.ifremer.echobase.entities.data.Sample;
import fr.ifremer.echobase.entities.data.SampleData;
import fr.ifremer.echobase.entities.references.SpeciesCategory;
@@ -69,19 +67,19 @@
prepareInputFile(conf.getBiometrySampleFile(),
getImportPath("biometrysample.csv.gz"));
- List<CsvFileImportResult<EchoBaseEntityEnum>> result;
+ List<EchoBaseCsvFileImportResult> result;
result = doImport(conf, CatchesImportService.class, 3);
- assertCsvImportResult(result, 0, Sample.class, NB_SAMPLE_TOTAL, 0, NB_SAMPLE);
- assertCsvImportResult(result, 0, SampleData.class, NB_SAMPLE_DATA_TOTAL, 0, NB_SAMPLE_DATA);
- assertCsvImportResult(result, 0, SpeciesCategory.class, 4,0,456);
+ assertCsvImportResult(result, 0, Sample.class, NB_SAMPLE_TOTAL, 0, NB_SAMPLE, NB_SAMPLE_TOTAL);
+ assertCsvImportResult(result, 0, SampleData.class, NB_SAMPLE_DATA_TOTAL, 0, NB_SAMPLE_DATA, 0);
+ assertCsvImportResult(result, 0, SpeciesCategory.class, 4, 0, 456, 0);
- assertCsvImportResult(result, 1, Sample.class, NB_SAMPLE_UNSORTED, 0, NB_SAMPLE);
- assertCsvImportResult(result, 1, SampleData.class, NB_SAMPLE_DATA_UNSORTED, 0, NB_SAMPLE_DATA);
- assertCsvImportResult(result, 1, SpeciesCategory.class, 9, 0, 456);
+ assertCsvImportResult(result, 1, Sample.class, NB_SAMPLE_UNSORTED, 0, NB_SAMPLE, NB_SAMPLE_UNSORTED);
+ assertCsvImportResult(result, 1, SampleData.class, NB_SAMPLE_DATA_UNSORTED, 0, NB_SAMPLE_DATA, 0);
+ assertCsvImportResult(result, 1, SpeciesCategory.class, 9, 0, 456, 0);
- assertCsvImportResult(result, 2, Sample.class, NB_SAMPLE_BIOMETRY, 0, NB_SAMPLE);
- assertCsvImportResult(result, 2, SampleData.class, NB_SAMPLE_DATA_BIOMETRY, 0, NB_SAMPLE_DATA);
+ assertCsvImportResult(result, 2, Sample.class, NB_SAMPLE_BIOMETRY, 0, NB_SAMPLE, NB_SAMPLE_BIOMETRY);
+ assertCsvImportResult(result, 2, SampleData.class, NB_SAMPLE_DATA_BIOMETRY, 0, NB_SAMPLE_DATA, 0);
assertImportSampleDatas();
}
@@ -102,11 +100,11 @@
prepareInputFile(conf.getTotalSampleFile(),
getImportPath("totalsample.csv.gz"));
- List<CsvFileImportResult<EchoBaseEntityEnum>> result;
+ List<EchoBaseCsvFileImportResult> result;
result = doImport(conf, CatchesImportService.class, 1);
- assertCsvImportResult(result, 0, Sample.class, NB_SAMPLE_TOTAL);
- assertCsvImportResult(result, 0, SampleData.class, NB_SAMPLE_DATA_TOTAL);
+ assertCsvImportResult(result, 0, Sample.class, NB_SAMPLE_TOTAL, NB_SAMPLE_TOTAL);
+ assertCsvImportResult(result, 0, SampleData.class, NB_SAMPLE_DATA_TOTAL, 0);
}
@Ignore
@@ -125,11 +123,11 @@
prepareInputFile(conf.getSubSampleFile(),
getImportPath("subsample.csv.gz"));
- List<CsvFileImportResult<EchoBaseEntityEnum>> result;
+ List<EchoBaseCsvFileImportResult> result;
result = doImport(conf, CatchesImportService.class, 1);
- assertCsvImportResult(result, 0, Sample.class, NB_SAMPLE_UNSORTED);
- assertCsvImportResult(result, 0, SampleData.class, NB_SAMPLE_DATA_UNSORTED);
+ assertCsvImportResult(result, 0, Sample.class, NB_SAMPLE_UNSORTED, NB_SAMPLE_UNSORTED);
+ assertCsvImportResult(result, 0, SampleData.class, NB_SAMPLE_DATA_UNSORTED, 0);
}
@Ignore
@@ -148,10 +146,10 @@
prepareInputFile(conf.getBiometrySampleFile(),
getImportPath("biometrysample.csv.gz"));
- List<CsvFileImportResult<EchoBaseEntityEnum>> result;
+ List<EchoBaseCsvFileImportResult> result;
result = doImport(conf, CatchesImportService.class, 1);
- assertCsvImportResult(result, 0, Sample.class, NB_SAMPLE_BIOMETRY);
- assertCsvImportResult(result, 0, SampleData.class, NB_SAMPLE_DATA_BIOMETRY);
+ assertCsvImportResult(result, 0, Sample.class, NB_SAMPLE_BIOMETRY, NB_SAMPLE_BIOMETRY);
+ assertCsvImportResult(result, 0, SampleData.class, NB_SAMPLE_DATA_BIOMETRY, 0);
}
}
Modified: trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/CommonAllImportServiceIT.java
===================================================================
--- trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/CommonAllImportServiceIT.java 2012-09-07 10:19:04 UTC (rev 632)
+++ trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/CommonAllImportServiceIT.java 2012-09-07 10:57:12 UTC (rev 633)
@@ -23,14 +23,12 @@
*/
package fr.ifremer.echobase.services.importdata;
-import fr.ifremer.echobase.entities.EchoBaseEntityEnum;
import fr.ifremer.echobase.entities.ImportType;
import fr.ifremer.echobase.entities.data.Transect;
import fr.ifremer.echobase.entities.data.Transit;
import fr.ifremer.echobase.entities.data.Voyage;
import fr.ifremer.echobase.services.FakeEchoBaseServiceContext;
import org.junit.Test;
-import org.nuiton.topia.persistence.csv.in.CsvFileImportResult;
import java.util.List;
@@ -79,12 +77,12 @@
conf.setImportType(ImportType.COMMON_ALL);
- List<CsvFileImportResult<EchoBaseEntityEnum>> result;
- result = doImport(conf, CommonImportService.class, 3);
+ List<EchoBaseCsvFileImportResult> result;
+ result = doImport(conf, CommonAllImportService.class, 3);
- assertCsvImportResult(result, 0, Voyage.class, NB_VOYAGE);
- assertCsvImportResult(result, 1, Transit.class, NB_TRANSIT);
- assertCsvImportResult(result, 2, Transect.class, NB_TRANSECT);
+ assertCsvImportResult(result, 0, Voyage.class, NB_VOYAGE,NB_VOYAGE);
+ assertCsvImportResult(result, 1, Transit.class, NB_TRANSIT,0);
+ assertCsvImportResult(result, 2, Transect.class, NB_TRANSECT,0);
assertImportCommonData();
}
Modified: trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/CommonTransectImportServiceIT.java
===================================================================
--- trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/CommonTransectImportServiceIT.java 2012-09-07 10:19:04 UTC (rev 632)
+++ trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/CommonTransectImportServiceIT.java 2012-09-07 10:57:12 UTC (rev 633)
@@ -23,13 +23,11 @@
*/
package fr.ifremer.echobase.services.importdata;
-import fr.ifremer.echobase.entities.EchoBaseEntityEnum;
import fr.ifremer.echobase.entities.ImportType;
import fr.ifremer.echobase.entities.data.Transect;
import fr.ifremer.echobase.entities.data.Transit;
import fr.ifremer.echobase.services.FakeEchoBaseServiceContext;
import org.junit.Test;
-import org.nuiton.topia.persistence.csv.in.CsvFileImportResult;
import java.util.List;
@@ -75,10 +73,10 @@
transit.clearTransect();
}
- List<CsvFileImportResult<EchoBaseEntityEnum>> result;
- result = doImport(conf, CommonImportService.class, 1);
+ List<EchoBaseCsvFileImportResult> result;
+ result = doImport(conf, CommonTransectImportService.class, 1);
- assertCsvImportResult(result, 0, Transect.class, NB_TRANSECT);
+ assertCsvImportResult(result, 0, Transect.class, NB_TRANSECT,NB_TRANSECT);
assertImportCommonData();
}
Modified: trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/OperationImportServiceIT.java
===================================================================
--- trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/OperationImportServiceIT.java 2012-09-07 10:19:04 UTC (rev 632)
+++ trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/OperationImportServiceIT.java 2012-09-07 10:57:12 UTC (rev 633)
@@ -23,8 +23,6 @@
*/
package fr.ifremer.echobase.services.importdata;
-import fr.ifremer.echobase.entities.EchoBaseEntityEnum;
-import org.nuiton.topia.persistence.csv.in.CsvFileImportResult;
import fr.ifremer.echobase.entities.data.GearMetadataValue;
import fr.ifremer.echobase.entities.data.Operation;
import fr.ifremer.echobase.entities.data.OperationMetadataValue;
@@ -70,12 +68,12 @@
prepareInputFile(conf.getGearMetadataFile(),
getImportPath("gearmetadatavalue.csv.gz"));
- List<CsvFileImportResult<EchoBaseEntityEnum>> result;
+ List<EchoBaseCsvFileImportResult> result;
result = doImport(conf, OperationImportService.class, 3);
- assertCsvImportResult(result, 0, Operation.class, NB_OPERATION);
- assertCsvImportResult(result, 1, OperationMetadataValue.class, NB_OPERATION_METADATAVALUE);
- assertCsvImportResult(result, 2, GearMetadataValue.class, NB_GEAR_METADATAVALUE);
+ assertCsvImportResult(result, 0, Operation.class, NB_OPERATION,NB_OPERATION);
+ assertCsvImportResult(result, 1, OperationMetadataValue.class, NB_OPERATION_METADATAVALUE,0);
+ assertCsvImportResult(result, 2, GearMetadataValue.class, NB_GEAR_METADATAVALUE,0);
assertImportOperations();
}
Modified: trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/ResultsEsduCellImportServiceIT.java
===================================================================
--- trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/ResultsEsduCellImportServiceIT.java 2012-09-07 10:19:04 UTC (rev 632)
+++ trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/ResultsEsduCellImportServiceIT.java 2012-09-07 10:57:12 UTC (rev 633)
@@ -23,16 +23,14 @@
*/
package fr.ifremer.echobase.services.importdata;
-import fr.ifremer.echobase.entities.ImportType;
-import fr.ifremer.echobase.io.InputFile;
import fr.ifremer.echobase.csv.EchoBaseCsvUtil;
-import fr.ifremer.echobase.entities.EchoBaseEntityEnum;
-import org.nuiton.topia.persistence.csv.in.CsvFileImportResult;
+import fr.ifremer.echobase.entities.ImportType;
import fr.ifremer.echobase.entities.data.Category;
import fr.ifremer.echobase.entities.data.Result;
import fr.ifremer.echobase.entities.references.AgeCategory;
import fr.ifremer.echobase.entities.references.SizeCategory;
import fr.ifremer.echobase.entities.references.SpeciesCategory;
+import fr.ifremer.echobase.io.InputFile;
import fr.ifremer.echobase.services.FakeEchoBaseServiceContext;
import org.junit.Test;
@@ -79,11 +77,11 @@
conf.setDataProcessingId(getDataProcessingId());
- List<CsvFileImportResult<EchoBaseEntityEnum>> result;
+ List<EchoBaseCsvFileImportResult> result;
result = doImport(conf, ResultsEsduCellImportService.class, 1);
- assertCsvImportResult(result, 0, Result.class, 43533);
- assertCsvImportResult(result, 0, Category.class, 7);
+ assertCsvImportResult(result, 0, Result.class, 43533,43533);
+ assertCsvImportResult(result, 0, Category.class, 7,0);
}
@Test
@@ -111,12 +109,12 @@
conf.setDataProcessingId(getDataProcessingId());
- List<CsvFileImportResult<EchoBaseEntityEnum>> result;
+ List<EchoBaseCsvFileImportResult> result;
result = doImport(conf, ResultsEsduCellImportService.class, 1);
- assertCsvImportResult(result, 0, Result.class, 357291);
- assertCsvImportResult(result, 0, Category.class, 27);
- assertCsvImportResult(result, 0, SpeciesCategory.class, 1, 0, 457);
+ assertCsvImportResult(result, 0, Result.class, 357291,357291);
+ assertCsvImportResult(result, 0, Category.class, 27,0);
+ assertCsvImportResult(result, 0, SpeciesCategory.class, 1, 0, 457,0);
}
@Test
@@ -144,13 +142,13 @@
conf.setDataProcessingId(getDataProcessingId());
- List<CsvFileImportResult<EchoBaseEntityEnum>> result;
+ List<EchoBaseCsvFileImportResult> result;
result = doImport(conf, ResultsEsduCellImportService.class, 1);
- assertCsvImportResult(result, 0, Result.class, 68108);
- assertCsvImportResult(result, 0, Category.class, 129);
- assertCsvImportResult(result, 0, SpeciesCategory.class, 129, 0, 585);
- assertCsvImportResult(result, 0, SizeCategory.class, 62, 0, 69);
+ assertCsvImportResult(result, 0, Result.class, 68108,68108);
+ assertCsvImportResult(result, 0, Category.class, 129,0);
+ assertCsvImportResult(result, 0, SpeciesCategory.class, 129, 0, 585,0);
+ assertCsvImportResult(result, 0, SizeCategory.class, 62, 0, 69,0);
}
@Test
@@ -178,13 +176,13 @@
conf.setDataProcessingId(getDataProcessingId());
- List<CsvFileImportResult<EchoBaseEntityEnum>> result;
+ List<EchoBaseCsvFileImportResult> result;
result = doImport(conf, ResultsEsduCellImportService.class, 1);
- assertCsvImportResult(result, 0, Category.class, 14);
- assertCsvImportResult(result, 0, Result.class, 10021);
- assertCsvImportResult(result, 0, AgeCategory.class, 6, 0, 10);
- assertCsvImportResult(result, 0, SpeciesCategory.class, 14, 0, 470);
+ assertCsvImportResult(result, 0, Category.class, 14,0);
+ assertCsvImportResult(result, 0, Result.class, 10021,10021);
+ assertCsvImportResult(result, 0, AgeCategory.class, 6, 0, 10,0);
+ assertCsvImportResult(result, 0, SpeciesCategory.class, 14, 0, 470,0);
}
}
\ No newline at end of file
Modified: trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/ResultsMapCellImportServiceIT.java
===================================================================
--- trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/ResultsMapCellImportServiceIT.java 2012-09-07 10:19:04 UTC (rev 632)
+++ trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/ResultsMapCellImportServiceIT.java 2012-09-07 10:57:12 UTC (rev 633)
@@ -23,9 +23,7 @@
*/
package fr.ifremer.echobase.services.importdata;
-import fr.ifremer.echobase.entities.EchoBaseEntityEnum;
import fr.ifremer.echobase.entities.ImportType;
-import org.nuiton.topia.persistence.csv.in.CsvFileImportResult;
import fr.ifremer.echobase.entities.data.Category;
import fr.ifremer.echobase.entities.data.Cell;
import fr.ifremer.echobase.entities.data.Data;
@@ -71,13 +69,13 @@
prepareInputFile(conf.getMapsFile(), getImportPath("maps.csv.gz"));
- List<CsvFileImportResult<EchoBaseEntityEnum>> result;
+ List<EchoBaseCsvFileImportResult> result;
result = doImport(conf, ResultsMapCellImportService.class, 1);
- assertCsvImportResult(result, 0, Cell.class, 380);
- assertCsvImportResult(result, 0, Data.class, 2280);
- assertCsvImportResult(result, 0, Result.class, 380);
- assertCsvImportResult(result, 0, Category.class, 1);
+ assertCsvImportResult(result, 0, Cell.class, 380, 380);
+ assertCsvImportResult(result, 0, Data.class, 2280, 0);
+ assertCsvImportResult(result, 0, Result.class, 380, 0);
+ assertCsvImportResult(result, 0, Category.class, 1, 0);
}
}
\ No newline at end of file
Modified: trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/ResultsRegionCellImportServiceIT.java
===================================================================
--- trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/ResultsRegionCellImportServiceIT.java 2012-09-07 10:19:04 UTC (rev 632)
+++ trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/ResultsRegionCellImportServiceIT.java 2012-09-07 10:57:12 UTC (rev 633)
@@ -23,9 +23,7 @@
*/
package fr.ifremer.echobase.services.importdata;
-import fr.ifremer.echobase.entities.EchoBaseEntityEnum;
import fr.ifremer.echobase.entities.ImportType;
-import org.nuiton.topia.persistence.csv.in.CsvFileImportResult;
import fr.ifremer.echobase.entities.data.Category;
import fr.ifremer.echobase.entities.data.Cell;
import fr.ifremer.echobase.entities.data.Data;
@@ -81,15 +79,15 @@
conf.getVoyageId(),
conf.getRegionAssociationFile());
- List<CsvFileImportResult<EchoBaseEntityEnum>> result;
+ List<EchoBaseCsvFileImportResult> result;
result = doImport(conf, ResultsRegionCellImportService.class, 3);
- assertCsvImportResult(result, 0, Cell.class, 10, 0, 2083);
- assertCsvImportResult(result, 0, Data.class, 238);
- assertCsvImportResult(result, 1, Cell.class, 0, 4146, 2083);
- assertCsvImportResult(result, 2, Result.class, 2128);
- assertCsvImportResult(result, 2, Category.class, 27);
- assertCsvImportResult(result, 2, SpeciesCategory.class, 1, 0, 457);
+ assertCsvImportResult(result, 0, Cell.class, 10, 0, 2083,10);
+ assertCsvImportResult(result, 0, Data.class, 238,0);
+ assertCsvImportResult(result, 1, Cell.class, 0, 4146, 2083,0);
+ assertCsvImportResult(result, 2, Result.class, 2128,0);
+ assertCsvImportResult(result, 2, Category.class, 27,0);
+ assertCsvImportResult(result, 2, SpeciesCategory.class, 1, 0, 457,0);
}
}
\ No newline at end of file
Modified: trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/ResultsVoyageImportServiceIT.java
===================================================================
--- trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/ResultsVoyageImportServiceIT.java 2012-09-07 10:19:04 UTC (rev 632)
+++ trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/importdata/ResultsVoyageImportServiceIT.java 2012-09-07 10:57:12 UTC (rev 633)
@@ -23,9 +23,7 @@
*/
package fr.ifremer.echobase.services.importdata;
-import fr.ifremer.echobase.entities.EchoBaseEntityEnum;
import fr.ifremer.echobase.entities.ImportType;
-import org.nuiton.topia.persistence.csv.in.CsvFileImportResult;
import fr.ifremer.echobase.entities.data.Echotype;
import fr.ifremer.echobase.entities.data.LengthAgeKey;
import fr.ifremer.echobase.entities.data.LengthWeightKey;
@@ -74,12 +72,12 @@
getImportPath("lengthWeightKey.csv.gz"));
prepareInputFile(conf.getEchotypeFile(), getImportPath("echotype.csv.gz"));
- List<CsvFileImportResult<EchoBaseEntityEnum>> result;
+ List<EchoBaseCsvFileImportResult> result;
result = doImport(conf, ResultsVoyageImportService.class, 3);
- assertCsvImportResult(result, 0, LengthAgeKey.class, NB_LENGTH_AGE_KEY);
- assertCsvImportResult(result, 1, LengthWeightKey.class, NB_LENGTH_WEIGHT_KEY);
- assertCsvImportResult(result, 2, Echotype.class, NB_ECHOTYPE);
+ assertCsvImportResult(result, 0, LengthAgeKey.class, NB_LENGTH_AGE_KEY, NB_LENGTH_AGE_KEY);
+ assertCsvImportResult(result, 1, LengthWeightKey.class, NB_LENGTH_WEIGHT_KEY, NB_LENGTH_WEIGHT_KEY);
+ assertCsvImportResult(result, 2, Echotype.class, NB_ECHOTYPE, NB_ECHOTYPE);
}
@Ignore
@@ -101,10 +99,10 @@
prepareInputFile(conf.getLengthAgeKeyFile(),
getImportPath("lengthAgeKey.csv.gz"));
- List<CsvFileImportResult<EchoBaseEntityEnum>> result;
+ List<EchoBaseCsvFileImportResult> result;
result = doImport(conf, ResultsVoyageImportService.class, 1);
- assertCsvImportResult(result, 0, LengthAgeKey.class, NB_LENGTH_AGE_KEY);
+ assertCsvImportResult(result, 0, LengthAgeKey.class, NB_LENGTH_AGE_KEY, NB_LENGTH_AGE_KEY);
}
@Ignore
@@ -126,10 +124,10 @@
prepareInputFile(conf.getLengthWeightKeyFile(),
getImportPath("lengthWeightKey.csv.gz"));
- List<CsvFileImportResult<EchoBaseEntityEnum>> result;
+ List<EchoBaseCsvFileImportResult> result;
result = doImport(conf, ResultsVoyageImportService.class, 1);
- assertCsvImportResult(result, 0, LengthWeightKey.class, NB_LENGTH_WEIGHT_KEY);
+ assertCsvImportResult(result, 0, LengthWeightKey.class, NB_LENGTH_WEIGHT_KEY, NB_LENGTH_WEIGHT_KEY);
}
@Ignore
@@ -150,10 +148,10 @@
prepareInputFile(conf.getEchotypeFile(), getImportPath("echotype.csv.gz"));
- List<CsvFileImportResult<EchoBaseEntityEnum>> result;
+ List<EchoBaseCsvFileImportResult> result;
result = doImport(conf, ResultsVoyageImportService.class, 1);
- assertCsvImportResult(result, 0, Echotype.class, NB_ECHOTYPE);
+ assertCsvImportResult(result, 0, Echotype.class, NB_ECHOTYPE, NB_ECHOTYPE);
}
}
\ No newline at end of file
1
0
Author: mdoray
Date: 2012-09-07 12:19:04 +0200 (Fri, 07 Sep 2012)
New Revision: 632
Url: http://forge.codelutin.com/repositories/revision/echobase/632
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-07 10:17:43 UTC (rev 631)
+++ trunk/src/site/rst/index.rst 2012-09-07 10:19:04 UTC (rev 632)
@@ -55,6 +55,8 @@
- Comment créer une `application embarquée`_.
+.. _Ifremer forge: https://forge.ifremer.fr/www/echor
+.. _ICES WGFAST: http://www.acoustics.washington.edu/FAST
.. _installation: ./install.html
.. _modèle: ./model.html
.. _imports: ./imports.html
1
0
Author: mdoray
Date: 2012-09-07 12:17:43 +0200 (Fri, 07 Sep 2012)
New Revision: 631
Url: http://forge.codelutin.com/repositories/revision/echobase/631
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-06 15:23:26 UTC (rev 630)
+++ trunk/src/site/rst/index.rst 2012-09-07 10:17:43 UTC (rev 631)
@@ -29,8 +29,20 @@
Présentation
------------
-A Faire...
+L'Institut Français pour l'Exploration de la Mer (Ifremer) fournit une suite de logiciels libres pour stocker des données
+acoustiques halieutiques et calculer des indicateurs sur la base de données de campagnes. L'objectif est de contribuer à la
+mise en place de systèmes de surveillance des écosystèmes marins alimentés par les données de campagnes scientifiques à la mer.
+La suite logicielle comprend une base de données postgreSQL dédiée au stockage des données acoustiques, de navigation et de pêche issues
+de campagnes écosystémiques (Echobase) et de codes R (EchoR) permettant de calculer des indicateurs de l'état de populations de poissons
+pélagiques basés sur les données stockées dans Echobase.
+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
r630 - in trunk: echobase-domain/src/main/java/fr/ifremer/echobase/entities echobase-domain/src/main/java/fr/ifremer/echobase/persistence/migration/workingDb echobase-ui/src/main
by tchemit@users.forge.codelutin.com 06 Sep '12
by tchemit@users.forge.codelutin.com 06 Sep '12
06 Sep '12
Author: tchemit
Date: 2012-09-06 17:23:26 +0200 (Thu, 06 Sep 2012)
New Revision: 630
Url: http://forge.codelutin.com/repositories/revision/echobase/630
Log:
add svn properties + license header
Modified:
trunk/echobase-domain/src/main/java/fr/ifremer/echobase/entities/ImportType.java
trunk/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/migration/workingDb/MigrationCallbackV0_9.java
trunk/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/migration/workingDb/MigrationCallbackV1_2.java
trunk/echobase-ui/src/main/validationRules.txt
Modified: trunk/echobase-domain/src/main/java/fr/ifremer/echobase/entities/ImportType.java
===================================================================
--- trunk/echobase-domain/src/main/java/fr/ifremer/echobase/entities/ImportType.java 2012-09-06 15:21:36 UTC (rev 629)
+++ trunk/echobase-domain/src/main/java/fr/ifremer/echobase/entities/ImportType.java 2012-09-06 15:23:26 UTC (rev 630)
@@ -1,5 +1,28 @@
package fr.ifremer.echobase.entities;
+/*
+ * #%L
+ * EchoBase :: Domain
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 - 2012 Ifremer, Codelutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+
import fr.ifremer.echobase.I18nAble;
import static org.nuiton.i18n.I18n.n_;
Property changes on: trunk/echobase-domain/src/main/java/fr/ifremer/echobase/entities/ImportType.java
___________________________________________________________________
Modified: svn:keywords
- Author Date Id Revision
+ Author Date Id Revision HeadURL
Modified: trunk/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/migration/workingDb/MigrationCallbackV0_9.java
===================================================================
--- trunk/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/migration/workingDb/MigrationCallbackV0_9.java 2012-09-06 15:21:36 UTC (rev 629)
+++ trunk/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/migration/workingDb/MigrationCallbackV0_9.java 2012-09-06 15:23:26 UTC (rev 630)
@@ -1,5 +1,28 @@
package fr.ifremer.echobase.persistence.migration.workingDb;
+/*
+ * #%L
+ * EchoBase :: Domain
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 - 2012 Ifremer, Codelutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+
import org.hibernate.dialect.Dialect;
import org.hibernate.dialect.H2Dialect;
import org.hibernate.dialect.PostgreSQLDialect;
Property changes on: trunk/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/migration/workingDb/MigrationCallbackV0_9.java
___________________________________________________________________
Modified: svn:keywords
- Author Date Id Revision
+ Author Date Id Revision HeadURL
Modified: trunk/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/migration/workingDb/MigrationCallbackV1_2.java
===================================================================
--- trunk/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/migration/workingDb/MigrationCallbackV1_2.java 2012-09-06 15:21:36 UTC (rev 629)
+++ trunk/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/migration/workingDb/MigrationCallbackV1_2.java 2012-09-06 15:23:26 UTC (rev 630)
@@ -1,5 +1,28 @@
package fr.ifremer.echobase.persistence.migration.workingDb;
+/*
+ * #%L
+ * EchoBase :: Domain
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 - 2012 Ifremer, Codelutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+
import org.hibernate.dialect.Dialect;
import org.hibernate.dialect.H2Dialect;
import org.hibernate.dialect.PostgreSQLDialect;
Property changes on: trunk/echobase-domain/src/main/java/fr/ifremer/echobase/persistence/migration/workingDb/MigrationCallbackV1_2.java
___________________________________________________________________
Modified: svn:keywords
- Author Date Id Revision
+ Author Date Id Revision HeadURL
Property changes on: trunk/echobase-ui/src/main/validationRules.txt
___________________________________________________________________
Modified: svn:keywords
- Author Date Id Revision
+ Author Date Id Revision HeadURL
1
0