Author: fdesbois Date: 2010-04-01 18:21:22 +0000 (Thu, 01 Apr 2010) New Revision: 409 Removed: trunk/wao-business/src/main/java/fr/ifremer/wao/WaoContextO.java trunk/wao-business/src/main/java/fr/ifremer/wao/WaoExceptionO.java trunk/wao-business/src/main/java/fr/ifremer/wao/WaoRunner.java trunk/wao-business/src/main/java/fr/ifremer/wao/WaoRunnerImpl.java trunk/wao-business/src/main/java/fr/ifremer/wao/mock/ Modified: trunk/changelog.txt trunk/wao-business/src/main/java/fr/ifremer/wao/WaoBusinessException.java trunk/wao-business/src/main/java/fr/ifremer/wao/WaoContextImpl.java trunk/wao-business/src/main/java/fr/ifremer/wao/WaoGlobal.java trunk/wao-business/src/main/java/fr/ifremer/wao/WaoProperty.java trunk/wao-business/src/main/java/fr/ifremer/wao/bean/SamplingFilterImpl.java trunk/wao-business/src/main/java/fr/ifremer/wao/io/ImportHelper.java trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceContactImpl.java trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceSynthesisImpl.java trunk/wao-business/src/main/resources/i18n/wao-business-en_GB.properties trunk/wao-business/src/main/resources/i18n/wao-business-fr_FR.properties trunk/wao-business/src/main/xmi/wao.zargo trunk/wao-business/src/test/java/fr/ifremer/wao/ErrorDB1_0Test.java trunk/wao-business/src/test/java/fr/ifremer/wao/TestManager.java trunk/wao-business/src/test/java/fr/ifremer/wao/WaoGlobalTest.java trunk/wao-business/src/test/java/fr/ifremer/wao/WaoUtilsTest.java trunk/wao-business/src/test/java/fr/ifremer/wao/entity/SampleRowImplTest.java trunk/wao-business/src/test/java/fr/ifremer/wao/io/ImportHelperTest.java trunk/wao-business/src/test/java/fr/ifremer/wao/service/ActivityCalendarImportTest.java trunk/wao-business/src/test/java/fr/ifremer/wao/service/ServiceBoatImplTest.java trunk/wao-business/src/test/java/fr/ifremer/wao/service/ServiceReferentialImplTest.java trunk/wao-business/src/test/java/fr/ifremer/wao/service/ServiceSamplingImplTest.java trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/base/AbstractFilteredPage.java trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/components/Layout.java trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/data/AbstractMappedGridDataSource.java trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/data/BoatDataSource.java trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/data/ContactDataSource.java trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Administration.java trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/BoatActivityCalendar.java trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Boats.java trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Contacts.java trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/ExceptionReport.java trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Index.java trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/SampleRowForm.java trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/SampleRowHistoric.java trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/SamplingPlan.java trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Synthesis.java trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/UserProfile.java trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/services/AppModule.java Log: - use ServiceTransformer for ServiceSynthesis - delete old WaoContextO and WaoExceptionO - clean ServiceContactImpl Modified: trunk/changelog.txt =================================================================== --- trunk/changelog.txt 2010-04-01 17:14:29 UTC (rev 408) +++ trunk/changelog.txt 2010-04-01 18:21:22 UTC (rev 409) @@ -9,6 +9,8 @@ Evolutions ++++++++++ +- [fdesbois] Utilisation ServiceTransformer de ToPIA pour générer le squelette + des services. - [fdesbois] Evo #1980 : Droits "lecture seule" pour les utilisateurs - [fdesbois] Evo #2233 : Gérer les formats de dates par défaut d'OpenOffice pour l'import CSV (JJ/MM/AA) @@ -32,7 +34,7 @@ +++++++++ - [fdesbois] Ano #2237 : Impossible de changer les zones de pêche -- [fdesbois] Ano #2235 : Temp d'affichage page contacts ou plan +- [fdesbois] Ano #2235 : Temps d'affichage lent pour les pages contacts et plan d'échantillonnage - [fdesbois] Ano #2228 : Erreur d'affichage de la synthèse : réactivité de la saisie dans Allegro Modified: trunk/wao-business/src/main/java/fr/ifremer/wao/WaoBusinessException.java =================================================================== --- trunk/wao-business/src/main/java/fr/ifremer/wao/WaoBusinessException.java 2010-04-01 17:14:29 UTC (rev 408) +++ trunk/wao-business/src/main/java/fr/ifremer/wao/WaoBusinessException.java 2010-04-01 18:21:22 UTC (rev 409) @@ -33,7 +33,7 @@ * Mise a jour: $Date$ * par : $Author$ */ -public class WaoBusinessException extends WaoExceptionO { +public class WaoBusinessException extends Exception { protected Type type; Modified: trunk/wao-business/src/main/java/fr/ifremer/wao/WaoContextImpl.java =================================================================== --- trunk/wao-business/src/main/java/fr/ifremer/wao/WaoContextImpl.java 2010-04-01 17:14:29 UTC (rev 408) +++ trunk/wao-business/src/main/java/fr/ifremer/wao/WaoContextImpl.java 2010-04-01 18:21:22 UTC (rev 409) @@ -22,6 +22,7 @@ package fr.ifremer.wao; +import fr.ifremer.wao.io.ImportHelper; import java.nio.charset.Charset; import java.util.Date; import java.util.Locale; @@ -208,13 +209,16 @@ // getValue() on PollenProperty WaoProperty.setContext(this); // temp - WaoContextO.setContext(this); +// WaoContextO.setContext(this); // Set context in utils static class for entities WaoUtils.setContext(this); + + // Need to use it as an instance + ImportHelper.setContext(this); // Create the default admin in database - WaoGlobal.createDefaultAdmin(); + WaoGlobal.createDefaultAdmin(this); if (log.isInfoEnabled()) { log.info("wao is started !"); Deleted: trunk/wao-business/src/main/java/fr/ifremer/wao/WaoContextO.java =================================================================== --- trunk/wao-business/src/main/java/fr/ifremer/wao/WaoContextO.java 2010-04-01 17:14:29 UTC (rev 408) +++ trunk/wao-business/src/main/java/fr/ifremer/wao/WaoContextO.java 2010-04-01 18:21:22 UTC (rev 409) @@ -1,248 +0,0 @@ -/** - * *##% - * Wao :: Business - * Copyright (C) 2009 - 2010 Ifremer - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 Lesser Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * ##%* - */ - - -package fr.ifremer.wao; - - -import fr.ifremer.wao.entity.ActivityCalendar; -import java.io.IOException; -import java.nio.charset.Charset; -import java.util.Date; -import java.util.Properties; -import org.apache.commons.lang.RandomStringUtils; -import org.apache.commons.lang.StringUtils; -import org.apache.commons.mail.EmailException; -import org.apache.commons.mail.SimpleEmail; -import org.apache.log4j.Level; -import org.apache.log4j.PatternLayout; -import org.apache.log4j.RollingFileAppender; -import org.hibernate.exception.SQLGrammarException; -import org.nuiton.topia.TopiaContext; -import org.nuiton.topia.TopiaContextFactory; -import org.nuiton.topia.TopiaException; -import org.nuiton.topia.TopiaNotFoundException; -import org.nuiton.topia.persistence.TopiaEntity; -import org.nuiton.topia.persistence.TopiaId; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * WaoContext.java - * - * Created on 2009-11-23 - * - * @author fdesbois - * @version $Revision$ - * - * Last update: $Date$ - * by : $Author$ - */ -public class WaoContextO { - - private static final Logger log = LoggerFactory.getLogger(WaoContextO.class); - - private static WaoRunner runner; - - private static boolean activityCalendarImport; - - private static org.apache.log4j.Logger activityCalendarAccessLogger; - - private static WaoContextImpl context; - - public static void setContext(WaoContextImpl context) { - if (log.isDebugEnabled()) { - log.debug("#### use correct context"); - } - WaoContextO.context = context; - } - - public static void setRunner(WaoRunner run) { - if (log.isDebugEnabled()) { - log.debug("set runner in context"); - } - runner = run; - } - - public static Date getCurrentDate() { - return context.getCurrentDate(); - } - - public static String getProperty(String key) { - return context.getConfiguration().getOption(key); - } - - public static TopiaContext getTopiaRootContext() throws WaoExceptionO { - if (context.getConfiguration() == null) { - throw new WaoExceptionO("Configuration must be set before initializing context"); - } - try { - Properties props = context.getConfiguration().getOptions(); - return TopiaContextFactory.getContext(props); - } catch (TopiaNotFoundException eee) { - serviceException(null, eee.getMessage(), eee); - } - return null; - } - - public static void setActivityCalendarImport(boolean value) { - activityCalendarImport = value; - } - - public static boolean isActivityCalendarImportRun() { - return activityCalendarImport; - } - - public static void addActivityCalendarAccessLog(String message) throws IOException { - if (activityCalendarAccessLogger == null) { - // Define appender configuration only once - String filename = - WaoProperty.FILENAME_LOG_ACTIVITY_ACCESS.getValue(); - - PatternLayout layout = new PatternLayout(); - layout.setConversionPattern("%d %m%n"); - RollingFileAppender appender = new RollingFileAppender(); - appender.setName("ActivityCalendarAccess"); - appender.setFile(filename); - appender.setImmediateFlush(true); - appender.setMaxFileSize("2MB"); - appender.setMaxBackupIndex(10); - appender.setAppend(true); - appender.setThreshold(Level.INFO); - appender.setLayout(layout); - appender.activateOptions(); - - activityCalendarAccessLogger = - org.apache.log4j.Logger.getLogger(ActivityCalendar.class); - - activityCalendarAccessLogger.addAppender(appender); - } - - if (log.isDebugEnabled()) { - log.debug("message : " + message); - } - - activityCalendarAccessLogger.info(message); - } - - public static void serviceException(TopiaContext transaction, String message, Exception eee) throws WaoExceptionO { - if (log.isDebugEnabled()) { - log.debug("An error occured",eee); - } - if (!(eee instanceof WaoExceptionO)) { - //if (!(eee instanceof TopiaException)) { - try { - if (transaction != null && !transaction.isClosed()) { - if (log.isInfoEnabled()) { - log.info("Saving annulation : Transaction rollback"); - } - transaction.rollbackTransaction(); - //transaction.closeContext(); - } - } catch (TopiaException eeee) { - throw new WaoExceptionO("Fatal topia error when close context", eeee); - } - //} - if (eee instanceof SQLGrammarException && log.isErrorEnabled()) { - log.error("SQL executed with error : " + ((SQLGrammarException)eee).getSQL()); - } - throw new WaoExceptionO(message,eee); - } else { - throw (WaoExceptionO)eee; - } - } - - public static void closeTransaction(TopiaContext transaction) throws WaoExceptionO { - try { - if (transaction != null) { - transaction.closeContext(); - } - } catch (TopiaException eee) { - throw new WaoExceptionO("Fatal topia error when close context", eee); - } - } - - /** - * Generate a random string of "length" character alphanumeric. - * @param length number of characters for the final string - * @return a String of "length" character - */ - public static String createRandomString(int length) { -// Random random = new Random(); -// StringBuilder sb = new StringBuilder(); -// while (sb.length() < length) { -// sb.append(Integer.toHexString(random.nextInt())); -// } -// return sb.toString(); - return RandomStringUtils.randomAlphanumeric(length); - } - - public static String encodeString(String string) { - return MD5.encode(string); - } - - public static String convertId(String topiaId) { - if (topiaId != null && !topiaId.isEmpty()) { - int index = topiaId.indexOf('#'); - String id = topiaId.replace('#', 'K'); - return id.substring(index); - } - return ""; - } - - public static Charset getCsvCharset() { - return Charset.forName("UTF-8"); - } - - public static String prepareSampleRowCode(String code) { - // Replace single number after year by a double one : 2010_111 -> 2010_0111 - code = code.replaceFirst("_(\\d{3})$", "_0$1"); - // Replace single number after year by a double one : 2010_11 -> 2010_0011 - code = code.replaceFirst("_(\\d{2})$", "_00$1"); - // Replace single number after year by a double one : 2010_1 -> 2010_0001 - code = code.replaceFirst("_(\\d)$", "_000$1"); - return code; - } - - public static <E extends TopiaEntity> boolean prepareTopiaId(Class<E> entityClass, E entity) { - String topiaId = entity.getTopiaId(); - // TODO-FD20100211 : add this behavior in topia in a - // new method createOrUpdate - if (StringUtils.isEmpty(entity.getTopiaId())) { - topiaId = TopiaId.create(entityClass); - entity.setTopiaId(topiaId); - return true; - } - return false; - } - - public static void sendEmail(String to, String subject, String msg) throws EmailException { - SimpleEmail email = new SimpleEmail(); - email.setHostName(WaoProperty.EMAIL_HOST.getValue()); - email.setSmtpPort(Integer.parseInt(WaoProperty.EMAIL_PORT.getValue())); - email.setFrom(WaoProperty.EMAIL_FROM.getValue()); - email.addTo(to); - email.setSubject(subject); - email.setMsg(msg); - email.setCharset("UTF-8"); - email.send(); - } -} Deleted: trunk/wao-business/src/main/java/fr/ifremer/wao/WaoExceptionO.java =================================================================== --- trunk/wao-business/src/main/java/fr/ifremer/wao/WaoExceptionO.java 2010-04-01 17:14:29 UTC (rev 408) +++ trunk/wao-business/src/main/java/fr/ifremer/wao/WaoExceptionO.java 2010-04-01 18:21:22 UTC (rev 409) @@ -1,44 +0,0 @@ -/* - * *##% - * Wao :: Business - * Copyright (C) 2009 - 2010 Ifremer - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 Lesser Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * ##%* - */ - -package fr.ifremer.wao; - -/** - * WaoException - * - * Created: 7 nov. 2009 - * - * @author fdesbois - * @version $Revision$ - * - * Mise a jour: $Date$ - * par : $Author$ - */ -public class WaoExceptionO extends Exception { - - public WaoExceptionO(String msg) { - super(msg); - } - - public WaoExceptionO(String msg, Throwable cause) { - super(msg, cause); - } -} Modified: trunk/wao-business/src/main/java/fr/ifremer/wao/WaoGlobal.java =================================================================== --- trunk/wao-business/src/main/java/fr/ifremer/wao/WaoGlobal.java 2010-04-01 17:14:29 UTC (rev 408) +++ trunk/wao-business/src/main/java/fr/ifremer/wao/WaoGlobal.java 2010-04-01 18:21:22 UTC (rev 409) @@ -26,6 +26,7 @@ import fr.ifremer.wao.entity.CompanyDAO; import fr.ifremer.wao.entity.WaoUser; import fr.ifremer.wao.entity.WaoUserDAO; +import org.nuiton.i18n.I18n; import org.nuiton.topia.TopiaContext; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -50,10 +51,11 @@ * * @throws WaoException */ - static void createDefaultAdmin() throws WaoExceptionO { + static void createDefaultAdmin(WaoContextImplementor context) + throws WaoException { TopiaContext transaction = null; try { - transaction = WaoContextO.getTopiaRootContext().beginTransaction(); + transaction = context.beginTransaction(); WaoUserDAO dao = WaoDAOHelper.getWaoUserDAO(transaction); @@ -73,7 +75,7 @@ Company company = companyDAO.create(Company.ACTIVE, false, Company.NAME, "ADMIN"); - String password = WaoContextO.encodeString("password"); + String password = context.encodeString("password"); WaoUser user = dao.create( WaoUser.ROLE, UserRole.ADMIN.ordinal(), @@ -89,9 +91,11 @@ //transaction.closeContext(); } catch (Exception eee) { - WaoContextO.serviceException(null, "Error during database initialization", eee); + context.doCatch(transaction, eee, + I18n.n_("wao.error.global.createDefaultAdmin")); + //Error during database initialization", eee); } finally { - WaoContextO.closeTransaction(transaction); + context.doFinally(transaction); } } Modified: trunk/wao-business/src/main/java/fr/ifremer/wao/WaoProperty.java =================================================================== --- trunk/wao-business/src/main/java/fr/ifremer/wao/WaoProperty.java 2010-04-01 17:14:29 UTC (rev 408) +++ trunk/wao-business/src/main/java/fr/ifremer/wao/WaoProperty.java 2010-04-01 18:21:22 UTC (rev 409) @@ -48,6 +48,6 @@ if (context != null) { return context.getProperty(this); } - return WaoContextO.getProperty(key); + return null; } } Deleted: trunk/wao-business/src/main/java/fr/ifremer/wao/WaoRunner.java =================================================================== --- trunk/wao-business/src/main/java/fr/ifremer/wao/WaoRunner.java 2010-04-01 17:14:29 UTC (rev 408) +++ trunk/wao-business/src/main/java/fr/ifremer/wao/WaoRunner.java 2010-04-01 18:21:22 UTC (rev 409) @@ -1,68 +0,0 @@ -/* - * *##% - * Wao :: Business - * Copyright (C) 2009 - 2010 Ifremer - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 Lesser Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * ##%* - */ - -package fr.ifremer.wao; - -import java.util.Date; -import org.nuiton.util.ApplicationConfig; - -/** - * WaoRun - * - * Created: 24 nov. 2009 - * - * @author fdesbois - * @version $Revision$ - * - * Mise a jour: $Date$ - * par : $Author$ - */ -public interface WaoRunner { - - /** - * Start the application. - * - * @throws WaoException - */ - void start() throws WaoExceptionO; - - /** - * Stop the application. - * - * @throws WaoException - */ - void stop() throws WaoExceptionO; - - /** - * Return the current date, depends on environment. - * - * @return the current Date - */ - Date getCurrentDate(); - - /** - * Return the configuration depends on environment. - * - * @return the ApplicationConfig which contains the application properties - */ - ApplicationConfig getConfiguration(); - -} Deleted: trunk/wao-business/src/main/java/fr/ifremer/wao/WaoRunnerImpl.java =================================================================== --- trunk/wao-business/src/main/java/fr/ifremer/wao/WaoRunnerImpl.java 2010-04-01 17:14:29 UTC (rev 408) +++ trunk/wao-business/src/main/java/fr/ifremer/wao/WaoRunnerImpl.java 2010-04-01 18:21:22 UTC (rev 409) @@ -1,130 +0,0 @@ -/* - * *##% - * Wao :: Business - * Copyright (C) 2009 - 2010 Ifremer - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 Lesser Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * ##%* - */ - -package fr.ifremer.wao; - -import java.util.Date; -import java.util.Locale; - -import org.nuiton.i18n.I18n; -import org.nuiton.topia.TopiaException; -import org.nuiton.topia.migration.ManualMigrationEngine; -import org.nuiton.util.ApplicationConfig; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * StartWao - * - * Created: 24 nov. 2009 - * - * @author fdesbois - * @version $Revision$ - * - * Mise a jour: $Date$ - * par : $Author$ - */ -public class WaoRunnerImpl implements WaoRunner { - - private ApplicationConfig configuration; - - private static final Logger logger = - LoggerFactory.getLogger(WaoRunnerImpl.class); - - public WaoRunnerImpl() { - } - - @Override - public void start() throws WaoExceptionO { - try { - configuration = new ApplicationConfig(); - configuration.setAppName("wao"); - configuration.setConfigFileName("Wao.properties"); - configuration.parse(new String[]{}); - configuration.setOption("topia.persistence.classes", - WaoDAOHelper.getImplementationClassesAsString()); - - // migration configuration - String callBackName = null; - String dialect = configuration.getOption("hibernate.dialect"); - if (dialect.contains("PostgreSQL")) { - callBackName = PgMigrationCallback.class.getName(); - } else if (dialect.contains("H2")) { - // Unsupported yet - callBackName = null; - } - - if (callBackName != null) { - configuration.setOption( - ManualMigrationEngine.MIGRATION_APPLICATION_VERSION, - WaoDAOHelper.getModelVersion()); - configuration.setOption( - ManualMigrationEngine.MIGRATION_MAPPING_DIRECTORY, - "oldmappings"); - configuration.setOption( - ManualMigrationEngine.MIGRATION_MODEL_NAME, - WaoDAOHelper.getModelName()); - configuration.setOption( - "topia.service.migration", - ManualMigrationEngine.class.getName()); - configuration.setOption( - ManualMigrationEngine.MIGRATION_CALLBACK, - callBackName); - } else { - if (logger.isWarnEnabled()) { - logger.warn("Database with dialect " + dialect + " is not" + - "supported for migration from 1.0 version"); - } - } - - configuration.printConfig(); - - I18n.init(Locale.FRANCE); - // Use the context to set the runner for default environment. - WaoContextO.setRunner(this); - // Create the default admin in database - WaoGlobal.createDefaultAdmin(); - } catch (Exception eee) { - WaoContextO.serviceException(null, - "Error during loadConfiguration from " + - "'Wao.properties' file", eee); - } - } - - @Override - public void stop() throws WaoExceptionO { - try { - WaoContextO.getTopiaRootContext().closeContext(); - } catch (TopiaException eee) { - WaoContextO.serviceException(null, "Error when closing Topia root context", eee); - } - } - - @Override - public Date getCurrentDate() { - return new Date(); - } - - @Override - public ApplicationConfig getConfiguration() { - return configuration; - } -} Modified: trunk/wao-business/src/main/java/fr/ifremer/wao/bean/SamplingFilterImpl.java =================================================================== --- trunk/wao-business/src/main/java/fr/ifremer/wao/bean/SamplingFilterImpl.java 2010-04-01 17:14:29 UTC (rev 408) +++ trunk/wao-business/src/main/java/fr/ifremer/wao/bean/SamplingFilterImpl.java 2010-04-01 18:21:22 UTC (rev 409) @@ -21,13 +21,12 @@ package fr.ifremer.wao.bean; -import fr.ifremer.wao.WaoContextO; +import fr.ifremer.wao.WaoUtils; import fr.ifremer.wao.entity.FishingZone; import fr.ifremer.wao.entity.SampleRow; import java.util.Calendar; import java.util.GregorianCalendar; import org.apache.commons.lang.StringUtils; -import org.nuiton.topia.TopiaException; import org.nuiton.topia.framework.TopiaQuery; import org.nuiton.topia.framework.TopiaQuery.Op; @@ -95,7 +94,7 @@ // Only rows which are not finished will be kept // Date current = WaoContext.getCurrentDate(); Calendar calendar = new GregorianCalendar(); - calendar.setTime(WaoContextO.getCurrentDate()); + calendar.setTime(WaoUtils.getCurrentDate()); calendar.add(Calendar.MONTH, getNbMonthFinishedFromToday()); query.add(main + "." + SampleRow.PERIOD_END, Op.GE, calendar.getTime()); } @@ -106,7 +105,8 @@ @Override public boolean isSamplingFiltered() { // all field except fromDate - return getSampleRow() != null || StringUtils.isNotEmpty(getSectorName()) || StringUtils.isNotEmpty(getFacadeName()) || + return getSampleRow() != null || StringUtils.isNotEmpty(getSectorName()) + || StringUtils.isNotEmpty(getFacadeName()) || getPeriod() != null || getProfession() != null; } Modified: trunk/wao-business/src/main/java/fr/ifremer/wao/io/ImportHelper.java =================================================================== --- trunk/wao-business/src/main/java/fr/ifremer/wao/io/ImportHelper.java 2010-04-01 17:14:29 UTC (rev 408) +++ trunk/wao-business/src/main/java/fr/ifremer/wao/io/ImportHelper.java 2010-04-01 18:21:22 UTC (rev 409) @@ -59,6 +59,8 @@ LoggerFactory.getLogger(ImportHelper.class); protected CsvReader reader; + + protected static WaoContextImplementor context; // 2000 -> 2099 public static final int CURRENT_MILLENIUM = 2000; @@ -70,6 +72,10 @@ this.reader = reader; } + public static void setContext(WaoContextImplementor context) { + ImportHelper.context = context; + } + public static Boolean parseContactValidation(CsvReader reader, IOHeader header) throws IOException { String validation = read(reader, header); Boolean result = null; @@ -94,7 +100,7 @@ time.setTime(timeFormat.parse(code)); } else { // Use current date with no time as a reference if no code is set - time.setTime(WaoContextO.getCurrentDate()); + time.setTime(context.getCurrentDate()); time.set(Calendar.HOUR_OF_DAY, 0); time.set(Calendar.MINUTE, 0); time.set(Calendar.SECOND, 0); @@ -110,14 +116,14 @@ result.set(Calendar.SECOND, time.get(Calendar.SECOND)); result.set(Calendar.MILLISECOND, time.get(Calendar.MILLISECOND)); } else { - result.setTime(WaoContextO.getCurrentDate()); + result.setTime(context.getCurrentDate()); } return result.getTime(); } public static String readSampleRowCode(CsvReader reader) throws IOException { String code = read(reader, SAMPLING.PLAN_CODE); - return WaoContextO.prepareSampleRowCode(code); + return context.prepareSampleRowCode(code); } /** Modified: trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceContactImpl.java =================================================================== --- trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceContactImpl.java 2010-04-01 17:14:29 UTC (rev 408) +++ trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceContactImpl.java 2010-04-01 18:21:22 UTC (rev 409) @@ -28,7 +28,6 @@ import fr.ifremer.wao.WaoBusinessException; import fr.ifremer.wao.WaoBusinessException.Type; import fr.ifremer.wao.WaoDAOHelper; -import fr.ifremer.wao.WaoExceptionO; import fr.ifremer.wao.bean.ContactState; import java.io.IOException; import java.io.InputStream; @@ -64,14 +63,11 @@ import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; -import java.util.Arrays; import java.util.Date; -import java.util.HashMap; import java.util.List; import java.util.Map; import org.apache.commons.lang.BooleanUtils; import org.apache.commons.lang.StringUtils; -import org.apache.commons.lang.time.DurationFormatUtils; import org.nuiton.topia.TopiaContext; import org.nuiton.topia.TopiaException; import org.nuiton.topia.persistence.TopiaEntity; @@ -91,91 +87,39 @@ */ public class ServiceContactImpl extends ServiceContactAbstract { - private static final Logger log = LoggerFactory.getLogger(ServiceContactImpl.class); + private static final Logger log = + LoggerFactory.getLogger(ServiceContactImpl.class); -// protected TopiaContext rootContext; -// -// public ServiceContactImpl() throws WaoExceptionO { -// rootContext = context.getTopiaRootContext(); -// } - @Override public Map<String, Contact> executeGetContacts(TopiaContext transaction, ContactFilter filter) throws TopiaException { -// Map<String, Contact> results = new HashMap<String, Contact>(); -// TopiaContext transaction = null; -// try { -// long startTime = 0; -// if (log.isDebugEnabled()) { -// startTime = System.currentTimeMillis(); -// } -// transaction = rootContext.beginTransaction(); - ContactDAO dao = WaoDAOHelper.getContactDAO(transaction); + ContactDAO dao = WaoDAOHelper.getContactDAO(transaction); - TopiaQuery query = dao.createQuery("C").addDistinct(); + TopiaQuery query = dao.createQuery("C").addDistinct(); - query = filter.prepareQueryForContact(query); + query = filter.prepareQueryForContact(query); - query.addOrderDesc("C." + TopiaEntity.TOPIA_CREATE_DATE).addLoad(Contact.OBSERVER + "." + WaoUser.COMPANY); + query.addOrderDesc("C." + TopiaEntity.TOPIA_CREATE_DATE). + addLoad(Contact.OBSERVER + "." + WaoUser.COMPANY); - if (log.isDebugEnabled()) { - log.debug("Query : " + query); - } + if (log.isDebugEnabled()) { + log.debug("Query : " + query); + } - query.addLoad(Contact.SAMPLE_ROW + "." + SampleRow.SAMPLE_MONTH); - return dao.findAllMappedByQuery(query); - -// if (log.isDebugEnabled()) { -// long stopTime = System.currentTimeMillis(); -// log.debug("W:[ getContacts ] Time = " + -// DurationFormatUtils.formatDurationHMS( -// stopTime - startTime)); -// } -// -// //transaction.closeContext(); -// } catch (Exception eee) { -// context.serviceException(transaction, -// "Impossible de filtrer la liste des contacts", eee); -// } finally { -// context.closeTransaction(transaction); -// } -// return results; + query.addLoad(Contact.SAMPLE_ROW + "." + SampleRow.SAMPLE_MONTH); + return dao.findAllMappedByQuery(query); } @Override public int executeGetNbContacts(TopiaContext transaction, ContactFilter filter) throws TopiaException { -// TopiaContext transaction = null; -// int result = 0; -// try { -// long startTime = 0; -// if (log.isDebugEnabled()) { -// startTime = System.currentTimeMillis(); -// } -// transaction = rootContext.beginTransaction(); - ContactDAO dao = WaoDAOHelper.getContactDAO(transaction); - TopiaQuery query = dao.createQuery("C"); - query = filter.prepareQueryForContact(query); + ContactDAO dao = WaoDAOHelper.getContactDAO(transaction); + TopiaQuery query = dao.createQuery("C"); + query = filter.prepareQueryForContact(query); - return query.executeCount(); - -// if (log.isDebugEnabled()) { -// long stopTime = System.currentTimeMillis(); -// log.debug("W:[ getNbContacts ] Time = " + -// DurationFormatUtils.formatDurationHMS( -// stopTime - startTime)); -// } -// -// //transaction.closeContext(); -// } catch (Exception eee) { -// context.serviceException(transaction, -// "Impossible de compter le nombre de contacts filtrés", eee); -// } finally { -// context.closeTransaction(transaction); -// } -// return result; + return query.executeCount(); } @Override @@ -191,52 +135,29 @@ @Override public void executeSaveContact(TopiaContext transaction, Contact contact, boolean delete) throws TopiaException { -// TopiaContext transaction = null; -// try { -// long startTime = 0; -// if (log.isDebugEnabled()) { -// startTime = System.currentTimeMillis(); -// } -// transaction = rootContext.beginTransaction(); - ContactDAO dao = WaoDAOHelper.getContactDAO(transaction); + ContactDAO dao = WaoDAOHelper.getContactDAO(transaction); - if (log.isDebugEnabled()) { - log.debug("Create date : " + contact.getTopiaCreateDate()); - } + if (log.isDebugEnabled()) { + log.debug("Create date : " + contact.getTopiaCreateDate()); + } - context.prepareTopiaId(Contact.class, contact); - if (delete) { - dao.delete(contact); - } else { - dao.update(contact); - } + context.prepareTopiaId(Contact.class, contact); + if (delete) { + dao.delete(contact); + } else { + dao.update(contact); + } - transaction.commitTransaction(); - -// if (log.isDebugEnabled()) { -// long stopTime = System.currentTimeMillis(); -// log.debug("W:[ saveContact ] Time = " + -// DurationFormatUtils.formatDurationHMS( -// stopTime - startTime)); -// } -// //transaction.closeContext(); -// } catch (Exception eee) { -// context.serviceException(transaction, -// "Impossible de sauvegarder le contact", eee); -// } finally { -// context.closeTransaction(transaction); -// } + transaction.commitTransaction(); } @Override public InputStream executeExportContactCsv(TopiaContext transaction, ContactFilter filter) throws Exception { -// TopiaContext transaction = null; -// InputStream result = null; + CsvWriter writer = null; try { -// transaction = rootContext.beginTransaction(); File file = File.createTempFile("wao-contacts-", ".csv"); file.deleteOnExit(); @@ -248,7 +169,9 @@ FileOutputStream output = new FileOutputStream(file); writer = new CsvWriter(output, ',', context.getCsvCharset()); - ExportHelper<ContactHeader> export = new ExportHelper<ContactHeader>(writer, CONTACT.getTotalHeaders()) { + ExportHelper<ContactHeader> export = + new ExportHelper<ContactHeader>(writer, + CONTACT.getTotalHeaders()) { @Override public void record(ContactHeader header, String value) { @@ -256,9 +179,11 @@ } @Override - protected String getHeaderValue(int index) throws IOException { + protected String getHeaderValue(int index) + throws IOException { if (log.isDebugEnabled()) { - log.debug("record header : " + index + " = " + WaoCsvHeader.getHeaderForContactCsv(index)); + log.debug("record header : " + index + " = " + + WaoCsvHeader.getHeaderForContactCsv(index)); } return WaoCsvHeader.getHeaderForContactCsv(index); } @@ -288,24 +213,36 @@ export.newRecord(); // Contact part - export.record(CONTACT.CONT_CODE, timeFormat.format(contact.getTopiaCreateDate())); - export.record(CONTACT.CONT_CREATION, dateFormat.format(contact.getTopiaCreateDate())); - export.record(CONTACT.CONT_ETAT, contact.getContactState().libelle()); + export.record(CONTACT.CONT_CODE, + timeFormat.format(contact.getTopiaCreateDate())); + export.record(CONTACT.CONT_CREATION, + dateFormat.format(contact.getTopiaCreateDate())); + export.record(CONTACT.CONT_ETAT, + contact.getContactState().libelle()); if (contact.getTideBeginDate() != null) { - export.record(CONTACT.CONT_DEBUT_MAREE, dateFormat.format(contact.getTideBeginDate())); + export.record(CONTACT.CONT_DEBUT_MAREE, + dateFormat.format(contact.getTideBeginDate())); } if (contact.getTideEndDate() != null) { - export.record(CONTACT.CONT_FIN_MAREE, dateFormat.format(contact.getTideEndDate())); + export.record(CONTACT.CONT_FIN_MAREE, + dateFormat.format(contact.getTideEndDate())); } - export.record(CONTACT.CONT_NB_OBSERV, String.valueOf(contact.getNbObservants())); - export.record(CONTACT.CONT_MAM_CAPT, CONTACT.formatMammals(contact.getMammalsCapture())); - export.record(CONTACT.CONT_MAM_OBS, CONTACT.formatMammals(contact.getMammalsObservation())); - export.record(CONTACT.CONT_COMMENT, contact.getComment()); + export.record(CONTACT.CONT_NB_OBSERV, + String.valueOf(contact.getNbObservants())); + export.record(CONTACT.CONT_MAM_CAPT, + CONTACT.formatMammals(contact.getMammalsCapture())); + export.record(CONTACT.CONT_MAM_OBS, + CONTACT.formatMammals(contact.getMammalsObservation())); + export.record(CONTACT.CONT_COMMENT, + contact.getComment()); if (contact.getDataInputDate() != null) { - export.record(CONTACT.CONT_ALLEGRO, dateFormat.format(contact.getDataInputDate())); + export.record(CONTACT.CONT_ALLEGRO, + dateFormat.format(contact.getDataInputDate())); } - export.record(CONTACT.CONT_SOCIETE_VALID, CONTACT.formatValidation(contact.getValidationCompany())); - export.record(CONTACT.CONT_PROGRAM_VALID, CONTACT.formatValidation(contact.getValidationProgram())); + export.record(CONTACT.CONT_SOCIETE_VALID, + CONTACT.formatValidation(contact.getValidationCompany())); + export.record(CONTACT.CONT_PROGRAM_VALID, + CONTACT.formatValidation(contact.getValidationProgram())); // Observer part WaoUser observer = contact.getObserver(); @@ -319,9 +256,12 @@ SampleRow row = contact.getSampleRow(); export.record(SAMPLING.PLAN_CODE, row.getCode()); export.record(SAMPLING.PROGRAMME_CODE, row.getProgramName()); - export.record(SAMPLING.PROGRAMME_DEBUT, dateFormat.format(row.getPeriodBegin())); - export.record(SAMPLING.PROGRAMME_FIN, dateFormat.format(row.getPeriodEnd())); - export.record(SAMPLING.PECHE_AUTRE, row.getFishingZonesInfos()); + export.record(SAMPLING.PROGRAMME_DEBUT, + dateFormat.format(row.getPeriodBegin())); + export.record(SAMPLING.PROGRAMME_FIN, + dateFormat.format(row.getPeriodEnd())); + export.record(SAMPLING.PECHE_AUTRE, + row.getFishingZonesInfos()); // FishingZone part String divisions = ""; @@ -329,14 +269,17 @@ for (FishingZone zone : row.getFishingZone()) { divisions += separator + zone.getDistrictCode(); } - export.record(FISHING_ZONE.PECHE_DIVISION, divisions.substring(separator.length())); + export.record(FISHING_ZONE.PECHE_DIVISION, + divisions.substring(separator.length())); export.record(FISHING_ZONE.PECHE_FACADE, row.getFacade()); export.record(FISHING_ZONE.PECHE_ZONE, row.getSectors()); // Profession part Profession profession = row.getProfession(); - export.record(SAMPLING.METIER_CODE_DCF5, profession.getCodeDCF5()); - export.record(SAMPLING.METIER_MAILLAGE, profession.getMeshSize()); + export.record(SAMPLING.METIER_CODE_DCF5, + profession.getCodeDCF5()); + export.record(SAMPLING.METIER_MAILLAGE, + profession.getMeshSize()); export.record(SAMPLING.METIER_TAILLE, profession.getSize()); export.record(SAMPLING.METIER_AUTRE, profession.getOther()); export.record(SAMPLING.METIER_LIBELLE, profession.getLibelle()); @@ -344,7 +287,8 @@ // Boat part Boat boat = contact.getBoat(); - export.record(BOAT.NAVS_COD, String.valueOf(boat.getImmatriculation())); + export.record(BOAT.NAVS_COD, + String.valueOf(boat.getImmatriculation())); export.record(BOAT.CARN_NOM, boat.getName()); export.record(BOAT.QUARTIER_IMMA, boat.getDistrictCode()); @@ -352,18 +296,13 @@ } return new FileInputStream(file); - //transaction.closeContext(); } catch (Exception eee) { throw eee; -// context.serviceException(transaction, -// "Impossible d'exporter les contacts", eee); } finally { if (writer != null) { writer.close(); } -// context.closeTransaction(transaction); } -// return result; } @Override @@ -371,189 +310,221 @@ WaoUser user, InputStream input) throws TopiaException, IOException, WaoBusinessException, ParseException { -// TopiaContext transaction = null; + ImportResults result = new ImportResultsImpl(); int currRow = 1; -// CsvReader reader = null; -// try { -// transaction = rootContext.beginTransaction(); - CsvReader reader = new CsvReader(input, context.getCsvCharset()); - reader.readHeaders(); + CsvReader reader = new CsvReader(input, context.getCsvCharset()); + reader.readHeaders(); - ContactDAO dao = WaoDAOHelper.getContactDAO(transaction); - WaoUserDAO userDAO = WaoDAOHelper.getWaoUserDAO(transaction); - CompanyDAO companyDAO = WaoDAOHelper.getCompanyDAO(transaction); - SampleRowDAO rowDAO = WaoDAOHelper.getSampleRowDAO(transaction); - BoatDAO boatDAO = WaoDAOHelper.getBoatDAO(transaction); - - long tic; - tic = System.currentTimeMillis(); - while(reader.readRecord()) { - currRow++; + ContactDAO dao = WaoDAOHelper.getContactDAO(transaction); + WaoUserDAO userDAO = WaoDAOHelper.getWaoUserDAO(transaction); + SampleRowDAO rowDAO = WaoDAOHelper.getSampleRowDAO(transaction); + BoatDAO boatDAO = WaoDAOHelper.getBoatDAO(transaction); - String observerId = ImportHelper.read(reader, CONTACT.OBSERV_ID); - String state = ImportHelper.read(reader, CONTACT.CONT_ETAT); + long tic; + tic = System.currentTimeMillis(); + while(reader.readRecord()) { + currRow++; - ContactState contactState = ContactState.valueOfLibelle(state); + String observerId = ImportHelper.read(reader, CONTACT.OBSERV_ID); + String state = ImportHelper.read(reader, CONTACT.CONT_ETAT); - if (contactState == null) { - throw new WaoBusinessException(Type.IMPORT_ERROR, this.getClass(), + ContactState contactState = ContactState.valueOfLibelle(state); + + if (contactState == null) { + throw new WaoBusinessException(Type.IMPORT_ERROR, + this.getClass(), + "Erreur ligne " + currRow + " : " + + "Etat du contact invalide '" + state + "', " + + "valeurs possibles : " + + ContactState.availableStates()); + } + + WaoUser observer = userDAO.findByLogin(observerId); + if (observer != null) { + Company company = user.getCompany(); + // For an admin, get the company from database + if (user.isAdmin()) { + // FIXME-FD20100104 findContains not optimized in TopiaDAOImpl + //company = companyDAO.findContainsWaoUser(observer); + company = observer.getCompany(); + // For a user, check if the observer as the same company as the current user + } else if (!observer.getCompany().equals(company)) { + throw new WaoBusinessException(Type.IMPORT_ERROR, + this.getClass(), "Erreur ligne " + currRow + " : " + - "Etat du contact invalide '" + state + "', valeurs possibles : " + - ContactState.availableStates()); + "L'observateur avec pour login '" + observerId + + "' n'appartient pas à votre société !"); } - WaoUser observer = userDAO.findByLogin(observerId); - if (observer != null) { - Company company = user.getCompany(); - // For an admin, get the company from database - if (user.isAdmin()) { - // FIXME-FD20100104 findContains not optimized in TopiaDAOImpl - //company = companyDAO.findContainsWaoUser(observer); - company = observer.getCompany(); - // For a user, check if the observer as the same company as the current user - } else if (!observer.getCompany().equals(company)) { - throw new WaoBusinessException(Type.IMPORT_ERROR, this.getClass(), - "Erreur ligne " + currRow + " : " + - "L'observateur avec pour login '" + observerId + "' n'appartient pas à votre société !"); - } + if (company != null) { + String rowCode = ImportHelper.readSampleRowCode(reader); - if (company != null) { - String rowCode = ImportHelper.readSampleRowCode(reader); + SampleRow row = rowDAO.findByProperties( + SampleRow.CODE, rowCode, + SampleRow.COMPANY, company); - SampleRow row = rowDAO.findByProperties(SampleRow.CODE, rowCode, SampleRow.COMPANY, company); + if (row != null) { + int boatImmatriculation = + ImportHelper.readInt(reader, BOAT.NAVS_COD); - if (row != null) { - int boatImmatriculation = ImportHelper.readInt(reader, BOAT.NAVS_COD); + Boat boat = boatDAO.findByImmatriculation( + boatImmatriculation); - Boat boat = boatDAO.findByImmatriculation(boatImmatriculation); + if (boat != null) { - if (boat != null) { + ElligibleBoatDAO elligibleDAO = + WaoDAOHelper.getElligibleBoatDAO(transaction); + ElligibleBoat elligible = + elligibleDAO.findByProperties( + ElligibleBoat.BOAT, boat, + ElligibleBoat.SAMPLE_ROW, row); - ElligibleBoatDAO elligibleDAO = WaoDAOHelper.getElligibleBoatDAO(transaction); - ElligibleBoat elligible = elligibleDAO.findByProperties( - ElligibleBoat.BOAT, boat, ElligibleBoat.SAMPLE_ROW, row); - - if (elligible == null) { - // Create new elligible boat not active in a global way - elligible = elligibleDAO.create( - ElligibleBoat.BOAT, boat, ElligibleBoat.SAMPLE_ROW, row); - if (log.isTraceEnabled()) { - log.trace("Create elligibleBoat for : " + boat.getImmatriculation() + " - " + row.getCode()); - } + if (elligible == null) { + // Create new elligible boat not active in a global way + elligible = elligibleDAO.create( + ElligibleBoat.BOAT, boat, + ElligibleBoat.SAMPLE_ROW, row); + if (log.isTraceEnabled()) { + log.trace("Create elligibleBoat for : " + + boat.getImmatriculation() + " - " + + row.getCode()); } - elligible.setCompanyActive(Boolean.TRUE); + } + elligible.setCompanyActive(Boolean.TRUE); - Contact contact = null; + Contact contact = null; - String createDateString = ImportHelper.read(reader, CONTACT.CONT_CREATION); - String contactCode = ImportHelper.read(reader, CONTACT.CONT_CODE); - Date createDate = ImportHelper.parseContactCreateDate(contactCode, createDateString); + String createDateString = + ImportHelper.read(reader, + CONTACT.CONT_CREATION); + String contactCode = + ImportHelper.read(reader, + CONTACT.CONT_CODE); + Date createDate = + ImportHelper.parseContactCreateDate( + contactCode, createDateString); - if (log.isDebugEnabled()) { - log.debug("Ligne " + currRow + " : Create date : " + createDate); - } + if (log.isDebugEnabled()) { + log.debug("Ligne " + currRow + + " : Create date : " + createDate); + } - if (/*!StringUtils.isEmpty(contactCode) && */StringUtils.isNotEmpty(createDateString)) { - // Get entity from database - TopiaQuery query = dao.createQuery(). - add(TopiaEntity.TOPIA_CREATE_DATE, createDate). - add(Contact.OBSERVER + "." + WaoUser.COMPANY, company). - add(Contact.BOAT, boat). - add(Contact.SAMPLE_ROW, row); - contact = dao.findByQuery(query); - } + if (/*!StringUtils.isEmpty(contactCode) && */ + StringUtils.isNotEmpty(createDateString)) { + // Get entity from database + TopiaQuery query = dao.createQuery(). + add(TopiaEntity.TOPIA_CREATE_DATE, + createDate). + add(Contact.OBSERVER + "." + + WaoUser.COMPANY, company). + add(Contact.BOAT, boat). + add(Contact.SAMPLE_ROW, row); + contact = dao.findByQuery(query); + } - if (contact != null && contact.getValidationCompany() != null) { - result.addError(currRow, "Le contact est déjà validé dans l'application et ne peut pas être importé"); - result.incNbRefused(); - continue; - } + if (contact != null && + contact.getValidationCompany() != null) { + result.addError(currRow, "Le contact est" + + " déjà validé dans l'application" + + " et ne peut pas être importé"); + result.incNbRefused(); + continue; + } - // new contact to import - boolean newContact = false; - if (contact == null) { - contact = dao.create( - TopiaEntity.TOPIA_CREATE_DATE, createDate, - Contact.SAMPLE_ROW, row, - Contact.BOAT, boat); - newContact = true; - } + // new contact to import + boolean newContact = false; + if (contact == null) { + contact = dao.create( + TopiaEntity.TOPIA_CREATE_DATE, createDate, + Contact.SAMPLE_ROW, row, + Contact.BOAT, boat); + newContact = true; + } - Date tideBegin = ImportHelper.readDate(reader, CONTACT.CONT_DEBUT_MAREE); - Date tideEnd = ImportHelper.readDate(reader, CONTACT.CONT_FIN_MAREE); - Date dataInput = ImportHelper.readDate(reader, CONTACT.CONT_ALLEGRO); - int nbObservants = ImportHelper.readInt(reader, CONTACT.CONT_NB_OBSERV); - if (nbObservants == -1) { - nbObservants = 0; - } - boolean mammalsCapture = - ImportHelper.parseContactMammals(reader, CONTACT.CONT_MAM_CAPT); - boolean mammalsObsv = - ImportHelper.parseContactMammals(reader, CONTACT.CONT_MAM_OBS); + Date tideBegin = + ImportHelper.readDate(reader, + CONTACT.CONT_DEBUT_MAREE); + Date tideEnd = + ImportHelper.readDate(reader, + CONTACT.CONT_FIN_MAREE); + Date dataInput = + ImportHelper.readDate(reader, + CONTACT.CONT_ALLEGRO); + int nbObservants = ImportHelper.readInt(reader, + CONTACT.CONT_NB_OBSERV); + if (nbObservants == -1) { + nbObservants = 0; + } + boolean mammalsCapture = + ImportHelper.parseContactMammals(reader, + CONTACT.CONT_MAM_CAPT); + boolean mammalsObsv = + ImportHelper.parseContactMammals(reader, + CONTACT.CONT_MAM_OBS); - contact.setObserver(observer); - contact.setContactState(contactState); - contact.setTideBeginDate(tideBegin); - contact.setTideEndDate(tideEnd); - contact.setNbObservants(nbObservants); - contact.setMammalsCapture(mammalsCapture); - contact.setMammalsObservation(mammalsObsv); - contact.setDataInputDate(dataInput); + contact.setObserver(observer); + contact.setContactState(contactState); + contact.setTideBeginDate(tideBegin); + contact.setTideEndDate(tideEnd); + contact.setNbObservants(nbObservants); + contact.setMammalsCapture(mammalsCapture); + contact.setMammalsObservation(mammalsObsv); + contact.setDataInputDate(dataInput); - // Import validations only for superadmin and a new contact : useful for archives - // FIXME : can update validation when the user is the super admin - if (newContact && user.isAdmin() && user.getLogin().equals("admin")) { - if (log.isDebugEnabled()) { - log.debug("SuperAdmin import :: validations"); - } - Boolean companyValidation = ImportHelper.parseContactValidation(reader, CONTACT.CONT_SOCIETE_VALID); - Boolean programValidation = ImportHelper.parseContactValidation(reader, CONTACT.CONT_PROGRAM_VALID); - contact.setValidationCompany(companyValidation); - contact.setValidationProgram(programValidation); + // Import validations only for superadmin and a new contact : useful for archives + // FIXME : can update validation when the user is the super admin + if (newContact && user.isAdmin() && user.getLogin().equals("admin")) { + if (log.isDebugEnabled()) { + log.debug("SuperAdmin import :: validations"); + } + Boolean companyValidation = ImportHelper.parseContactValidation(reader, CONTACT.CONT_SOCIETE_VALID); + Boolean programValidation = ImportHelper.parseContactValidation(reader, CONTACT.CONT_PROGRAM_VALID); + contact.setValidationCompany(companyValidation); + contact.setValidationProgram(programValidation); - // Add realTideTime for this contact if validations are ok and state is BOARDING_DONE - if (BooleanUtils.isTrue(companyValidation) && BooleanUtils.isNotFalse(programValidation) && - contact.getContactState().equals(ContactState.BOARDING_DONE)) { - boolean ok = contact.getSampleRow().addRealTideTime(contact); - if (!ok) { - DateFormat dateFormat1 = new SimpleDateFormat("MM/yyyy"); - result.addError(currRow, "Impossible de mettre à jour le nombre de marée réels, vérifiez le mois " + - "de " + dateFormat1.format(contact.getTideBeginDate()) + " pour la ligne du plan " + row.getCode()); - result.incNbRefused(); - continue; - } + // Add realTideTime for this contact if validations are ok and state is BOARDING_DONE + if (BooleanUtils.isTrue(companyValidation) && BooleanUtils.isNotFalse(programValidation) && + contact.getContactState().equals(ContactState.BOARDING_DONE)) { + boolean ok = contact.getSampleRow().addRealTideTime(contact); + if (!ok) { + DateFormat dateFormat1 = new SimpleDateFormat("MM/yyyy"); + result.addError(currRow, "Impossible de mettre à jour le nombre de marée réels, vérifiez le mois " + + "de " + dateFormat1.format(contact.getTideBeginDate()) + " pour la ligne du plan " + row.getCode()); + result.incNbRefused(); + continue; } } + } - result.incNbImported(); + result.incNbImported(); - } else { - result.addError(currRow, "Navire inexistant avec l'immatriculation : " + boatImmatriculation); - result.incNbRefused(); - } } else { - result.addError(currRow, "Ligne d'échantillon inexistante ou incompatible avec la société " + - "pour le code : " + rowCode); + result.addError(currRow, "Navire inexistant avec l'immatriculation : " + boatImmatriculation); result.incNbRefused(); } } else { - result.addError(currRow, "Cet utilisateur n'est lié à aucune société : " + user.getFullName()); + result.addError(currRow, "Ligne d'échantillon inexistante ou incompatible avec la société " + + "pour le code : " + rowCode); result.incNbRefused(); } } else { - result.addError(currRow, "Utilisateur inexistant avec l'identifiant : " + observerId); + result.addError(currRow, "Cet utilisateur n'est lié à aucune société : " + user.getFullName()); result.incNbRefused(); } + } else { + result.addError(currRow, "Utilisateur inexistant avec l'identifiant : " + observerId); + result.incNbRefused(); + } - if (result.getNbRowsImported() % 1000 == 0) { - transaction.commitTransaction(); - tic = ImportHelper.logTimeAndMemory(log, tic, "contacts ligne " + currRow); - } + if (result.getNbRowsImported() % 1000 == 0) { + transaction.commitTransaction(); + tic = ImportHelper.logTimeAndMemory(log, tic, "contacts ligne " + currRow); } + } - transaction.commitTransaction(); + transaction.commitTransaction(); //transaction.closeContext(); // } catch (ParseException eee) { Modified: trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceSynthesisImpl.java =================================================================== --- trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceSynthesisImpl.java 2010-04-01 17:14:29 UTC (rev 408) +++ trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceSynthesisImpl.java 2010-04-01 18:21:22 UTC (rev 409) @@ -21,9 +21,8 @@ package fr.ifremer.wao.service; -import fr.ifremer.wao.WaoContextO; -import fr.ifremer.wao.WaoExceptionO; import fr.ifremer.wao.WaoDAOHelper; +import fr.ifremer.wao.WaoException; import fr.ifremer.wao.bean.ContactAverageReactivityImpl; import fr.ifremer.wao.bean.ContactAverageReactivity; import fr.ifremer.wao.bean.BoardingResult; @@ -51,8 +50,8 @@ import java.util.Map; import java.util.SortedMap; import java.util.TreeMap; -import org.apache.commons.lang.time.DurationFormatUtils; import org.nuiton.topia.TopiaContext; +import org.nuiton.topia.TopiaException; import org.nuiton.topia.framework.TopiaQuery; import org.nuiton.topia.framework.TopiaQuery.Op; import org.nuiton.topia.persistence.TopiaEntity; @@ -72,26 +71,29 @@ * Mise a jour: $Date$ * par : $Author$ */ -public class ServiceSynthesisImpl implements ServiceSynthesis { +public class ServiceSynthesisImpl extends ServiceSynthesisAbstract { private static final Logger log = LoggerFactory.getLogger(ServiceSynthesisImpl.class); - protected TopiaContext rootContext; +// protected TopiaContext rootContext; +// +// public ServiceSynthesisImpl() throws WaoExceptionO { +// rootContext = context.getTopiaRootContext(); +// } - public ServiceSynthesisImpl() throws WaoExceptionO { - rootContext = WaoContextO.getTopiaRootContext(); - } - @Override - public List<SortedMap<Date, Integer>> getDataSampling(SamplingFilter filter) throws WaoExceptionO { - TopiaContext transaction = null; - List<SortedMap<Date, Integer>> results = new ArrayList<SortedMap<Date, Integer>>(); - try { - long startTime = 0; - if (log.isDebugEnabled()) { - startTime = System.currentTimeMillis(); - } - transaction = rootContext.beginTransaction(); + public List<SortedMap<Date, Integer>> executeGetDataSampling( + TopiaContext transaction, SamplingFilter filter) + throws TopiaException { +// TopiaContext transaction = null; + List<SortedMap<Date, Integer>> results = + new ArrayList<SortedMap<Date, Integer>>(); +// try { +// long startTime = 0; +// if (log.isDebugEnabled()) { +// startTime = System.currentTimeMillis(); +// } +// transaction = rootContext.beginTransaction(); PeriodDates period = filter.getPeriod(); if (period == null || period.getFromDate() == null || period.getThruDate() == null) { @@ -142,20 +144,20 @@ } } - if (log.isDebugEnabled()) { - long stopTime = System.currentTimeMillis(); - log.debug("W:[ getDataSampling ] Time = " + - DurationFormatUtils.formatDurationHMS( - stopTime - startTime)); - } - - //transaction.closeContext(); - } catch (Exception eee) { - WaoContextO.serviceException(transaction, - "Impossible de récupérer les données pour le graphique dynamique des efforts de marées", eee); - } finally { - WaoContextO.closeTransaction(transaction); - } +// if (log.isDebugEnabled()) { +// long stopTime = System.currentTimeMillis(); +// log.debug("W:[ getDataSampling ] Time = " + +// DurationFormatUtils.formatDurationHMS( +// stopTime - startTime)); +// } +// +// //transaction.closeContext(); +// } catch (Exception eee) { +// context.serviceException(transaction, +// "Impossible de récupérer les données pour le graphique dynamique des efforts de marées", eee); +// } finally { +// context.closeTransaction(transaction); +// } return results; } @@ -174,18 +176,19 @@ * @throws WaoException */ @Override - public BoardingResult getBoardingBoats(Company company, Date fromDate) - throws WaoExceptionO { - TopiaContext transaction = null; + public BoardingResult executeGetBoardingBoats(TopiaContext transaction, + Company company, Date fromDate) + throws TopiaException { +// TopiaContext transaction = null; Map<String, Integer> map = new LinkedHashMap<String, Integer>(); BoardingResult result = new BoardingResultImpl(); result.setData(map); - try { - long startTime = 0; - if (log.isDebugEnabled()) { - startTime = System.currentTimeMillis(); - } - transaction = rootContext.beginTransaction(); +// try { +// long startTime = 0; +// if (log.isDebugEnabled()) { +// startTime = System.currentTimeMillis(); +// } +// transaction = rootContext.beginTransaction(); // Initialiaze max boardings and its max key value final int maxBoardings = 12; @@ -255,36 +258,37 @@ result.setMaxBoardingValue(maxValue.intValue()); } - if (log.isDebugEnabled()) { - long stopTime = System.currentTimeMillis(); - log.debug("W:[ getBoardingBoats ] Time = " + - DurationFormatUtils.formatDurationHMS( - stopTime - startTime)); - } - - //transaction.closeContext(); - } catch (Exception eee) { - WaoContextO.serviceException(transaction, - "Impossible de récupérer les données pour le graphique " + - "dynamique des efforts de marées", eee); - } finally { - WaoContextO.closeTransaction(transaction); - } +// if (log.isDebugEnabled()) { +// long stopTime = System.currentTimeMillis(); +// log.debug("W:[ getBoardingBoats ] Time = " + +// DurationFormatUtils.formatDurationHMS( +// stopTime - startTime)); +// } +// +// //transaction.closeContext(); +// } catch (Exception eee) { +// context.serviceException(transaction, +// "Impossible de récupérer les données pour le graphique " + +// "dynamique des efforts de marées", eee); +// } finally { +// context.closeTransaction(transaction); +// } return result; } @Override - public Map<String, Double> getNonComplianceBoardingIndicator(Company company) throws WaoExceptionO { - TopiaContext transaction = null; + public Map<String, Double> executeGetNonComplianceBoardingIndicator( + TopiaContext transaction, Company company) throws TopiaException { +// TopiaContext transaction = null; // Carefull with results, the company may not be present in the map : // only if there is no unfinished sampleRow or no contact done Map<String, Double> results = new HashMap<String, Double>(); - try { - long startTime = 0; - if (log.isDebugEnabled()) { - startTime = System.currentTimeMillis(); - } - transaction = rootContext.beginTransaction(); +// try { +// long startTime = 0; +// if (log.isDebugEnabled()) { +// startTime = System.currentTimeMillis(); +// } +// transaction = rootContext.beginTransaction(); ContactDAO dao = WaoDAOHelper.getContactDAO(transaction); @@ -298,7 +302,7 @@ String companyName = companyProp + "." + Company.NAME; // Only for unfinished sampleRows - Date current = WaoContextO.getCurrentDate(); + Date current = context.getCurrentDate(); query.add(sampleRow + "." + SampleRow.PERIOD_END, Op.GE, current); if (company != null) { @@ -352,38 +356,41 @@ } } - if (log.isDebugEnabled()) { - long stopTime = System.currentTimeMillis(); - log.debug("W:[ getNonComplianceBoardingIndicator ] Time = " + - DurationFormatUtils.formatDurationHMS( - stopTime - startTime)); - } - - //transaction.closeContext(); - } catch (Exception eee) { - String msgEnd = ""; - if (company != null) { - msgEnd = " pour la société " + company.getName(); - } - WaoContextO.serviceException(transaction, - "Impossible de récupérer l'indicateur de non respect du " + - "nombre d'observateurs embarqués" + msgEnd, eee); - } finally { - WaoContextO.closeTransaction(transaction); - } +// if (log.isDebugEnabled()) { +// long stopTime = System.currentTimeMillis(); +// log.debug("W:[ getNonComplianceBoardingIndicator ] Time = " + +// DurationFormatUtils.formatDurationHMS( +// stopTime - startTime)); +// } +// +// //transaction.closeContext(); +// } catch (Exception eee) { +// String msgEnd = ""; +// if (company != null) { +// msgEnd = " pour la société " + company.getName(); +// } +// context.serviceException(transaction, +// "Impossible de récupérer l'indicateur de non respect du " + +// "nombre d'observateurs embarqués" + msgEnd, eee); +// } finally { +// context.closeTransaction(transaction); +// } return results; } @Override - public Collection<ContactStateStatistics> getContactStateStatistics(Company company, PeriodDates period) throws WaoExceptionO { - TopiaContext transaction = null; - Map<String, ContactStateStatistics> results = new HashMap<String, ContactStateStatistics>(); - try { - long startTime = 0; - if (log.isDebugEnabled()) { - startTime = System.currentTimeMillis(); - } - transaction = rootContext.beginTransaction(); + public Collection<ContactStateStatistics> executeGetContactStateStatistics( + TopiaContext transaction, Company company, PeriodDates period) + throws TopiaException { +// TopiaContext transaction = null; + Map<String, ContactStateStatistics> results = + new HashMap<String, ContactStateStatistics>(); +// try { +// long startTime = 0; +// if (log.isDebugEnabled()) { +// startTime = System.currentTimeMillis(); +// } +// transaction = rootContext.beginTransaction(); ContactDAO dao = WaoDAOHelper.getContactDAO(transaction); @@ -444,40 +451,42 @@ stats.addResult(state, rowCount.intValue()); } - if (log.isDebugEnabled()) { - long stopTime = System.currentTimeMillis(); - log.debug("W:[ getContactStateStatistics ] Time = " + - DurationFormatUtils.formatDurationHMS( - stopTime - startTime)); - } - - } catch (Exception eee) { - String msgEnd = ""; - if (company != null) { - msgEnd = " pour la société " + company.getName(); - } - WaoContextO.serviceException(transaction, - "Impossible de récupérer les statistiques sur les états des " + - "contacts " + msgEnd, eee); - } finally { - WaoContextO.closeTransaction(transaction); - } +// if (log.isDebugEnabled()) { +// long stopTime = System.currentTimeMillis(); +// log.debug("W:[ getContactStateStatistics ] Time = " + +// DurationFormatUtils.formatDurationHMS( +// stopTime - startTime)); +// } +// +// } catch (Exception eee) { +// String msgEnd = ""; +// if (company != null) { +// msgEnd = " pour la société " + company.getName(); +// } +// context.serviceException(transaction, +// "Impossible de récupérer les statistiques sur les états des " + +// "contacts " + msgEnd, eee); +// } finally { +// context.closeTransaction(transaction); +// } return results.values(); } @Override - public Collection<ContactAverageReactivity> getContactDataInputDateReactivity(Company company, PeriodDates period) throws WaoExceptionO { - TopiaContext transaction = null; + public Collection<ContactAverageReactivity> + executeGetContactDataInputDateReactivity(TopiaContext transaction, + Company company, PeriodDates period) throws TopiaException { +// TopiaContext transaction = null; // Carefull with results, the company may not be present in the map : // only if there is no unfinished sampleRow or no contact done Map<String, ContactAverageReactivity> results = new HashMap<String, ContactAverageReactivity>(); - try { - long startTime = 0; - if (log.isDebugEnabled()) { - startTime = System.currentTimeMillis(); - } - transaction = rootContext.beginTransaction(); +// try { +// long startTime = 0; +// if (log.isDebugEnabled()) { +// startTime = System.currentTimeMillis(); +// } +// transaction = rootContext.beginTransaction(); ContactDAO dao = WaoDAOHelper.getContactDAO(transaction); @@ -534,24 +543,24 @@ avg.addValue(nbDays); } - if (log.isDebugEnabled()) { - long stopTime = System.currentTimeMillis(); - log.debug("W:[ getContactDataInputDateReactivity ] Time = " + - DurationFormatUtils.formatDurationHMS( - stopTime - startTime)); - } - - } catch (Exception eee) { - String msgEnd = ""; - if (company != null) { - msgEnd = " pour la société " + company.getName(); - } - WaoContextO.serviceException(transaction, - "Impossible de récupérer l'indicateur de réactivité sur " + - "les dates de saisies dans Allegro" + msgEnd, eee); - } finally { - WaoContextO.closeTransaction(transaction); - } +// if (log.isDebugEnabled()) { +// long stopTime = System.currentTimeMillis(); +// log.debug("W:[ getContactDataInputDateReactivity ] Time = " + +// DurationFormatUtils.formatDurationHMS( +// stopTime - startTime)); +// } +// +// } catch (Exception eee) { +// String msgEnd = ""; +// if (company != null) { +// msgEnd = " pour la société " + company.getName(); +// } +// context.serviceException(transaction, +// "Impossible de récupérer l'indicateur de réactivité sur " + +// "les dates de saisies dans Allegro" + msgEnd, eee); +// } finally { +// context.closeTransaction(transaction); +// } return results.values(); } Modified: trunk/wao-business/src/main/resources/i18n/wao-business-en_GB.properties =================================================================== --- trunk/wao-business/src/main/resources/i18n/wao-business-en_GB.properties 2010-04-01 17:14:29 UTC (rev 408) +++ trunk/wao-business/src/main/resources/i18n/wao-business-en_GB.properties 2010-04-01 18:21:22 UTC (rev 409) @@ -7,6 +7,7 @@ wao.error.context.rollback= wao.error.context.start= wao.error.context.stop= +wao.error.global.createDefaultAdmin= wao.error.sampleMonth.addRealTideTime= wao.error.sampleRow.saveSampleRowLog= wao.error.serviceBoat.createUpdateCompanyBoatInfos= @@ -48,6 +49,11 @@ wao.error.serviceSampling.getSampleRowsByFilter= wao.error.serviceSampling.getSampleRowsOrderedByFishingZone= wao.error.serviceSampling.importSamplingPlanCsv= +wao.error.serviceSynthesis.getBoardingBoats= +wao.error.serviceSynthesis.getContactDataInputDateReactivity= +wao.error.serviceSynthesis.getContactStateStatistics= +wao.error.serviceSynthesis.getDataSampling= +wao.error.serviceSynthesis.getNonComplianceBoardingIndicator= wao.error.serviceUser.connect= wao.error.serviceUser.createUpdateCompany= wao.error.serviceUser.createUpdateUser= Modified: trunk/wao-business/src/main/resources/i18n/wao-business-fr_FR.properties =================================================================== --- trunk/wao-business/src/main/resources/i18n/wao-business-fr_FR.properties 2010-04-01 17:14:29 UTC (rev 408) +++ trunk/wao-business/src/main/resources/i18n/wao-business-fr_FR.properties 2010-04-01 18:21:22 UTC (rev 409) @@ -7,6 +7,7 @@ wao.error.context.rollback=Une erreur est survenue pendant l'annulation de la transaction courante wao.error.context.start=Une erreur est survenue pendant le d\u00E9marrage de l'application wao.error.context.stop=Une erreur est survenue pendant la fermeture de l'application +wao.error.global.createDefaultAdmin= wao.error.sampleMonth.addRealTideTime=Impossible d'enregistrer le nombre de mar\u00E9es r\u00E9els pour le mois de %1$s [ligne \: %2$s] wao.error.sampleRow.saveSampleRowLog=Impossible d'enregistrer le commentaire \u00E9crit par %1$s wao.error.serviceBoat.createUpdateCompanyBoatInfos=Impossible de cr\u00E9er ou modifier les informations li\u00E9s au navire %1$d pour la soci\u00E9t\u00E9 %2$s @@ -22,12 +23,12 @@ wao.error.serviceBoat.getNbBoatsByFilter=Impossible de filtrer la liste des navires wao.error.serviceBoat.importActivityCalendarCsv=Probl\u00E8me d'import du fichier CSV des calendriers d'activit\u00E9 wao.error.serviceBoat.importBoatCsv=Probl\u00E8me d'import du fichier CSV. V\u00E9rifiez l'en-t\u00EAte du fichier \: [ NAVS_COD,CARN_NOM,CARN_LONGUEUR_HT,CARN_ANNEE,QUARTIER_IMMA,PER_COD,PER_NOM,PER_PRENOM,NAVS_ACTIVE ]. Voir documentation pour plus de d\u00E9tails. -wao.error.serviceContact.exportContactCsv= -wao.error.serviceContact.getContacts= -wao.error.serviceContact.getNbContacts= -wao.error.serviceContact.getNewContact= -wao.error.serviceContact.importContactCsv= -wao.error.serviceContact.saveContact= +wao.error.serviceContact.exportContactCsv=Impossible d'exporter les contacts +wao.error.serviceContact.getContacts=Impossible de filtrer la liste des contacts +wao.error.serviceContact.getNbContacts=Impossible de compter le nombre de contacts filtr\u00E9s +wao.error.serviceContact.getNewContact=Impossible d'instancier un nouveau contact +wao.error.serviceContact.importContactCsv=Impossible d'importer les contacts +wao.error.serviceContact.saveContact=Impossible de sauvegarder le contact wao.error.serviceNews.getNews=Impossible de r\u00E9cup\u00E9rer l'ensemble des news wao.error.serviceNews.saveNews=Impossible d'enregistrer la news ayant pour titre '%1$s' wao.error.serviceReferential.getFacades=Impossible de charger la liste des facades @@ -47,7 +48,12 @@ wao.error.serviceSampling.getSampleRowByCode=Impossible de charger la ligne d'\u00E9chantillon ayant pour code %1$s wao.error.serviceSampling.getSampleRowsByFilter=Impossible de r\u00E9cup\u00E9rer la liste des lignes du plan d'\u00E9chantillonnage wao.error.serviceSampling.getSampleRowsOrderedByFishingZone=Impossible de r\u00E9cup\u00E9rer la liste des lignes du plan d'\u00E9chantillonnage -wao.error.serviceSampling.importSamplingPlanCsv= +wao.error.serviceSampling.importSamplingPlanCsv=Erreur \u00E0 la ligne %1$d [CODE \= %2$s] +wao.error.serviceSynthesis.getBoardingBoats= +wao.error.serviceSynthesis.getContactDataInputDateReactivity= +wao.error.serviceSynthesis.getContactStateStatistics= +wao.error.serviceSynthesis.getDataSampling= +wao.error.serviceSynthesis.getNonComplianceBoardingIndicator= wao.error.serviceUser.connect=Une erreur est survenue lors de la demande de connexion wao.error.serviceUser.createUpdateCompany=Impossible de cr\u00E9er ou de mettre \u00E0 jour la soci\u00E9t\u00E9 wao.error.serviceUser.createUpdateUser=Impossible de cr\u00E9er ou de mettre \u00E0 jour l'utilisateur Modified: trunk/wao-business/src/main/xmi/wao.zargo =================================================================== (Binary files differ) Modified: trunk/wao-business/src/test/java/fr/ifremer/wao/ErrorDB1_0Test.java =================================================================== --- trunk/wao-business/src/test/java/fr/ifremer/wao/ErrorDB1_0Test.java 2010-04-01 17:14:29 UTC (rev 408) +++ trunk/wao-business/src/test/java/fr/ifremer/wao/ErrorDB1_0Test.java 2010-04-01 18:21:22 UTC (rev 409) @@ -80,12 +80,12 @@ } @Before - public void setUp() throws WaoExceptionO, ArgumentsParserException { + public void setUp() throws ArgumentsParserException { manager.start(); } @After - public void tearDown() throws WaoExceptionO, TopiaException { + public void tearDown() throws TopiaException { manager.stop(); } Modified: trunk/wao-business/src/test/java/fr/ifremer/wao/TestManager.java =================================================================== --- trunk/wao-business/src/test/java/fr/ifremer/wao/TestManager.java 2010-04-01 17:14:29 UTC (rev 408) +++ trunk/wao-business/src/test/java/fr/ifremer/wao/TestManager.java 2010-04-01 18:21:22 UTC (rev 409) @@ -124,7 +124,7 @@ return instance; } - public ServiceReferential getServiceReferential() throws WaoExceptionO { + public ServiceReferential getServiceReferential() { ServiceReferentialImpl instance = new ServiceReferentialImpl(); instance.setContext(getContext()); return instance; @@ -136,27 +136,27 @@ return instance; } - public ServiceSampling getServiceSampling() throws WaoExceptionO { + public ServiceSampling getServiceSampling() { ServiceSamplingImpl instance = new ServiceSamplingImpl(); instance.setContext(getContext()); return instance; } - public ServiceSynthesis getServiceSynthesis() throws WaoExceptionO { + public ServiceSynthesis getServiceSynthesis() { ServiceSynthesisImpl instance = new ServiceSynthesisImpl(); -// instance.setContext(context); + instance.setContext(getContext()); return instance; } - public ServiceUser getServiceUser() throws WaoExceptionO { + public ServiceUser getServiceUser() { ServiceUserImpl instance = new ServiceUserImpl(); instance.setContext(getContext()); return instance; } - public ServiceContact getServiceContact() throws WaoExceptionO { + public ServiceContact getServiceContact() { ServiceContactImpl instance = new ServiceContactImpl(); - instance.setContext(context); + instance.setContext(getContext()); return instance; } Modified: trunk/wao-business/src/test/java/fr/ifremer/wao/WaoGlobalTest.java =================================================================== --- trunk/wao-business/src/test/java/fr/ifremer/wao/WaoGlobalTest.java 2010-04-01 17:14:29 UTC (rev 408) +++ trunk/wao-business/src/test/java/fr/ifremer/wao/WaoGlobalTest.java 2010-04-01 18:21:22 UTC (rev 409) @@ -67,12 +67,12 @@ } @Before - public void setUp() throws WaoExceptionO { + public void setUp() { manager.start(); } @After - public void tearDown() throws WaoExceptionO { + public void tearDown() { manager.stop(); } @@ -83,7 +83,7 @@ public void testCreateDefaultAdmin() throws Exception { System.out.println("createDefaultAdmin"); - WaoGlobal.createDefaultAdmin(); + WaoGlobal.createDefaultAdmin(manager.getContext()); ServiceUser serviceUser = manager.getServiceUser(); Modified: trunk/wao-business/src/test/java/fr/ifremer/wao/WaoUtilsTest.java =================================================================== --- trunk/wao-business/src/test/java/fr/ifremer/wao/WaoUtilsTest.java 2010-04-01 17:14:29 UTC (rev 408) +++ trunk/wao-business/src/test/java/fr/ifremer/wao/WaoUtilsTest.java 2010-04-01 18:21:22 UTC (rev 409) @@ -64,12 +64,12 @@ } @Before - public void setUp() throws WaoExceptionO { + public void setUp() { manager.start(); } @After - public void tearDown() throws WaoExceptionO { + public void tearDown() { manager.stop(); } Modified: trunk/wao-business/src/test/java/fr/ifremer/wao/entity/SampleRowImplTest.java =================================================================== --- trunk/wao-business/src/test/java/fr/ifremer/wao/entity/SampleRowImplTest.java 2010-04-01 17:14:29 UTC (rev 408) +++ trunk/wao-business/src/test/java/fr/ifremer/wao/entity/SampleRowImplTest.java 2010-04-01 18:21:22 UTC (rev 409) @@ -21,7 +21,6 @@ package fr.ifremer.wao.entity; -import fr.ifremer.wao.WaoExceptionO; import fr.ifremer.wao.WaoDAOHelper; import fr.ifremer.wao.TestManager; import java.util.Calendar; @@ -79,7 +78,7 @@ manager.stop(); } - private SampleRow prepareData() throws WaoExceptionO, TopiaException { + private SampleRow prepareData() throws TopiaException { TopiaContext transaction = manager.getContext().beginTransaction(); SampleRowDAO dao = WaoDAOHelper.getSampleRowDAO(transaction); @@ -102,7 +101,7 @@ return myRow; } - private SampleRow getRowFromContext() throws WaoExceptionO, TopiaException { + private SampleRow getRowFromContext() throws TopiaException { TopiaContext transaction = manager.getContext().beginTransaction(); SampleRowDAO dao = WaoDAOHelper.getSampleRowDAO(transaction); SampleRow resultRow = dao.findByCode("2010_1"); Modified: trunk/wao-business/src/test/java/fr/ifremer/wao/io/ImportHelperTest.java =================================================================== --- trunk/wao-business/src/test/java/fr/ifremer/wao/io/ImportHelperTest.java 2010-04-01 17:14:29 UTC (rev 408) +++ trunk/wao-business/src/test/java/fr/ifremer/wao/io/ImportHelperTest.java 2010-04-01 18:21:22 UTC (rev 409) @@ -72,7 +72,7 @@ } @Before - public void setUp() throws WaoExceptionO, IOException { + public void setUp() throws IOException { manager.start(); InputStream input = getClass().getResourceAsStream("/import/misc.csv"); @@ -81,7 +81,7 @@ } @After - public void tearDown() throws WaoExceptionO { + public void tearDown() { reader.close(); manager.stop(); Modified: trunk/wao-business/src/test/java/fr/ifremer/wao/service/ActivityCalendarImportTest.java =================================================================== --- trunk/wao-business/src/test/java/fr/ifremer/wao/service/ActivityCalendarImportTest.java 2010-04-01 17:14:29 UTC (rev 408) +++ trunk/wao-business/src/test/java/fr/ifremer/wao/service/ActivityCalendarImportTest.java 2010-04-01 18:21:22 UTC (rev 409) @@ -21,7 +21,7 @@ package fr.ifremer.wao.service; -import fr.ifremer.wao.WaoExceptionO; +import fr.ifremer.wao.WaoBusinessException; import fr.ifremer.wao.WaoProperty; import fr.ifremer.wao.TestManager; import java.io.BufferedReader; @@ -70,12 +70,12 @@ } @Before - public void setUp() throws WaoExceptionO { + public void setUp() { manager.start(); } @After - public void tearDown() throws WaoExceptionO { + public void tearDown() { manager.stop(); } @@ -83,7 +83,8 @@ * Test of run method, of class ActivityCalendarImport. */ @Test - public void testRun() throws IOException, InterruptedException, WaoExceptionO { + public void testRun() + throws IOException, InterruptedException, WaoBusinessException { log.info("run"); ServiceBoat serviceBoat = manager.getServiceBoat(); Modified: trunk/wao-business/src/test/java/fr/ifremer/wao/service/ServiceBoatImplTest.java =================================================================== --- trunk/wao-business/src/test/java/fr/ifremer/wao/service/ServiceBoatImplTest.java 2010-04-01 17:14:29 UTC (rev 408) +++ trunk/wao-business/src/test/java/fr/ifremer/wao/service/ServiceBoatImplTest.java 2010-04-01 18:21:22 UTC (rev 409) @@ -21,7 +21,7 @@ package fr.ifremer.wao.service; -import fr.ifremer.wao.WaoExceptionO; +import fr.ifremer.wao.WaoBusinessException; import fr.ifremer.wao.WaoDAOHelper; import fr.ifremer.wao.WaoProperty; import fr.ifremer.wao.bean.BoatFilterImpl; @@ -204,7 +204,7 @@ } private List<SampleRow> prepareSampleRows(Company company) - throws WaoExceptionO, TopiaException { + throws TopiaException, WaoBusinessException { ServiceReferential serviceReferential = manager.getServiceReferential(); InputStream input = getClass().getResourceAsStream("/import/zonesPeche.csv"); serviceReferential.importFishingZoneCsv(input); Modified: trunk/wao-business/src/test/java/fr/ifremer/wao/service/ServiceReferentialImplTest.java =================================================================== --- trunk/wao-business/src/test/java/fr/ifremer/wao/service/ServiceReferentialImplTest.java 2010-04-01 17:14:29 UTC (rev 408) +++ trunk/wao-business/src/test/java/fr/ifremer/wao/service/ServiceReferentialImplTest.java 2010-04-01 18:21:22 UTC (rev 409) @@ -21,7 +21,6 @@ package fr.ifremer.wao.service; -import fr.ifremer.wao.WaoExceptionO; import fr.ifremer.wao.TestManager; import fr.ifremer.wao.WaoException; import fr.ifremer.wao.bean.SamplingFilter; @@ -128,7 +127,7 @@ * @throws WaoException if error during import or getFishingZones */ @Test - public void testGetFishingZones() throws WaoExceptionO { + public void testGetFishingZones() { log.info("getFishingZones"); InputStream input = getClass().getResourceAsStream("/import/zonesPeche.csv"); @@ -144,7 +143,7 @@ * @throws WaoException if import error */ @Test - public void testImportFishingZoneCsv() throws WaoExceptionO { + public void testImportFishingZoneCsv() { log.info("importFishingZoneCsv"); InputStream input = getClass().getResourceAsStream("/import/zonesPeche.csv"); Modified: trunk/wao-business/src/test/java/fr/ifremer/wao/service/ServiceSamplingImplTest.java =================================================================== --- trunk/wao-business/src/test/java/fr/ifremer/wao/service/ServiceSamplingImplTest.java 2010-04-01 17:14:29 UTC (rev 408) +++ trunk/wao-business/src/test/java/fr/ifremer/wao/service/ServiceSamplingImplTest.java 2010-04-01 18:21:22 UTC (rev 409) @@ -21,9 +21,9 @@ package fr.ifremer.wao.service; -import fr.ifremer.wao.WaoExceptionO; +import fr.ifremer.wao.WaoBusinessException; import fr.ifremer.wao.WaoDAOHelper; -import fr.ifremer.wao.WaoContextO; +import fr.ifremer.wao.WaoException; import fr.ifremer.wao.bean.ImportResults; import fr.ifremer.wao.bean.SamplingFilter; import fr.ifremer.wao.bean.SamplingFilterImpl; @@ -298,7 +298,7 @@ } - private List<FishingZone> prepareFishingZones(TopiaContext transaction) throws WaoExceptionO, TopiaException { + private List<FishingZone> prepareFishingZones(TopiaContext transaction) throws TopiaException { FishingZoneDAO fishingZoneDAO = WaoDAOHelper.getFishingZoneDAO(transaction); @@ -465,7 +465,8 @@ } @Test - public void testImportSamplingPlanCsv() throws WaoExceptionO, TopiaException { + public void testImportSamplingPlanCsv() + throws TopiaException, WaoException, WaoBusinessException { log.info("importSamplingPlanCsv"); /** PREPARE DATA **/ Modified: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/base/AbstractFilteredPage.java =================================================================== --- trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/base/AbstractFilteredPage.java 2010-04-01 17:14:29 UTC (rev 408) +++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/base/AbstractFilteredPage.java 2010-04-01 18:21:22 UTC (rev 409) @@ -21,7 +21,7 @@ package fr.ifremer.wao.ui.base; -import fr.ifremer.wao.WaoExceptionO; +import fr.ifremer.wao.WaoException; import fr.ifremer.wao.bean.BoatFilter; import fr.ifremer.wao.entity.Company; import fr.ifremer.wao.entity.SampleRow; @@ -143,7 +143,7 @@ * @param observerSelect if true, observer select will be initialized * @throws WaoException */ - protected void initSelectFilters(boolean companySelect, boolean observerSelect, boolean programSelect) throws WaoExceptionO { + protected void initSelectFilters(boolean companySelect, boolean observerSelect, boolean programSelect) throws WaoException { this.observerSelect = observerSelect; this.programSelect = programSelect; @@ -185,22 +185,22 @@ resetSampleRowSelect(); } - protected void resetCompanySelect() throws WaoExceptionO { + protected void resetCompanySelect() throws WaoException { companySelectModel = null; getCompanySelectModel(); } - protected void resetFacadeSelect() throws WaoExceptionO { + protected void resetFacadeSelect() throws WaoException { facadeSelectModel = null; getFacadeSelectModel(); } - protected void resetSectorSelect() throws WaoExceptionO { + protected void resetSectorSelect() throws WaoException { sectorSelectModel = null; getSectorSelectModel(); } - protected void resetSampleRowSelect() throws WaoExceptionO { + protected void resetSampleRowSelect() throws WaoException { sampleRowSelectModel = null; getSampleRowSelectModel(); } @@ -212,7 +212,7 @@ * @return the SelectModel for facade names * @throws WaoException */ - public SelectModel getFacadeSelectModel() throws WaoExceptionO { + public SelectModel getFacadeSelectModel() throws WaoException { if (facadeSelectModel == null) { List<OptionModel> options = new ArrayList<OptionModel>(); for (String facadeName : serviceReferential.getFacades(getFilter())) { @@ -230,7 +230,7 @@ * @return the SelectModel for sector names * @throws WaoException */ - public SelectModel getSectorSelectModel() throws WaoExceptionO { + public SelectModel getSectorSelectModel() throws WaoException { if (sectorSelectModel == null) { List<OptionModel> options = new ArrayList<OptionModel>(); for (String sectorName : serviceReferential.getSectors(getFilter())) { @@ -249,7 +249,7 @@ * @return the GenericSelectModel<SampleRow> for sampleRows * @throws WaoException */ - public GenericSelectModel<SampleRow> getSampleRowSelectModel() throws WaoExceptionO { + public GenericSelectModel<SampleRow> getSampleRowSelectModel() throws WaoException { if (sampleRowSelectModel == null) { // WARN : no use of sampleRow filter SampleRow rowFiltered = getFilter().getSampleRow(); @@ -271,7 +271,7 @@ * @return the GenericSelectModel<Company> for companies * @throws WaoException */ - public GenericSelectModel<Company> getCompanySelectModel() throws WaoExceptionO { + public GenericSelectModel<Company> getCompanySelectModel() throws WaoException { if (companySelectModel == null) { List<Company> companies = serviceUser.getCompanies(isAvailableDataForFiltersOnly()); companySelectModel = new GenericSelectModel<Company>(companies,Company.class, @@ -288,7 +288,7 @@ * @return the GenericSelectModel<WaoUser> for observers * @throws WaoException */ - public GenericSelectModel<WaoUser> getObserverSelectModel() throws WaoExceptionO { + public GenericSelectModel<WaoUser> getObserverSelectModel() throws WaoException { if (observerSelectModel == null) { List<WaoUser> observers = new ArrayList<WaoUser>(); if (getFilter().getCompany() != null) { @@ -309,7 +309,7 @@ * @return the SelectModel for program names * @throws WaoException */ - public SelectModel getProgramSelectModel() throws WaoExceptionO { + public SelectModel getProgramSelectModel() throws WaoException { if (programSelectModel == null) { List<OptionModel> options = new ArrayList<OptionModel>(); for (String programName : serviceSampling.getPrograms(getFilter().getCompany())) { @@ -320,7 +320,7 @@ return programSelectModel; } - protected abstract BoatFilter getFilter() throws WaoExceptionO; + protected abstract BoatFilter getFilter() throws WaoException; /** * Used to show only active company and observers. @@ -329,7 +329,7 @@ */ protected abstract boolean isAvailableDataForFiltersOnly(); - public String[] onProvideCompletionsFromBoatName(String input) throws WaoExceptionO { + public String[] onProvideCompletionsFromBoatName(String input) throws WaoException { List<String> results = serviceBoat.getBoatNamesStartWith(input); return results.toArray(new String[0]); } @@ -340,7 +340,7 @@ * * @throws WaoException */ - public void onSelectedFromSearch() throws WaoExceptionO { + public void onSelectedFromSearch() throws WaoException { if (log.isDebugEnabled()) { log.debug("REFRESH FILTERS DATA"); } @@ -370,7 +370,7 @@ * @throws WaoException * @see AbstractFilteredPage#onSelectedFromRefreshByProgram() */ - public void onSelectedFromRefreshByCompany() throws WaoExceptionO { + public void onSelectedFromRefreshByCompany() throws WaoException { // Reset programs (the behavior is needed even if programSelect is false) getFilter().setProgramName(null); onSelectedFromRefreshByProgram(); @@ -396,7 +396,7 @@ * @throws WaoException * @see AbstractFilteredPage#onSelectedFromRefreshByFacade() */ - public void onSelectedFromRefreshByProgram() throws WaoExceptionO { + public void onSelectedFromRefreshByProgram() throws WaoException { // Reset facades getFilter().setFacadeName(null); onSelectedFromRefreshByFacade(); @@ -412,7 +412,7 @@ * @throws WaoException * @see AbstractFilteredPage#onSelectedFromRefreshBySector() */ - public void onSelectedFromRefreshByFacade() throws WaoExceptionO { + public void onSelectedFromRefreshByFacade() throws WaoException { // Reset sectors getFilter().setSectorName(null); onSelectedFromRefreshBySector(); @@ -428,7 +428,7 @@ * @throws WaoException * @see AbstractFilteredPage#onSelectedFromSearch() */ - public void onSelectedFromRefreshBySector() throws WaoExceptionO { + public void onSelectedFromRefreshBySector() throws WaoException { // Update selected data onSelectedFromSearch(); // Reset sampleRows; Modified: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/components/Layout.java =================================================================== --- trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/components/Layout.java 2010-04-01 17:14:29 UTC (rev 408) +++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/components/Layout.java 2010-04-01 18:21:22 UTC (rev 409) @@ -23,7 +23,7 @@ import fr.ifremer.wao.WaoBusinessException; import fr.ifremer.wao.WaoBusinessException.Type; -import fr.ifremer.wao.WaoExceptionO; +import fr.ifremer.wao.WaoException; import fr.ifremer.wao.WaoProperty; import fr.ifremer.wao.entity.WaoUser; import fr.ifremer.wao.service.ServiceUser; @@ -250,7 +250,7 @@ } @Log - Object onSuccessFromConnexionForm() throws WaoExceptionO { + Object onSuccessFromConnexionForm() throws WaoException { try { // FIXME-FD20100120 Problem with NPE in Topia --> see Ano #243 on nuiton.org if (login != null && password != null) { @@ -270,7 +270,7 @@ public boolean hasConnexionErrors() { return connexionFeedback.hasErrors(); } - void onSuccessFromForgetPassword() throws WaoExceptionO { + void onSuccessFromForgetPassword() throws WaoException { try { serviceUser.forgetPassword(email); connexionFeedback.addInfo("Un email avec votre nouveau mot de passe vous a été envoyé."); Modified: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/data/AbstractMappedGridDataSource.java =================================================================== --- trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/data/AbstractMappedGridDataSource.java 2010-04-01 17:14:29 UTC (rev 408) +++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/data/AbstractMappedGridDataSource.java 2010-04-01 18:21:22 UTC (rev 409) @@ -21,7 +21,7 @@ package fr.ifremer.wao.ui.data; -import fr.ifremer.wao.WaoExceptionO; +import fr.ifremer.wao.WaoException; import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -68,7 +68,7 @@ if (log.isTraceEnabled()) { log.trace("Count : " + nbRows); } - } catch (WaoExceptionO eee) { + } catch (WaoException eee) { throw new TapestryException("", eee); } } @@ -87,14 +87,15 @@ // FIXME manage sort columns in execute ???? seems obvious --> needed for Contacts, done for Boats //sortResults(sortConstraints); - } catch (WaoExceptionO eee) { + } catch (WaoException eee) { throw new TapestryException("", eee); } } - protected abstract Map<K, E> execute(int startIndex, int endIndex, SortConstraint orderBy) throws WaoExceptionO; + protected abstract Map<K, E> execute(int startIndex, int endIndex, + SortConstraint orderBy) throws WaoException; - protected abstract int count() throws WaoExceptionO; + protected abstract int count() throws WaoException; protected SortConstraint getSortConstraint(List<SortConstraint> sortConstraints) { for (SortConstraint constraint : sortConstraints) Modified: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/data/BoatDataSource.java =================================================================== --- trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/data/BoatDataSource.java 2010-04-01 17:14:29 UTC (rev 408) +++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/data/BoatDataSource.java 2010-04-01 18:21:22 UTC (rev 409) @@ -21,7 +21,7 @@ package fr.ifremer.wao.ui.data; -import fr.ifremer.wao.WaoExceptionO; +import fr.ifremer.wao.WaoException; import fr.ifremer.wao.bean.BoatFilter; import fr.ifremer.wao.entity.Boat; import fr.ifremer.wao.service.ServiceBoat; @@ -58,10 +58,8 @@ @Override - protected Map<Integer, Boat> execute(int startIndex, int endIndex, SortConstraint orderBy) throws WaoExceptionO { - if (log.isInfoEnabled()) { - log.info("BUSINESS REQUEST [getBoatsByFilter]"); - } + protected Map<Integer, Boat> execute(int startIndex, int endIndex, SortConstraint orderBy) throws WaoException { + filter.setStartIndex(startIndex); filter.setEndIndex(endIndex); @@ -84,10 +82,7 @@ } @Override - protected int count() throws WaoExceptionO { - if (log.isInfoEnabled()) { - log.info("BUSINESS REQUEST [getNbBoatsByFilter]"); - } + protected int count() throws WaoException { return service.getNbBoatsByFilter(filter); } Modified: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/data/ContactDataSource.java =================================================================== --- trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/data/ContactDataSource.java 2010-04-01 17:14:29 UTC (rev 408) +++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/data/ContactDataSource.java 2010-04-01 18:21:22 UTC (rev 409) @@ -21,7 +21,7 @@ package fr.ifremer.wao.ui.data; -import fr.ifremer.wao.WaoExceptionO; +import fr.ifremer.wao.WaoException; import fr.ifremer.wao.bean.ContactFilter; import fr.ifremer.wao.entity.Contact; import fr.ifremer.wao.service.ServiceContact; @@ -60,20 +60,14 @@ } @Override - protected Map<String, Contact> execute(int startIndex, int endIndex, SortConstraint orderBy) throws WaoExceptionO { - if (log.isInfoEnabled()) { - log.info("BUSINESS REQUEST [getContactsByFilter]"); - } + protected Map<String, Contact> execute(int startIndex, int endIndex, SortConstraint orderBy) throws WaoException { filter.setStartIndex(startIndex); filter.setEndIndex(endIndex); return serviceContact.getContacts(filter); } @Override - protected int count() throws WaoExceptionO { - if (log.isInfoEnabled()) { - log.info("BUSINESS REQUEST [getNbContacts]"); - } + protected int count() throws WaoException { return serviceContact.getNbContacts(filter); } Modified: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Administration.java =================================================================== --- trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Administration.java 2010-04-01 17:14:29 UTC (rev 408) +++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Administration.java 2010-04-01 18:21:22 UTC (rev 409) @@ -23,7 +23,7 @@ import fr.ifremer.wao.WaoBusinessException; import fr.ifremer.wao.WaoException; -import fr.ifremer.wao.WaoExceptionO; +import fr.ifremer.wao.WaoException; import fr.ifremer.wao.bean.UserRole; import fr.ifremer.wao.entity.Company; import fr.ifremer.wao.entity.CompanyImpl; @@ -127,7 +127,7 @@ private boolean addNewUserSelected; private boolean deleteUserSelected; - void setupRender() throws WaoExceptionO { + void setupRender() throws WaoException { companies = null; getCompanies(); user = null; @@ -172,24 +172,21 @@ /**************************** FORMS ****************************************/ - public List<Company> getCompanies() throws WaoExceptionO { + public List<Company> getCompanies() throws WaoException { if (companies == null) { - if (log.isInfoEnabled()) { - log.info("BUSINESS REQUEST [getCompanies]"); - } companies = serviceUser.getCompanies(false); } return companies; } - public GenericSelectModel<Company> getCompaniesSelectModel() throws WaoExceptionO { + public GenericSelectModel<Company> getCompaniesSelectModel() throws WaoException { if (companiesSelectModel == null) { companiesSelectModel = new GenericSelectModel<Company>(getCompanies(), Company.class, Company.NAME, "id", propertyAccess); } return companiesSelectModel; } - public Company getCompany() throws WaoExceptionO { + public Company getCompany() throws WaoException { if (company == null) { if (companyId != null) { company = getCompaniesSelectModel().findObject(companyId); @@ -200,7 +197,7 @@ return company; } - public boolean isUsersAvailable() throws WaoExceptionO { + public boolean isUsersAvailable() throws WaoException { return !StringUtils.isEmpty(getCompany().getId()) && getCompany().getActive(); } @@ -216,13 +213,13 @@ user = null; } - void onSuccessFromCompany() throws WaoExceptionO { + void onSuccessFromCompany() throws WaoException { serviceUser.createUpdateCompany(company); companyId = company.getId(); } @Log - public GenericSelectModel<WaoUser> getUsersSelectModel() throws WaoExceptionO { + public GenericSelectModel<WaoUser> getUsersSelectModel() throws WaoException { if (usersSelectModel == null) { List<WaoUser> users = serviceUser.getUsersByCompany(getCompany()); if (log.isDebugEnabled()) { @@ -234,7 +231,7 @@ } @Log - public WaoUser getUser() throws WaoExceptionO { + public WaoUser getUser() throws WaoException { if (user == null) { if (userId != null) { if (log.isDebugEnabled()) { @@ -264,7 +261,7 @@ deleteUserSelected = true; } - void onSuccessFromUserActionsForm() throws WaoExceptionO { + void onSuccessFromUserActionsForm() throws WaoException { if (addNewUserSelected) { userId = null; } else if (deleteUserSelected && userId != null) { @@ -281,7 +278,7 @@ } @Log - void onSuccessFromUser() throws WaoExceptionO { + void onSuccessFromUser() throws WaoException { if (log.isDebugEnabled()) { log.debug("User : " + user); } Modified: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/BoatActivityCalendar.java =================================================================== --- trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/BoatActivityCalendar.java 2010-04-01 17:14:29 UTC (rev 408) +++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/BoatActivityCalendar.java 2010-04-01 18:21:22 UTC (rev 409) @@ -21,7 +21,7 @@ package fr.ifremer.wao.ui.pages; -import fr.ifremer.wao.WaoExceptionO; +import fr.ifremer.wao.WaoException; import fr.ifremer.wao.entity.ActivityCalendar; import fr.ifremer.wao.entity.ActivityMonth; import fr.ifremer.wao.entity.ActivityProfession; @@ -108,17 +108,14 @@ return Collections.singletonList(boat); } - public ActivityCalendar getActivityCalendar() throws WaoExceptionO { + public ActivityCalendar getActivityCalendar() throws WaoException { if (activityCalendar == null) { - if (log.isInfoEnabled()) { - log.info("BUSINESS REQUEST [getLastActivityCalendar]"); - } this.activityCalendar = serviceBoat.getLastActivityCalendar(user, getBoat()); } return activityCalendar; } - public ActivityMonth getActivityMonth() throws WaoExceptionO { + public ActivityMonth getActivityMonth() throws WaoException { return getActivityCalendar().getActivityMonth(month); } @@ -142,7 +139,7 @@ return getProfessionIndexMax() != -1; } - public ActivityProfession getActivityProfession() throws WaoExceptionO { + public ActivityProfession getActivityProfession() throws WaoException { if (getActivityMonth() == null) { return null; } @@ -152,7 +149,7 @@ return getActivityMonth().getActivityProfession().get(professionIndex); } - public int getZoneIndexMax() throws WaoExceptionO { + public int getZoneIndexMax() throws WaoException { int result = 0; for (ActivityMonth activityMonth : activityCalendar.getActivityMonth()) { month = activityMonth.getMonth(); @@ -179,7 +176,7 @@ // return getZoneIndexMax() != -1; // } - public ActivityZone getActivityZone() throws WaoExceptionO { + public ActivityZone getActivityZone() throws WaoException { ActivityProfession profession = getActivityProfession(); if (profession == null) { return null; Modified: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Boats.java =================================================================== --- trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Boats.java 2010-04-01 17:14:29 UTC (rev 408) +++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Boats.java 2010-04-01 18:21:22 UTC (rev 409) @@ -23,7 +23,7 @@ import fr.ifremer.wao.WaoBusinessException; import fr.ifremer.wao.WaoException; -import fr.ifremer.wao.WaoExceptionO; +import fr.ifremer.wao.WaoException; import fr.ifremer.wao.bean.BoatFilterImpl; import fr.ifremer.wao.entity.Boat; import fr.ifremer.wao.bean.BoatFilter; @@ -143,7 +143,7 @@ @InjectComponent private FeedBack filterFeedback; - void setupRender() throws WaoExceptionO { + void setupRender() throws WaoException { sampleRow = null; getSampleRow(); // Profession select reset @@ -223,9 +223,6 @@ InputStream getActivityCalendarLogFile() throws FileNotFoundException { if (activityCalendarLogFile == null) { - if (log.isInfoEnabled()) { - log.info("BUSINESS REQUEST [getActivityCalendarLogFile]"); - } activityCalendarLogFile = serviceBoat.getActivityCalendarLogFile(); } return activityCalendarLogFile; @@ -245,9 +242,6 @@ InputStream getActivityCalendarLogAccessFile() throws FileNotFoundException { if (activityCalendarLogAccessFile == null) { - if (log.isInfoEnabled()) { - log.info("BUSINESS REQUEST [getActivityCalendarLogAccessFile]"); - } activityCalendarLogAccessFile = serviceBoat.getActivityCalendarLogAccessFile(); } @@ -269,7 +263,7 @@ @Log void onSuccessFromImportActivityCalendarsForm() - throws WaoExceptionO, IOException { + throws WaoException, IOException { if (canImportReferentials()) { InputStream input = activityCalendarsCsvFile.getStream(); if (log.isDebugEnabled()) { @@ -358,7 +352,7 @@ * @see AbstractFilteredPage */ @Override - public BoatFilter getFilter() throws WaoExceptionO { + public BoatFilter getFilter() throws WaoException { if (boatFilter == null) { if (log.isDebugEnabled()) { log.debug("Create filter"); @@ -382,25 +376,19 @@ * @return the sampleRow from business * @throws WaoException */ - public SampleRow getSampleRow() throws WaoExceptionO { + public SampleRow getSampleRow() throws WaoException { if (sampleRow == null && !StringUtils.isEmpty(sampleRowContextId)) { - if (log.isInfoEnabled()) { - log.info("BUSINESS REQUEST [getSampleRow]"); - } sampleRow = serviceSampling.getSampleRow(sampleRowContextId); } return sampleRow; } - public boolean isSampleRowExists() throws WaoExceptionO { + public boolean isSampleRowExists() throws WaoException { return getSampleRow() != null; } - public GenericSelectModel<Profession> getProfessionSelectModel() throws WaoExceptionO { + public GenericSelectModel<Profession> getProfessionSelectModel() throws WaoException { if (professionSelectModel == null) { - if (log.isInfoEnabled()) { - log.info("BUSINESS REQUEST [getProfessions]"); - } List<Profession> professions = serviceReferential.getProfessions(); professionSelectModel = new GenericSelectModel<Profession>(professions, Profession.class, "code", "topiaId", propertyAccess); @@ -443,7 +431,7 @@ * @see AbstractFilteredPage#onSelectedFromSearch() */ @Override - public void onSelectedFromSearch() throws WaoExceptionO { + public void onSelectedFromSearch() throws WaoException { super.onSelectedFromSearch(); if (log.isDebugEnabled()) { log.debug("FILTER : facadeName=" + boatFilter.getFacadeName()); @@ -465,7 +453,7 @@ * @return the filtersZone if it's a refresh data for select, or the page otherwise * @throws WaoException for business errors */ - Object onSuccessFromFiltersForm() throws WaoExceptionO { + Object onSuccessFromFiltersForm() throws WaoException { if (isEdited()) { return filtersZone.getBody(); } @@ -503,7 +491,7 @@ * @throws WaoException * @see BoatDataSource */ - public BoatDataSource getBoats() throws WaoExceptionO { + public BoatDataSource getBoats() throws WaoException { if (boats == null) { boats = new BoatDataSource(getFilter(), serviceBoat); } @@ -533,7 +521,7 @@ return new SimpleDateFormat("dd/MM/yyyy"); } - public boolean canCreateNewContactFromList() throws WaoExceptionO { + public boolean canCreateNewContactFromList() throws WaoException { if (!user.isAdmin() && !user.getReadOnly() && isSampleRowExists()) { return boat.canCreateContact(user.getCompany()); } @@ -551,7 +539,7 @@ log.debug("Filter sampleRow : " + getFilter().getSampleRow()); } result = serviceBoat.exportBoatCsv(getFilter()); - } catch (WaoExceptionO eee) { + } catch (WaoException eee) { throw new IOException(eee); } return result; @@ -559,7 +547,7 @@ }; } - Block onActionFromShowBoatInfos(Integer boatImma) throws WaoExceptionO { + Block onActionFromShowBoatInfos(Integer boatImma) throws WaoException { boatSelectedImmatriculation = boatImma; // Suppress persistant boat informations companyBoatInfos = null; @@ -628,11 +616,8 @@ return displayBoatInfos; } - public CompanyBoatInfos getCompanyBoatInfos() throws WaoExceptionO { - if (companyBoatInfos == null && boatSelectedImmatriculation != null && getCompany() != null) { - if (log.isInfoEnabled()) { - log.info("BUSINESS REQUEST [getElligibleBoats]"); - } + public CompanyBoatInfos getCompanyBoatInfos() throws WaoException { + if (companyBoatInfos == null && boatSelectedImmatriculation != null && getCompany() != null) { companyBoatInfos = serviceBoat.getCompanyBoatInfos(boatSelectedImmatriculation, getCompany()); } return companyBoatInfos; @@ -645,11 +630,8 @@ * @return the GenericSelectModel<Company> * @throws WaoException */ - public GenericSelectModel<Company> getCompanies() throws WaoExceptionO { + public GenericSelectModel<Company> getCompanies() throws WaoException { if (companies == null) { - if (log.isDebugEnabled()) { - log.debug("BUSINESS REQUEST [getCompanies]"); - } List<Company> results = serviceUser.getCompanies(true); companies = new GenericSelectModel<Company>(results, Company.class, "name","topiaId",propertyAccess); } @@ -663,7 +645,7 @@ * @return the current Company * @throws WaoException */ - public Company getCompany() throws WaoExceptionO { + public Company getCompany() throws WaoException { if (company == null) { if (StringUtils.isNotEmpty(companySelectedId)) { company = getCompanies().findObject(companySelectedId); @@ -680,7 +662,7 @@ * @return the selected boat from the grid * @throws WaoException */ - public Boat getBoatSelected() throws WaoExceptionO { + public Boat getBoatSelected() throws WaoException { if (log.isDebugEnabled()) { log.debug("selected imma : " + boatSelectedImmatriculation); log.debug("exist boat ? : " + getBoats().contains(boatSelectedImmatriculation)); @@ -712,7 +694,7 @@ this.boardingFromDate = boardingFromDate; } - public BoatInfos getBoatInfos() throws WaoExceptionO { + public BoatInfos getBoatInfos() throws WaoException { if (getCompanyBoatInfos() == null) { return null; } @@ -726,7 +708,7 @@ * @throws WaoException * @see BusinessUtils#getContactStyle(Contact, boolean) */ - public String getlastContactStyle() throws WaoExceptionO { + public String getlastContactStyle() throws WaoException { Contact contact = getCompanyBoatInfos().getLastContact(); return BusinessUtils.getContactStyle(contact, user.isAdmin()); } @@ -741,7 +723,7 @@ return BooleanUtils.isFalse(elligibleBoat.getCompanyActive()); } - public boolean canCreateNewContactFromElligibleBoat() throws WaoExceptionO { + public boolean canCreateNewContactFromElligibleBoat() throws WaoException { if (!user.isAdmin() && !user.getReadOnly() && !isElligibleBoatCompanyActiveFalse()) { Boat currentBoat = getBoatInfos().getBoat(); @@ -766,19 +748,19 @@ return !user.getReadOnly(); } - void onSuccess() throws WaoExceptionO { + void onSuccess() throws WaoException { if (getBoatInfos() != null) { boatSelectedImmatriculation = getBoatInfos().getBoat().getImmatriculation(); } } - Block onSuccessFromCompanySelectForm() throws WaoExceptionO { + Block onSuccessFromCompanySelectForm() throws WaoException { companyBoatInfos = null; getCompanyBoatInfos(); return boatInfosZone.getBody(); } - Block onActionFromEditBoatInfos() throws WaoExceptionO { + Block onActionFromEditBoatInfos() throws WaoException { if (canEditBoatInfos()) { boatInfosEditable = true; // WARNING :: Reset sampleRow select for edition mode, no limit for @@ -790,7 +772,7 @@ return boatInfosZone.getBody(); } - Block onActionFromCancelEditBoatInfos() throws WaoExceptionO { + Block onActionFromCancelEditBoatInfos() throws WaoException { /*if (propertyChange.isChanged()) { if (log.isDebugEnabled()) { log.debug("Change property"); @@ -804,7 +786,7 @@ return boatInfosZone.getBody(); } - void onSelectedFromAddBoatInfosSampleRow() throws WaoExceptionO { + void onSelectedFromAddBoatInfosSampleRow() throws WaoException { // We stay in edition mode boatInfosEditable = true; if (StringUtils.isNotEmpty(boatInfosSampleRowId)) { @@ -813,17 +795,17 @@ } } - void onSelectedFromRemoveBoatInfosSampleRow(String sampleRowCode) throws WaoExceptionO { + void onSelectedFromRemoveBoatInfosSampleRow(String sampleRowCode) throws WaoException { boatInfosEditable = true; companyBoatInfos.removeElligibleBoat(sampleRowCode); } - void onSelectedFromActiveBoatInfosSampleRow(String sampleRowCode) throws WaoExceptionO { + void onSelectedFromActiveBoatInfosSampleRow(String sampleRowCode) throws WaoException { boatInfosEditable = true; companyBoatInfos.activeElligibleBoat(sampleRowCode); } - Block onSuccessFromBoatInfosForm() throws WaoExceptionO { + Block onSuccessFromBoatInfosForm() throws WaoException { if (!boatInfosEditable && canEditBoatInfos()) { // Save data serviceBoat.createUpdateCompanyBoatInfos(companyBoatInfos); @@ -832,7 +814,7 @@ return boatInfosZone.getBody(); } - Block onSuccessFromCalculateBoardings() throws WaoExceptionO { + Block onSuccessFromCalculateBoardings() throws WaoException { //boatSelectedImmatriculation = getBoatInfos().getBoat().getImmatriculation(); return boatInfosZone.getBody(); } @@ -842,7 +824,7 @@ @InjectPage private Contacts contacts; - Object onActionFromAddNewContactFromBoat(int boatImmatriculation) throws WaoExceptionO { + Object onActionFromAddNewContactFromBoat(int boatImmatriculation) throws WaoException { // Get selected sampleRow sampleRow = getSampleRow(); // Get boat from list @@ -851,7 +833,7 @@ return contacts; } - Object onActionFromAddNewContactFromSampleRow(String sampleRowCode) throws WaoExceptionO { + Object onActionFromAddNewContactFromSampleRow(String sampleRowCode) throws WaoException { // Get sampleRow from elligibleBoat list ElligibleBoat elligible = getCompanyBoatInfos().getElligibleBoat(sampleRowCode); sampleRow = elligible.getSampleRow(); @@ -864,11 +846,11 @@ @InjectPage private BoatActivityCalendar calendarPage; - public boolean hasActivityCalendar() throws WaoExceptionO { + public boolean hasActivityCalendar() throws WaoException { return getBoatSelected().sizeActivityCalendar() != 0; } - Object onActionFromShowLastActivityCalendar() throws WaoExceptionO { + Object onActionFromShowLastActivityCalendar() throws WaoException { calendarPage.setBoat(getBoatSelected()); return calendarPage; } Modified: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Contacts.java =================================================================== --- trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Contacts.java 2010-04-01 17:14:29 UTC (rev 408) +++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Contacts.java 2010-04-01 18:21:22 UTC (rev 409) @@ -23,7 +23,7 @@ import fr.ifremer.wao.WaoBusinessException; import fr.ifremer.wao.WaoException; -import fr.ifremer.wao.WaoExceptionO; +import fr.ifremer.wao.WaoException; import fr.ifremer.wao.bean.BoatFilter; import fr.ifremer.wao.bean.ContactFilter; import fr.ifremer.wao.bean.ContactFilterImpl; @@ -121,7 +121,7 @@ // private String contactEditedId; @Log - void setupRender() throws WaoExceptionO { + void setupRender() throws WaoException { // if (contactEdited == null) { if (log.isDebugEnabled()) { log.debug("RESET DATA"); @@ -149,7 +149,7 @@ @Property private ContactState stateFilter; - public ContactFilter getContactFilter() throws WaoExceptionO { + public ContactFilter getContactFilter() throws WaoException { if (contactFilter == null) { if (log.isDebugEnabled()) { log.debug("Init contactFilter"); @@ -168,7 +168,7 @@ } @Override - protected BoatFilter getFilter() throws WaoExceptionO { + protected BoatFilter getFilter() throws WaoException { return getContactFilter(); } @@ -191,7 +191,7 @@ } @Log - Object onSuccessFromFiltersForm() throws WaoExceptionO { + Object onSuccessFromFiltersForm() throws WaoException { if (isEdited()) { return filtersZone.getBody(); } @@ -222,7 +222,7 @@ } @Log - void onSuccessFromImportContacts() throws WaoExceptionO { + void onSuccessFromImportContacts() throws WaoException { if (canImportExport()) { try { ImportResults result = serviceContact.importContactCsv(user, @@ -251,7 +251,7 @@ try { result = serviceContact.exportContactCsv( getContactFilter()); - } catch (WaoExceptionO eee) { + } catch (WaoException eee) { throw new IOException(eee); } return result; @@ -292,7 +292,7 @@ private boolean even = true; - public ContactDataSource getContacts() throws WaoExceptionO { + public ContactDataSource getContacts() throws WaoException { if (contacts == null) { if (log.isInfoEnabled()) { log.info("Create DataSource"); @@ -341,7 +341,7 @@ return BusinessUtils.getTooltipBoat(contact.getBoat()); } - public String getTooltipExportFrom() throws WaoExceptionO { + public String getTooltipExportFrom() throws WaoException { if (getContactFilter().getFromDate() != null) { return "depuis le " + getDateFormat().format(getContactFilter().getFromDate()); } @@ -443,7 +443,7 @@ } } - void onSelectedFromAcceptContact(String contactId) throws WaoExceptionO { + void onSelectedFromAcceptContact(String contactId) throws WaoException { if (log.isDebugEnabled()) { log.debug("Accept contact : " + contactId); } @@ -457,7 +457,7 @@ } } - void onSelectedFromRefuseContact(String contactId) throws WaoExceptionO { + void onSelectedFromRefuseContact(String contactId) throws WaoException { if (log.isDebugEnabled()) { log.debug("Refuse contact : " + contactId); } @@ -471,7 +471,7 @@ } } - void onSelectedFromUnvalidateContact(String contactId) throws WaoExceptionO { + void onSelectedFromUnvalidateContact(String contactId) throws WaoException { if (log.isDebugEnabled()) { log.debug("Unvalidate contact : " + contactId); } @@ -492,7 +492,7 @@ } } - void onSelectedFromEditContact(String contactId) throws WaoExceptionO { + void onSelectedFromEditContact(String contactId) throws WaoException { if (log.isDebugEnabled()) { log.debug("Edit contact : " + contactId); } @@ -504,7 +504,7 @@ edited = true; } - void onSelectedFromDeleteContact(String contactId) throws WaoExceptionO { + void onSelectedFromDeleteContact(String contactId) throws WaoException { if (log.isDebugEnabled()) { log.debug("Delete contact : " + contactId); } @@ -512,7 +512,7 @@ deleted = true; } - void onSelectedFromSaveContact(String contactId) throws WaoExceptionO { + void onSelectedFromSaveContact(String contactId) throws WaoException { if (log.isDebugEnabled()) { log.debug("Save contact : " + contactId); } @@ -526,7 +526,7 @@ } } - void onSelectedFromCancelEditContact() throws WaoExceptionO { + void onSelectedFromCancelEditContact() throws WaoException { contactEdited = null; edited = true; } @@ -675,7 +675,7 @@ //return gridZone; } - public void createNewContact(Boat boat, SampleRow sampleRow) throws WaoExceptionO { + public void createNewContact(Boat boat, SampleRow sampleRow) throws WaoException { contact = serviceContact.getNewContact(user, sampleRow, boat); // Check boat not null and validation for create the new contact if (boat != null && boat.canCreateContact(user.getCompany())) { Modified: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/ExceptionReport.java =================================================================== --- trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/ExceptionReport.java 2010-04-01 17:14:29 UTC (rev 408) +++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/ExceptionReport.java 2010-04-01 18:21:22 UTC (rev 409) @@ -22,7 +22,6 @@ package fr.ifremer.wao.ui.pages; import fr.ifremer.wao.WaoException; -import fr.ifremer.wao.WaoExceptionO; import fr.ifremer.wao.ui.base.WaoPage; import fr.ifremer.wao.ui.components.Layout; import fr.ifremer.wao.ui.data.BusinessUtils; @@ -69,13 +68,13 @@ @Override public void reportException(Throwable eee) { - this.exception = getWaoExceptionO(eee); - if (exception != null) { - layout.addError(exception.getMessage()); - this.exception = exception.getCause(); - layout.addError("Erreur : " + this.exception.getClass().getSimpleName() - + " : " + this.exception.getMessage()); - } else { +// this.exception = getWaoExceptionO(eee); +// if (exception != null) { +// layout.addError(exception.getMessage()); +// this.exception = exception.getCause(); +// layout.addError("Erreur : " + this.exception.getClass().getSimpleName() +// + " : " + this.exception.getMessage()); +// } else { this.exception = getWaoException(eee); if (exception != null) { String[] errors = @@ -88,7 +87,7 @@ this.exception.getClass().getSimpleName() + " : " + this.exception.getMessage()); } - } +// } } protected Throwable getWaoException(Throwable eee) { @@ -101,14 +100,14 @@ return getWaoException(eee.getCause()); } - protected Throwable getWaoExceptionO(Throwable eee) { - if (eee == null) { - return eee; - } - if (eee instanceof WaoExceptionO) { - return eee; - } - return getWaoExceptionO(eee.getCause()); - } +// protected Throwable getWaoExceptionO(Throwable eee) { +// if (eee == null) { +// return eee; +// } +// if (eee instanceof WaoExceptionO) { +// return eee; +// } +// return getWaoExceptionO(eee.getCause()); +// } } Modified: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Index.java =================================================================== --- trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Index.java 2010-04-01 17:14:29 UTC (rev 408) +++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Index.java 2010-04-01 18:21:22 UTC (rev 409) @@ -21,7 +21,7 @@ package fr.ifremer.wao.ui.pages; -import fr.ifremer.wao.WaoExceptionO; +import fr.ifremer.wao.WaoException; import fr.ifremer.wao.entity.News; import fr.ifremer.wao.entity.NewsImpl; import fr.ifremer.wao.entity.WaoUser; @@ -97,7 +97,7 @@ @Log - void setupRender() throws WaoExceptionO { + void setupRender() throws WaoException { if (editedId == null || !"NEW".equals(editedId)) { newsList = null; getNewsList(); @@ -114,7 +114,7 @@ // return editedId; // } - public List<News> getNewsList() throws WaoExceptionO { + public List<News> getNewsList() throws WaoException { if (newsList == null) { newsList = serviceNews.getNews(); } @@ -140,7 +140,7 @@ return dateFormat; } - void onActionFromAddNews() throws WaoExceptionO { + void onActionFromAddNews() throws WaoException { news = new NewsImpl(); // Create a new list with the new news in first position List<News> list = new ArrayList<News>(); @@ -150,12 +150,12 @@ editedId = "NEW"; } - void onActionFromEditNews(int rowIndex) throws WaoExceptionO { + void onActionFromEditNews(int rowIndex) throws WaoException { news = getNewsList().get(rowIndex); this.editedId = news.getTopiaId(); } - void onActionFromDeleteNews(int rowIndex) throws WaoExceptionO { + void onActionFromDeleteNews(int rowIndex) throws WaoException { news = getNewsList().get(rowIndex); serviceNews.saveNews(news, true); //newsList = null; @@ -164,11 +164,11 @@ void onActionFromCancelEdit() { } - void onSelectedFromSaveNews(int rowIndex) throws WaoExceptionO { + void onSelectedFromSaveNews(int rowIndex) throws WaoException { news = getNewsList().get(rowIndex); } - void onSuccessFromNewsForm() throws WaoExceptionO { + void onSuccessFromNewsForm() throws WaoException { if (canEditNews()) { serviceNews.saveNews(news, false); //this.editedId = null; Modified: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/SampleRowForm.java =================================================================== --- trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/SampleRowForm.java 2010-04-01 17:14:29 UTC (rev 408) +++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/SampleRowForm.java 2010-04-01 18:21:22 UTC (rev 409) @@ -22,9 +22,8 @@ package fr.ifremer.wao.ui.pages; import fr.ifremer.wao.WaoBusinessException; -import fr.ifremer.wao.WaoContextO; import fr.ifremer.wao.WaoException; -import fr.ifremer.wao.WaoExceptionO; +import fr.ifremer.wao.WaoException; import fr.ifremer.wao.entity.Boat; import fr.ifremer.wao.entity.Company; import fr.ifremer.wao.entity.FishingZone; @@ -127,7 +126,7 @@ return sampleRowId; } - void setupRender() throws WaoExceptionO { + void setupRender() throws WaoException { // Reset data sampleRow = null; getSampleRow(); @@ -188,11 +187,8 @@ * @return a GenericSelectModel<Profession> * @throws WaoException */ - public GenericSelectModel<Profession> getProfessionSelectModel() throws WaoExceptionO { + public GenericSelectModel<Profession> getProfessionSelectModel() throws WaoException { if (professionSelectModel == null) { - if (log.isInfoEnabled()) { - log.info("BUSINESS REQUEST [getProfessions]"); - } List<Profession> professions = serviceReferential.getProfessions(); professionSelectModel = new GenericSelectModel<Profession>(professions, Profession.class, "code", "topiaId", propertyAccess); @@ -214,7 +210,7 @@ * * @throws WaoException */ - void onSelectedFromAddNewProfession() throws WaoExceptionO { + void onSelectedFromAddNewProfession() throws WaoException { Profession profession = new ProfessionImpl(); if (!StringUtils.isEmpty(professionId)) { Profession professionSelected = getProfessionSelectModel().findObject(professionId); @@ -255,11 +251,8 @@ * @return a GenericSelectModel<FishingZone> * @throws WaoException */ - public GenericSelectModel<FishingZone> getFishingZoneSelectModel() throws WaoExceptionO { + public GenericSelectModel<FishingZone> getFishingZoneSelectModel() throws WaoException { if (fishingZoneSelectModel == null) { - if (log.isInfoEnabled()) { - log.info("BUSINESS REQUEST [getFishingZones]"); - } List<FishingZone> zones = serviceReferential.getFishingZones(); fishingZoneSelectModel = new GenericSelectModel<FishingZone>(zones, FishingZone.class, "code", "topiaId", propertyAccess); @@ -273,7 +266,7 @@ * @return a List of FishingZone linked with the SampleRow * @throws WaoException */ - public List<FishingZone> getFishingZones() throws WaoExceptionO { + public List<FishingZone> getFishingZones() throws WaoException { return getSampleRow().getFishingZone(); } @@ -282,7 +275,7 @@ * * @throws WaoException */ - void onSelectedFromAddFishingZone() throws WaoExceptionO { + void onSelectedFromAddFishingZone() throws WaoException { fishingZone = getFishingZoneSelectModel().findObject(fishingZoneId); if (!getFishingZones().contains(fishingZone)) { if (log.isDebugEnabled()) { @@ -299,7 +292,7 @@ * @param index of the FishingZone in the list (from loop component) * @throws WaoException */ - void onSelectedFromRemoveFishingZone(int index) throws WaoExceptionO { + void onSelectedFromRemoveFishingZone(int index) throws WaoException { if (log.isDebugEnabled()) { log.debug("Remove fishingZone at position : " + index); } @@ -349,11 +342,8 @@ private boolean periodChanged; - public SelectModel getProgramSelectModel() throws WaoExceptionO { + public SelectModel getProgramSelectModel() throws WaoException { if (programSelectModel == null) { - if (log.isInfoEnabled()) { - log.info("BUSINESS REQUEST [getPrograms]"); - } List<OptionModel> options = new ArrayList<OptionModel>(); for (String name : serviceSampling.getPrograms(null)) { options.add(new OptionModelImpl(name, name)); @@ -379,7 +369,7 @@ // return getSampleRow().getProgram(); // } - public PeriodDates getPeriod() throws WaoExceptionO { + public PeriodDates getPeriod() throws WaoException { if (period == null) { Date begin = getSampleRow().getPeriodBegin(); Date end = getSampleRow().getPeriodEnd(); @@ -388,7 +378,7 @@ return period; } - public List<SampleMonth> getSampleMonths() throws WaoExceptionO { + public List<SampleMonth> getSampleMonths() throws WaoException { if (sampleMonths == null) { sampleMonths = new ArrayList<SampleMonth>(); for (Date currMonth : getPeriod().getMonths()) { @@ -448,7 +438,7 @@ * @throws WaoException */ @Log - void onSelectedFromRefreshMonths() throws WaoExceptionO { + void onSelectedFromRefreshMonths() throws WaoException { getSampleRow().setPeriod(period); periodChanged = true; // Reset sampleMonths for new period @@ -457,7 +447,7 @@ saveProgram(); } - protected void saveProgram() throws WaoExceptionO { + protected void saveProgram() throws WaoException { // Save programName if (StringUtils.isNotEmpty(programName)) { getSampleRow().setProgramName(programName); @@ -471,7 +461,7 @@ } @Log - void onSelectedFromDeleteMonth(int index) throws WaoExceptionO { + void onSelectedFromDeleteMonth(int index) throws WaoException { getSampleMonths().remove(index); edited = true; } @@ -509,12 +499,9 @@ @Persist private WaoPropertyChangeListener propertyChange; - public SampleRow getSampleRow() throws WaoExceptionO { + public SampleRow getSampleRow() throws WaoException { if (sampleRow == null) { if (!StringUtils.isEmpty(sampleRowId)) { - if (log.isInfoEnabled()) { - log.info("BUSINESS REQUEST [getSampleRow]"); - } sampleRow = serviceSampling.getSampleRow(sampleRowId); propertyChange = new WaoPropertyChangeListener(); for (SampleMonth month : sampleRow.getSampleMonth()) { @@ -528,7 +515,7 @@ return sampleRow; } - public SampleRowLog getSampleRowLog() throws WaoExceptionO { + public SampleRowLog getSampleRowLog() throws WaoException { if (sampleRowLog == null) { sampleRowLog = getSampleRow().getNewSampleRowLog(user); } @@ -545,11 +532,8 @@ return sampleRowModel; } - public GenericSelectModel<Company> getCompanySelectModel() throws WaoExceptionO { + public GenericSelectModel<Company> getCompanySelectModel() throws WaoException { if (companySelectModel == null) { - if (log.isInfoEnabled()) { - log.info("BUSINESS REQUEST [getCompanies]"); - } List<Company> companies = serviceUser.getCompanies(true); companySelectModel = new GenericSelectModel<Company>(companies, Company.class, "name", "topiaId", propertyAccess); @@ -557,7 +541,7 @@ return companySelectModel; } - public boolean isCreateMode() throws WaoExceptionO { + public boolean isCreateMode() throws WaoException { return StringUtils.isEmpty(getSampleRow().getTopiaId()); } @@ -565,12 +549,12 @@ cancel = true; } - void onSelectedFromSaveData() throws WaoExceptionO { + void onSelectedFromSaveData() throws WaoException { saveProgram(); } @Log - void onValidateFormFromSampleRowForm() throws WaoExceptionO { + void onValidateFormFromSampleRowForm() throws WaoException { sampleRowForm.clearErrors(); try { // Only for save or periodChanged (refreshMonth) @@ -661,7 +645,7 @@ } @Log - Object onSuccessFromSampleRowForm() throws WaoExceptionO { + Object onSuccessFromSampleRowForm() throws WaoException { if (cancel) { return this; } Modified: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/SampleRowHistoric.java =================================================================== --- trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/SampleRowHistoric.java 2010-04-01 17:14:29 UTC (rev 408) +++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/SampleRowHistoric.java 2010-04-01 18:21:22 UTC (rev 409) @@ -22,7 +22,7 @@ package fr.ifremer.wao.ui.pages; import fr.ifremer.wao.WaoBusinessException; -import fr.ifremer.wao.WaoExceptionO; +import fr.ifremer.wao.WaoException; import fr.ifremer.wao.bean.UserRole; import fr.ifremer.wao.entity.SampleRow; import fr.ifremer.wao.entity.SampleRowLog; @@ -100,7 +100,7 @@ return sampleRowCode; } - void setupRender() throws WaoExceptionO { + void setupRender() throws WaoException { if (StringUtils.isEmpty(sampleRowCode)) { layout.addFatal("L'historique ne peut pas être affiché : " + "Aucun code de ligne n'est spécifié dans l'url. "); @@ -121,7 +121,7 @@ } } - public SampleRow getSampleRow() throws WaoExceptionO { + public SampleRow getSampleRow() throws WaoBusinessException { if (sampleRow == null) { sampleRow = serviceSampling.getSampleRowByCode(user, sampleRowCode); } @@ -142,7 +142,7 @@ return content; } - public SampleRowLog getNewLog() throws WaoExceptionO { + public SampleRowLog getNewLog() throws WaoBusinessException { if (newLog == null) { newLog = getSampleRow().getNewSampleRowLog(user); } @@ -154,7 +154,7 @@ !user.getReadOnly(); } - public void onSuccessFromAddComment() throws WaoExceptionO { + public void onSuccessFromAddComment() throws WaoException { if (canAddComment()) { sampleRow.saveSampleRowLog(newLog); } Modified: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/SamplingPlan.java =================================================================== --- trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/SamplingPlan.java 2010-04-01 17:14:29 UTC (rev 408) +++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/SamplingPlan.java 2010-04-01 18:21:22 UTC (rev 409) @@ -24,7 +24,7 @@ import fr.ifremer.wao.WaoBusinessException; import fr.ifremer.wao.WaoException; -import fr.ifremer.wao.WaoExceptionO; +import fr.ifremer.wao.WaoException; import fr.ifremer.wao.bean.FacadeRow; import fr.ifremer.wao.bean.ImportResults; import fr.ifremer.wao.entity.Company; @@ -121,7 +121,7 @@ } @Log - void onSuccessFromImportSamplingPlan() throws WaoExceptionO { + void onSuccessFromImportSamplingPlan() throws WaoException { if (canImportSamplingPlan()) { try { ImportResults result = serviceSampling.importSamplingPlanCsv( @@ -212,11 +212,8 @@ * @return List of SampleRow * @throws WaoException */ - public List<SampleRow> getData() throws WaoExceptionO { + public List<SampleRow> getData() throws WaoException { if (data == null) { - if (log.isInfoEnabled()) { - log.info("BUSINESS REQUEST [getSampleRowsOrderedByFishingZone]"); - } Company company = null; if (!user.isAdmin()) { company = user.getCompany(); @@ -399,13 +396,13 @@ * @param rowIndex index of the row in the table * @throws WaoException for a data problem */ - void onActionFromFilterPeriodDates(int rowIndex) throws WaoExceptionO { + void onActionFromFilterPeriodDates(int rowIndex) throws WaoException { row = getData().get(rowIndex); period.setFromDate(row.getPeriodBegin()); period.setThruDate(row.getPeriodEnd()); } - void onActionFromDeleteSampleRow(int rowIndex) throws WaoExceptionO { + void onActionFromDeleteSampleRow(int rowIndex) throws WaoException { row = getData().get(rowIndex); serviceSampling.deleteSampleRow(row); } Modified: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Synthesis.java =================================================================== --- trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Synthesis.java 2010-04-01 17:14:29 UTC (rev 408) +++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Synthesis.java 2010-04-01 18:21:22 UTC (rev 409) @@ -21,7 +21,7 @@ package fr.ifremer.wao.ui.pages; -import fr.ifremer.wao.WaoExceptionO; +import fr.ifremer.wao.WaoException; import fr.ifremer.wao.bean.BoardingResult; import fr.ifremer.wao.bean.BoatFilter; import fr.ifremer.wao.bean.BoatFilterImpl; @@ -105,7 +105,7 @@ @InjectComponent private Zone delegator; - public Block getActiveBlock() throws WaoExceptionO { + public Block getActiveBlock() throws WaoException { if (activeSynthesis == null) { // Initialize default synthesis by Data Sampling activeSynthesis = SynthesisId.GRAPH_SAMPLING; @@ -165,12 +165,12 @@ private boolean reset; - private void initSamplingBlock() throws WaoExceptionO { + private void initSamplingBlock() throws WaoException { initSelectFilters(true, false, true); } @Override - public BoatFilter getFilter() throws WaoExceptionO { + public BoatFilter getFilter() throws WaoException { if (dataSamplingFilter == null) { dataSamplingFilter = new BoatFilterImpl(); if (!user.isAdmin()) { @@ -180,7 +180,7 @@ return dataSamplingFilter; } - public PeriodDates getPeriod() throws WaoExceptionO { + public PeriodDates getPeriod() throws WaoException { if (getFilter().getPeriod() == null) { PeriodDates period = PeriodDates.createMonthsPeriodFromToday(-12); if (log.isDebugEnabled()) { @@ -196,10 +196,7 @@ return false; } - public JFreeChart getDataSamplingChart() throws WaoExceptionO { - if (log.isInfoEnabled()) { - log.info("BUSINESS REQUEST [getDataSampling]"); - } + public JFreeChart getDataSamplingChart() throws WaoException { List<SortedMap<Date, Integer>> res = serviceSynthesis.getDataSampling(getFilter()); Map<String, Map<?, Integer>> data = new HashMap<String, Map<?, Integer>>(); data.put("Planifié", res.get(0)); @@ -243,7 +240,7 @@ @Property private String companyIdForBoarding; - private void initBoardingBlock() throws WaoExceptionO { + private void initBoardingBlock() throws WaoException { resetCompanySelect(); // Set the companyIdForBoarding is only necessary for an admin which // have access to a select with all active companies (from Filters : @@ -256,7 +253,7 @@ } } - public JFreeChart getBoardingBoatsChart() throws WaoExceptionO { + public JFreeChart getBoardingBoatsChart() throws WaoException { Map<String, Map<?, Integer>> data = new HashMap<String, Map<?, Integer>>(); data.put("Navires", getBoardingResult().getData()); @@ -272,11 +269,8 @@ "Nb embarquements", ChartType.BAR, data); } - public BoardingResult getBoardingResult() throws WaoExceptionO { + public BoardingResult getBoardingResult() throws WaoException { if (boardingResult == null) { - if (log.isInfoEnabled()) { - log.info("BUSINESS REQUEST [getBoardingBoats]"); - } boardingResult = serviceSynthesis.getBoardingBoats( getCompanyForBoarding(), getFromDate()); } @@ -300,7 +294,7 @@ } @Log - void onSuccessFromFilterCompanyForBoarding() throws WaoExceptionO { + void onSuccessFromFilterCompanyForBoarding() throws WaoException { companyForBoarding = getCompanySelectModel().findObject(companyIdForBoarding); } @@ -320,7 +314,7 @@ * @throws WaoException */ public Map<String, Double> getNonComplianceBoarding() - throws WaoExceptionO { + throws WaoException { if (nonComplianceBoarding == null) { Company company = !user.isAdmin() ? user.getCompany() : null; nonComplianceBoarding = @@ -336,7 +330,7 @@ * @return the value of the indicator * @throws WaoException */ - public Double getNonComplianceBoardingValue() throws WaoExceptionO { + public Double getNonComplianceBoardingValue() throws WaoException { return getNonComplianceBoarding().get(user.getCompany().getName()); } @@ -370,7 +364,7 @@ * @throws WaoException */ public Collection<ContactStateStatistics> getContactStateStatistics() - throws WaoExceptionO { + throws WaoException { if (contactStateStatistics == null) { Company company = !user.isAdmin() ? user.getCompany() : null; contactStateStatistics = @@ -421,7 +415,7 @@ private ContactAverageReactivity allegroReactivityEntry; public Collection<ContactAverageReactivity> getAllegroReactivity() - throws WaoExceptionO { + throws WaoException { if (allegroReactivity == null) { Company company = !user.isAdmin() ? user.getCompany() : null; allegroReactivity = @@ -438,7 +432,7 @@ return periodForAllegroReactivity; } - public Double getAllegroReactivityValue() throws WaoExceptionO { + public Double getAllegroReactivityValue() throws WaoException { if (!getAllegroReactivity().isEmpty()) { ContactAverageReactivity entry = (ContactAverageReactivity) CollectionUtils.get(getAllegroReactivity(), 0); @@ -448,7 +442,7 @@ } } - public String getAllegroReactivityStyle() throws WaoExceptionO { + public String getAllegroReactivityStyle() throws WaoException { double value = user.isAdmin() ? allegroReactivityEntry.getResult() : getAllegroReactivityValue(); if (value >= 15.) { Modified: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/UserProfile.java =================================================================== --- trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/UserProfile.java 2010-04-01 17:14:29 UTC (rev 408) +++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/UserProfile.java 2010-04-01 18:21:22 UTC (rev 409) @@ -22,7 +22,7 @@ package fr.ifremer.wao.ui.pages; import fr.ifremer.wao.WaoBusinessException; -import fr.ifremer.wao.WaoExceptionO; +import fr.ifremer.wao.WaoException; import fr.ifremer.wao.entity.WaoUser; import fr.ifremer.wao.service.ServiceUser; import fr.ifremer.wao.ui.base.WaoPage; @@ -90,7 +90,7 @@ return userEditable; } - void onSuccessFromUserForm() throws WaoExceptionO { + void onSuccessFromUserForm() throws WaoException { if (password != null && !password.equals(password2)) { userForm.recordError("Les deux password ne sont pas identiques, vérifiez la saisie !"); Modified: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/services/AppModule.java =================================================================== --- trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/services/AppModule.java 2010-04-01 17:14:29 UTC (rev 408) +++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/services/AppModule.java 2010-04-01 18:21:22 UTC (rev 409) @@ -48,7 +48,6 @@ public class AppModule { public static void bind(ServiceBinder binder) { - binder.bind(ServiceSynthesis.class, ServiceSynthesisImpl.class); binder.bind(ContactModelFactory.class); } @@ -95,6 +94,12 @@ return instance; } + public ServiceSynthesis buildServiceSynthesis(WaoManager manager) { + ServiceSynthesisImpl instance = new ServiceSynthesisImpl(); + instance.setContext(manager.getContext()); + return instance; + } + public static void contributeApplicationDefaults( MappedConfiguration<String, String> configuration) { // Contributions to ApplicationDefaults will override any contributions to @@ -103,7 +108,7 @@ // you can extend this list of locales (it's a comma separated series of locale names; // the first locale name is the default when there's no reasonable match). - configuration.add(SymbolConstants.SUPPORTED_LOCALES, "fr,en"); + configuration.add(SymbolConstants.SUPPORTED_LOCALES, "fr"); // The factory default is true but during the early stages of an application // overriding to false is a good idea. In addition, this is often overridden