Author: tchemit Date: 2011-11-25 00:06:43 +0100 (Fri, 25 Nov 2011) New Revision: 116 Url: http://forge.codelutin.com/repositories/revision/echobase/116 Log: - cinematic for import data - use generic dao methods in services - add svn properties - add topia connection provider in configuration (there is still some problems in pg) Added: trunk/echobase-services/src/main/java/fr/ifremer/echobase/InputFile.java trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ImportDataConfiguration.java trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ImportDataService.java trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/importData/ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/importData/ConfigureFiles.java trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/importData/ConfigureVoyage.java trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/importData/ImportMode.java trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/importData/LaunchImport.java trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/importData/ trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/importData/ConfigureFiles-validation.xml trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/importData/ConfigureVoyage-validation.xml trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/import/configureFiles.jsp trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/import/configureVoyage.jsp Removed: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/ImportAction.java trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/ImportAction-doImport-validation.xml Modified: trunk/echobase-entities/src/main/java/fr/ifremer/echobase/EchoBaseConfiguration.java trunk/echobase-entities/src/main/java/fr/ifremer/echobase/EchoBaseConfigurationOption.java trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/EntitiesUtil.java trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/data/DataUtil.java trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/references/ReferencesUtil.java trunk/echobase-entities/src/main/resources/i18n/echobase-entities_fr_FR.properties trunk/echobase-entities/src/test/java/fr/ifremer/echobase/TestHelper.java trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/AbstractEchoBaseService.java trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/DbEditorService.java trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EmbeddedApplicationService.java trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ExportSqlService.java trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/UserService.java trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/VoyageService.java trunk/echobase-services/src/main/resources/embedded/startEchobase.bat trunk/echobase-services/src/main/resources/embedded/startEchobase.sh trunk/echobase-services/src/main/resources/i18n/echobase-services_fr_FR.properties trunk/echobase-services/src/test/java/fr/ifremer/echobase/entities/MockEntityVisitorCreator.java trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/AbstractEchoBaseServiceTest.java trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/EmbeddedApplicationServiceTest.java trunk/echobase-services/src/test/resources/echobase.properties trunk/echobase-ui/pom.xml trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/EchoBaseSession.java trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/export/CreateEmbeddedApplication.java trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/export/ManageExportQuery.java trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/user/ManageUser.java trunk/echobase-ui/src/main/resources/config/struts-import.xml trunk/echobase-ui/src/main/resources/echobase.properties trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/export/ManageExportQuery-saveExportQuery-validation.xml trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/user/LoginAction-login-validation.xml trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/user/ManageUser-validation.xml trunk/echobase-ui/src/main/resources/i18n/echobase-ui_fr_FR.properties trunk/echobase-ui/src/main/webapp/WEB-INF/includes/header.jsp trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/import/importProgress.jsp trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/import/importResult.jsp trunk/pom.xml trunk/src/doc/reunions/reunion-2011-11-15.txt Modified: trunk/echobase-entities/src/main/java/fr/ifremer/echobase/EchoBaseConfiguration.java =================================================================== --- trunk/echobase-entities/src/main/java/fr/ifremer/echobase/EchoBaseConfiguration.java 2011-11-24 14:18:03 UTC (rev 115) +++ trunk/echobase-entities/src/main/java/fr/ifremer/echobase/EchoBaseConfiguration.java 2011-11-24 23:06:43 UTC (rev 116) @@ -113,8 +113,8 @@ return file; } - public char getCsvCharSeparator() { - char csvSeparator = applicationConfig.getOption(char.class, EchoBaseConfigurationOption.CSV_CHAR_SEPARATOR.key); + public char getCsvSeparator() { + char csvSeparator = applicationConfig.getOption(char.class, EchoBaseConfigurationOption.CSV_SEPARATOR.key); Preconditions.checkNotNull(csvSeparator); return csvSeparator; } Modified: trunk/echobase-entities/src/main/java/fr/ifremer/echobase/EchoBaseConfigurationOption.java =================================================================== --- trunk/echobase-entities/src/main/java/fr/ifremer/echobase/EchoBaseConfigurationOption.java 2011-11-24 14:18:03 UTC (rev 115) +++ trunk/echobase-entities/src/main/java/fr/ifremer/echobase/EchoBaseConfigurationOption.java 2011-11-24 23:06:43 UTC (rev 116) @@ -50,7 +50,7 @@ SITE_URL("project.siteUrl", "URL du site de l'application", "", URL.class), - CSV_CHAR_SEPARATOR("csv.separator", + CSV_SEPARATOR("csv.separator", "Caractère de séparation pour les fichiers csv", ";", char.class), WAR_DIRECTORY("war.directory", Property changes on: trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/EntitiesUtil.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Property changes on: trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/data/DataUtil.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Property changes on: trunk/echobase-entities/src/main/java/fr/ifremer/echobase/entities/references/ReferencesUtil.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Modified: trunk/echobase-entities/src/main/resources/i18n/echobase-entities_fr_FR.properties =================================================================== --- trunk/echobase-entities/src/main/resources/i18n/echobase-entities_fr_FR.properties 2011-11-24 14:18:03 UTC (rev 115) +++ trunk/echobase-entities/src/main/resources/i18n/echobase-entities_fr_FR.properties 2011-11-24 23:06:43 UTC (rev 116) @@ -61,7 +61,7 @@ echobase.common.dataQualityFlagValue= echobase.common.dataValue= echobase.common.dateCreated= -echobase.common.datum= +echobase.common.datum=datum echobase.common.depthStratum=depthStratum echobase.common.depthStratumId= echobase.common.depthStratumMeaning= @@ -283,11 +283,11 @@ echobase.common.vesselTransit= echobase.common.vesselType= echobase.common.voyage=Campagne -echobase.common.voyageDescription= -echobase.common.voyageEndDate= -echobase.common.voyageEndHarbour= -echobase.common.voyageName= -echobase.common.voyageStartDate= -echobase.common.voyageStartHarbour= +echobase.common.voyageDescription=Description de campagne +echobase.common.voyageEndDate=Date de fin de campagne +echobase.common.voyageEndHarbour=Port de fin de campagne +echobase.common.voyageName=Nom de la campagne +echobase.common.voyageStartDate=Date de début de campagne +echobase.common.voyageStartHarbour=Port de début de campagne echobase.common.weight= echobase.config.data.directory.description=Chemin de l'application Property changes on: trunk/echobase-entities/src/test/java/fr/ifremer/echobase/TestHelper.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/echobase-services/src/main/java/fr/ifremer/echobase/InputFile.java =================================================================== --- trunk/echobase-services/src/main/java/fr/ifremer/echobase/InputFile.java (rev 0) +++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/InputFile.java 2011-11-24 23:06:43 UTC (rev 116) @@ -0,0 +1,86 @@ +/* + * #%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; + +import java.io.File; +import java.io.Serializable; + +/** + * Object to receive a uploaded file. + * + * @author tchemit <chemit@codelutin.com> + * @since 0.2 + */ +public class InputFile implements Serializable { + + private static final long serialVersionUID = 1L; + + /** Name of the file (from the client side). */ + protected String fileName; + + /** Location of the uploaded file (from the server side). */ + protected File file; + + /** Content type of the uploaded file. */ + protected String contentType; + + /** Label of the import. */ + protected String label; + + public InputFile(String label) { + this.label = label; + } + + public String getFileName() { + return fileName; + } + + public File getFile() { + return file; + } + + public String getLabel() { + return label; + } + + public String getContentType() { + return contentType; + } + + public void setFileName(String fileName) { + this.fileName = fileName; + } + + public void setFile(File file) { + this.file = file; + } + + public void setContentType(String contentType) { + this.contentType = contentType; + } + + public void setLabel(String label) { + this.label = label; + } +} Property changes on: trunk/echobase-services/src/main/java/fr/ifremer/echobase/InputFile.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/AbstractEchoBaseService.java =================================================================== --- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/AbstractEchoBaseService.java 2011-11-24 14:18:03 UTC (rev 115) +++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/AbstractEchoBaseService.java 2011-11-24 23:06:43 UTC (rev 116) @@ -23,11 +23,13 @@ */ package fr.ifremer.echobase.services; +import com.google.common.base.Preconditions; import fr.ifremer.echobase.EchoBaseConfiguration; import fr.ifremer.echobase.EchoBaseTechnicalException; import fr.ifremer.echobase.entities.EchoBaseDAOHelper; import fr.ifremer.echobase.entities.EchoBaseEntityEnum; import fr.ifremer.echobase.entities.meta.DbMeta; +import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.time.DateUtils; import org.nuiton.topia.TopiaContext; import org.nuiton.topia.TopiaException; @@ -35,6 +37,7 @@ import org.nuiton.topia.persistence.TopiaEntity; import java.util.Date; +import java.util.List; import java.util.Locale; /** @@ -50,6 +53,30 @@ this.serviceContext = serviceContext; } + public <E extends TopiaEntity> List<E> getEntities(Class<E> entityType) { + Preconditions.checkNotNull(entityType); + try { + List<E> result = getDAO(entityType).findAll(); + return result; + } catch (TopiaException eee) { + throw new EchoBaseTechnicalException( + "Could not obtain data for type " + entityType, eee); + } + } + + public <E extends TopiaEntity> E getEntityById(Class<E> entityType, String id) { + Preconditions.checkNotNull(entityType); + Preconditions.checkArgument(StringUtils.isNotEmpty(id)); + try { + E result = getDAO(entityType).findByTopiaId(id); + return result; + } catch (TopiaException eee) { + throw new EchoBaseTechnicalException( + "Could not obtain data of id [" + id + "] for type " + + entityType, eee); + } + } + protected TopiaContext getTransaction() { return serviceContext.getTransaction(); } @@ -94,7 +121,7 @@ protected Date newDate() { Date result = new Date(); - DateUtils.setMilliseconds(result,0); + DateUtils.setMilliseconds(result, 0); return result; } 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 2011-11-24 14:18:03 UTC (rev 115) +++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/DbEditorService.java 2011-11-24 23:06:43 UTC (rev 116) @@ -461,7 +461,7 @@ protected <E extends TopiaEntity> DbEditorCsvModel<E> buildForImport(TableMeta tableMetas) { - DbEditorCsvModel<E> model = new DbEditorCsvModel<E>(getConfiguration().getCsvCharSeparator(), + DbEditorCsvModel<E> model = new DbEditorCsvModel<E>(getConfiguration().getCsvSeparator(), tableMetas); ModelBuilder<E> modelBuilder = model.modelBuilder; @@ -488,7 +488,7 @@ protected <E extends TopiaEntity> DbEditorCsvModel<E> buildForSave(TableMeta tableMetas) { - DbEditorCsvModel<E> model = new DbEditorCsvModel<E>(getConfiguration().getCsvCharSeparator(), + DbEditorCsvModel<E> model = new DbEditorCsvModel<E>(getConfiguration().getCsvSeparator(), tableMetas); ModelBuilder<E> modelBuilder = model.modelBuilder; @@ -519,7 +519,7 @@ protected <E extends TopiaEntity> DbEditorCsvModel<E> buildForExport(TableMeta tableMetas) { - DbEditorCsvModel<E> model = new DbEditorCsvModel<E>(getConfiguration().getCsvCharSeparator(), + DbEditorCsvModel<E> model = new DbEditorCsvModel<E>(getConfiguration().getCsvSeparator(), tableMetas); ModelBuilder<E> modelBuilder = model.modelBuilder; @@ -546,7 +546,7 @@ protected <E extends TopiaEntity> DbEditorCsvModel<E> buildForLoad(TableMeta tableMetas, boolean addDecorated) { - DbEditorCsvModel<E> model = new DbEditorCsvModel<E>(getConfiguration().getCsvCharSeparator(), + DbEditorCsvModel<E> model = new DbEditorCsvModel<E>(getConfiguration().getCsvSeparator(), tableMetas); ModelBuilder<E> modelBuilder = model.modelBuilder; Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EmbeddedApplicationService.java =================================================================== --- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EmbeddedApplicationService.java 2011-11-24 14:18:03 UTC (rev 115) +++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/EmbeddedApplicationService.java 2011-11-24 23:06:43 UTC (rev 116) @@ -140,7 +140,7 @@ for (StartFiles startFile : StartFiles.values()) { InputStream inputStream = - getClass().getResourceAsStream(startFile.getFilePath()); + getClass().getResourceAsStream(startFile.getFilePath()); File startFileDest = new File(zipDirectory, startFile.getFileName()); OutputStream outputStream = new FileOutputStream(startFileDest); @@ -172,7 +172,7 @@ } protected TopiaContext createH2Batabase(File zipDirectory, - String... voyageIds) throws IOException, TopiaException { + String... voyageIds) throws IOException, TopiaException { return createH2Batabase(zipDirectory, true, voyageIds); } @@ -212,7 +212,7 @@ newService(ExportSqlService.class); // get all export queries from application - List<ExportQuery> queries = exportSqlService.getQueries(); + List<ExportQuery> queries = exportSqlService.getEntities(ExportQuery.class); // remove link to application user for (ExportQuery query : queries) { @@ -227,7 +227,7 @@ newServiceContext.newService(ExportSqlService.class); // get all queries from h2 db - queries = exportSqlService.getQueries(); + queries = exportSqlService.getEntities(ExportQuery.class); // attach them to default created admin user in the db for (ExportQuery query : queries) { Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ExportSqlService.java =================================================================== --- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ExportSqlService.java 2011-11-24 14:18:03 UTC (rev 115) +++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ExportSqlService.java 2011-11-24 23:06:43 UTC (rev 116) @@ -24,10 +24,8 @@ package fr.ifremer.echobase.services; import fr.ifremer.echobase.EchoBaseTechnicalException; -import fr.ifremer.echobase.entities.EchoBaseDAOHelper; import fr.ifremer.echobase.entities.EchoBaseUser; import fr.ifremer.echobase.entities.ExportQuery; -import fr.ifremer.echobase.entities.ExportQueryDAO; import org.apache.commons.lang3.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -35,6 +33,7 @@ import org.nuiton.topia.TopiaException; import org.nuiton.topia.framework.TopiaContextImplementor; import org.nuiton.topia.framework.TopiaSQLQuery; +import org.nuiton.topia.persistence.TopiaDAO; import org.nuiton.util.csv.Export; import java.sql.Connection; @@ -55,28 +54,10 @@ /** Logger. */ private static final Log log = LogFactory.getLog(ExportSqlService.class); - public List<ExportQuery> getQueries() { + public ExportQuery createOrUpdate(ExportQuery exportQuery, + EchoBaseUser user) { try { - List<ExportQuery> result = getDAO().findAll(); - return result; - } catch (TopiaException eee) { - throw new EchoBaseTechnicalException("Could not obtain export queries", eee); - } - } - - public ExportQuery getQueryById(String queryId) { - - try { - ExportQuery result = getDAO().findByTopiaId(queryId); - return result; - } catch (TopiaException eee) { - throw new EchoBaseTechnicalException("Could not obtain export query with id " + queryId, eee); - } - } - - public ExportQuery createOrUpdate(ExportQuery exportQuery, EchoBaseUser user) { - try { - ExportQueryDAO dao = getDAO(); + TopiaDAO<ExportQuery> dao = getDAO(ExportQuery.class); ExportQuery entityToSave; // No id, creating new one entity @@ -103,7 +84,7 @@ public void delete(String topiaId) { try { - ExportQueryDAO dao = getDAO(); + TopiaDAO<ExportQuery> dao = getDAO(ExportQuery.class); ExportQuery entityToDelete = dao.findByTopiaId(topiaId); dao.delete(entityToDelete); @@ -118,7 +99,8 @@ // get a query to count all rows for the request GenericSQLQuery sqlQuery = new GenericSQLQuery(sql, pager); try { - List<Map<String, Object>> result = sqlQuery.getResult(getTransaction()); + List<Map<String, Object>> result = + sqlQuery.getResult(getTransaction()); return result.toArray(new Map[result.size()]); } catch (TopiaException eee) { throw new EchoBaseTechnicalException("Could not execute sql query", eee); @@ -152,22 +134,17 @@ } catch (TopiaException eee) { throw new EchoBaseTechnicalException("Could not execute sql query", eee); } - ExportSqlCsvModel csvModel = sqlQuery.generateCsvModel(getConfiguration().getCsvCharSeparator()); + char csvSeparator = getConfiguration().getCsvSeparator(); + ExportSqlCsvModel csvModel = sqlQuery.generateCsvModel(csvSeparator); Export<Map<String, Object>> exporter = Export.newExport(csvModel, rows); - String content = null; try { - content = exporter.startExportAsString(); + String content = exporter.startExportAsString(); return content; } catch (Exception eee) { throw new EchoBaseTechnicalException("Could not export sql", eee); } - } - protected ExportQueryDAO getDAO() throws TopiaException { - return EchoBaseDAOHelper.getExportQueryDAO(getTransaction()); - } - private static class GenericSQLQuery extends TopiaSQLQuery<Map<String, Object>> { protected String[] columnNames; Added: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ImportDataConfiguration.java =================================================================== --- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ImportDataConfiguration.java (rev 0) +++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ImportDataConfiguration.java 2011-11-24 23:06:43 UTC (rev 116) @@ -0,0 +1,134 @@ +/* + * #%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 fr.ifremer.echobase.entities.data.Voyage; + +import java.io.Serializable; +import java.util.Locale; + +import static org.nuiton.i18n.I18n.l_; + +/** + * Configuration of an import data action. + * + * @author tchemit <chemit@codelutin.com> + * @since 0.2 + */ +public class ImportDataConfiguration implements Serializable { + + private static final long serialVersionUID = 1L; + + /** Voyage used for the import (may not be in db if needed to be created). */ + protected Voyage voyage; + + protected InputFile acousticFile; + + protected InputFile captureFile; + + protected InputFile lectureAgeGenFile; + + protected InputFile eventsFile; + + protected InputFile typeEchoSpeciesFile; + + protected int nbSteps; + + private float stepIncrement; + + protected float progression; + + public ImportDataConfiguration(Locale locale) { + acousticFile = new InputFile(l_(locale, "echobase.common.acousticImport")); + captureFile = new InputFile(l_(locale, "echobase.common.captureImport")); + lectureAgeGenFile = new InputFile(l_(locale, "echobase.common.lectureAgeGenImport")); + eventsFile = new InputFile(l_(locale, "echobase.common.eventsImport")); + typeEchoSpeciesFile = new InputFile(l_(locale, "echobase.common.typeEchoSpeciesImport")); + } + + public Voyage getVoyage() { + return voyage; + } + + public InputFile getAcousticFile() { + return acousticFile; + } + + public InputFile getCaptureFile() { + return captureFile; + } + + public InputFile getLectureAgeGenFile() { + return lectureAgeGenFile; + } + + public InputFile getEventsFile() { + return eventsFile; + } + + public InputFile getTypeEchoSpeciesFile() { + return typeEchoSpeciesFile; + } + + public int getNbSteps() { + return nbSteps; + } + + public float getProgression() { + return progression; + } + + public void setVoyage(Voyage voyage) { + this.voyage = voyage; + } + + public void setProgression(float progression) { + this.progression = progression; + } + + public void incrementsProgression() { + setProgression(progression + stepIncrement); + } + + public void computeSteps() { + nbSteps = 0; + if (acousticFile.getFile() != null) { + nbSteps++; + } + if (captureFile.getFile() != null) { + nbSteps++; + } + if (lectureAgeGenFile.getFile() != null) { + nbSteps++; + } + if (eventsFile.getFile() != null) { + nbSteps++; + } + if (typeEchoSpeciesFile.getFile() != null) { + nbSteps++; + } + stepIncrement = 100f / nbSteps; + } +} Property changes on: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ImportDataConfiguration.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/ImportDataService.java =================================================================== --- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ImportDataService.java (rev 0) +++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ImportDataService.java 2011-11-24 23:06:43 UTC (rev 116) @@ -0,0 +1,198 @@ +/* + * #%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 com.google.common.collect.Maps; +import fr.ifremer.echobase.EchoBaseTechnicalException; +import fr.ifremer.echobase.InputFile; +import fr.ifremer.echobase.entities.data.Voyage; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import java.io.File; +import java.util.Map; + +/** + * Service to import datas. + * + * @author tchemit <chemit@codelutin.com> + * @since 0.2 + */ +public class ImportDataService extends AbstractEchoBaseService { + + /** Logger. */ + private static final Log log = LogFactory.getLog(ImportDataService.class); + + public Map<InputFile, CsvImportResult> startImport(ImportDataConfiguration configuration) { + + Map<InputFile, CsvImportResult> result = Maps.newHashMap(); + + Voyage voyage = configuration.getVoyage(); + + // compute nb step to treate (means nb imports to do) + configuration.computeSteps(); + + if (log.isInfoEnabled()) { + log.info("Starts data import with voyage " + + voyage.getVoyageName()); + } + + InputFile acousticFile = configuration.getAcousticFile(); + if (acousticFile.getFile() != null) { + + // do acoustic import + try { + CsvImportResult importResult = importAcoustic(voyage, acousticFile); + configuration.incrementsProgression(); + result.put(acousticFile, importResult); + } finally { + deleteFile(acousticFile); + } + } + + InputFile captureFile = configuration.getCaptureFile(); + if (captureFile.getFile() != null) { + + // do capture import + try { + CsvImportResult importResult = importCapture(voyage, captureFile); + configuration.incrementsProgression(); + result.put(captureFile, importResult); + } finally { + deleteFile(captureFile); + } + } + + InputFile eventsFile = configuration.getEventsFile(); + if (eventsFile.getFile() != null) { + + // do events import + try { + CsvImportResult importResult = importEvents(voyage, eventsFile); + configuration.incrementsProgression(); + result.put(eventsFile, importResult); + } finally { + deleteFile(eventsFile); + } + } + + InputFile lectureAgeGenFile = configuration.getLectureAgeGenFile(); + if (lectureAgeGenFile.getFile() != null) { + + // do lecture age gen import + try { + CsvImportResult importResult = importLectureAgeGen(voyage, lectureAgeGenFile); + configuration.incrementsProgression(); + result.put(lectureAgeGenFile, importResult); + } finally { + deleteFile(lectureAgeGenFile); + } + } + + InputFile typeEchoSpeciesFile = configuration.getTypeEchoSpeciesFile(); + if (typeEchoSpeciesFile.getFile() != null) { + + // do echo species import + try { + CsvImportResult importResult = importTypeEchoSpecies(voyage, typeEchoSpeciesFile); + configuration.incrementsProgression(); + result.put(typeEchoSpeciesFile, importResult); + } finally { + deleteFile(typeEchoSpeciesFile); + } + } + + 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 CsvImportResult importAcoustic(Voyage voyage, InputFile importFile) { + if (log.isInfoEnabled()) { + log.info("Starts " + importFile.getLabel() + " with file " + + importFile.getFile()); + } + CsvImportResult result = new CsvImportResult(); + prepareImport(); + return result; + } + + protected CsvImportResult importCapture(Voyage voyage, InputFile importFile) { + if (log.isInfoEnabled()) { + log.info("Starts " + importFile.getLabel() + " with file " + + importFile.getFile()); + } + CsvImportResult result = new CsvImportResult(); + prepareImport(); + return result; + } + + protected CsvImportResult importEvents(Voyage voyage, InputFile importFile) { + if (log.isInfoEnabled()) { + log.info("Starts " + importFile.getLabel() + " with file " + + importFile.getFile()); + } + CsvImportResult result = new CsvImportResult(); + prepareImport(); + return result; + } + + protected CsvImportResult importLectureAgeGen(Voyage voyage, InputFile importFile) { + if (log.isInfoEnabled()) { + log.info("Starts " + importFile.getLabel() + " with file " + + importFile.getFile()); + } + CsvImportResult result = new CsvImportResult(); + prepareImport(); + return result; + } + + protected CsvImportResult importTypeEchoSpecies(Voyage voyage, InputFile importFile) { + if (log.isInfoEnabled()) { + log.info("Starts " + importFile.getLabel() + " with file " + + importFile.getFile()); + } + CsvImportResult result = new CsvImportResult(); + prepareImport(); + return result; + } + + protected void prepareImport() { + try { + Thread.sleep(2000); + } catch (InterruptedException e) { + // ignore + } + } +} Property changes on: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/ImportDataService.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/UserService.java =================================================================== --- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/UserService.java 2011-11-24 14:18:03 UTC (rev 115) +++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/UserService.java 2011-11-24 23:06:43 UTC (rev 116) @@ -26,7 +26,6 @@ import com.google.common.base.Preconditions; import fr.ifremer.echobase.EchoBaseConfiguration; import fr.ifremer.echobase.EchoBaseTechnicalException; -import fr.ifremer.echobase.entities.EchoBaseDAOHelper; import fr.ifremer.echobase.entities.EchoBaseUser; import fr.ifremer.echobase.entities.EchoBaseUserDAO; import fr.ifremer.echobase.entities.EchoBaseUserDTO; @@ -76,15 +75,6 @@ } } - public EchoBaseUser getUserById(String topiaId) { - try { - EchoBaseUser user = getDAO().findByTopiaId(topiaId); - return user; - } catch (TopiaException eee) { - throw new EchoBaseTechnicalException(eee); - } - } - public EchoBaseUser getUserByEmail(String email) { Preconditions.checkNotNull(email); try { @@ -162,6 +152,6 @@ } protected EchoBaseUserDAO getDAO() throws TopiaException { - return EchoBaseDAOHelper.getEchoBaseUserDAO(getTransaction()); + return (EchoBaseUserDAO) getDAO(EchoBaseUser.class); } } Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/VoyageService.java =================================================================== --- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/VoyageService.java 2011-11-24 14:18:03 UTC (rev 115) +++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/VoyageService.java 2011-11-24 23:06:43 UTC (rev 116) @@ -24,39 +24,25 @@ package fr.ifremer.echobase.services; import fr.ifremer.echobase.EchoBaseTechnicalException; -import fr.ifremer.echobase.entities.EchoBaseDAOHelper; import fr.ifremer.echobase.entities.data.Voyage; -import fr.ifremer.echobase.entities.data.VoyageDAO; import org.nuiton.topia.TopiaException; -import java.util.List; - /** - * Service to manage all concerning voayges. + * Service to manage all concerning voyages. * * @author sletellier <letellier@codelutin.com> */ public class VoyageService extends AbstractEchoBaseService { - public List<Voyage> getVoyages() { + public Voyage createVoyage(Voyage voyage) { try { - List<Voyage> voyages = getDAO().findAll(); - return voyages; + Voyage result = getDAO(Voyage.class).create(voyage); + commitTransaction("Could not create voyage " + + voyage.getVoyageName()); + return result; } catch (TopiaException eee) { throw new EchoBaseTechnicalException(eee); } } - public Voyage getVoyageById(String topiaId) { - try { - Voyage voyage = getDAO().findByTopiaId(topiaId); - return voyage; - } catch (TopiaException eee) { - throw new EchoBaseTechnicalException(eee); - } - } - - protected VoyageDAO getDAO() throws TopiaException { - return EchoBaseDAOHelper.getVoyageDAO(getTransaction()); - } } Property changes on: trunk/echobase-services/src/main/resources/embedded/startEchobase.bat ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Property changes on: trunk/echobase-services/src/main/resources/embedded/startEchobase.sh ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native 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-11-24 14:18:03 UTC (rev 115) +++ trunk/echobase-services/src/main/resources/i18n/echobase-services_fr_FR.properties 2011-11-24 23:06:43 UTC (rev 116) @@ -0,0 +1,5 @@ +echobase.common.acousticImport=Import Acoustique +echobase.common.captureImport=Import Pêcherie +echobase.common.eventsImport=Import Evènements +echobase.common.lectureAgeGenImport=Import Lecture Agen Gen +echobase.common.typeEchoSpeciesImport=Import Type EchoSpecies Modified: trunk/echobase-services/src/test/java/fr/ifremer/echobase/entities/MockEntityVisitorCreator.java =================================================================== --- trunk/echobase-services/src/test/java/fr/ifremer/echobase/entities/MockEntityVisitorCreator.java 2011-11-24 14:18:03 UTC (rev 115) +++ trunk/echobase-services/src/test/java/fr/ifremer/echobase/entities/MockEntityVisitorCreator.java 2011-11-24 23:06:43 UTC (rev 116) @@ -51,7 +51,7 @@ protected TopiaContext transaction; - private static final int NB_ASSOCIATIONS = 2; + private static final int NB_ASSOCIATIONS = 1; public MockEntityVisitorCreator(TopiaContext transaction) { this.transaction = transaction; Property changes on: trunk/echobase-services/src/test/java/fr/ifremer/echobase/entities/MockEntityVisitorCreator.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Property changes on: trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/AbstractEchoBaseServiceTest.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Modified: trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/EmbeddedApplicationServiceTest.java =================================================================== --- trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/EmbeddedApplicationServiceTest.java 2011-11-24 14:18:03 UTC (rev 115) +++ trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/EmbeddedApplicationServiceTest.java 2011-11-24 23:06:43 UTC (rev 116) @@ -28,6 +28,7 @@ import fr.ifremer.echobase.entities.MockEntityVisitorCreator; import fr.ifremer.echobase.entities.data.Voyage; import fr.ifremer.echobase.entities.data.VoyageDAO; +import org.junit.Ignore; import org.junit.Test; import org.nuiton.topia.TopiaContext; @@ -39,6 +40,7 @@ * @author sletellier <letellier@codelutin.com> * @since 0.2 */ +@Ignore public class EmbeddedApplicationServiceTest extends AbstractEchoBaseServiceTest { public static final String TEST_ECHOBASE_EMBEDDED = "test-echobase-embedded"; Property changes on: trunk/echobase-services/src/test/java/fr/ifremer/echobase/services/EmbeddedApplicationServiceTest.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Property changes on: trunk/echobase-services/src/test/resources/echobase.properties ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Modified: trunk/echobase-ui/pom.xml =================================================================== --- trunk/echobase-ui/pom.xml 2011-11-24 14:18:03 UTC (rev 115) +++ trunk/echobase-ui/pom.xml 2011-11-24 23:06:43 UTC (rev 116) @@ -262,6 +262,7 @@ <executions> <execution> <goals> + <goal>parserValidation</goal> <goal>parserJava</goal> <goal>gen</goal> <goal>bundle</goal> Modified: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/EchoBaseSession.java =================================================================== --- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/EchoBaseSession.java 2011-11-24 14:18:03 UTC (rev 115) +++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/EchoBaseSession.java 2011-11-24 23:06:43 UTC (rev 116) @@ -24,6 +24,7 @@ package fr.ifremer.echobase.ui; import fr.ifremer.echobase.entities.EchoBaseUser; +import fr.ifremer.echobase.services.ImportDataConfiguration; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -44,6 +45,9 @@ /** Key to set User connected in this session. */ protected static final String PROPERTY_ECHO_BASE_USER = "echobaseUser"; + /** Key to keep import configuration in this session. */ + protected static final String PROPERTY_IMPORT_DATA_CONFIGURATION = "importDataConfiguration"; + /** To store all properties in this session. */ protected Map<String, Object> store; @@ -65,6 +69,14 @@ set(PROPERTY_ECHO_BASE_USER, echoBaseUser); } + public ImportDataConfiguration getImportDataConfiguration() { + return get(PROPERTY_IMPORT_DATA_CONFIGURATION, ImportDataConfiguration.class); + } + + public void setImportDataConfiguration(ImportDataConfiguration configuration) { + set(PROPERTY_IMPORT_DATA_CONFIGURATION, configuration); + } + /** * Remove form this session, the object from his given key and returns it. * @@ -121,9 +133,13 @@ * @param value the object to store in this session */ protected void set(String key, Object value) { - store.put(key, value); - if (log.isInfoEnabled()) { - log.info("Set in user session data [" + key + "] = " + value); + if (value == null) { + remove(key); + } else { + store.put(key, value); + if (log.isInfoEnabled()) { + log.info("Set in user session data [" + key + "] = " + value); + } } } } Deleted: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/ImportAction.java =================================================================== --- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/ImportAction.java 2011-11-24 14:18:03 UTC (rev 115) +++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/ImportAction.java 2011-11-24 23:06:43 UTC (rev 116) @@ -1,94 +0,0 @@ -/* - * #%L - * EchoBase :: UI - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2011 Ifremer, Codelutin - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * #L% - */ -package fr.ifremer.echobase.ui.actions; - -import com.opensymphony.xwork2.Preparable; -import fr.ifremer.echobase.entities.data.Voyage; -import fr.ifremer.echobase.services.VoyageService; -import fr.ifremer.echobase.services.models.ImportModel; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import java.util.List; -import java.util.Map; - -/** - * Action to manage imports - * - * @author sletellier <letellier@codelutin.com> - * @since 0.1 - */ -public class ImportAction extends EchoBaseActionSupport implements Preparable { - - private static final long serialVersionUID = 1L; - - protected static final Log log = LogFactory.getLog(ImportAction.class); - - protected ImportModel importModel; - - protected Map<String, String> voyages; - - public ImportModel getImportModel() { - if (importModel == null) { - importModel = new ImportModel(); - } - return importModel; - } - - public String getSelectedVoyageId() { - String selectedVoyageId = getImportModel().getSelectedVoyageId(); - return selectedVoyageId; - } - - public void setSelectedVoyageId(String selectedVoyageId) { - VoyageService service = newService(VoyageService.class); - Voyage selectedVoyage = service.getVoyageById(selectedVoyageId); - getImportModel().setSelectedVoyage(selectedVoyage); - } - - public Map<String, String> getVoyages() { - return voyages; - } - - @Override - public void prepare() throws Exception { - VoyageService service = newService(VoyageService.class); - List<Voyage> allVoyages = service.getVoyages(); - voyages = sortAndDecorate(allVoyages, null); - } - - @Override - public String execute() throws Exception { - log.info("Will import : " + getImportModel().toString()); - return SUCCESS; - } - -// @Override -// public void validate() { -// //FIXME : do a real validation with a xml validation file. -// if (!importModel.validate()) { -// addActionError(_("echobase.error.importArgument")); -// } -// } -} Modified: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/export/CreateEmbeddedApplication.java =================================================================== --- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/export/CreateEmbeddedApplication.java 2011-11-24 14:18:03 UTC (rev 115) +++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/export/CreateEmbeddedApplication.java 2011-11-24 23:06:43 UTC (rev 116) @@ -73,7 +73,7 @@ public String execute() throws Exception { VoyageService service = newService(VoyageService.class); - List<Voyage> allVoyages = service.getVoyages(); + List<Voyage> allVoyages = service.getEntities(Voyage.class); voyages = sortAndDecorate(allVoyages, null); EchoBaseConfiguration configuration = getConfiguration(); Modified: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/export/ManageExportQuery.java =================================================================== --- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/export/ManageExportQuery.java 2011-11-24 14:18:03 UTC (rev 115) +++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/export/ManageExportQuery.java 2011-11-24 23:06:43 UTC (rev 116) @@ -100,7 +100,8 @@ public void prepare() throws Exception { ExportSqlService service = newService(ExportSqlService.class); - Collection<ExportQuery> sqlQueries = service.getQueries(); + Collection<ExportQuery> sqlQueries = + service.getEntities(ExportQuery.class); queries = sortAndDecorate(sqlQueries, null); if (sqlQueries.isEmpty()) { @@ -117,7 +118,7 @@ } else { // load query from database - query = service.getQueryById(selectedQueryId); + query = service.getEntityById(ExportQuery.class, selectedQueryId); } } } \ No newline at end of file Added: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/importData/ConfigureFiles.java =================================================================== --- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/importData/ConfigureFiles.java (rev 0) +++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/importData/ConfigureFiles.java 2011-11-24 23:06:43 UTC (rev 116) @@ -0,0 +1,187 @@ +/* + * #%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% + */ +package fr.ifremer.echobase.ui.actions.importData; + +import com.opensymphony.xwork2.Preparable; +import fr.ifremer.echobase.InputFile; +import fr.ifremer.echobase.entities.data.Voyage; +import fr.ifremer.echobase.services.ImportDataConfiguration; +import fr.ifremer.echobase.services.VoyageService; +import fr.ifremer.echobase.ui.actions.EchoBaseActionSupport; +import org.apache.commons.io.FileUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.nuiton.util.FileUtil; + +import java.io.File; +import java.io.IOException; + +/** + * Action to load input files to import. + * + * @author tchemit <chemit@codelutin.com> + * @since 0.2 + */ +public class ConfigureFiles extends EchoBaseActionSupport implements Preparable { + + private static final long serialVersionUID = 1L; + + /** Logger. */ + private static final Log log = LogFactory.getLog(ConfigureFiles.class); + + /** Import data configuration to push in session. */ + protected ImportDataConfiguration model; + + /** Id of selected voyage used in import. */ + protected String voyageId; + + public void setVoyageId(String voyageId) { + this.voyageId = voyageId; + } + + public void setAcoustic(File file) { + getModel().getAcousticFile().setFile(file); + } + + public void setAcousticContentType(String contentType) { + getModel().getAcousticFile().setContentType(contentType); + } + + public void setAcousticFileName(String fileName) { + getModel().getAcousticFile().setFileName(fileName); + } + + public void setCapture(File file) { + getModel().getCaptureFile().setFile(file); + } + + public void setCaptureContentType(String contentType) { + getModel().getCaptureFile().setContentType(contentType); + } + + public void setCaptureFileName(String fileName) { + getModel().getCaptureFile().setFileName(fileName); + } + + public void setLectureAgeGen(File file) { + getModel().getLectureAgeGenFile().setFile(file); + } + + public void setLectureAgeGenContentType(String contentType) { + getModel().getLectureAgeGenFile().setContentType(contentType); + } + + public void setLectureAgeGenFileName(String fileName) { + getModel().getLectureAgeGenFile().setFileName(fileName); + } + + public void setEvents(File file) { + getModel().getEventsFile().setFile(file); + } + + public void setEventsContentType(String contentType) { + getModel().getEventsFile().setContentType(contentType); + } + + public void setEventsFileName(String fileName) { + getModel().getEventsFile().setFileName(fileName); + } + + public void setTypeEchoSpecies(File file) { + getModel().getTypeEchoSpeciesFile().setFile(file); + } + + public void setTypeEchoSpeciesContentType(String contentType) { + getModel().getTypeEchoSpeciesFile().setContentType(contentType); + } + + public void setTypeEchoSpeciesFileName(String fileName) { + getModel().getTypeEchoSpeciesFile().setFileName(fileName); + } + + public String getVoyageId() { + return voyageId; + } + + public ImportDataConfiguration getModel() { + if (model == null) { + model = new ImportDataConfiguration(getLocale()); + } + return model; + } + + @Override + public String input() throws Exception { + + // remove configuration from session + getEchoBaseSession().setImportDataConfiguration(null); + + return INPUT; + } + + @Override + public String execute() throws Exception { + + ImportDataConfiguration importModel = getModel(); + File tempDirectory = FileUtils.getTempDirectory(); + File dataDirectory = new File(tempDirectory, "echobase-import" + System.currentTimeMillis()); + FileUtil.createDirectoryIfNecessary(dataDirectory); + if (log.isInfoEnabled()) { + log.info("Temporary directory to use : " + dataDirectory); + } + copyFile(importModel.getAcousticFile(), dataDirectory); + copyFile(importModel.getCaptureFile(), dataDirectory); + copyFile(importModel.getEventsFile(), dataDirectory); + copyFile(importModel.getLectureAgeGenFile(), dataDirectory); + copyFile(importModel.getTypeEchoSpeciesFile(), dataDirectory); + + getEchoBaseSession().setImportDataConfiguration(importModel); + return SUCCESS; + } + + @Override + public void prepare() throws Exception { + + VoyageService service = newService(VoyageService.class); + + Voyage voyage = service.getEntityById(Voyage.class, voyageId); + getModel().setVoyage(voyage); + } + + protected void copyFile(InputFile inputFile, File dataDirectory) throws IOException { + File source = inputFile.getFile(); + if (source != null) { + + File target = new File(dataDirectory, inputFile.getFileName()); + if (log.isInfoEnabled()) { + log.info("Copy file " + source + " to " + target); + } + FileUtils.copyFile(source, target); + + // keep target (source file will be removed at the end of this action) + inputFile.setFile(target); + } + + } +} Property changes on: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/importData/ConfigureFiles.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/importData/ConfigureVoyage.java =================================================================== --- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/importData/ConfigureVoyage.java (rev 0) +++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/importData/ConfigureVoyage.java 2011-11-24 23:06:43 UTC (rev 116) @@ -0,0 +1,170 @@ +/* + * #%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% + */ +package fr.ifremer.echobase.ui.actions.importData; + +import com.google.common.collect.Maps; +import com.opensymphony.xwork2.interceptor.annotations.InputConfig; +import fr.ifremer.echobase.entities.data.Voyage; +import fr.ifremer.echobase.entities.data.VoyageImpl; +import fr.ifremer.echobase.entities.references.AreaOfOperation; +import fr.ifremer.echobase.entities.references.Mission; +import fr.ifremer.echobase.services.VoyageService; +import fr.ifremer.echobase.ui.actions.EchoBaseActionSupport; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import java.util.List; +import java.util.Map; + +/** + * Configure the step 1 of import data (says which campagne to use). + * + * @author tchemit <chemit@codelutin.com> + * @since 0.2 + */ +public class ConfigureVoyage extends EchoBaseActionSupport { + + private static final long serialVersionUID = 1L; + + /** Logger. */ + private static final Log log = LogFactory.getLog(ConfigureVoyage.class); + + /** Universe of existing voyages. */ + protected Map<String, String> voyages; + + /** Universe of existing missions. */ + protected Map<String, String> missions; + + /** Universe of existing areaOfOperations. */ + protected Map<String, String> areaOfOperations; + + /** Universe of possible import modes. */ + protected Map<String, String> importModes; + + /** Selected import mode. */ + protected ImportMode importMode; + + /** Voyage to use. */ + protected Voyage voyage; + + /** Mission selected id. */ + protected String missionId; + + /** Area of operation selected id. */ + protected String areaOfOperationId; + + public Voyage getVoyage() { + if (voyage == null) { + voyage = new VoyageImpl(); + } + return voyage; + } + + public Map<String, String> getImportModes() { + return importModes; + } + + public Map<String, String> getVoyages() { + return voyages; + } + + public Map<String, String> getMissions() { + return missions; + } + + public Map<String, String> getAreaOfOperations() { + return areaOfOperations; + } + + public ImportMode getImportMode() { + return importMode; + } + + public void setMissionId(String missionId) { + this.missionId = missionId; + } + + public void setAreaOfOperationId(String areaOfOperationId) { + this.areaOfOperationId = areaOfOperationId; + } + + public void setImportMode(ImportMode importMode) { + this.importMode = importMode; + } + + @Override + public String input() throws Exception { + importModes = Maps.newLinkedHashMap(); + for (ImportMode mode : ImportMode.values()) { + importModes.put(mode.name(), _(mode.getI18nKey())); + } + + if (importMode == null) { + importMode = ImportMode.USE_EXISTING_VOYAGE; + } + + VoyageService service = newService(VoyageService.class); + List<Voyage> allVoyages = service.getEntities(Voyage.class); + voyages = sortAndDecorate(allVoyages, null); + + List<Mission> allMissions = service.getEntities(Mission.class); + missions = sortAndDecorate(allMissions, null); + + List<AreaOfOperation> allAreaOfOperations = + service.getEntities(AreaOfOperation.class); + areaOfOperations = sortAndDecorate(allAreaOfOperations, null); + if (log.isInfoEnabled()) { + log.info("File errors : "+getFieldErrors()); + } + return INPUT; + } + + @InputConfig(methodName = "input") + @Override + public String execute() throws Exception { + + if (importMode == ImportMode.CREATE_NEW_VOYAGE) { + + // create voyage in db + VoyageService service = newService(VoyageService.class); + Voyage voyageToCreate = getVoyage(); + //TODO Remove this test when references will be ok + if (StringUtils.isNotEmpty(missionId)) { + Mission mission = + service.getEntityById(Mission.class, missionId); + voyage.setMission(mission); + } + //TODO Remove this test when references will be ok + if (StringUtils.isNotEmpty(areaOfOperationId)) { + AreaOfOperation area = service.getEntityById(AreaOfOperation.class, + areaOfOperationId); + voyage.setAreaOfOperation(area); + } + voyage = service.createVoyage(voyageToCreate); + } + return SUCCESS; + } + +} Property changes on: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/importData/ConfigureVoyage.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/importData/ImportMode.java =================================================================== --- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/importData/ImportMode.java (rev 0) +++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/importData/ImportMode.java 2011-11-24 23:06:43 UTC (rev 116) @@ -0,0 +1,49 @@ +/* + * #%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% + */ +package fr.ifremer.echobase.ui.actions.importData; + +import static org.nuiton.i18n.I18n.n_; + +/** + * Define import mode (use an existing voayge, or create a new one. + * + * @author tchemit <chemit@codelutin.com> + * @since 0.2 + */ +public enum ImportMode { + + CREATE_NEW_VOYAGE(n_("echobase.common.importMode.createNewVoyage")), + USE_EXISTING_VOYAGE(n_("echobase.common.importMode.useExistingVoyage")); + + + private final String i18nKey; + + ImportMode(String i18nKey) { + this.i18nKey = i18nKey; + } + + public String getI18nKey() { + return i18nKey; + } +} Property changes on: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/importData/ImportMode.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/importData/LaunchImport.java =================================================================== --- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/importData/LaunchImport.java (rev 0) +++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/importData/LaunchImport.java 2011-11-24 23:06:43 UTC (rev 116) @@ -0,0 +1,90 @@ +/* + * #%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% + */ +package fr.ifremer.echobase.ui.actions.importData; + +import com.opensymphony.xwork2.Preparable; +import fr.ifremer.echobase.InputFile; +import fr.ifremer.echobase.services.CsvImportResult; +import fr.ifremer.echobase.services.ImportDataConfiguration; +import fr.ifremer.echobase.services.ImportDataService; +import fr.ifremer.echobase.ui.actions.EchoBaseActionSupport; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import java.util.Map; + +/** + * To launch the import data process. + * + * @author tchemit <chemit@codelutin.com> + * @since 0.2 + */ +public class LaunchImport extends EchoBaseActionSupport implements Preparable { + + private static final long serialVersionUID = 1L; + + /** Logger. */ + private static final Log log = LogFactory.getLog(LaunchImport.class); + + /** Import data configuration to push in session. */ + protected ImportDataConfiguration model; + + protected Map<InputFile, CsvImportResult> importResult; + + transient ImportDataService service; + + public ImportDataConfiguration getModel() { + return model; + } + + public Map<InputFile, CsvImportResult> getImportResult() { + return importResult; + } + + @Override + public void prepare() throws Exception { + + model = getEchoBaseSession().getImportDataConfiguration(); + + service = newService(ImportDataService.class); + } + + @Override + public String execute() throws Exception { + + try { + if (log.isInfoEnabled()) { + log.info("Start imports with voyage " + + model.getVoyage().getVoyageName()); + } + + importResult = service.startImport(model); + return SUCCESS; + } finally { + + // remove configuration from session + getEchoBaseSession().setImportDataConfiguration(null); + } + } +} Property changes on: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/importData/LaunchImport.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/user/ManageUser.java =================================================================== --- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/user/ManageUser.java 2011-11-24 14:18:03 UTC (rev 115) +++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/user/ManageUser.java 2011-11-24 23:06:43 UTC (rev 116) @@ -76,7 +76,7 @@ if (!StringUtils.isEmpty(userId)) { // load user - user = getUserService().getUserById(userId).toDTO(); + user = getUserService().getEntityById(EchoBaseUser.class, userId).toDTO(); log.info("Selected user " + user.getEmail()); } Modified: trunk/echobase-ui/src/main/resources/config/struts-import.xml =================================================================== --- trunk/echobase-ui/src/main/resources/config/struts-import.xml 2011-11-24 14:18:03 UTC (rev 115) +++ trunk/echobase-ui/src/main/resources/config/struts-import.xml 2011-11-24 23:06:43 UTC (rev 116) @@ -32,20 +32,40 @@ <package name="import" extends="loggued" namespace="/import"> - <!-- Display import page --> - <action name="import" class="fr.ifremer.echobase.ui.actions.ImportAction" - method="input"> - <result name="input">/WEB-INF/jsp/import/import.jsp</result> + <!-- Configure import voyage --> + <action name="configureVoyage" + class="fr.ifremer.echobase.ui.actions.importData.ConfigureVoyage"> + <interceptor-ref name="paramsPrepareParamsStackLoggued"/> + <result name="input">/WEB-INF/jsp/import/configureVoyage.jsp</result> + <result type="redirectAction"> + <param name="namespace">/import</param> + <param name="actionName">configureFiles</param> + <param name="method">input</param> + <param name="voyageId">${voyage.topiaId}</param> + </result> </action> - <!-- Display import page --> - <action name="doImport" class="fr.ifremer.echobase.ui.actions.ImportAction"> + <!-- Configure import files --> + <action name="configureFiles" + class="fr.ifremer.echobase.ui.actions.importData.ConfigureFiles"> <interceptor-ref name="paramsPrepareParamsStackLoggued"/> - <!--<result name="wait">/WEB-INF/jsp/import/importProgress.jsp</result>--> - <result name="input">/WEB-INF/jsp/import/import.jsp</result> - <result>/WEB-INF/jsp/import/importProgress.jsp</result> + <result name="input">/WEB-INF/jsp/import/configureFiles.jsp</result> + <result type="redirectAction"> + <param name="namespace">/import</param> + <param name="actionName">doImport</param> + </result> </action> + <!-- Starts import --> + <action name="doImport" + class="fr.ifremer.echobase.ui.actions.importData.LaunchImport" + method="execute"> + <interceptor-ref name="basicStackLoggued"/> + <interceptor-ref name="execAndWait"/> + <result name="wait">/WEB-INF/jsp/import/importProgress.jsp</result> + <result>/WEB-INF/jsp/import/importResult.jsp</result> + </action> + </package> </struts> Modified: trunk/echobase-ui/src/main/resources/echobase.properties =================================================================== --- trunk/echobase-ui/src/main/resources/echobase.properties 2011-11-24 14:18:03 UTC (rev 115) +++ trunk/echobase-ui/src/main/resources/echobase.properties 2011-11-24 23:06:43 UTC (rev 116) @@ -29,6 +29,7 @@ hibernate.hbm2ddl.auto=none hibernate.show_sql=false hibernate.dialect=org.hibernate.dialect.H2Dialect +hibernate.connection.provider_class=org.nuiton.topia.framework.TopiaConnectionProvider hibernate.connection.driver_class=org.h2.Driver hibernate.connection.url=jdbc:h2:file:${data.directory}/db/echobase Deleted: trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/ImportAction-doImport-validation.xml =================================================================== --- trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/ImportAction-doImport-validation.xml 2011-11-24 14:18:03 UTC (rev 115) +++ trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/ImportAction-doImport-validation.xml 2011-11-24 23:06:43 UTC (rev 116) @@ -1,36 +0,0 @@ -<!-- - #%L - EchoBase :: UI - - $Id$ - $HeadURL$ - %% - Copyright (C) 2011 Ifremer, Codelutin - %% - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - #L% - --> -<!DOCTYPE validators PUBLIC - "-//OpenSymphony Group//XWork Validator 1.0.2//EN" - "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd"> -<validators> - - <field name="importModel.accessImport"> - <field-validator type="expression"> - <param name="expression">(importModel.accessImport == null ^ importModel.selectedVoyage == null) == 1</param> - <message key="echobase.validation.import.selectedVoyageOrAccessImport.required"/> - </field-validator> - </field> - -</validators> \ No newline at end of file Modified: trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/export/ManageExportQuery-saveExportQuery-validation.xml =================================================================== --- trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/export/ManageExportQuery-saveExportQuery-validation.xml 2011-11-24 14:18:03 UTC (rev 115) +++ trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/export/ManageExportQuery-saveExportQuery-validation.xml 2011-11-24 23:06:43 UTC (rev 116) @@ -29,27 +29,27 @@ <field name="query.name"> <field-validator type="requiredstring"> - <message key="echobase.validation.export.name.requiredstring"/> + <message key="echobase.error.export.name.requiredstring"/> </field-validator> </field> <field name="query.description"> <field-validator type="requiredstring"> - <message key="echobase.validation.export.description.requiredstring"/> + <message key="echobase.error.export.description.requiredstring"/> </field-validator> </field> <field name="query.sqlQuery"> <field-validator type="requiredstring"> - <message key="echobase.validation.export.sqlQuery.requiredstring"/> + <message key="echobase.error.export.sqlQuery.requiredstring"/> </field-validator> <field-validator type="regex"> <!-- TODO sletellier 2011/11/14 : Find a better regex exression to define sql query --> <param name="expression">^\s*select\s+.+\s+from\s+.+$</param> <param name="caseSensitive">false</param> - <message key="echobase.validation.export.sqlQuery.wrongformat"/> + <message key="echobase.error.export.sqlQuery.wrongformat"/> </field-validator> </field> Added: trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/importData/ConfigureFiles-validation.xml =================================================================== --- trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/importData/ConfigureFiles-validation.xml (rev 0) +++ trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/importData/ConfigureFiles-validation.xml 2011-11-24 23:06:43 UTC (rev 116) @@ -0,0 +1,35 @@ +<!-- + #%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% + --> +<!DOCTYPE validators PUBLIC + "-//OpenSymphony Group//XWork Validator 1.0.2//EN" + "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd"> +<validators> + + <field name="voyageId"> + <field-validator type="requiredstring"> + <message key="echobase.error.import.voyage.required"/> + </field-validator> + </field> + +</validators> \ No newline at end of file Property changes on: trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/importData/ConfigureFiles-validation.xml ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/importData/ConfigureVoyage-validation.xml =================================================================== --- trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/importData/ConfigureVoyage-validation.xml (rev 0) +++ trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/importData/ConfigureVoyage-validation.xml 2011-11-24 23:06:43 UTC (rev 116) @@ -0,0 +1,92 @@ +<!-- + #%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% + --> +<!DOCTYPE validators PUBLIC + "-//OpenSymphony Group//XWork Validator 1.0.2//EN" + "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd"> +<validators> + + <field name="importMode"> + <field-validator type="required"> + <message key="echobase.error.import.importMode.required"/> + </field-validator> + </field> + + <field name="voyage.topiaId"> + <field-validator type="requiredstring"> + <param name="skip">importMode.name() != "USE_EXISTING_VOYAGE"</param> + <message key="echobase.error.import.voyage.required"/> + </field-validator> + </field> + + <field name="voyage.voyageName"> + <field-validator type="requiredstring"> + <param name="skip">importMode.name() != "CREATE_NEW_VOYAGE"</param> + <message key="echobase.error.import.voyageName.required"/> + </field-validator> + </field> + + <field name="voyage.datum"> + <field-validator type="requiredstring"> + <param name="skip">importMode.name() != "CREATE_NEW_VOYAGE"</param> + <message key="echobase.error.import.datum.required"/> + </field-validator> + </field> + + <field name="voyage.voyageDescription"> + <field-validator type="requiredstring"> + <param name="skip">importMode.name() != "CREATE_NEW_VOYAGE"</param> + <message key="echobase.error.import.voyageDescription.required"/> + </field-validator> + </field> + + <!-- TODO Reput this when references are in db --> + <!--field name="missionId"> + <field-validator type="requiredstring"> + <param name="skip">${importMode.name} != "CREATE_NEW_VOYAGE"</param> + <message key="echobase.error.import.missionId.required"/> + </field-validator> + </field--> + + <!--field name="areaOfOperationId"> + <field-validator type="requiredstring"> + <param name="skip">importMode.name() != "CREATE_NEW_VOYAGE"</param> + <message key="echobase.error.import.areaOfOperationId.required"/> + </field-validator> + </field--> + + <field name="voyage.voyageStartDate"> + <field-validator type="required"> + <param name="skip">importMode.name() != "CREATE_NEW_VOYAGE"</param> + <message key="echobase.error.import.voyageStartDate.required"/> + </field-validator> + </field> + + <field name="voyage.voyageEndDate"> + <field-validator type="required"> + <param name="skip">importMode.name() != "CREATE_NEW_VOYAGE"</param> + <message key="echobase.error.import.voyageEndDate.required"/> + </field-validator> + </field> + +</validators> \ No newline at end of file Property changes on: trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/importData/ConfigureVoyage-validation.xml ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Modified: trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/user/LoginAction-login-validation.xml =================================================================== --- trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/user/LoginAction-login-validation.xml 2011-11-24 14:18:03 UTC (rev 115) +++ trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/user/LoginAction-login-validation.xml 2011-11-24 23:06:43 UTC (rev 116) @@ -29,7 +29,7 @@ <field name="email"> <field-validator type="login"> - <message key="echobase.validation.login.wrongLogin"/> + <message key="echobase.error.login.wrongLogin"/> </field-validator> </field> Modified: trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/user/ManageUser-validation.xml =================================================================== --- trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/user/ManageUser-validation.xml 2011-11-24 14:18:03 UTC (rev 115) +++ trunk/echobase-ui/src/main/resources/fr/ifremer/echobase/ui/actions/user/ManageUser-validation.xml 2011-11-24 23:06:43 UTC (rev 116) @@ -29,14 +29,14 @@ <field name="user.email"> <field-validator type="login"> - <message key="echobase.validation.login.wrongLogin"/> + <message key="echobase.error.login.wrongLogin"/> </field-validator> </field> <field name="user.password"> <field-validator type="requiredstring"> - <message key="echobase.validation.login.password.requiredstring"/> + <message key="echobase.error.login.password.requiredstring"/> </field-validator> </field> 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 2011-11-24 14:18:03 UTC (rev 115) +++ trunk/echobase-ui/src/main/resources/i18n/echobase-ui_fr_FR.properties 2011-11-24 23:06:43 UTC (rev 116) @@ -18,16 +18,19 @@ echobase.action.return=Retour echobase.action.save=Sauvegarder echobase.action.saveSqlQuery=Enregistrer la requête +echobase.action.validateImportVoyage=Valider la campagne echobase.common.admin=Administrateur echobase.common.comment=Commentaire echobase.common.email=Email echobase.common.entityType=Type d'entité +echobase.common.importMode=Type de campagne +echobase.common.importMode.createNewVoyage=Créer une nouvelle campagne +echobase.common.importMode.useExistingVoyage=Utiliser une campagne existante echobase.common.jdbcLogin=Login de connexion echobase.common.jdbcPassword=Mot de passe echobase.common.jdbcUrl=Url de connexion echobase.common.password=Mot de passe echobase.common.user=Utilisateur -echobase.common.voyage=Voyage echobase.error.bad.password=Mot de passe incorrrect echobase.error.email.already.used= echobase.error.export.description.requiredstring=La description de l'export est obligatoire @@ -36,7 +39,7 @@ echobase.error.export.sqlQuery.wrongformat=La requêtes n'est pas valide echobase.error.fileDontExist= echobase.error.fileNotFound= -echobase.error.import.selectedVoyageOrAccessImport.required=Merci de selectionner un voyage ou un import access +echobase.error.import.selectedVoyageOrAccessImport.required=Merci de selectionner un campagne echobase.error.importArgument= echobase.error.importFile.required=Fichier d'import obligatoire echobase.error.login.password.requiredstring=Le mot de passe est obligatoire @@ -47,7 +50,7 @@ echobase.error.warlocation.notFound=L'application n'a pas été trouvé à l'emplacement suivant %s echobase.header.request.result=Résultat de la requête sql echobase.header.user.gridTitle=Liste des utilisateurs -echobase.header.voyageSelect=Selectionnez un voyage +echobase.header.voyageSelect=Selectionnez une campagne echobase.info.dbeditor.propertyDiffsResult=Résultat d'import de données echobase.info.no.sqlQuery.saved=Aucune requête d'export sql enregistré echobase.info.no.sqlQuery.selected=Aucune requête d'export sql sélectionnée @@ -79,6 +82,10 @@ echobase.legend.dbeditor.edit=Edition de '%s' echobase.legend.embeddedApplication.configuration=Configuration de l'application embarquée echobase.legend.import=Import configuration +echobase.legend.import.configuration.files=Choix des fichiers d'import +echobase.legend.import.configuration.voyage=Configurer la campagne +echobase.legend.import.configuration.voyage.resume=Résumé de la campagne à utiliser +echobase.legend.importFileResult=Résultat de l'import %s echobase.legend.sqlQuery.configuration=Configuration de la requête echobase.legend.sqlQuery.result=Résultats de la requête echobase.menu.connectToDbInformations=Se connecter à la base @@ -104,6 +111,7 @@ echobase.title.export=Export echobase.title.exportTable=Exporter une table echobase.title.import=Imports +echobase.title.import.configuration=Configuration d'un import echobase.title.importProgress=Import en cours echobase.title.importResult=Résultats de l'import echobase.title.importTable=Importer une table Modified: trunk/echobase-ui/src/main/webapp/WEB-INF/includes/header.jsp =================================================================== --- trunk/echobase-ui/src/main/webapp/WEB-INF/includes/header.jsp 2011-11-24 14:18:03 UTC (rev 115) +++ trunk/echobase-ui/src/main/webapp/WEB-INF/includes/header.jsp 2011-11-24 23:06:43 UTC (rev 116) @@ -55,7 +55,7 @@ <div class="cleanBoth"> <ul> <li> - <s:a action="import" namespace="/import"> + <s:a action="configureVoyage" namespace="/import" method="input"> <s:text name="echobase.menu.import"/></s:a> </li> <li> Added: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/import/configureFiles.jsp =================================================================== --- trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/import/configureFiles.jsp (rev 0) +++ trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/import/configureFiles.jsp 2011-11-24 23:06:43 UTC (rev 116) @@ -0,0 +1,71 @@ +<%-- + #%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.import"/></title> + +<s:form namespace="/import" method="POST" enctype="multipart/form-data"> + + <fieldset> + <legend> + <s:text name="echobase.legend.import.configuration.voyage.resume"/> + </legend> + <s:label value="%{model.voyage.voyageName}" + key='echobase.common.voyageName'/> + + <s:label value="%{model.voyage.voyageDescription}" + key='echobase.common.voyageDescription'/> + </fieldset> + + <hr/> + <fieldset> + <legend> + <s:text name="echobase.legend.import.configuration.files"/> + </legend> + + <s:hidden key="voyageId" label=''/> + + <s:file name="acoustic" + key="echobase.label.import.accoustique"/> + + <s:file name="capture" + key="echobase.label.import.pecherie"/> + + <s:file name="lectureAgeGen" + key="echobase.label.import.lectureAgeGen"/> + + <s:file name="events" + key="echobase.label.import.events"/> + + <s:file name="typeEchoSpecies" + key="echobase.label.import.typeEchoSpecies"/> + + </fieldset> + <br/> + <s:submit id="addFilesSubmit" action="configureFiles" + value='%{getText("echobase.action.import")}'/> + + +</s:form> \ No newline at end of file Property changes on: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/import/configureFiles.jsp ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/import/configureVoyage.jsp =================================================================== --- trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/import/configureVoyage.jsp (rev 0) +++ trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/import/configureVoyage.jsp 2011-11-24 23:06:43 UTC (rev 116) @@ -0,0 +1,127 @@ +<%-- + #%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" %> + +<script type="text/javascript"> + + jQuery(document).ready(function () { + + var importMode = $('[name="importMode"]'); + importMode.change(function(event) { + $('[class="importMode"]').hide(); + $('#' + this.value).show(); + }); + var val = $('[name="importMode"][checked="checked"]').val(); + $('[class="importMode"]').hide(); + $("#"+val).show(); + }); +</script> +<title><s:text name="echobase.title.import.configuration"/></title> + +<s:form id="importForm" namespace="/import" method="POST"> + + <fieldset> + <legend> + <s:text name="echobase.legend.import.configuration.voyage"/> + </legend> + + <s:radio key='importMode' list="importModes" + label='%{getText("echobase.common.importMode")}' + required="true" /> + + <hr/> + + <div id='USE_EXISTING_VOYAGE' class='importMode'> + <s:select name="voyage.topiaId" value="''" + label='%{getText("echobase.common.voyage")}' + list="voyages" headerKey="" headerValue=""/> + </div> + + <div id='CREATE_NEW_VOYAGE' class='importMode'> + + <%-- + String PROPERTY_VOYAGE_NAME = "voyageName"; + + String PROPERTY_VOYAGE_START_DATE = "voyageStartDate"; + + String PROPERTY_VOYAGE_END_DATE = "voyageEndDate"; + + String PROPERTY_VOYAGE_START_HARBOUR = "voyageStartHarbour"; + + String PROPERTY_VOYAGE_END_HARBOUR = "voyageEndHarbour"; + + String PROPERTY_VOYAGE_DESCRIPTION = "voyageDescription"; + + String PROPERTY_DATUM = "datum"; + + String PROPERTY_MISSION = "mission"; + + String PROPERTY_AREA_OF_OPERATION = "areaOfOperation"; + + String PROPERTY_TRANSIT = "transit"; + + String PROPERTY_ECHOTYPE = "echotype"; + --%> + + <s:textfield key="voyage.voyageName" + label='%{getText("echobase.common.voyageName")}'/> + + <s:textfield key="voyage.voyageStartHarbour" + label='%{getText("echobase.common.voyageStartHarbour")}'/> + + <s:textfield key="voyage.voyageEndHarbour" + label='%{getText("echobase.common.voyageEndHarbour")}'/> + + <s:textfield key="voyage.datum" + label='%{getText("echobase.common.datum")}'/> + + <s:textarea key="voyage.voyageDescription" + label='%{getText("echobase.common.voyageDescription")}'/> + + <s:select name="missionId" value="''" + label='%{getText("echobase.common.mission")}' + list="missions" headerKey="" headerValue=""/> + + <s:select name="areaOfOperationId" value="''" + label='%{getText("echobase.common.areaOfOperation")}' + list="areaOfOperations" headerKey="" headerValue=""/> + + <sj:datepicker key="voyage.voyageStartDate" + label='%{getText("echobase.common.voyageStartDate")}' + value="%{new java.util.Date()}" + displayFormat="dd/mm/yy"/> + + <sj:datepicker key="voyage.voyageEndDate" + label='%{getText("echobase.common.voyageEndDate")}' + value="%{new java.util.Date()}" + displayFormat="dd/mm/yy"/> + </div> + + </fieldset> + <br/> + <s:submit value='%{getText("echobase.action.validateImportVoyage")}' + action="configureVoyage" /> +</s:form> \ No newline at end of file Property changes on: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/import/configureVoyage.jsp ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Modified: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/import/importProgress.jsp =================================================================== --- trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/import/importProgress.jsp 2011-11-24 14:18:03 UTC (rev 115) +++ trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/import/importProgress.jsp 2011-11-24 23:06:43 UTC (rev 116) @@ -25,9 +25,16 @@ <%@ taglib prefix="s" uri="/struts-tags" %> <%@ taglib prefix="sj" uri="/struts-jquery-tags" %> +<s:url id="url" action="doImport" namespace="/import"/> +<meta http-equiv="refresh" content="1;url=${url}"/> + <title><s:text name="echobase.title.importProgress"/></title> -<sj:progressbar value="%{EchoBaseActionContext.progression}"/> +<%-- TODO letellier 20111104 : Add warn icon --%> +<p><s:text name="echobase.message.warnImportInProgress"/></p> -<%-- TODO letellier 20111104 : Add warn icon --%> -<p><s:text name="echobase.message.warnImportInProgress"/></p> \ No newline at end of file +<br/> + +<div> + <sj:progressbar value="%{model.progression}"/> +</div> \ No newline at end of file Modified: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/import/importResult.jsp =================================================================== --- trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/import/importResult.jsp 2011-11-24 14:18:03 UTC (rev 115) +++ trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/import/importResult.jsp 2011-11-24 23:06:43 UTC (rev 116) @@ -26,4 +26,23 @@ <title><s:text name="echobase.title.importResult"/></title> -<%-- TODO letellier 20111104 : Add import results --%> \ No newline at end of file +<s:iterator value="importResult" var="entry"> + <s:set var="inputFile" value="%{#entry.key}"/> + <s:set var="result" value="%{#entry.value}"/> + <fieldset> + <legend> + <s:text name="echobase.legend.importFileResult"> + <s:param><strong><s:property value="%{#inputFile.label}"/></strong></s:param> + </s:text> + </legend> + + <s:label value="%{#inputFile.fileName}" + label="%{getText('echobase.label.importFile')}"/> + + <s:label value="%{#result.numberCreated}" + label="%{getText('echobase.label.numberOfCreatedEntities')}"/> + + <s:label value="%{#result.numberUpdated}" + label="%{getText('echobase.label.numberOfUpdatedEntities')}"/> + </fieldset> +</s:iterator> Modified: trunk/pom.xml =================================================================== --- trunk/pom.xml 2011-11-24 14:18:03 UTC (rev 115) +++ trunk/pom.xml 2011-11-24 23:06:43 UTC (rev 116) @@ -27,8 +27,6 @@ <!-- *** Project Information ************************************* --> <!-- ************************************************************* --> - <name>EchoBase</name> - <description>Projet EchoBase</description> <inceptionYear>2011</inceptionYear> <url>http://maven-site.forge.codelutin.com/echobase</url> Modified: trunk/src/doc/reunions/reunion-2011-11-15.txt =================================================================== --- trunk/src/doc/reunions/reunion-2011-11-15.txt 2011-11-24 14:18:03 UTC (rev 115) +++ trunk/src/doc/reunions/reunion-2011-11-15.txt 2011-11-24 23:06:43 UTC (rev 116) @@ -23,7 +23,7 @@ - DataMetadataName - CategoryMeaning - CategoryType - - CellMEthod + - CellMethod - discussion autour de la modélisation des *Class* que l'on renomme en *Category* - suppression de l'entité du référentiel *Region* qui sera au final remplacée