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@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@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@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@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@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@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@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@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@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@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@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@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@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@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@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@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@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@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@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@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@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@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@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@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