Author: tchemit Date: 2011-12-11 22:39:42 +0100 (Sun, 11 Dec 2011) New Revision: 167 Url: http://forge.codelutin.com/repositories/revision/echobase/167 Log: -remove legacy import code -improve db import -add some little improvments Added: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ImportDbConfiguration.java Removed: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ImportHistoricalConfiguration.java trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ImportHistoricalService.java trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/models/ImportExportModelSupport.java Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/DbImportExportService.java trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EchoBaseServiceSupport.java trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/models/CsvModelUtil.java trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/models/EntityAssociationCsvModel.java trunk/echobase-services/src/main/resources/i18n/echobase-services_fr_FR.properties Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/DbImportExportService.java =================================================================== --- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/DbImportExportService.java 2011-12-11 21:37:31 UTC (rev 166) +++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/DbImportExportService.java 2011-12-11 21:39:42 UTC (rev 167) @@ -33,6 +33,7 @@ import fr.ifremer.echobase.entities.meta.AssociationMeta; import fr.ifremer.echobase.entities.meta.MetaFilenameAware; import fr.ifremer.echobase.entities.meta.TableMeta; +import fr.ifremer.echobase.services.models.CsvModelUtil; import fr.ifremer.echobase.services.models.EntityAssociationCsvModel; import org.apache.commons.io.FileUtils; import org.apache.commons.logging.Log; @@ -48,7 +49,6 @@ import java.io.IOException; import java.io.InputStreamReader; import java.io.Reader; -import java.util.Collection; import java.util.List; import java.util.Map; import java.util.zip.ZipEntry; @@ -71,12 +71,14 @@ /** * Import a complete db from the given zip file. * - * @param file zip file where all csv files are located - * @param user user which perform the import + * @param model model of the db import operation + * @param user user which perform the import * @throws IOException if any io exception while import */ - public void importDb(File file, EchoBaseUser user) throws IOException { + public void importDb(ImportDbConfiguration model, EchoBaseUser user) throws IOException { + File file = model.getInput().getFile(); + ZipFile zipFile = new ZipFile(file); try { MetaFilenameAware[] entries = getEntries(); @@ -89,7 +91,7 @@ // check that all mandatories for (MetaFilenameAware entry : entries) { String filename = entry.getFilename(); - ZipEntry zipEntry = zipFile.getEntry(filename); + ZipEntry zipEntry = zipFile.getEntry("echobase/" + filename); if (zipEntry == null) { missingEntries.add(filename); @@ -110,10 +112,15 @@ // missingEntries + " in import " + file); } + int size = entriestoConsume.size(); + model.setNbSteps(size + 1); + // consume all found entries for (Map.Entry<MetaFilenameAware, ZipEntry> entry : entriestoConsume.entrySet()) { + model.incrementsProgression(); + MetaFilenameAware entryDef = entry.getKey(); ZipEntry value = entry.getValue(); CsvImportResult csvResult = CsvImportResult.newResult( @@ -134,7 +141,7 @@ if (log.isInfoEnabled()) { log.info("Import done with user " + user.getEmail()); } - commitTransaction("Could not commit db import " + file); + commitTransaction("Could not commit db import from file " + file); } finally { zipFile.close(); } @@ -154,11 +161,12 @@ File zipFile = new File(tempDirectory, fileName + ".zip"); DbEditorService service = getDbEditorService(); + File dir = new File(tempDirectory, "echobase"); MetaFilenameAware[] entries = getEntries(); for (MetaFilenameAware entry : entries) { - File entryFile = new File(tempDirectory, entry.getFilename()); + File entryFile = new File(dir, entry.getFilename()); if (entry instanceof AssociationMeta) { AssociationMeta associationMeta = (AssociationMeta) entry; @@ -169,7 +177,7 @@ } } - EchoBaseIOUtil.compressZipFile(zipFile, tempDirectory); + EchoBaseIOUtil.compressZipFile(zipFile, dir); return zipFile; } @@ -186,10 +194,26 @@ AssociationMeta associationMeta = (AssociationMeta) entry; + EchoBaseEntityEnum source = associationMeta.getSource(); + List<TopiaEntity> sourceEntities = getEntities(source); + Map<String, TopiaEntity> sourcesById; + Map<String, TopiaEntity> targetsById; + sourcesById = Maps.uniqueIndex(sourceEntities, CsvModelUtil.TO_TOPIAID); + EchoBaseEntityEnum target = associationMeta.getTarget(); + if (source.equals(target)) { + targetsById = sourcesById; + } else { + + List<TopiaEntity> targetEntities = getEntities(target); + targetsById = Maps.uniqueIndex(targetEntities, CsvModelUtil.TO_TOPIAID); + } + ImportExportModel<TopiaEntity> model = EntityAssociationCsvModel.newModel( getConfiguration().getCsvSeparator(), - associationMeta + associationMeta, + sourcesById, + targetsById ); importEntityAssociation(associationMeta, model, csvResult, reader); @@ -200,7 +224,8 @@ TableMeta tableMeta = (TableMeta) entry; - ImportExportModel<TopiaEntity> model = service.buildForImport(tableMeta); + ImportExportModel<TopiaEntity> model = + service.buildForImport(tableMeta); importEntities(tableMeta, model, csvResult, reader); } @@ -208,27 +233,31 @@ public MetaFilenameAware[] getEntries() { - List<MetaFilenameAware> result = Lists.newArrayList(); + List<MetaFilenameAware> entities = Lists.newArrayList(); + List<MetaFilenameAware> associations = Lists.newArrayList(); - addEntries(result, EntitiesUtil.getReferenceTypesForCopy()); - addEntries(result, EntitiesUtil.getDataTypesforCopy()); - return result.toArray(new MetaFilenameAware[result.size()]); + addEntries(entities, associations, EntitiesUtil.getReferenceTypesForCopy()); + addEntries(entities, associations, EntitiesUtil.getDataTypesforCopy()); + entities.addAll(associations); + return entities.toArray(new MetaFilenameAware[entities.size()]); } protected TableMeta getTableMeta(EchoBaseEntityEnum tableName) { return getDbEditorService().getTableMeta(tableName); } - protected void addEntries(List<MetaFilenameAware> result, + protected void addEntries(List<MetaFilenameAware> entities, + List<MetaFilenameAware> associations, EchoBaseEntityEnum[] types) { for (EchoBaseEntityEnum type : types) { TableMeta tableMeta = getTableMeta(type); - result.add(tableMeta); + entities.add(tableMeta); - for (AssociationMeta associationMeta : tableMeta.getAssociations()) { - result.add(associationMeta); - } +// for (AssociationMeta associationMeta : tableMeta.getAssociations()) { +// associations.add(associationMeta); +// } + associations.addAll(tableMeta.getAssociations()); } } @@ -244,9 +273,11 @@ CsvImportResult result, Reader reader) { + if (log.isInfoEnabled()) { + log.info("Will import " + meta); + } Import<TopiaEntity> importer = Import.newImport(csvModel, reader); - try { TopiaDAO<TopiaEntity> dao = getDAO(meta.getSource()); @@ -272,7 +303,9 @@ ImportExportModel<E> csvModel, CsvImportResult result, Reader reader) { - + if (log.isInfoEnabled()) { + log.info("Will import " + meta); + } try { EchoBaseEntityEnum sourceType = meta.getSource(); @@ -285,25 +318,26 @@ try { for (E row : importer) { - E entityToSave = sourceDAO.findByTopiaId(row.getTopiaId()); - - // check entity exits ? - if (entityToSave == null) { - throw new EchoBaseTechnicalException( - "Could not find entity with id " + row.getTopiaId()); - } - Collection<TopiaEntity> assoc = meta.getChilds(row); - Collection<TopiaEntity> associationToSave = Lists.newArrayList(); - for (TopiaEntity topiaEntity : assoc) { - TopiaEntity byTopiaId = targetDAO.findByTopiaId(topiaEntity.getTopiaId()); - if (byTopiaId == null) { - throw new EchoBaseTechnicalException( - "Could not find entity with id " + topiaEntity.getTopiaId()); - } - associationToSave.add(byTopiaId); - result.incrementsNumberUpdated(); - } - meta.setChilds(entityToSave, associationToSave); + sourceDAO.update(row); +// E entityToSave = sourceDAO.findByTopiaId(row.getTopiaId()); +// +// // check entity exits ? +// if (entityToSave == null) { +// throw new EchoBaseTechnicalException( +// "Could not find entity with id " + row.getTopiaId()); +// } +// Collection<TopiaEntity> assoc = meta.getChilds(row); +// Collection<TopiaEntity> associationToSave = Lists.newArrayList(); +// for (TopiaEntity topiaEntity : assoc) { +// TopiaEntity byTopiaId = targetDAO.findByTopiaId(topiaEntity.getTopiaId()); +// if (byTopiaId == null) { +// throw new EchoBaseTechnicalException( +// "Could not find entity with id " + topiaEntity.getTopiaId()); +// } +// associationToSave.add(byTopiaId); +// result.incrementsNumberUpdated(); +// } +// meta.setChilds(entityToSave, associationToSave); } } finally { @@ -315,5 +349,4 @@ throw new EchoBaseTechnicalException(eee); } } - } Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EchoBaseServiceSupport.java =================================================================== --- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EchoBaseServiceSupport.java 2011-12-11 21:37:31 UTC (rev 166) +++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EchoBaseServiceSupport.java 2011-12-11 21:39:42 UTC (rev 167) @@ -53,6 +53,10 @@ this.serviceContext = serviceContext; } + public <E extends TopiaEntity> List<E> getEntities(EchoBaseEntityEnum entityType) { + Class<E> contract = (Class<E>) entityType.getContract(); + return getEntities(contract); + } public <E extends TopiaEntity> List<E> getEntities(Class<E> entityType) { Preconditions.checkNotNull(entityType); try { Added: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ImportDbConfiguration.java =================================================================== --- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ImportDbConfiguration.java (rev 0) +++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ImportDbConfiguration.java 2011-12-11 21:39:42 UTC (rev 167) @@ -0,0 +1,101 @@ +/* + * #%L + * EchoBase :: Services + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2011 Ifremer, Codelutin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ +package fr.ifremer.echobase.services; + +import fr.ifremer.echobase.InputFile; +import org.apache.commons.io.FileUtils; + +import java.io.File; +import java.io.IOException; +import java.io.Serializable; +import java.util.Locale; + +import static org.nuiton.i18n.I18n.l_; + +/** + * Configuration of a import db operation. + * + * @author tchemit <chemit@codelutin.com> + * @since 0.2 + */ +public class ImportDbConfiguration implements Serializable { + + private static final long serialVersionUID = 1L; + + protected File workingDirectory; + + protected InputFile input; + + protected int nbSteps; + + private float stepIncrement; + + protected float progression; + + public ImportDbConfiguration(Locale locale) { + input = InputFile.newFile( + l_(locale, "echobase.common.importDbFile")); + } + + public File getWorkingDirectory() { + return workingDirectory; + } + + public InputFile getInput() { + return input; + } + + public int getNbSteps() { + return nbSteps; + } + + public float getProgression() { + return progression; + } + + public void setWorkingDirectory(File workingDirectory) { + this.workingDirectory = workingDirectory; + } + + public void setProgression(float progression) { + this.progression = progression; + } + + public void incrementsProgression() { + setProgression(progression + stepIncrement); + } + + public void setNbSteps(int nbSteps) { + + this.nbSteps = nbSteps; + stepIncrement = 100f / nbSteps; + } + + public void destroy() throws IOException { + if (workingDirectory != null) { + FileUtils.deleteDirectory(workingDirectory); + } + } + +} Property changes on: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ImportDbConfiguration.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/ImportHistoricalConfiguration.java =================================================================== --- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ImportHistoricalConfiguration.java 2011-12-11 21:37:31 UTC (rev 166) +++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ImportHistoricalConfiguration.java 2011-12-11 21:39:42 UTC (rev 167) @@ -1,102 +0,0 @@ -/* - * #%L - * EchoBase :: Services - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2011 Ifremer, Codelutin - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * #L% - */ -package fr.ifremer.echobase.services; - -import fr.ifremer.echobase.InputFile; -import org.apache.commons.io.FileUtils; - -import java.io.File; -import java.io.IOException; -import java.io.Serializable; -import java.util.Locale; - -import static org.nuiton.i18n.I18n.l_; - -/** - * Configuration of an historical import. - * - * @author tchemit <chemit@codelutin.com> - * @since 0.2 - */ -public class ImportHistoricalConfiguration implements Serializable { - - private static final long serialVersionUID = 1L; - - protected File workingDirectory; - - - protected InputFile input; - - protected int nbSteps; - - private float stepIncrement; - - protected float progression; - - public ImportHistoricalConfiguration(Locale locale) { - input = InputFile.newFile( - l_(locale, "echobase.common.importHistoricalFile")); - } - - public File getWorkingDirectory() { - return workingDirectory; - } - - public InputFile getInput() { - return input; - } - - public int getNbSteps() { - return nbSteps; - } - - public float getProgression() { - return progression; - } - - public void setWorkingDirectory(File workingDirectory) { - this.workingDirectory = workingDirectory; - } - - public void setProgression(float progression) { - this.progression = progression; - } - - public void incrementsProgression() { - setProgression(progression + stepIncrement); - } - - public void computeSteps() { - nbSteps = 0; - - stepIncrement = 100f / nbSteps; - } - - public void destroy() throws IOException { - if (workingDirectory != null) { - FileUtils.deleteDirectory(workingDirectory); - } - } - -} \ No newline at end of file Deleted: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ImportHistoricalService.java =================================================================== --- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ImportHistoricalService.java 2011-12-11 21:37:31 UTC (rev 166) +++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ImportHistoricalService.java 2011-12-11 21:39:42 UTC (rev 167) @@ -1,94 +0,0 @@ -/* - * #%L - * EchoBase :: Services - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2011 Ifremer, Codelutin - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * #L% - */ -package fr.ifremer.echobase.services; - -import fr.ifremer.echobase.EchoBaseTechnicalException; -import fr.ifremer.echobase.InputFile; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import java.io.File; - -/** - * To import historical datas (from access database). - * - * @author tchemit <chemit@codelutin.com> - * @since 0.2 - */ -public class ImportHistoricalService extends EchoBaseServiceSupport { - - /** Logger. */ - private static final Log log = - LogFactory.getLog(ImportHistoricalService.class); - - public CsvImportResult startImport(ImportHistoricalConfiguration configuration) { - - CsvImportResult result; - - InputFile input = configuration.getInput(); - - if (log.isInfoEnabled()) { - log.info("Starts historical import with file " + - input.getFileName()); - } - - try { - - result = doImport(input); - - } finally { - deleteFile(input); - } - return result; - } - - protected CsvImportResult doImport(InputFile input) { - - CsvImportResult result = CsvImportResult.newResult(null, input.getFileName(), false); - prepareImport(); - return result; - } - - protected void deleteFile(InputFile input) { - File file = input.getFile(); - - if (log.isInfoEnabled()) { - log.info("Will delete import file " + file); - } - boolean wasDel = file.delete(); - if (!wasDel) { - throw new EchoBaseTechnicalException("Could not delete file " + file); - } - } - - - protected void prepareImport() { - try { - Thread.sleep(2000); - } catch (InterruptedException e) { - // ignore - } - } - -} Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/models/CsvModelUtil.java =================================================================== --- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/models/CsvModelUtil.java 2011-12-11 21:37:31 UTC (rev 166) +++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/models/CsvModelUtil.java 2011-12-11 21:39:42 UTC (rev 167) @@ -50,21 +50,30 @@ */ public class CsvModelUtil extends Common { + public static final Function<TopiaEntity, String> TO_TOPIAID = new Function<TopiaEntity, String>() { + + @Override + public String apply(TopiaEntity input) { + return input.getTopiaId().toLowerCase(); + } + }; + public static <E extends TopiaEntity> ForeignKeyValue<E> newForeignKeyValue(Class<E> type) { return new ForeignKeyValue<E>(type); } public static <E extends TopiaEntity> ForeignKeyValue<E> newForeignKeyValue(Class<E> type, Collection<E> entitites) { - return new ForeignKeyValue<E>(type, entitites, new Function<E, String>() { - @Override - public String apply(E input) { - return input.getTopiaId().toLowerCase(); - } - }); + Map<String, E> universe = Maps.uniqueIndex(entitites, TO_TOPIAID); + return newForeignKeyValue(type, universe); } + public static <E extends TopiaEntity> ForeignKeyValue<E> newForeignKeyValue(Class<E> type, Map<String, E> universe) { + return new ForeignKeyValue<E>(type, universe); + } + public static <E extends TopiaEntity> ForeignKeyValue<E> newForeignKeyValue(Class<E> type, Collection<E> entitites, Function<E, String> transform) { - return new ForeignKeyValue<E>(type, entitites, transform); + Map<String, E> universe = Maps.uniqueIndex(entitites, transform); + return new ForeignKeyValue<E>(type, universe); } public static <E extends TopiaEntity> ForeignKeyDecoratedValue<E> newForeignKeyDecoratedValue(Class<E> entityType, @@ -72,16 +81,22 @@ return new ForeignKeyDecoratedValue<E>(entityType, decoratorService, locale); } - public static <E extends TopiaEntity> AssociationValueParserFormatter<E> newAssociationValueParserFormatter(Class<E> type) { - return new AssociationValueParserFormatter<E>(type); + public static <E extends TopiaEntity> AssociationValueParserFormatter<E> newAssociationValueParserFormatter(Class<E> entityType, + Map<String, E> universe) { + return new AssociationValueParserFormatter<E>(entityType, universe); } public static class AssociationValueParserFormatter<E extends TopiaEntity> implements ValueParserFormatter<Collection<E>> { protected final Class<E> entityType; - public AssociationValueParserFormatter(Class<E> entityType) { + protected final Map<String, E> universe; + + public AssociationValueParserFormatter( + Class<E> entityType, + Map<String, E> universe) { this.entityType = entityType; + this.universe = universe; } @Override @@ -92,6 +107,7 @@ String[] ids = value.split("\\|"); for (String id : ids) { E association = ObjectUtil.newInstance(entityType); +// E association = universe.get(id); association.setTopiaId(id); result.add(association); } @@ -120,10 +136,9 @@ protected final Map<String, E> universe; public ForeignKeyValue(Class<E> entityType, - Collection<E> entitites, - Function<E, String> transform) { + Map<String, E> universe) { this.entityType = entityType; - universe = Maps.uniqueIndex(entitites, transform); + this.universe = universe; } public ForeignKeyValue(Class<E> entityType) { Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/models/EntityAssociationCsvModel.java =================================================================== --- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/models/EntityAssociationCsvModel.java 2011-12-11 21:37:31 UTC (rev 166) +++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/models/EntityAssociationCsvModel.java 2011-12-11 21:39:42 UTC (rev 167) @@ -32,6 +32,7 @@ import java.util.Collection; import java.util.List; +import java.util.Map; /** * A model to import / export associations of entities into csv files. @@ -48,8 +49,17 @@ protected ModelBuilder<E> modelBuilder; public static <E extends TopiaEntity> EntityAssociationCsvModel<E> newModel(char separator, - AssociationMeta meta) { - return new EntityAssociationCsvModel<E>(separator, meta); + AssociationMeta meta, + Map<String, E> sourcesById, + Map<String, TopiaEntity> targetsById + ) { + EntityAssociationCsvModel<E> model = new EntityAssociationCsvModel<E>( + separator, + meta, + sourcesById, + targetsById); + + return model; } @Override @@ -79,22 +89,32 @@ } protected EntityAssociationCsvModel(char separator, - AssociationMeta meta) { + AssociationMeta meta, + Map<String, E> sourcesById, + Map<String, TopiaEntity> targetsById) { this.separator = separator; this.meta = meta; modelBuilder = new ModelBuilder<E>(); + Class<E> source= + (Class<E>) meta.getSource().getContract(); + // topiaId <-> topiaId modelBuilder.newColumnForImportExport( TopiaEntity.TOPIA_ID, - TopiaEntity.TOPIA_ID + TopiaEntity.TOPIA_ID, + CsvModelUtil.newForeignKeyValue(source, sourcesById) ); // add association -> target + Class<TopiaEntity> target = + (Class<TopiaEntity>) meta.getTarget().getImplementation(); + modelBuilder.newColumnForImportExport( meta.getName(), meta.getName(), - CsvModelUtil.newAssociationValueParserFormatter(meta.getTarget().getImplementation()) + CsvModelUtil.newAssociationValueParserFormatter(target,targetsById) +// CsvModelUtil.newAssociationValueParserFormatter(meta.getTarget().getImplementation()) ); } Deleted: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/models/ImportExportModelSupport.java =================================================================== --- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/models/ImportExportModelSupport.java 2011-12-11 21:37:31 UTC (rev 166) +++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/models/ImportExportModelSupport.java 2011-12-11 21:39:42 UTC (rev 167) @@ -1,71 +0,0 @@ -/* - * #%L - * EchoBase :: Services - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2011 Ifremer, Codelutin - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * #L% - */ -package fr.ifremer.echobase.services.models; - -import org.nuiton.util.csv.ExportableColumn; -import org.nuiton.util.csv.ImportExportModel; -import org.nuiton.util.csv.ImportableColumn; -import org.nuiton.util.csv.ModelBuilder; - -import java.util.Collection; -import java.util.List; - -/** - * TODO - * - * @author tchemit <chemit@codelutin.com> - * @since TODO - */ -public abstract class ImportExportModelSupport<E> implements ImportExportModel<E> { - - protected char separator; - - protected ModelBuilder<E> modelBuilder; - - protected ImportExportModelSupport(char separator) { - this.separator = separator; - modelBuilder = new ModelBuilder<E>(); - } - - @Override - public char getSeparator() { - return separator; - } - - @Override - public void pushCsvHeaderNames(List<String> headerNames) { - } - - @Override - public Collection<ExportableColumn<E, Object>> getColumnsForExport() { - return (Collection) - modelBuilder.getColumnsForExport(); - } - - @Override - public Collection<ImportableColumn<E, Object>> getColumnsForImport() { - return (Collection) - modelBuilder.getColumnsForImport(); - } -} Modified: trunk/echobase-services/src/main/resources/i18n/echobase-services_fr_FR.properties =================================================================== --- trunk/echobase-services/src/main/resources/i18n/echobase-services_fr_FR.properties 2011-12-11 21:37:31 UTC (rev 166) +++ trunk/echobase-services/src/main/resources/i18n/echobase-services_fr_FR.properties 2011-12-11 21:39:42 UTC (rev 167) @@ -3,6 +3,6 @@ echobase.common.eventsImport=Import Evènements echobase.common.importDataMode.acoustic=Import Acoustic echobase.common.importDataMode.all=Import globale -echobase.common.importHistoricalFile=Fichier MS-ACCESS de données historiques +echobase.common.importDbFile=File d'import (zip) echobase.common.lectureAgeGenImport=Import Lecture Agen Gen echobase.common.typeEchoSpeciesImport=Import Type EchoSpecies