[Suiviobsmer-commits] r402 - in trunk: . wao-business wao-business/src/main/java/fr/ifremer/wao wao-business/src/main/java/fr/ifremer/wao/bean wao-business/src/main/java/fr/ifremer/wao/entity wao-business/src/main/java/fr/ifremer/wao/io wao-business/src/main/java/fr/ifremer/wao/mock wao-business/src/main/java/fr/ifremer/wao/service wao-business/src/main/resources wao-business/src/main/resources/i18n wao-business/src/main/resources/oldmappings wao-business/src/main/resources/oldmappings/Wao wao-business/src/
Author: fdesbois Date: 2010-04-01 13:28:03 +0000 (Thu, 01 Apr 2010) New Revision: 402 Added: trunk/wao-business/nbactions.xml trunk/wao-business/src/main/java/fr/ifremer/wao/WaoContextImpl.java 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/WaoProperty.java trunk/wao-business/src/main/resources/i18n/ 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/resources/oldmappings/Wao/ trunk/wao-business/src/main/resources/oldmappings/Wao/1.1/ trunk/wao-business/src/main/resources/oldmappings/Wao/1.1/fr/ trunk/wao-business/src/main/resources/oldmappings/Wao/1.1/fr/ifremer/ trunk/wao-business/src/main/resources/oldmappings/Wao/1.1/fr/ifremer/wao/ trunk/wao-business/src/main/resources/oldmappings/Wao/1.1/fr/ifremer/wao/entity/ trunk/wao-business/src/main/resources/oldmappings/Wao/1.1/fr/ifremer/wao/entity/ActivityCalendarImpl.hbm.xml trunk/wao-business/src/main/resources/oldmappings/Wao/1.1/fr/ifremer/wao/entity/ActivityMonthImpl.hbm.xml trunk/wao-business/src/main/resources/oldmappings/Wao/1.1/fr/ifremer/wao/entity/ActivityProfessionImpl.hbm.xml trunk/wao-business/src/main/resources/oldmappings/Wao/1.1/fr/ifremer/wao/entity/ActivityZoneImpl.hbm.xml trunk/wao-business/src/main/resources/oldmappings/Wao/1.1/fr/ifremer/wao/entity/BoatImpl.hbm.xml trunk/wao-business/src/main/resources/oldmappings/Wao/1.1/fr/ifremer/wao/entity/BoatInfosImpl.hbm.xml trunk/wao-business/src/main/resources/oldmappings/Wao/1.1/fr/ifremer/wao/entity/CompanyImpl.hbm.xml trunk/wao-business/src/main/resources/oldmappings/Wao/1.1/fr/ifremer/wao/entity/ContactImpl.hbm.xml trunk/wao-business/src/main/resources/oldmappings/Wao/1.1/fr/ifremer/wao/entity/ElligibleBoatImpl.hbm.xml trunk/wao-business/src/main/resources/oldmappings/Wao/1.1/fr/ifremer/wao/entity/FishingZoneImpl.hbm.xml trunk/wao-business/src/main/resources/oldmappings/Wao/1.1/fr/ifremer/wao/entity/NewsImpl.hbm.xml trunk/wao-business/src/main/resources/oldmappings/Wao/1.1/fr/ifremer/wao/entity/ProfessionImpl.hbm.xml trunk/wao-business/src/main/resources/oldmappings/Wao/1.1/fr/ifremer/wao/entity/SampleMonthImpl.hbm.xml trunk/wao-business/src/main/resources/oldmappings/Wao/1.1/fr/ifremer/wao/entity/SampleRowImpl.hbm.xml trunk/wao-business/src/main/resources/oldmappings/Wao/1.1/fr/ifremer/wao/entity/SampleRowLogImpl.hbm.xml trunk/wao-business/src/main/resources/oldmappings/Wao/1.1/fr/ifremer/wao/entity/ShipOwnerImpl.hbm.xml trunk/wao-business/src/main/resources/oldmappings/Wao/1.1/fr/ifremer/wao/entity/WaoUserImpl.hbm.xml trunk/wao-business/src/test/java/fr/ifremer/wao/TestManager.java trunk/wao-business/src/test/java/fr/ifremer/wao/io/ImportHelperTest.java Removed: trunk/wao-business/src/main/java/fr/ifremer/wao/WaoContext.java trunk/wao-business/src/main/java/fr/ifremer/wao/WaoException.java trunk/wao-business/src/main/java/fr/ifremer/wao/mock/ServiceNewsMock.java trunk/wao-business/src/test/java/fr/ifremer/wao/ImportHelperTest.java trunk/wao-business/src/test/java/fr/ifremer/wao/WaoRunnerTest.java trunk/wao-business/src/test/java/fr/ifremer/wao/io/ImportHelperTest.java Modified: trunk/changelog.txt trunk/pom.xml trunk/wao-business/pom.xml trunk/wao-business/src/main/java/fr/ifremer/wao/WaoBusinessException.java trunk/wao-business/src/main/java/fr/ifremer/wao/WaoGlobal.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/bean/SamplingFilterImpl.java trunk/wao-business/src/main/java/fr/ifremer/wao/entity/BoatImpl.java trunk/wao-business/src/main/java/fr/ifremer/wao/entity/BoatInfosImpl.java trunk/wao-business/src/main/java/fr/ifremer/wao/entity/CompanyImpl.java trunk/wao-business/src/main/java/fr/ifremer/wao/entity/SampleMonthImpl.java trunk/wao-business/src/main/java/fr/ifremer/wao/entity/SampleRowImpl.java trunk/wao-business/src/main/java/fr/ifremer/wao/entity/WaoUserImpl.java trunk/wao-business/src/main/java/fr/ifremer/wao/io/ImportHelper.java trunk/wao-business/src/main/java/fr/ifremer/wao/service/ActivityCalendarImport.java trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceBoatImpl.java trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceContactImpl.java trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceNewsImpl.java trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceReferentialImpl.java trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceSamplingImpl.java trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceSynthesisImpl.java trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceUserImpl.java 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/WaoGlobalTest.java trunk/wao-business/src/test/java/fr/ifremer/wao/WaoUtilsTest.java trunk/wao-business/src/test/java/fr/ifremer/wao/entity/BoatImplTest.java trunk/wao-business/src/test/java/fr/ifremer/wao/entity/BoatInfosImplTest.java trunk/wao-business/src/test/java/fr/ifremer/wao/entity/SampleRowImplTest.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-business/src/test/java/fr/ifremer/wao/service/ServiceSynthesisImplTest.java trunk/wao-business/src/test/java/fr/ifremer/wao/service/ServiceUserImplTest.java trunk/wao-business/src/test/resources/log4j.properties trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/base/AbstractFilteredPage.java trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/components/FeedBack.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/BusinessUtils.java trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/data/ContactDataSource.java trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/data/ExportStreamResponse.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 trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/services/WaoManager.java Log: - Use ServiceTransformer (refactor Context managment + service implementations) - Remove updateFishingZone in createUpdateSampleRow, the topia evol on inverse tagValue resolve issue on saving fishingZone directly in sampleRow (Ano #2237) Modified: trunk/changelog.txt =================================================================== --- trunk/changelog.txt 2010-04-01 13:27:59 UTC (rev 401) +++ trunk/changelog.txt 2010-04-01 13:28:03 UTC (rev 402) @@ -9,6 +9,7 @@ Evolutions ++++++++++ +- [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) - [fdesbois] Evo #2229 : Gestion du chemin vers les logs de l'application @@ -30,6 +31,8 @@ Anomalies +++++++++ +- [fdesbois] Ano #2235 : Temp d'affichage page contacts ou plan + d'échantillonnage - [fdesbois] Ano #2228 : Erreur d'affichage de la synthèse : réactivité de la saisie dans Allegro Modified: trunk/pom.xml =================================================================== --- trunk/pom.xml 2010-04-01 13:27:59 UTC (rev 401) +++ trunk/pom.xml 2010-04-01 13:28:03 UTC (rev 402) @@ -215,8 +215,9 @@ <labs.id>154</labs.id> <!-- libraries version --> + <i18n.version>1.2</i18n.version> <nuitonutils.version>1.2.1-SNAPSHOT</nuitonutils.version> - <topia.version>2.3.1-SNAPSHOT</topia.version> + <topia.version>2.3.2-SNAPSHOT</topia.version> <eugene.version>2.0</eugene.version> <tapestry.version>5.1.0.5</tapestry.version> @@ -233,6 +234,12 @@ </scm> <build> +<!-- <resources> + <resource> + <directory>src/main/filters</directory> + <filtering>true</filtering> + </resource> + </resources>--> <pluginManagement> <plugins> @@ -266,6 +273,12 @@ </dependencies> </plugin> + <plugin> + <groupId>org.nuiton.i18n</groupId> + <artifactId>maven-i18n-plugin</artifactId> + <version>${i18n.version}</version> + </plugin> + </plugins> </pluginManagement> Added: trunk/wao-business/nbactions.xml =================================================================== --- trunk/wao-business/nbactions.xml (rev 0) +++ trunk/wao-business/nbactions.xml 2010-04-01 13:28:03 UTC (rev 402) @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="UTF-8"?> +<actions> + <action> + <actionName>CUSTOM-offline</actionName> + <displayName>offline</displayName> + <goals> + <goal>clean</goal> + <goal>install</goal> + <goal>-o</goal> + </goals> + </action> + </actions> Modified: trunk/wao-business/pom.xml =================================================================== --- trunk/wao-business/pom.xml 2010-04-01 13:27:59 UTC (rev 401) +++ trunk/wao-business/pom.xml 2010-04-01 13:28:03 UTC (rev 402) @@ -132,8 +132,9 @@ <defaultPackage>fr.ifremer.wao</defaultPackage> <templates> org.nuiton.topia.generator.TopiaMetaTransformer, - org.nuiton.topia.generator.InterfaceTransformer, - org.nuiton.topia.generator.BeanTransformer + org.nuiton.topia.generator.BeanTransformer, + org.nuiton.topia.generator.ServiceTransformer, + org.nuiton.topia.generator.InterfaceTransformer </templates> </configuration> <goals> @@ -156,6 +157,34 @@ </execution> </executions> </plugin> + <plugin> + <groupId>org.nuiton.i18n</groupId> + <artifactId>maven-i18n-plugin</artifactId> + <executions> + <execution> + <configuration> + <entries> + <entry> + <basedir>${maven.gen.dir}/java</basedir> + </entry> + </entries> + </configuration> + <goals> + <goal>parserJava</goal> + <goal>gen</goal> + </goals> + </execution> + <execution> + <id>make-bundle</id> + <configuration> + <bundleOutputName>wao-business</bundleOutputName> + </configuration> + <goals> + <goal>bundle</goal> + </goals> + </execution> + </executions> + </plugin> </plugins> </build> 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 13:27:59 UTC (rev 401) +++ trunk/wao-business/src/main/java/fr/ifremer/wao/WaoBusinessException.java 2010-04-01 13:28:03 UTC (rev 402) @@ -33,7 +33,7 @@ * Mise a jour: $Date$ * par : $Author$ */ -public class WaoBusinessException extends WaoException { +public class WaoBusinessException extends WaoExceptionO { protected Type type; Deleted: trunk/wao-business/src/main/java/fr/ifremer/wao/WaoContext.java =================================================================== --- trunk/wao-business/src/main/java/fr/ifremer/wao/WaoContext.java 2010-04-01 13:27:59 UTC (rev 401) +++ trunk/wao-business/src/main/java/fr/ifremer/wao/WaoContext.java 2010-04-01 13:28:03 UTC (rev 402) @@ -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 WaoContext { - - private static final Logger log = LoggerFactory.getLogger(WaoContext.class); - - public static final String PROP_FILENAME_LOG_ACTIVITY_IMPORT = - "wao.log.activityCalendar.import"; - public static final String PROP_FILENAME_LOG_ACTIVITY_ACCESS = - "wao.log.activityCalendar.access"; - public static final String PROP_EMAIL_HOST = "wao.email.host"; - public static final String PROP_EMAIL_PORT = "wao.email.port"; - public static final String PROP_EMAIL_FROM = "wao.email.from"; - public static final String PROP_VERSION = "wao.version"; - public static final String PROP_SERVER = "wao.server.path"; - - private static WaoRunner runner; - - private static boolean activityCalendarImport; - - private static org.apache.log4j.Logger activityCalendarAccessLogger; - - public static void setRunner(WaoRunner run) { - if (log.isDebugEnabled()) { - log.debug("set runner in context"); - } - runner = run; - } - - public static Date getCurrentDate() { - return runner.getCurrentDate(); - } - - public static String getProperty(String key) { - return runner.getConfiguration().getOption(key); - } - - public static TopiaContext getTopiaRootContext() throws WaoException { - if (runner.getConfiguration() == null) { - throw new WaoException("Configuration must be set before initializing context"); - } - try { - Properties props = runner.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 = getProperty(PROP_FILENAME_LOG_ACTIVITY_ACCESS); - - 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 WaoException { - if (log.isDebugEnabled()) { - log.debug("An error occured",eee); - } - if (!(eee instanceof WaoException)) { - //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 WaoException("Fatal topia error when close context", eeee); - } - //} - if (eee instanceof SQLGrammarException && log.isErrorEnabled()) { - log.error("SQL executed with error : " + ((SQLGrammarException)eee).getSQL()); - } - throw new WaoException(message,eee); - } else { - throw (WaoException)eee; - } - } - - public static void closeTransaction(TopiaContext transaction) throws WaoException { - try { - if (transaction != null) { - transaction.closeContext(); - } - } catch (TopiaException eee) { - throw new WaoException("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(getProperty(PROP_EMAIL_HOST)); - email.setSmtpPort(Integer.parseInt(getProperty(PROP_EMAIL_PORT))); - email.setFrom(getProperty(PROP_EMAIL_FROM)); - email.addTo(to); - email.setSubject(subject); - email.setMsg(msg); - email.setCharset("UTF-8"); - email.send(); - } -} Added: trunk/wao-business/src/main/java/fr/ifremer/wao/WaoContextImpl.java =================================================================== --- trunk/wao-business/src/main/java/fr/ifremer/wao/WaoContextImpl.java (rev 0) +++ trunk/wao-business/src/main/java/fr/ifremer/wao/WaoContextImpl.java 2010-04-01 13:28:03 UTC (rev 402) @@ -0,0 +1,413 @@ +/** + * *##% + * 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.nio.charset.Charset; +import java.util.Date; +import java.util.Locale; +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.hibernate.exception.SQLGrammarException; +import org.nuiton.i18n.I18n; +import org.nuiton.i18n.init.DefaultI18nInitializer; +import org.nuiton.topia.TopiaContext; +import org.nuiton.topia.TopiaContextFactory; +import org.nuiton.topia.TopiaException; +import org.nuiton.topia.TopiaNotFoundException; +import org.nuiton.topia.migration.ManualMigrationEngine; +import org.nuiton.topia.persistence.TopiaEntity; +import org.nuiton.topia.persistence.TopiaId; +import org.nuiton.util.ApplicationConfig; +import org.nuiton.util.ArgumentsParserException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import static org.nuiton.i18n.I18n.n_; +import static org.nuiton.i18n.I18n._; + +/** + * WaoContext.java + * + * Created on 2009-11-23 + * + * @author fdesbois + * @version $Revision$ + * + * Last update: $Date$ + * by : $Author: fdesbois $ + */ +public class WaoContextImpl implements WaoContextImplementor { + private static final Logger log = + LoggerFactory.getLogger(WaoContextImpl.class); + +// private static WaoRunner runner; + + private boolean activityCalendarImport; + + private Date currentDate; + + private ApplicationConfig configuration; + + private static final String DEFAULT_FILENAME = "Wao.properties"; + + private static final String APP_NAME = "wao"; + +// private static org.apache.log4j.Logger activityCalendarAccessLogger; + +// public static void setRunner(WaoRunner run) { +// if (log.isDebugEnabled()) { +// log.debug("set runner in context"); +// } +// runner = run; +// } + + @Override + public Date getCurrentDate() { + if (currentDate == null) { + return new Date(); + } + return currentDate; + } + + public void setCurrentDate(Date date) { + currentDate = date; + } + + @Override + public String getProperty(WaoProperty property) { + return getConfiguration().getOption(property.getKey()); + } + + @Override + public ApplicationConfig getConfiguration() { + if (configuration == null) { + loadDefaultConfiguration(); + } + return configuration; + } + + /** + * Default configuration file will be loaded using + * {@link org.nuiton.util.ApplicationConfig }. + * Then the other configuration initialization will be done in + * {@link #loadConfiguration(ApplicationConfig)} method. + */ + protected void loadDefaultConfiguration() { + try { + if (log.isInfoEnabled()) { + log.info("load default configuration from " + DEFAULT_FILENAME); + } + ApplicationConfig conf = new ApplicationConfig(); + conf.setAppName(APP_NAME); + conf.setConfigFileName(DEFAULT_FILENAME); + conf.parse(new String[]{}); + + conf.printConfig(); + + executeMigration(conf); + + loadConfiguration(conf); + } catch (ArgumentsParserException eee) { + doCatch(eee, n_("wao.error.context.parse"), DEFAULT_FILENAME); + } + } + + protected void executeMigration(ApplicationConfig conf) { + // migration configuration + String callBackName = null; + String dialect = conf.getOption("hibernate.dialect"); + if (dialect.contains("PostgreSQL")) { + callBackName = PgMigrationCallback.class.getName(); + } else if (dialect.contains("H2")) { + // Unsupported yet + callBackName = null; + } + + if (callBackName != null) { + conf.setOption( + ManualMigrationEngine.MIGRATION_APPLICATION_VERSION, + WaoDAOHelper.getModelVersion()); + conf.setOption( + ManualMigrationEngine.MIGRATION_MAPPING_DIRECTORY, + "oldmappings"); + conf.setOption( + ManualMigrationEngine.MIGRATION_MODEL_NAME, + WaoDAOHelper.getModelName()); + conf.setOption( + "topia.service.migration", + ManualMigrationEngine.class.getName()); + conf.setOption( + ManualMigrationEngine.MIGRATION_CALLBACK, + callBackName); + } else { + if (log.isWarnEnabled()) { + log.warn("Database with dialect " + dialect + " is not " + + "supported for migration from 1.0 version"); + } + } + } + + /** + * Load the application configuration : + * <pre> + * - Add entities implementation classes for Topia-persistence + * </pre> + * + * @param conf ApplicationConfig + */ + //@Override + public void loadConfiguration(ApplicationConfig conf) { + configuration = conf; + configuration.setOption("topia.persistence.classes", + WaoDAOHelper.getImplementationClassesAsString()); + } + + /** + * Start of the application. The application configuration will be loaded + * automatically if needed using {@link #loadDefaultConfiguration }. Also + * you can manually load the configuration using + * {@link #loadConfiguration(ApplicationConfig)} + * This start does : + * <pre> + * - Initialize i18n for error messages + * - Create default admin if needed (this will load the topiaRootContext). + * </pre> + * + */ + @Override + public void start() { + try { + if (log.isInfoEnabled()) { + log.info("Start Wao"); + } + I18n.setInitializer(new DefaultI18nInitializer("wao-business")); + I18n.init(Locale.FRANCE); + + // Set context in PollenProperty enum to use easily method + // getValue() on PollenProperty + WaoProperty.setContext(this); + // temp + WaoContextO.setContext(this); + + // Create the default admin in database + WaoGlobal.createDefaultAdmin(); + + if (log.isInfoEnabled()) { + log.info("wao is started !"); + } + + } catch (Exception eee) { + doCatch(eee, n_("wao.error.context.start")); + } + } + + /** + * Stop the application. Close the Topia rootContext. + */ + @Override + public void stop() { + try { + if (log.isInfoEnabled()) { + log.info("Stop Wao"); + } + getTopiaRootContext().closeContext(); + } catch (Exception eee) { + doCatch(eee, n_("wao.error.context.stop")); + } + } + + protected TopiaContext getTopiaRootContext() throws WaoException { + try { + return TopiaContextFactory.getContext( + getConfiguration().getOptions()); + } catch (TopiaNotFoundException eee) { + doCatch(eee, n_("wao.error.context.getRootContext")); + } + return null; + } + + @Override + public TopiaContext beginTransaction() throws TopiaException { + return getTopiaRootContext().beginTransaction(); + } + + @Override + public void setActivityCalendarImportRun(boolean value) { + activityCalendarImport = value; + } + + @Override + public boolean isActivityCalendarImportRun() { + return activityCalendarImport; + } + +// @Override +// public 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); +// } + + @Override + public void doCatch(Exception eee, String message, Object... args) + throws WaoException { + doCatch(null, eee, message, args); + } + + @Override + public void doCatch(TopiaContext transaction, Exception eee, + String message, Object... args) throws WaoException { + if (log.isDebugEnabled()) { + log.debug(_(message, args),eee); + } +// if (!(eee instanceof WaoException)) { + //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) { + doCatch(eeee, n_("wao.error.context.rollback")); + } + //} + if (eee instanceof SQLGrammarException && log.isErrorEnabled()) { + log.error("SQL executed with error : " + ((SQLGrammarException)eee).getSQL()); + } + throw new WaoException(eee, message, args); +// } else { +// throw (WaoException)eee; +// } + } + + @Override + public void doFinally(TopiaContext transaction) { + if (transaction != null) { + try { + transaction.closeContext(); + } catch (TopiaException eee) { +// if (log.isErrorEnabled()) { +// log.error(_("wao.error.context.close"), eee); +// } + doCatch(eee, n_("wao.error.context.close")); + } + } + } + + /** + * Generate a random string of "length" character alphanumeric. + * @param length number of characters for the final string + * @return a String of "length" character + */ + @Override + public String createRandomString(int length) { + return RandomStringUtils.randomAlphanumeric(length); + } + + @Override + public String encodeString(String string) { + return MD5.encode(string); + } + + @Override + public String convertId(String topiaId) { + if (topiaId != null && !topiaId.isEmpty()) { + int index = topiaId.indexOf('#'); + String id = topiaId.replace('#', 'K'); + return id.substring(index); + } + return ""; + } + + @Override + public Charset getCsvCharset() { + return Charset.forName("UTF-8"); + } + + @Override + public 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; + } + + @Override + public <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; + } + + @Override + public 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(); + } +} Property changes on: trunk/wao-business/src/main/java/fr/ifremer/wao/WaoContextImpl.java ___________________________________________________________________ Added: svn:keywords + "Author Date Id Revision HeadURL" Copied: trunk/wao-business/src/main/java/fr/ifremer/wao/WaoContextO.java (from rev 396, trunk/wao-business/src/main/java/fr/ifremer/wao/WaoContext.java) =================================================================== --- trunk/wao-business/src/main/java/fr/ifremer/wao/WaoContextO.java (rev 0) +++ trunk/wao-business/src/main/java/fr/ifremer/wao/WaoContextO.java 2010-04-01 13:28:03 UTC (rev 402) @@ -0,0 +1,248 @@ +/** + * *##% + * 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/WaoException.java =================================================================== --- trunk/wao-business/src/main/java/fr/ifremer/wao/WaoException.java 2010-04-01 13:27:59 UTC (rev 401) +++ trunk/wao-business/src/main/java/fr/ifremer/wao/WaoException.java 2010-04-01 13:28:03 UTC (rev 402) @@ -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 WaoException extends Exception { - - public WaoException(String msg) { - super(msg); - } - - public WaoException(String msg, Throwable cause) { - super(msg, cause); - } -} Copied: trunk/wao-business/src/main/java/fr/ifremer/wao/WaoExceptionO.java (from rev 395, trunk/wao-business/src/main/java/fr/ifremer/wao/WaoException.java) =================================================================== --- trunk/wao-business/src/main/java/fr/ifremer/wao/WaoExceptionO.java (rev 0) +++ trunk/wao-business/src/main/java/fr/ifremer/wao/WaoExceptionO.java 2010-04-01 13:28:03 UTC (rev 402) @@ -0,0 +1,44 @@ +/* + * *##% + * 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 13:27:59 UTC (rev 401) +++ trunk/wao-business/src/main/java/fr/ifremer/wao/WaoGlobal.java 2010-04-01 13:28:03 UTC (rev 402) @@ -50,12 +50,12 @@ * * @throws WaoException */ - static void createDefaultAdmin() throws WaoException { + static void createDefaultAdmin() throws WaoExceptionO { TopiaContext transaction = null; try { - transaction = WaoContext.getTopiaRootContext().beginTransaction(); + transaction = WaoContextO.getTopiaRootContext().beginTransaction(); - WaoUserDAO dao = WaoModelDAOHelper.getWaoUserDAO(transaction); + WaoUserDAO dao = WaoDAOHelper.getWaoUserDAO(transaction); long nbUsers = dao.size(); @@ -65,7 +65,7 @@ if (nbUsers == 0) { - CompanyDAO companyDAO = WaoModelDAOHelper.getCompanyDAO(transaction); + CompanyDAO companyDAO = WaoDAOHelper.getCompanyDAO(transaction); if (log.isInfoEnabled()) { log.info("Create first admin : login=\"admin\" / password=\"password\""); @@ -73,7 +73,7 @@ Company company = companyDAO.create(Company.ACTIVE, false, Company.NAME, "ADMIN"); - String password = WaoContext.encodeString("password"); + String password = WaoContextO.encodeString("password"); WaoUser user = dao.create( WaoUser.ROLE, UserRole.ADMIN.ordinal(), @@ -89,9 +89,9 @@ //transaction.closeContext(); } catch (Exception eee) { - WaoContext.serviceException(null, "Error during database initialization", eee); + WaoContextO.serviceException(null, "Error during database initialization", eee); } finally { - WaoContext.closeTransaction(transaction); + WaoContextO.closeTransaction(transaction); } } Added: trunk/wao-business/src/main/java/fr/ifremer/wao/WaoProperty.java =================================================================== --- trunk/wao-business/src/main/java/fr/ifremer/wao/WaoProperty.java (rev 0) +++ trunk/wao-business/src/main/java/fr/ifremer/wao/WaoProperty.java 2010-04-01 13:28:03 UTC (rev 402) @@ -0,0 +1,53 @@ + +package fr.ifremer.wao; + +/** + * WaoProperty + * + * Created: 31 mars 2010 + * + * @author fdesbois + * @version $Revision$ + * + * Mise a jour: $Date$ + * par : $Author$ + */ +public enum WaoProperty { + /** Path for log on activityCalendar import **/ + FILENAME_LOG_ACTIVITY_IMPORT("wao.log.activityCalendar.import"), + /** Path for log on activityCalendar access **/ + FILENAME_LOG_ACTIVITY_ACCESS("wao.log.activityCalendar.access"), + /** Host for email **/ + EMAIL_HOST("wao.email.host"), + /** Port for email **/ + EMAIL_PORT("wao.email.port"), + /** From for email **/ + EMAIL_FROM("wao.email.from"), + /** App version **/ + APP_VERSION("wao.version"), + /** Server path **/ + SERVER_PATH("wao.server.path"); + + private String key; + + private static WaoContext context; + + WaoProperty(String key) { + this.key = key; + } + + public String getKey() { + return key; + } + + public static void setContext(WaoContext context) { + WaoProperty.context = context; + } + + public String getValue() { + if (context != null) { + return context.getProperty(this); + } + return WaoContextO.getProperty(key); + } +} Property changes on: trunk/wao-business/src/main/java/fr/ifremer/wao/WaoProperty.java ___________________________________________________________________ Added: svn:keywords + "Author Date Id Revision HeadURL" Modified: 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 13:27:59 UTC (rev 401) +++ trunk/wao-business/src/main/java/fr/ifremer/wao/WaoRunner.java 2010-04-01 13:28:03 UTC (rev 402) @@ -42,14 +42,14 @@ * * @throws WaoException */ - void start() throws WaoException; + void start() throws WaoExceptionO; /** * Stop the application. * * @throws WaoException */ - void stop() throws WaoException; + void stop() throws WaoExceptionO; /** * Return the current date, depends on environment. Modified: 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 13:27:59 UTC (rev 401) +++ trunk/wao-business/src/main/java/fr/ifremer/wao/WaoRunnerImpl.java 2010-04-01 13:28:03 UTC (rev 402) @@ -53,14 +53,14 @@ } @Override - public void start() throws WaoException { + 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", - WaoModelDAOHelper.getImplementationClassesAsString()); + WaoDAOHelper.getImplementationClassesAsString()); // migration configuration String callBackName = null; @@ -75,13 +75,13 @@ if (callBackName != null) { configuration.setOption( ManualMigrationEngine.MIGRATION_APPLICATION_VERSION, - WaoModelDAOHelper.getModelVersion()); + WaoDAOHelper.getModelVersion()); configuration.setOption( ManualMigrationEngine.MIGRATION_MAPPING_DIRECTORY, "oldmappings"); configuration.setOption( ManualMigrationEngine.MIGRATION_MODEL_NAME, - WaoModelDAOHelper.getModelName()); + WaoDAOHelper.getModelName()); configuration.setOption( "topia.service.migration", ManualMigrationEngine.class.getName()); @@ -99,22 +99,22 @@ I18n.init(Locale.FRANCE); // Use the context to set the runner for default environment. - WaoContext.setRunner(this); + WaoContextO.setRunner(this); // Create the default admin in database WaoGlobal.createDefaultAdmin(); } catch (Exception eee) { - WaoContext.serviceException(null, + WaoContextO.serviceException(null, "Error during loadConfiguration from " + "'Wao.properties' file", eee); } } @Override - public void stop() throws WaoException { + public void stop() throws WaoExceptionO { try { - WaoContext.getTopiaRootContext().closeContext(); + WaoContextO.getTopiaRootContext().closeContext(); } catch (TopiaException eee) { - WaoContext.serviceException(null, "Error when closing Topia root context", eee); + WaoContextO.serviceException(null, "Error when closing Topia root context", eee); } } 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 13:27:59 UTC (rev 401) +++ trunk/wao-business/src/main/java/fr/ifremer/wao/bean/SamplingFilterImpl.java 2010-04-01 13:28:03 UTC (rev 402) @@ -21,7 +21,7 @@ package fr.ifremer.wao.bean; -import fr.ifremer.wao.WaoContext; +import fr.ifremer.wao.WaoContextO; import fr.ifremer.wao.entity.FishingZone; import fr.ifremer.wao.entity.SampleRow; import java.util.Calendar; @@ -95,7 +95,7 @@ // Only rows which are not finished will be kept // Date current = WaoContext.getCurrentDate(); Calendar calendar = new GregorianCalendar(); - calendar.setTime(WaoContext.getCurrentDate()); + calendar.setTime(WaoContextO.getCurrentDate()); calendar.add(Calendar.MONTH, getNbMonthFinishedFromToday()); query.add(main + "." + SampleRow.PERIOD_END, Op.GE, calendar.getTime()); } Modified: trunk/wao-business/src/main/java/fr/ifremer/wao/entity/BoatImpl.java =================================================================== --- trunk/wao-business/src/main/java/fr/ifremer/wao/entity/BoatImpl.java 2010-04-01 13:27:59 UTC (rev 401) +++ trunk/wao-business/src/main/java/fr/ifremer/wao/entity/BoatImpl.java 2010-04-01 13:28:03 UTC (rev 402) @@ -21,9 +21,9 @@ package fr.ifremer.wao.entity; -import fr.ifremer.wao.WaoException; -import fr.ifremer.wao.WaoContext; -import fr.ifremer.wao.WaoModelDAOHelper; +import fr.ifremer.wao.WaoExceptionO; +import fr.ifremer.wao.WaoContextO; +import fr.ifremer.wao.WaoDAOHelper; import fr.ifremer.wao.bean.ContactState; import java.io.Serializable; import java.util.Date; @@ -60,16 +60,16 @@ * @see fr.ifremer.wao.bean.ContactState#isFinalState() */ @Override - public boolean canCreateContact(Company company) throws WaoException { + public boolean canCreateContact(Company company) throws WaoExceptionO { boolean result = true; if (!getActive()) { result = false; } else { TopiaContext transaction = null; try { - transaction = WaoContext.getTopiaRootContext().beginTransaction(); + transaction = WaoContextO.getTopiaRootContext().beginTransaction(); - ContactDAO dao = WaoModelDAOHelper.getContactDAO(transaction); + ContactDAO dao = WaoDAOHelper.getContactDAO(transaction); Contact contact = dao.findByQuery(dao.createQueryLastContactForBoat(this, company)); if (contact != null) { @@ -78,12 +78,12 @@ //transaction.closeContext(); } catch (Exception eee) { - WaoContext.serviceException(transaction, + WaoContextO.serviceException(transaction, "Impossible de récupérer les informations privées du navire lié à la société " + "'" + company.getName() + "'", eee); } finally { - WaoContext.closeTransaction(transaction); + WaoContextO.closeTransaction(transaction); } } return result; @@ -99,25 +99,25 @@ * @see fr.ifremer.wao.entity.ContactDAO#createQueryDoneContactsFromDate(Boat, Date) */ @Override - public int getNbBoarding(Date fromDate) throws WaoException { + public int getNbBoarding(Date fromDate) throws WaoExceptionO { TopiaContext transaction = null; int result = 0; try { - transaction = WaoContext.getTopiaRootContext().beginTransaction(); + transaction = WaoContextO.getTopiaRootContext().beginTransaction(); - ContactDAO dao = WaoModelDAOHelper.getContactDAO(transaction); + ContactDAO dao = WaoDAOHelper.getContactDAO(transaction); TopiaQuery query = dao.createQueryDoneContactsFromDate(this, fromDate); result = query.executeCount(transaction); //transaction.closeContext(); } catch (Exception eee) { - WaoContext.serviceException(transaction, + WaoContextO.serviceException(transaction, "Impossible de récupérer le nombre d'embarquements réels depuis le " + "'" + fromDate + "'", eee); } finally { - WaoContext.closeTransaction(transaction); + WaoContextO.closeTransaction(transaction); } return result; } Modified: trunk/wao-business/src/main/java/fr/ifremer/wao/entity/BoatInfosImpl.java =================================================================== --- trunk/wao-business/src/main/java/fr/ifremer/wao/entity/BoatInfosImpl.java 2010-04-01 13:27:59 UTC (rev 401) +++ trunk/wao-business/src/main/java/fr/ifremer/wao/entity/BoatInfosImpl.java 2010-04-01 13:28:03 UTC (rev 402) @@ -21,9 +21,9 @@ package fr.ifremer.wao.entity; -import fr.ifremer.wao.WaoContext; -import fr.ifremer.wao.WaoException; -import fr.ifremer.wao.WaoModelDAOHelper; +import fr.ifremer.wao.WaoContextO; +import fr.ifremer.wao.WaoExceptionO; +import fr.ifremer.wao.WaoDAOHelper; import org.nuiton.topia.framework.TopiaQuery; import java.io.Serializable; import org.nuiton.topia.TopiaContext; @@ -58,13 +58,13 @@ * @see fr.ifremer.wao.entity.ContactDAO#createQueryDoneContactsFromDate(Boat, Date) */ @Override - public int getNbBoardingForCompany(Date fromDate) throws WaoException { + public int getNbBoardingForCompany(Date fromDate) throws WaoExceptionO { TopiaContext transaction = null; int result = 0; try { - transaction = WaoContext.getTopiaRootContext().beginTransaction(); + transaction = WaoContextO.getTopiaRootContext().beginTransaction(); - ContactDAO dao = WaoModelDAOHelper.getContactDAO(transaction); + ContactDAO dao = WaoDAOHelper.getContactDAO(transaction); TopiaQuery query = dao.createQueryDoneContactsFromDate(getBoat(), fromDate); query.add(Contact.OBSERVER + "." + WaoUser.COMPANY, getCompany()); @@ -73,12 +73,12 @@ //transaction.closeContext(); } catch (Exception eee) { - WaoContext.serviceException(transaction, + WaoContextO.serviceException(transaction, "Impossible de récupérer le nombre d'embarquements réels depuis le " + "'" + fromDate + "' pour la société '" + getCompany().getName() + "'", eee); } finally { - WaoContext.closeTransaction(transaction); + WaoContextO.closeTransaction(transaction); } return result; } Modified: trunk/wao-business/src/main/java/fr/ifremer/wao/entity/CompanyImpl.java =================================================================== --- trunk/wao-business/src/main/java/fr/ifremer/wao/entity/CompanyImpl.java 2010-04-01 13:27:59 UTC (rev 401) +++ trunk/wao-business/src/main/java/fr/ifremer/wao/entity/CompanyImpl.java 2010-04-01 13:28:03 UTC (rev 402) @@ -21,7 +21,7 @@ package fr.ifremer.wao.entity; -import fr.ifremer.wao.WaoContext; +import fr.ifremer.wao.WaoContextO; import java.io.Serializable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -50,6 +50,6 @@ */ @Override public String getId() { - return WaoContext.convertId(getTopiaId()); + return WaoContextO.convertId(getTopiaId()); } } Modified: trunk/wao-business/src/main/java/fr/ifremer/wao/entity/SampleMonthImpl.java =================================================================== --- trunk/wao-business/src/main/java/fr/ifremer/wao/entity/SampleMonthImpl.java 2010-04-01 13:27:59 UTC (rev 401) +++ trunk/wao-business/src/main/java/fr/ifremer/wao/entity/SampleMonthImpl.java 2010-04-01 13:28:03 UTC (rev 402) @@ -21,9 +21,9 @@ package fr.ifremer.wao.entity; -import fr.ifremer.wao.WaoContext; -import fr.ifremer.wao.WaoException; -import fr.ifremer.wao.WaoModelDAOHelper; +import fr.ifremer.wao.WaoContextO; +import fr.ifremer.wao.WaoExceptionO; +import fr.ifremer.wao.WaoDAOHelper; import java.io.Serializable; import java.text.DateFormat; import java.text.SimpleDateFormat; @@ -59,12 +59,12 @@ * @throws WaoException for saving problem */ @Override - public void addRealTideTime(int nbDays) throws WaoException { + public void addRealTideTime(int nbDays) throws WaoExceptionO { TopiaContext transaction = null; try { - transaction = WaoContext.getTopiaRootContext().beginTransaction(); + transaction = WaoContextO.getTopiaRootContext().beginTransaction(); - SampleMonthDAO dao = WaoModelDAOHelper.getSampleMonthDAO(transaction); + SampleMonthDAO dao = WaoDAOHelper.getSampleMonthDAO(transaction); SampleMonth month = dao.findByTopiaId(getTopiaId()); int result = month.getRealTidesValue() + nbDays; if (result < 0) { @@ -79,11 +79,11 @@ transaction.commitTransaction(); //transaction.closeContext(); } catch (Exception eee) { - WaoContext.serviceException(transaction, + WaoContextO.serviceException(transaction, "Impossible d'enregistrer le nombre de marées réels pour le mois de " + formatMonth() + " [ligne : " + this.getSampleRow().getCode() + "]", eee); } finally { - WaoContext.closeTransaction(transaction); + WaoContextO.closeTransaction(transaction); } } @@ -97,7 +97,7 @@ @Override public boolean isCurrentMonth() { Calendar current = new GregorianCalendar(); - current.setTime(WaoContext.getCurrentDate()); + current.setTime(WaoContextO.getCurrentDate()); Calendar calendar = new GregorianCalendar(); calendar.setTime(getPeriodDate()); Modified: trunk/wao-business/src/main/java/fr/ifremer/wao/entity/SampleRowImpl.java =================================================================== --- trunk/wao-business/src/main/java/fr/ifremer/wao/entity/SampleRowImpl.java 2010-04-01 13:27:59 UTC (rev 401) +++ trunk/wao-business/src/main/java/fr/ifremer/wao/entity/SampleRowImpl.java 2010-04-01 13:28:03 UTC (rev 402) @@ -21,9 +21,9 @@ package fr.ifremer.wao.entity; -import fr.ifremer.wao.WaoContext; -import fr.ifremer.wao.WaoException; -import fr.ifremer.wao.WaoModelDAOHelper; +import fr.ifremer.wao.WaoContextO; +import fr.ifremer.wao.WaoExceptionO; +import fr.ifremer.wao.WaoDAOHelper; import java.io.Serializable; import java.util.ArrayList; import java.util.Calendar; @@ -209,7 +209,7 @@ } @Override - public boolean addRealTideTime(Contact contact) throws WaoException { + public boolean addRealTideTime(Contact contact) throws WaoExceptionO { if (contact.getTideEndDate() == null || contact.getTideBeginDate() == null) { return false; } @@ -226,7 +226,7 @@ } @Override - public void removeRealTideTime(Contact contact) throws WaoException { + public void removeRealTideTime(Contact contact) throws WaoExceptionO { if (contact.getTideEndDate() == null || contact.getTideBeginDate() == null) { return; } @@ -247,14 +247,14 @@ @Override public boolean isStarted() { - Date current = WaoContext.getCurrentDate(); + Date current = WaoContextO.getCurrentDate(); return current.after(getPeriodBegin()) || current.equals(getPeriodBegin()); } @Override public boolean isFinished(int nbMonths) { Calendar calendar = new GregorianCalendar(); - calendar.setTime(WaoContext.getCurrentDate()); + calendar.setTime(WaoContextO.getCurrentDate()); calendar.add(Calendar.MONTH, nbMonths); return calendar.getTime().after(getPeriodEnd()); } @@ -288,7 +288,7 @@ * @throws WaoException */ @Override - public void saveSampleRowLog(SampleRowLog rowLog) throws WaoException { + public void saveSampleRowLog(SampleRowLog rowLog) throws WaoExceptionO { TopiaContext transaction = null; try { if (log.isInfoEnabled()) { @@ -298,10 +298,10 @@ " _ authorRole = " + author.getUserRole()); } - transaction = WaoContext.getTopiaRootContext().beginTransaction(); + transaction = WaoContextO.getTopiaRootContext().beginTransaction(); SampleRowLogDAO logDAO = - WaoModelDAOHelper.getSampleRowLogDAO(transaction); + WaoDAOHelper.getSampleRowLogDAO(transaction); logDAO.create(rowLog); @@ -311,11 +311,11 @@ // WaoContext.PROP_EMAIL_FROM } catch (Exception eee) { - WaoContext.serviceException(transaction, + WaoContextO.serviceException(transaction, "Impossible d'enregistrer le commentaire écrit par " + rowLog.getAuthor().getFullName(), eee); } finally { - WaoContext.closeTransaction(transaction); + WaoContextO.closeTransaction(transaction); } } Modified: trunk/wao-business/src/main/java/fr/ifremer/wao/entity/WaoUserImpl.java =================================================================== --- trunk/wao-business/src/main/java/fr/ifremer/wao/entity/WaoUserImpl.java 2010-04-01 13:27:59 UTC (rev 401) +++ trunk/wao-business/src/main/java/fr/ifremer/wao/entity/WaoUserImpl.java 2010-04-01 13:28:03 UTC (rev 402) @@ -21,7 +21,7 @@ package fr.ifremer.wao.entity; -import fr.ifremer.wao.WaoContext; +import fr.ifremer.wao.WaoContextO; import fr.ifremer.wao.bean.UserRole; import java.io.Serializable; import org.slf4j.Logger; @@ -64,7 +64,7 @@ */ @Override public String getId() { - return WaoContext.convertId(getTopiaId()); + return WaoContextO.convertId(getTopiaId()); } @Override 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 13:27:59 UTC (rev 401) +++ trunk/wao-business/src/main/java/fr/ifremer/wao/io/ImportHelper.java 2010-04-01 13:28:03 UTC (rev 402) @@ -94,7 +94,7 @@ time.setTime(timeFormat.parse(code)); } else { // Use current date with no time as a reference if no code is set - time.setTime(WaoContext.getCurrentDate()); + time.setTime(WaoContextO.getCurrentDate()); time.set(Calendar.HOUR_OF_DAY, 0); time.set(Calendar.MINUTE, 0); time.set(Calendar.SECOND, 0); @@ -110,14 +110,14 @@ result.set(Calendar.SECOND, time.get(Calendar.SECOND)); result.set(Calendar.MILLISECOND, time.get(Calendar.MILLISECOND)); } else { - result.setTime(WaoContext.getCurrentDate()); + result.setTime(WaoContextO.getCurrentDate()); } return result.getTime(); } public static String readSampleRowCode(CsvReader reader) throws IOException { String code = read(reader, SAMPLING.PLAN_CODE); - return WaoContext.prepareSampleRowCode(code); + return WaoContextO.prepareSampleRowCode(code); } /** Deleted: trunk/wao-business/src/main/java/fr/ifremer/wao/mock/ServiceNewsMock.java =================================================================== --- trunk/wao-business/src/main/java/fr/ifremer/wao/mock/ServiceNewsMock.java 2010-04-01 13:27:59 UTC (rev 401) +++ trunk/wao-business/src/main/java/fr/ifremer/wao/mock/ServiceNewsMock.java 2010-04-01 13:28:03 UTC (rev 402) @@ -1,113 +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.mock; - -import fr.ifremer.wao.WaoException; -import fr.ifremer.wao.entity.News; -import fr.ifremer.wao.entity.NewsImpl; -import fr.ifremer.wao.service.ServiceNews; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * ServiceNewsMock - * - * Created: 7 nov. 2009 - * - * @author fdesbois - * @version $Revision$ - * - * Mise a jour: $Date$ - * par : $Author$ - */ -public class ServiceNewsMock implements ServiceNews { - - private static final Logger log = LoggerFactory.getLogger(ServiceNewsMock.class); - - @Override - public List<News> getNews() throws WaoException { - List<News> results = new ArrayList<News>(); - - Integer[] tab = new Integer[12]; - - News news = new NewsImpl(); - news.setTopiaCreateDate(new Date()); - news.setTitle("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent mattis sapien sed nisi consequat tempus"); - news.setContent("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent mattis sapien sed nisi consequat tempus. " + - "Donec interdum egestas erat, varius viverra nisi sollicitudin ut. Aenean viverra luctus urna. Fusce et erat " + - "ut sem ornare pretium. Phasellus sit amet est erat. Donec fringilla auctor elit ac aliquet. Maecenas quis orci " + - "dolor, et semper turpis. Suspendisse sit amet euismod libero. Duis in lorem augue, at feugiat est. Aliquam " + - "ultricies adipiscing tempor. Donec enim mi, sollicitudin et cursus et, tristique vitae odio. Aenean adipiscing, " + - "diam ullamcorper scelerisque commodo, neque nisi congue ante, ut dignissim dolor mi id est. Ut sed fringilla " + - "turpis. Integer accumsan vehicula turpis sit amet luctus. Integer ac nunc purus. Phasellus id bibendum quam. " + - "Curabitur eu dolor mauris. Phasellus sed nunc felis, nec commodo urna.<br />" + - "Mauris non purus dui, sit amet lacinia eros. Mauris dictum lectus sed dolor pulvinar porttitor vitae " + - "vel quam. Etiam non nibh a mauris tincidunt eleifend. Cum sociis natoque penatibus et magnis dis parturient" + - " montes, nascetur ridiculus mus. Curabitur odio dui, hendrerit feugiat malesuada et, interdum eu odio. Aenean" + - " tincidunt, dui nec egestas malesuada, risus urna pharetra risus, quis hendrerit massa est at elit. Quisque porttitor" + - " malesuada arcu in tempor. Nunc quis dolor dui, ac laoreet mi. Donec suscipit nunc vel tellus pellentesque consequat." + - " Maecenas eget nunc mi, at porttitor enim. Morbi ornare, magna at faucibus consequat, mauris tellus commodo ante, a dictum" + - " risus arcu eu turpis. Nam lacinia, enim sit amet consectetur gravida, quam nibh porttitor mauris, ut euismod neque nisi" + - " eu nunc. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Vivamus sem libero," + - " blandit vel posuere eget, iaculis viverra mi. Aenean sit amet lobortis lorem. Nullam non enim ante. "); - - results.add(news); - - news = new NewsImpl(); - news.setTopiaCreateDate(new Date()); - news.setTitle("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent mattis sapien sed nisi consequat tempus"); - news.setContent("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent mattis sapien sed nisi consequat tempus. " + - "Donec interdum egestas erat, varius viverra nisi sollicitudin ut. Aenean viverra luctus urna. Fusce et erat " + - "ut sem ornare pretium. Phasellus sit amet est erat. Donec fringilla auctor elit ac aliquet. Maecenas quis orci " + - "dolor, et semper turpis. Suspendisse sit amet euismod libero. Duis in lorem augue, at feugiat est. Aliquam " + - "ultricies adipiscing tempor. Donec enim mi, sollicitudin et cursus et, tristique vitae odio. Aenean adipiscing, " + - "diam ullamcorper scelerisque commodo, neque nisi congue ante, ut dignissim dolor mi id est. Ut sed fringilla " + - "turpis. Integer accumsan vehicula turpis sit amet luctus. Integer ac nunc purus. Phasellus id bibendum quam. " + - "Curabitur eu dolor mauris. Phasellus sed nunc felis, nec commodo urna.<br />" + - "Mauris non purus dui, sit amet lacinia eros. Mauris dictum lectus sed dolor pulvinar porttitor vitae " + - "vel quam. Etiam non nibh a mauris tincidunt eleifend. Cum sociis natoque penatibus et magnis dis parturient" + - " montes, nascetur ridiculus mus. Curabitur odio dui, hendrerit feugiat malesuada et, interdum eu odio. Aenean" + - " tincidunt, dui nec egestas malesuada, risus urna pharetra risus, quis hendrerit massa est at elit. Quisque porttitor" + - " malesuada arcu in tempor. Nunc quis dolor dui, ac laoreet mi. Donec suscipit nunc vel tellus pellentesque consequat." + - " Maecenas eget nunc mi, at porttitor enim. Morbi ornare, magna at faucibus consequat, mauris tellus commodo ante, a dictum" + - " risus arcu eu turpis. Nam lacinia, enim sit amet consectetur gravida, quam nibh porttitor mauris, ut euismod neque nisi" + - " eu nunc. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Vivamus sem libero," + - " blandit vel posuere eget, iaculis viverra mi. Aenean sit amet lobortis lorem. Nullam non enim ante. "); - - results.add(news); - - if (log.isDebugEnabled()) { - log.debug("nb news : " + results.size()); - } - - return results; - } - - @Override - public void saveNews(News news, boolean delete) throws WaoException { - throw new UnsupportedOperationException("Not supported yet."); - } - -} Modified: trunk/wao-business/src/main/java/fr/ifremer/wao/service/ActivityCalendarImport.java =================================================================== --- trunk/wao-business/src/main/java/fr/ifremer/wao/service/ActivityCalendarImport.java 2010-04-01 13:27:59 UTC (rev 401) +++ trunk/wao-business/src/main/java/fr/ifremer/wao/service/ActivityCalendarImport.java 2010-04-01 13:28:03 UTC (rev 402) @@ -42,7 +42,6 @@ import java.io.IOException; import java.io.InputStream; import java.io.Writer; -import java.nio.charset.Charset; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.ArrayList; @@ -70,6 +69,8 @@ */ public class ActivityCalendarImport implements Runnable { + private WaoContextImplementor context; + private InputStream input; private Writer writer; @@ -120,11 +121,12 @@ } } - public ActivityCalendarImport(InputStream input) throws IOException { + public ActivityCalendarImport(WaoContextImplementor context, + InputStream input) throws IOException { super(); + this.context = context; this.input = input; - String filename = WaoContext.getProperty( - WaoContext.PROP_FILENAME_LOG_ACTIVITY_IMPORT); + String filename = WaoProperty.FILENAME_LOG_ACTIVITY_IMPORT.getValue(); File file = new File(filename); file.getParentFile().mkdirs(); if (file.exists()) { @@ -137,12 +139,12 @@ @Override public void run() { TopiaContext transaction = null; - WaoContext.setActivityCalendarImport(true); + context.setActivityCalendarImportRun(true); int currRow = 1; try { - transaction = WaoContext.getTopiaRootContext().beginTransaction(); + transaction = context.beginTransaction(); - CsvReader reader = new CsvReader(input, WaoContext.getCsvCharset()); + CsvReader reader = new CsvReader(input, context.getCsvCharset()); long startTime = System.currentTimeMillis(); @@ -156,11 +158,11 @@ Map<ActivityCalendarKey, ActivityCalendar> availableCalendars = new HashMap<ActivityCalendarKey, ActivityCalendar>(); - BoatDAO boatDAO = WaoModelDAOHelper.getBoatDAO(transaction); - ActivityCalendarDAO calendarDAO = WaoModelDAOHelper.getActivityCalendarDAO(transaction); - ActivityMonthDAO monthDAO = WaoModelDAOHelper.getActivityMonthDAO(transaction); - ActivityProfessionDAO professionDAO = WaoModelDAOHelper.getActivityProfessionDAO(transaction); - ActivityZoneDAO zoneDAO = WaoModelDAOHelper.getActivityZoneDAO(transaction); + BoatDAO boatDAO = WaoDAOHelper.getBoatDAO(transaction); + ActivityCalendarDAO calendarDAO = WaoDAOHelper.getActivityCalendarDAO(transaction); + ActivityMonthDAO monthDAO = WaoDAOHelper.getActivityMonthDAO(transaction); + ActivityProfessionDAO professionDAO = WaoDAOHelper.getActivityProfessionDAO(transaction); + ActivityZoneDAO zoneDAO = WaoDAOHelper.getActivityZoneDAO(transaction); while(reader.readRecord()) { currRow++; @@ -334,7 +336,7 @@ } } finally { IOUtils.closeQuietly(writer); - WaoContext.setActivityCalendarImport(false); + context.setActivityCalendarImportRun(false); try { transaction.closeContext(); } catch (TopiaException te) { Modified: trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceBoatImpl.java =================================================================== --- trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceBoatImpl.java 2010-04-01 13:27:59 UTC (rev 401) +++ trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceBoatImpl.java 2010-04-01 13:28:03 UTC (rev 402) @@ -25,9 +25,9 @@ import com.csvreader.CsvWriter; import fr.ifremer.wao.WaoBusinessException; import fr.ifremer.wao.WaoBusinessException.Type; -import fr.ifremer.wao.WaoContext; -import fr.ifremer.wao.WaoException; -import fr.ifremer.wao.WaoModelDAOHelper; +import fr.ifremer.wao.WaoContextO; +import fr.ifremer.wao.WaoDAOHelper; +import fr.ifremer.wao.WaoProperty; import org.nuiton.topia.TopiaException; import org.nuiton.topia.framework.TopiaQuery; import org.nuiton.topia.framework.TopiaQuery.Op; @@ -45,15 +45,14 @@ import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; -import java.nio.charset.Charset; import java.util.ArrayList; +import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.regex.Matcher; import java.util.regex.Pattern; import org.apache.commons.lang.StringUtils; -import org.apache.commons.lang.time.DurationFormatUtils; import org.nuiton.topia.TopiaContext; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -69,29 +68,30 @@ * Mise a jour: $Date$ * par : $Author$ */ -public class ServiceBoatImpl implements ServiceBoat { +public class ServiceBoatImpl extends ServiceBoatAbstract { private static final Logger log = LoggerFactory.getLogger(ServiceBoatImpl.class); - protected TopiaContext rootContext; +// protected TopiaContext rootContext; +// +// public ServiceBoatImpl() throws WaoExceptionO { +// rootContext = WaoContextO.getTopiaRootContext(); +// } - public ServiceBoatImpl() throws WaoException { - rootContext = WaoContext.getTopiaRootContext(); - } - @Override - public Map<Integer, Boat> getBoatsByFilter(BoatFilter filter) throws WaoException { - TopiaContext transaction = null; - Map<Integer, Boat> results = new HashMap<Integer, Boat>(); - try { - long startTime = 0; - if (log.isDebugEnabled()) { - startTime = System.currentTimeMillis(); - } + public Map<Integer, Boat> executeGetBoatsByFilter(TopiaContext transaction, + List<Object> errorArgs, BoatFilter filter) throws TopiaException { +// TopiaContext transaction = null; +// Map<Integer, Boat> results = new HashMap<Integer, Boat>(); +// try { +// long startTime = 0; +// if (log.isDebugEnabled()) { +// startTime = System.currentTimeMillis(); +// } +// +// transaction = rootContext.beginTransaction(); - transaction = rootContext.beginTransaction(); - - BoatDAO dao = WaoModelDAOHelper.getBoatDAO(transaction); + BoatDAO dao = WaoDAOHelper.getBoatDAO(transaction); TopiaQuery query = dao.createQuery("B"); query = createQueryForBoatFilter(query, filter); @@ -106,55 +106,56 @@ log.debug("Query : " + query); } - results = dao.findAllMappedByQuery(query, Boat.IMMATRICULATION, Integer.class); + return dao.findAllMappedByQuery(query, Boat.IMMATRICULATION, Integer.class); - if (log.isDebugEnabled()) { - long stopTime = System.currentTimeMillis(); - log.debug("W:[ getBoatsByFilter ] Time = " + - DurationFormatUtils.formatDurationHMS( - stopTime - startTime)); - } - - } catch (Exception eee) { - WaoContext.serviceException(transaction, "Impossible de filtrer la liste des navires", eee); - } finally { - WaoContext.closeTransaction(transaction); - } - return results; +// if (log.isDebugEnabled()) { +// long stopTime = System.currentTimeMillis(); +// log.debug("W:[ getBoatsByFilter ] Time = " + +// DurationFormatUtils.formatDurationHMS( +// stopTime - startTime)); +// } +// +// } catch (Exception eee) { +// WaoContextO.serviceException(transaction, "Impossible de filtrer la liste des navires", eee); +// } finally { +// WaoContextO.closeTransaction(transaction); +// } +// return results; } @Override - public int getNbBoatsByFilter(BoatFilter filter) throws WaoException { - TopiaContext transaction = null; - int result = 0; - try { - long startTime = 0; - if (log.isDebugEnabled()) { - startTime = System.currentTimeMillis(); - } - - transaction = rootContext.beginTransaction(); + public int executeGetNbBoatsByFilter(TopiaContext transaction, + List<Object> errorArgs, BoatFilter filter) throws TopiaException { +// TopiaContext transaction = null; +// int result = 0; +// try { +// long startTime = 0; +// if (log.isDebugEnabled()) { +// startTime = System.currentTimeMillis(); +// } +// +// transaction = rootContext.beginTransaction(); - BoatDAO dao = WaoModelDAOHelper.getBoatDAO(transaction); + BoatDAO dao = WaoDAOHelper.getBoatDAO(transaction); TopiaQuery query = dao.createQuery("B"); query = createQueryForBoatFilter(query, filter); - result = query.executeCount(); + return query.executeCount(); - if (log.isDebugEnabled()) { - long stopTime = System.currentTimeMillis(); - log.debug("W:[ getNbBoatsByFilter ] Time = " + - DurationFormatUtils.formatDurationHMS( - stopTime - startTime)); - } - - } catch (Exception eee) { - WaoContext.serviceException(transaction, "Impossible de filtrer la liste des navires", eee); - } finally { - WaoContext.closeTransaction(transaction); - } - return result; +// if (log.isDebugEnabled()) { +// long stopTime = System.currentTimeMillis(); +// log.debug("W:[ getNbBoatsByFilter ] Time = " + +// DurationFormatUtils.formatDurationHMS( +// stopTime - startTime)); +// } +// +// } catch (Exception eee) { +// WaoContextO.serviceException(transaction, "Impossible de filtrer la liste des navires", eee); +// } finally { +// WaoContextO.closeTransaction(transaction); +// } +// return result; } protected TopiaQuery createQueryForBoatFilter(TopiaQuery query, BoatFilter filter) throws TopiaException { @@ -193,35 +194,43 @@ * The ElligibleBoat entity contains the SampleRow and attributes useful * to know if the link is active or specific for the company. * + * @param transaction * @param boatImmatriculation immatriculation of the boat + * @param errorArgs * @param company the Company to filter the ElligibleBoats * @return an ElligibleBoatsCompany wich contains the map of ElligibleBoat, * the company and an empty list for deleted elements. + * @throws TopiaException */ @Override - public CompanyBoatInfos getCompanyBoatInfos(int boatImmatriculation, Company company) - throws WaoException { + public CompanyBoatInfos executeGetCompanyBoatInfos(TopiaContext transaction, + List<Object> errorArgs, int boatImmatriculation, Company company) + throws TopiaException { - Map<String, ElligibleBoat> elligibleBoats = new HashMap<String, ElligibleBoat>(); + errorArgs.add(boatImmatriculation); + errorArgs.add(company.getName()); + + Map<String, ElligibleBoat> elligibleBoats = + new HashMap<String, ElligibleBoat>(); CompanyBoatInfos result = new CompanyBoatInfosImpl(); result.setCompany(company); result.setElligibleBoats(elligibleBoats); result.setDeletedElligibleBoats(new ArrayList<ElligibleBoat>()); - TopiaContext transaction = null; - try { - long startTime = 0; - if (log.isDebugEnabled()) { - startTime = System.currentTimeMillis(); - } - - transaction = rootContext.beginTransaction(); +// TopiaContext transaction = null; +// try { +// long startTime = 0; +// if (log.isDebugEnabled()) { +// startTime = System.currentTimeMillis(); +// } +// +// transaction = rootContext.beginTransaction(); - BoatDAO dao = WaoModelDAOHelper.getBoatDAO(transaction); + BoatDAO dao = WaoDAOHelper.getBoatDAO(transaction); Boat boat = dao.findByImmatriculation(boatImmatriculation); - BoatInfosDAO boatInfosDAO = WaoModelDAOHelper.getBoatInfosDAO(transaction); + BoatInfosDAO boatInfosDAO = WaoDAOHelper.getBoatInfosDAO(transaction); BoatInfos boatInfos = boatInfosDAO.findByProperties( BoatInfos.BOAT, boat, BoatInfos.COMPANY, company); if (boatInfos == null) { @@ -253,7 +262,7 @@ } // Last contact - ContactDAO contactDAO = WaoModelDAOHelper.getContactDAO(transaction); + ContactDAO contactDAO = WaoDAOHelper.getContactDAO(transaction); TopiaQuery query = contactDAO.createQueryLastContactForBoat(boat, company). addLoad(Contact.SAMPLE_ROW, Contact.OBSERVER); @@ -263,46 +272,52 @@ result.setLastContact(contact); } - if (log.isDebugEnabled()) { - long stopTime = System.currentTimeMillis(); - log.debug("W:[ getCompanyBoatInfos ] Time = " + - DurationFormatUtils.formatDurationHMS( - stopTime - startTime)); - } - -// transaction.closeContext(); - } catch (Exception eee) { - WaoContext.serviceException(transaction, - "Impossible de récupérer les informations du navire " + - "immatriculé '" + boatImmatriculation + "'" + - " pour la société '" + company.getName() + "'", eee); - } finally { - WaoContext.closeTransaction(transaction); - } +// if (log.isDebugEnabled()) { +// long stopTime = System.currentTimeMillis(); +// log.debug("W:[ getCompanyBoatInfos ] Time = " + +// DurationFormatUtils.formatDurationHMS( +// stopTime - startTime)); +// } +// +//// transaction.closeContext(); +// } catch (Exception eee) { +// WaoContextO.serviceException(transaction, +// "Impossible de récupérer les informations du navire " + +// "immatriculé '" + boatImmatriculation + "'" + +// " pour la société '" + company.getName() + "'", eee); +// } finally { +// WaoContextO.closeTransaction(transaction); +// } return result; } @Override - public void createUpdateCompanyBoatInfos(CompanyBoatInfos companyBoatInfos) - throws WaoException { - TopiaContext transaction = null; - try { - long startTime = 0; - if (log.isDebugEnabled()) { - startTime = System.currentTimeMillis(); - } - transaction = rootContext.beginTransaction(); + public void executeCreateUpdateCompanyBoatInfos(TopiaContext transaction, + List<Object> errorArgs, + CompanyBoatInfos companyBoatInfos) throws TopiaException { +// TopiaContext transaction = null; +// try { +// long startTime = 0; +// if (log.isDebugEnabled()) { +// startTime = System.currentTimeMillis(); +// } +// transaction = rootContext.beginTransaction(); - BoatInfosDAO dao = WaoModelDAOHelper.getBoatInfosDAO(transaction); + Boat boat = companyBoatInfos.getBoatInfos().getBoat(); + Company company = companyBoatInfos.getCompany(); + errorArgs.add(boat.getImmatriculation()); + errorArgs.add(company.getName()); + BoatInfosDAO dao = WaoDAOHelper.getBoatInfosDAO(transaction); + BoatInfos boatInfos = companyBoatInfos.getBoatInfos(); - WaoContext.prepareTopiaId(BoatInfos.class, boatInfos); + context.prepareTopiaId(BoatInfos.class, boatInfos); dao.update(boatInfos); - ElligibleBoatDAO elligibleDAO = WaoModelDAOHelper.getElligibleBoatDAO(transaction); + ElligibleBoatDAO elligibleDAO = WaoDAOHelper.getElligibleBoatDAO(transaction); for (ElligibleBoat elligible : companyBoatInfos.getElligibleBoatsValues()) { - WaoContext.prepareTopiaId(ElligibleBoat.class, elligible); + context.prepareTopiaId(ElligibleBoat.class, elligible); elligibleDAO.update(elligible); } @@ -313,39 +328,42 @@ transaction.commitTransaction(); - if (log.isDebugEnabled()) { - long stopTime = System.currentTimeMillis(); - log.debug("W:[ createUpdateCompanyBoatInfos ] Time = " + - DurationFormatUtils.formatDurationHMS( - stopTime - startTime)); - } - //transaction.closeContext(); - } catch (Exception eee) { - Boat boat = companyBoatInfos.getBoatInfos().getBoat(); - Company company = companyBoatInfos.getCompany(); - WaoContext.serviceException(transaction, - "Impossible de créer ou modifier les informations liés au navire " + - boat.getImmatriculation() + " pour la société " + company.getName(), eee); - } finally { - WaoContext.closeTransaction(transaction); - } +// if (log.isDebugEnabled()) { +// long stopTime = System.currentTimeMillis(); +// log.debug("W:[ createUpdateCompanyBoatInfos ] Time = " + +// DurationFormatUtils.formatDurationHMS( +// stopTime - startTime)); +// } +// //transaction.closeContext(); +// } catch (Exception eee) { +// Boat boat = companyBoatInfos.getBoatInfos().getBoat(); +// Company company = companyBoatInfos.getCompany(); +// WaoContextO.serviceException(transaction, +// "Impossible de créer ou modifier les informations liés au navire " + +// boat.getImmatriculation() + " pour la société " + company.getName(), eee); +// } finally { +// WaoContextO.closeTransaction(transaction); +// } } @Override - public List<Boat> getBoatsByImmatriculations(String immatriculations) throws WaoException { + public List<Boat> executeGetBoatsByImmatriculations( + TopiaContext transaction, List<Object> errorArgs, + String immatriculations) + throws TopiaException, WaoBusinessException { List<Boat> boats = new ArrayList<Boat>(); - TopiaContext transaction = null; +// TopiaContext transaction = null; if (StringUtils.isEmpty(immatriculations)) { return boats; } - 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(); - BoatDAO dao = WaoModelDAOHelper.getBoatDAO(transaction); + BoatDAO dao = WaoDAOHelper.getBoatDAO(transaction); Pattern pattern = Pattern.compile("\\d{6}"); Matcher matcher = pattern.matcher(immatriculations); @@ -354,93 +372,99 @@ int immatriculation = Integer.parseInt(res); Boat boat = dao.findByImmatriculation(immatriculation); if (boat == null) { - throw new WaoBusinessException(Type.NOT_EXISTS, ServiceBoat.class, - "Immatriculation " + immatriculation + " incorrect, ne référence aucun navire"); + throw new WaoBusinessException(Type.NOT_EXISTS, + ServiceBoat.class, + "Immatriculation " + immatriculation + + " incorrect, ne référence aucun navire"); } boats.add(boat); } - if (log.isDebugEnabled()) { - long stopTime = System.currentTimeMillis(); - log.debug("W:[ getBoatsByImmatriculations ] Time = " + - DurationFormatUtils.formatDurationHMS( - stopTime - startTime)); - } - - //transaction.closeContext(); - } catch (Exception eee) { - WaoContext.serviceException(transaction, - "La chaîne d'immatriculations est incorrect ! Chaque immatriculation doit posséder 6 chiffres", eee); - } finally { - WaoContext.closeTransaction(transaction); - } +// if (log.isDebugEnabled()) { +// long stopTime = System.currentTimeMillis(); +// log.debug("W:[ getBoatsByImmatriculations ] Time = " + +// DurationFormatUtils.formatDurationHMS( +// stopTime - startTime)); +// } +// +// //transaction.closeContext(); +// } catch (Exception eee) { +// WaoContextO.serviceException(transaction, +// "La chaîne d'immatriculations est incorrect ! Chaque immatriculation doit posséder 6 chiffres", eee); +// } finally { +// WaoContextO.closeTransaction(transaction); +// } return boats; } @Override - public Boat getBoat(String boatId) throws WaoException { - TopiaContext transaction = null; - Boat result = null; - try { - long startTime = 0; - if (log.isDebugEnabled()) { - startTime = System.currentTimeMillis(); - } - transaction = rootContext.beginTransaction(); + public Boat executeGetBoat(TopiaContext transaction, List<Object> errorArgs, + String boatId) throws TopiaException { +// TopiaContext transaction = null; +// Boat result = null; +// try { +// long startTime = 0; +// if (log.isDebugEnabled()) { +// startTime = System.currentTimeMillis(); +// } +// transaction = rootContext.beginTransaction(); - BoatDAO dao = WaoModelDAOHelper.getBoatDAO(transaction); + BoatDAO dao = WaoDAOHelper.getBoatDAO(transaction); - result = dao.findByTopiaId(boatId); + return dao.findByTopiaId(boatId); - if (log.isDebugEnabled()) { - long stopTime = System.currentTimeMillis(); - log.debug("W:[ getBoat ] Time = " + - DurationFormatUtils.formatDurationHMS( - stopTime - startTime)); - } - - //transaction.closeContext(); - } catch (Exception eee) { - WaoContext.serviceException(transaction, "Impossible de charger le navire", eee); - } finally { - WaoContext.closeTransaction(transaction); - } - return result; +// if (log.isDebugEnabled()) { +// long stopTime = System.currentTimeMillis(); +// log.debug("W:[ getBoat ] Time = " + +// DurationFormatUtils.formatDurationHMS( +// stopTime - startTime)); +// } +// +// //transaction.closeContext(); +// } catch (Exception eee) { +// WaoContextO.serviceException(transaction, "Impossible de charger le navire", eee); +// } finally { +// WaoContextO.closeTransaction(transaction); +// } +// return result; } @Override - public List<String> getBoatNamesStartWith(String input) throws WaoException { - TopiaContext transaction = null; - List<String> results = new ArrayList<String>(); - try { - long startTime = 0; - if (log.isDebugEnabled()) { - startTime = System.currentTimeMillis(); - } - transaction = rootContext.beginTransaction(); + public List<String> executeGetBoatNamesStartWith(TopiaContext transaction, + List<Object> errorArgs, String input) throws TopiaException { +// TopiaContext transaction = null; +// List<String> results = new ArrayList<String>(); +// try { +// long startTime = 0; +// if (log.isDebugEnabled()) { +// startTime = System.currentTimeMillis(); +// } +// transaction = rootContext.beginTransaction(); input = StringUtils.upperCase(input); - BoatDAO dao = WaoModelDAOHelper.getBoatDAO(transaction); + errorArgs.add(input); - results = dao.createQuery().addDistinct().setSelect(Boat.NAME). + BoatDAO dao = WaoDAOHelper.getBoatDAO(transaction); + + return dao.createQuery().addDistinct().setSelect(Boat.NAME). add(Boat.NAME, Op.LIKE, input + "%").execute(); - if (log.isDebugEnabled()) { - long stopTime = System.currentTimeMillis(); - log.debug("W:[ getBoatNamesStartWith ] Time = " + - DurationFormatUtils.formatDurationHMS( - stopTime - startTime)); - } - - //transaction.closeContext(); - } catch (Exception eee) { - WaoContext.serviceException(transaction, - "Impossible de récupérer les navires avec un nom commencant par '" + input + "'", eee); - } finally { - WaoContext.closeTransaction(transaction); - } - return results; +// if (log.isDebugEnabled()) { +// long stopTime = System.currentTimeMillis(); +// log.debug("W:[ getBoatNamesStartWith ] Time = " + +// DurationFormatUtils.formatDurationHMS( +// stopTime - startTime)); +// } +// +// //transaction.closeContext(); +// } catch (Exception eee) { +// WaoContextO.serviceException(transaction, +// "Impossible de récupérer les navires avec un nom commencant par '" + input + "'", eee); +// } finally { +// WaoContextO.closeTransaction(transaction); +// } +// return results; } /** @@ -450,48 +474,67 @@ * QUARTIER_IMMA,PER_COD, PER_NOM,PER_PRENOM. * Existing boats (with same immatriculation) are updated. * + * @param transaction * @param input Stream corresponding to Csv file * @return an array with two int : the first corresponding to total number * of boats imported and the second corresponding only to new boats added. - * @throws WaoException + * @throws TopiaException + * @throws IOException + * @throws WaoBusinessException * @see com.csvreader.CsvReader */ @Override - public int[] importBoatCsv(InputStream input) throws WaoException { - TopiaContext transaction = null; + public int[] executeImportBoatCsv(TopiaContext transaction, InputStream input) + throws TopiaException, IOException, WaoBusinessException { +// TopiaContext transaction = null; int[] result = new int[]{0,0}; - try { - transaction = rootContext.beginTransaction(); +// try { +// transaction = rootContext.beginTransaction(); +// long startTime = System.currentTimeMillis(); - CsvReader reader = new CsvReader(input, WaoContext.getCsvCharset()); + CsvReader reader = new CsvReader(input, context.getCsvCharset()); reader.readHeaders(); - - long startTime = System.currentTimeMillis(); long tic; - BoatDAO boatDAO = WaoModelDAOHelper.getBoatDAO(transaction); - ShipOwnerDAO shipOwnerDAO = WaoModelDAOHelper.getShipOwnerDAO(transaction); + BoatDAO boatDAO = WaoDAOHelper.getBoatDAO(transaction); + ShipOwnerDAO shipOwnerDAO = WaoDAOHelper.getShipOwnerDAO(transaction); Map<String, ShipOwner> availableShipOwners = new HashMap<String, ShipOwner>(); tic = System.currentTimeMillis(); + Pattern pattern = Pattern.compile("\\d{6}"); while(reader.readRecord()) { result[0]++; -// if (log.isTraceEnabled()) { -// log.trace(" " + Arrays.asList(reader.getValues())); -// } + if (log.isDebugEnabled()) { + log.debug(" " + Arrays.asList(reader.getValues())); + } + String imma = ImportHelper.read(reader, BOAT.NAVS_COD); + Matcher matcher = pattern.matcher(imma); + if (!matcher.find()) { + throw new WaoBusinessException(Type.SYNTAX, + ServiceBoat.class, + "L'immatriculation ne comporte pas 6 chiffres"); + } - int immatriculation = ImportHelper.readInt(reader, BOAT.NAVS_COD); - String boatName = ImportHelper.read(reader, BOAT.CARN_NOM); - int boatLength = ImportHelper.readInt(reader, BOAT.CARN_LONGUEUR_HT); - int buildYear = ImportHelper.readInt(reader, BOAT.CARN_ANNEE); - String districtCode = ImportHelper.read(reader, BOAT.QUARTIER_IMMA); - String shipOwnerCode = ImportHelper.read(reader, BOAT.PER_COD); - String shipOwnerLastName = ImportHelper.read(reader, BOAT.PER_NOM); - String shipOwnerFirstName = ImportHelper.read(reader, BOAT.PER_PRENOM); - //String activeStr = reader.get(BOAT.NAVS_ACTIVE.name()).trim(); + int immatriculation = Integer.parseInt(imma); + + String boatName = + ImportHelper.read(reader, BOAT.CARN_NOM); + int boatLength = + ImportHelper.readInt(reader, BOAT.CARN_LONGUEUR_HT); + int buildYear = + ImportHelper.readInt(reader, BOAT.CARN_ANNEE); + String districtCode = + ImportHelper.read(reader, BOAT.QUARTIER_IMMA); + String shipOwnerCode = + ImportHelper.read(reader, BOAT.PER_COD); + String shipOwnerLastName = + ImportHelper.read(reader, BOAT.PER_NOM); + String shipOwnerFirstName = + ImportHelper.read(reader, BOAT.PER_PRENOM); + String activeStr = ImportHelper.read(reader, BOAT.NAVS_ACTIVE); boolean active = !activeStr.equals(BOAT.getBoatInactiveCode()); @@ -503,7 +546,8 @@ Boat boat = boatDAO.findByImmatriculation(immatriculation); if (boat == null) { - boat = boatDAO.create(Boat.IMMATRICULATION, immatriculation); + boat = boatDAO.create( + Boat.IMMATRICULATION, immatriculation); result[1]++; } boat.setName(boatName); @@ -513,18 +557,16 @@ boat.setActive(active); // Find existing shipOwner with code - //ShipOwner shipOwner = shipOwnerDAO.findByCode(shipOwnerCode); - ShipOwner shipOwner = availableShipOwners.get(shipOwnerCode); // If not available, select it from database if (shipOwner == null) { - //shipOwner = new TopiaQuery(ShipOwner.class).add(ShipOwner.CODE, shipOwnerCode).executeToEntity(transaction); shipOwner = shipOwnerDAO.findByCode(shipOwnerCode); // If not exist yet, create it if (shipOwner == null) { - shipOwner = shipOwnerDAO.create(ShipOwner.CODE, shipOwnerCode); + shipOwner = shipOwnerDAO.create( + ShipOwner.CODE, shipOwnerCode); } availableShipOwners.put(shipOwnerCode, shipOwner); @@ -533,55 +575,57 @@ shipOwner.setLastName(shipOwnerLastName); boat.setShipOwner(shipOwner); - //transaction.commitTransaction(); if (result[0] % 1000 == 0) { availableShipOwners.clear(); transaction.commitTransaction(); - tic = ImportHelper.logTimeAndMemory(log, tic, "navires ligne " + result[0]); + tic = ImportHelper.logTimeAndMemory( + log, tic, "navires ligne " + result[0]); } } // For the last rows transaction.commitTransaction(); - long stopTime = System.currentTimeMillis(); - - String execTime = DurationFormatUtils.formatDurationHMS(stopTime - startTime); - - if (log.isInfoEnabled()) { - log.info("Durée de l'import : " + execTime); - } - - //transaction.closeContext(); - } catch (Exception eee) { - WaoContext.serviceException(transaction, - "Problème d'import du fichier CSV. Vérifiez l'en-tête du fichier : [ NAVS_COD,CARN_NOM," + - "CARN_LONGUEUR_HT,CARN_ANNEE,QUARTIER_IMMA,PER_COD,PER_NOM,PER_PRENOM,NAVS_ACTIVE ]"/* et l'encodage [ UTF-8 ] */ + - " Voir documentation pour plus de détails.", - eee); - } finally { - WaoContext.closeTransaction(transaction); - } +// long stopTime = System.currentTimeMillis(); +// +// String execTime = DurationFormatUtils.formatDurationHMS(stopTime - startTime); +// +// if (log.isInfoEnabled()) { +// log.info("Durée de l'import : " + execTime); +// } +// +// //transaction.closeContext(); +// } catch (Exception eee) { +// WaoContextO.serviceException(transaction, +// "Problème d'import du fichier CSV. Vérifiez l'en-tête du fichier : [ NAVS_COD,CARN_NOM," + +// "CARN_LONGUEUR_HT,CARN_ANNEE,QUARTIER_IMMA,PER_COD,PER_NOM,PER_PRENOM,NAVS_ACTIVE ]"/* et l'encodage [ UTF-8 ] */ + +// " Voir documentation pour plus de détails.", +// eee); +// } finally { +// WaoContextO.closeTransaction(transaction); +// } return result; } @Override - public InputStream exportBoatCsv(BoatFilter filter) throws WaoException { - TopiaContext transaction = null; + public InputStream executeExportBoatCsv(TopiaContext transaction, + BoatFilter filter) throws Exception { +// TopiaContext transaction = null; InputStream result = null; CsvWriter writer = null; try { - transaction = rootContext.beginTransaction(); +// transaction = rootContext.beginTransaction(); File file = File.createTempFile("wao-boats-", ".csv"); file.deleteOnExit(); FileOutputStream output = new FileOutputStream(file); - writer = new CsvWriter(output, ',', WaoContext.getCsvCharset()); + writer = new CsvWriter(output, ',', context.getCsvCharset()); - ExportHelper<BOAT> export = new ExportHelper<BOAT>(writer, BOAT.getTotalHeaders()) { + ExportHelper<BOAT> export = + new ExportHelper<BOAT>(writer, BOAT.getTotalHeaders()) { @Override public String getHeaderValue(int index) throws IOException { return WaoCsvHeader.getHeaderForBoatCsv(index); @@ -596,7 +640,7 @@ export.writeHeaders(); // Get boats from database filterd by filter in argument - BoatDAO dao = WaoModelDAOHelper.getBoatDAO(transaction); + BoatDAO dao = WaoDAOHelper.getBoatDAO(transaction); TopiaQuery query = dao.createQuery("B"); query = createQueryForBoatFilter(query, filter); @@ -612,27 +656,39 @@ export.newRecord(); if (log.isTraceEnabled()) { - log.trace("add boat : " + boat.getName() + " (" + boat.getImmatriculation() + ")"); + log.trace("add boat : " + boat.getName() + " (" + + boat.getImmatriculation() + ")"); } - 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.CARN_LONGUEUR_HT, String.valueOf(boat.getBoatLength())); - export.record(BOAT.CARN_ANNEE, String.valueOf(boat.getBuildYear())); + export.record(BOAT.CARN_LONGUEUR_HT, + String.valueOf(boat.getBoatLength())); + export.record(BOAT.CARN_ANNEE, + String.valueOf(boat.getBuildYear())); export.record(BOAT.QUARTIER_IMMA, boat.getDistrictCode()); - export.record(BOAT.NAVS_ACTIVE, (!boat.getActive() ? BOAT.getBoatInactiveCode() : "")); + export.record(BOAT.NAVS_ACTIVE, + (!boat.getActive() ? BOAT.getBoatInactiveCode() : "")); if (filter.getCompany() != null) { - BoatInfos boatInfos = boat.getCompanyBoatInfos(filter.getCompany()); + BoatInfos boatInfos = + boat.getCompanyBoatInfos(filter.getCompany()); if (boatInfos != null) { - export.record(BOAT.CONT_PRENOM, boatInfos.getContactFirstName()); - export.record(BOAT.CONT_NOM, boatInfos.getContactLastName()); - export.record(BOAT.CONT_EMAIL, boatInfos.getContactEmail()); - export.record(BOAT.CONT_TEL, boatInfos.getContactPhoneNumber()); - export.record(BOAT.NAVS_DUP, String.valueOf(boatInfos.getDup())); - export.record(BOAT.NAVS_COMMENT, boatInfos.getComment()); + export.record(BOAT.CONT_PRENOM, + boatInfos.getContactFirstName()); + export.record(BOAT.CONT_NOM, + boatInfos.getContactLastName()); + export.record(BOAT.CONT_EMAIL, + boatInfos.getContactEmail()); + export.record(BOAT.CONT_TEL, + boatInfos.getContactPhoneNumber()); + export.record(BOAT.NAVS_DUP, + String.valueOf(boatInfos.getDup())); + export.record(BOAT.NAVS_COMMENT, + boatInfos.getComment()); } } @@ -642,42 +698,51 @@ //transaction.closeContext(); } catch (Exception eee) { - WaoContext.serviceException(transaction, - "Impossible d'exporter les navires sélectionnés", eee); + throw eee; +// WaoContextO.serviceException(transaction, +// "Impossible d'exporter les navires sélectionnés", eee); } finally { if (writer != null) { writer.close(); } - WaoContext.closeTransaction(transaction); +// WaoContextO.closeTransaction(transaction); } return result; } @Override - public void importActivityCalendarCsv(InputStream input) throws WaoException { - if (!WaoContext.isActivityCalendarImportRun()) { - try { - ActivityCalendarImport calendarImport = new ActivityCalendarImport(input); + public void executeImportActivityCalendarCsv(InputStream input) + throws IOException { + if (!context.isActivityCalendarImportRun()) { +// try { + ActivityCalendarImport calendarImport = + new ActivityCalendarImport(context, input); new Thread(calendarImport).start(); - } catch (IOException eee) { - WaoContext.serviceException(null, - "Problème d'import du fichier CSV des calendriers d'activité", eee); - } +// } catch (IOException eee) { +// WaoContextO.serviceException(null, +// "Problème d'import du fichier CSV des calendriers d'activité", eee); +// } } } @Override - public ActivityCalendar getLastActivityCalendar(WaoUser user, Boat boat) throws WaoException { - TopiaContext transaction = null; + public ActivityCalendar executeGetLastActivityCalendar( + TopiaContext transaction, List<Object> errorArgs, + WaoUser user, Boat boat) throws TopiaException, IOException { + + errorArgs.add(boat.getName()); + errorArgs.add(boat.getImmatriculation()); + +// TopiaContext transaction = null; ActivityCalendar result = null; - 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(); - ActivityCalendarDAO dao = WaoModelDAOHelper.getActivityCalendarDAO(transaction); + ActivityCalendarDAO dao = WaoDAOHelper.getActivityCalendarDAO(transaction); TopiaQuery query = dao.createQuery("A"). add("A." + ActivityCalendar.BOAT, boat); @@ -705,43 +770,45 @@ // Log ActivityCalendar access only for non admin user if (!user.isAdmin()) { Company company = user.getCompany(); - WaoContext.addActivityCalendarAccessLog( + // FIXME-FD20100401 Find a way to avoid using old context for + // logging access on ActivityCalendar + WaoContextO.addActivityCalendarAccessLog( "Calendrier " + result.getYear() + " du navire " + boat.getName() + " (" + boat.getImmatriculation() + ") vu " + "par " + user.getFullName() + " de la société " + company.getName()); } - if (log.isDebugEnabled()) { - long stopTime = System.currentTimeMillis(); - log.debug("W:[ getLastActivityCalendar ] Time = " + - DurationFormatUtils.formatDurationHMS( - stopTime - startTime)); - } - - //transaction.closeContext(); - } catch (Exception eee) { - WaoContext.serviceException(transaction, - "Impossible de charger le dernier calendrier d'activité du navire " + - boat.getName() + " (" + boat.getImmatriculation() + ")", eee); - } finally { - WaoContext.closeTransaction(transaction); - } +// if (log.isDebugEnabled()) { +// long stopTime = System.currentTimeMillis(); +// log.debug("W:[ getLastActivityCalendar ] Time = " + +// DurationFormatUtils.formatDurationHMS( +// stopTime - startTime)); +// } +// +// //transaction.closeContext(); +// } catch (Exception eee) { +// WaoContextO.serviceException(transaction, +// "Impossible de charger le dernier calendrier d'activité du navire " + +// boat.getName() + " (" + boat.getImmatriculation() + ")", eee); +// } finally { +// WaoContextO.closeTransaction(transaction); +// } return result; } @Override - public InputStream getActivityCalendarLogFile() throws FileNotFoundException { - String filename = WaoContext.getProperty( - WaoContext.PROP_FILENAME_LOG_ACTIVITY_IMPORT); + public InputStream executeGetActivityCalendarLogFile() + throws FileNotFoundException { + String filename = WaoProperty.FILENAME_LOG_ACTIVITY_IMPORT.getValue(); File file = new File(filename); return new FileInputStream(file); } @Override - public InputStream getActivityCalendarLogAccessFile() throws FileNotFoundException { - String filename = WaoContext.getProperty( - WaoContext.PROP_FILENAME_LOG_ACTIVITY_ACCESS); + public InputStream executeGetActivityCalendarLogAccessFile() + throws FileNotFoundException { + String filename = WaoProperty.FILENAME_LOG_ACTIVITY_ACCESS.getValue(); File file = new File(filename); return new FileInputStream(file); } 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 13:27:59 UTC (rev 401) +++ trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceContactImpl.java 2010-04-01 13:28:03 UTC (rev 402) @@ -27,9 +27,9 @@ import fr.ifremer.wao.io.ImportHelper.*; import fr.ifremer.wao.WaoBusinessException; import fr.ifremer.wao.WaoBusinessException.Type; -import fr.ifremer.wao.WaoException; -import fr.ifremer.wao.WaoModelDAOHelper; -import fr.ifremer.wao.WaoContext; +import fr.ifremer.wao.WaoExceptionO; +import fr.ifremer.wao.WaoDAOHelper; +import fr.ifremer.wao.WaoContextO; import fr.ifremer.wao.bean.ContactState; import java.io.IOException; import java.io.InputStream; @@ -95,12 +95,12 @@ protected TopiaContext rootContext; - public ServiceContactImpl() throws WaoException { - rootContext = WaoContext.getTopiaRootContext(); + public ServiceContactImpl() throws WaoExceptionO { + rootContext = WaoContextO.getTopiaRootContext(); } @Override - public Map<String, Contact> getContacts(ContactFilter filter) throws WaoException { + public Map<String, Contact> getContacts(ContactFilter filter) throws WaoExceptionO { Map<String, Contact> results = new HashMap<String, Contact>(); TopiaContext transaction = null; try { @@ -110,7 +110,7 @@ } transaction = rootContext.beginTransaction(); - ContactDAO dao = WaoModelDAOHelper.getContactDAO(transaction); + ContactDAO dao = WaoDAOHelper.getContactDAO(transaction); TopiaQuery query = dao.createQuery("C").addDistinct(); @@ -134,16 +134,16 @@ //transaction.closeContext(); } catch (Exception eee) { - WaoContext.serviceException(transaction, + WaoContextO.serviceException(transaction, "Impossible de filtrer la liste des contacts", eee); } finally { - WaoContext.closeTransaction(transaction); + WaoContextO.closeTransaction(transaction); } return results; } @Override - public int getNbContacts(ContactFilter filter) throws WaoException { + public int getNbContacts(ContactFilter filter) throws WaoExceptionO { TopiaContext transaction = null; int result = 0; try { @@ -153,7 +153,7 @@ } transaction = rootContext.beginTransaction(); - ContactDAO dao = WaoModelDAOHelper.getContactDAO(transaction); + ContactDAO dao = WaoDAOHelper.getContactDAO(transaction); TopiaQuery query = dao.createQuery("C"); query = filter.prepareQueryForContact(query); @@ -168,10 +168,10 @@ //transaction.closeContext(); } catch (Exception eee) { - WaoContext.serviceException(transaction, + WaoContextO.serviceException(transaction, "Impossible de compter le nombre de contacts filtrés", eee); } finally { - WaoContext.closeTransaction(transaction); + WaoContextO.closeTransaction(transaction); } return result; } @@ -187,7 +187,7 @@ } @Override - public void saveContact(Contact contact, boolean delete) throws WaoException { + public void saveContact(Contact contact, boolean delete) throws WaoExceptionO { TopiaContext transaction = null; try { long startTime = 0; @@ -196,13 +196,13 @@ } transaction = rootContext.beginTransaction(); - ContactDAO dao = WaoModelDAOHelper.getContactDAO(transaction); + ContactDAO dao = WaoDAOHelper.getContactDAO(transaction); if (log.isDebugEnabled()) { log.debug("Create date : " + contact.getTopiaCreateDate()); } - WaoContext.prepareTopiaId(Contact.class, contact); + WaoContextO.prepareTopiaId(Contact.class, contact); if (delete) { dao.delete(contact); } else { @@ -219,16 +219,16 @@ } //transaction.closeContext(); } catch (Exception eee) { - WaoContext.serviceException(transaction, + WaoContextO.serviceException(transaction, "Impossible de sauvegarder le contact", eee); } finally { - WaoContext.closeTransaction(transaction); + WaoContextO.closeTransaction(transaction); } } @Override public InputStream exportContactCsv(ContactFilter filter) - throws WaoException { + throws WaoExceptionO { TopiaContext transaction = null; InputStream result = null; CsvWriter writer = null; @@ -243,7 +243,7 @@ } FileOutputStream output = new FileOutputStream(file); - writer = new CsvWriter(output, ',', WaoContext.getCsvCharset()); + writer = new CsvWriter(output, ',', WaoContextO.getCsvCharset()); ExportHelper<ContactHeader> export = new ExportHelper<ContactHeader>(writer, CONTACT.getTotalHeaders()) { @@ -266,7 +266,7 @@ DateFormat dateFormat = CONTACT.getDateFormat(); // Get contacts from database - ContactDAO dao = WaoModelDAOHelper.getContactDAO(transaction); + ContactDAO dao = WaoDAOHelper.getContactDAO(transaction); TopiaQuery query = dao.createQuery("C"); query.addOrderDesc("C." + TopiaEntity.TOPIA_CREATE_DATE); @@ -351,19 +351,19 @@ //transaction.closeContext(); } catch (Exception eee) { - WaoContext.serviceException(transaction, + WaoContextO.serviceException(transaction, "Impossible d'exporter les contacts", eee); } finally { if (writer != null) { writer.close(); } - WaoContext.closeTransaction(transaction); + WaoContextO.closeTransaction(transaction); } return result; } @Override - public ImportResults importContactCsv(WaoUser user, InputStream input) throws WaoException { + public ImportResults importContactCsv(WaoUser user, InputStream input) throws WaoExceptionO { TopiaContext transaction = null; ImportResults result = new ImportResultsImpl(); int currRow = 1; @@ -371,14 +371,14 @@ try { transaction = rootContext.beginTransaction(); - reader = new CsvReader(input, WaoContext.getCsvCharset()); + reader = new CsvReader(input, WaoContextO.getCsvCharset()); reader.readHeaders(); - ContactDAO dao = WaoModelDAOHelper.getContactDAO(transaction); - WaoUserDAO userDAO = WaoModelDAOHelper.getWaoUserDAO(transaction); - CompanyDAO companyDAO = WaoModelDAOHelper.getCompanyDAO(transaction); - SampleRowDAO rowDAO = WaoModelDAOHelper.getSampleRowDAO(transaction); - BoatDAO boatDAO = WaoModelDAOHelper.getBoatDAO(transaction); + 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(); @@ -424,7 +424,7 @@ if (boat != null) { - ElligibleBoatDAO elligibleDAO = WaoModelDAOHelper.getElligibleBoatDAO(transaction); + ElligibleBoatDAO elligibleDAO = WaoDAOHelper.getElligibleBoatDAO(transaction); ElligibleBoat elligible = elligibleDAO.findByProperties( ElligibleBoat.BOAT, boat, ElligibleBoat.SAMPLE_ROW, row); @@ -550,7 +550,7 @@ //transaction.closeContext(); } catch (ParseException eee) { - WaoContext.serviceException(transaction, + WaoContextO.serviceException(transaction, "Erreur ligne " + currRow + " : " + "Le format des dates est incorrect, il doit être de la forme : JJ/MM/AAAA", eee); } catch (Exception eee) { @@ -561,10 +561,10 @@ log.error("Reader error", ex); } } - WaoContext.serviceException(transaction, + WaoContextO.serviceException(transaction, "Impossible d'importer les contacts", eee); } finally { - WaoContext.closeTransaction(transaction); + WaoContextO.closeTransaction(transaction); } return result; } Modified: trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceNewsImpl.java =================================================================== --- trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceNewsImpl.java 2010-04-01 13:27:59 UTC (rev 401) +++ trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceNewsImpl.java 2010-04-01 13:28:03 UTC (rev 402) @@ -21,15 +21,12 @@ package fr.ifremer.wao.service; -import fr.ifremer.wao.WaoContext; -import fr.ifremer.wao.WaoException; -import fr.ifremer.wao.WaoModelDAOHelper; +import fr.ifremer.wao.WaoDAOHelper; import fr.ifremer.wao.entity.News; import fr.ifremer.wao.entity.NewsDAO; -import java.util.ArrayList; import java.util.List; -import org.apache.commons.lang.time.DurationFormatUtils; import org.nuiton.topia.TopiaContext; +import org.nuiton.topia.TopiaException; import org.nuiton.topia.persistence.TopiaEntity; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -45,82 +42,88 @@ * Mise a jour: $Date$ * par : $Author$ */ -public class ServiceNewsImpl implements ServiceNews { +public class ServiceNewsImpl extends ServiceNewsAbstract { - private static final Logger log = LoggerFactory.getLogger(ServiceNewsImpl.class); + private static final Logger logger = + LoggerFactory.getLogger(ServiceNewsImpl.class); - protected TopiaContext rootContext; +// protected TopiaContext rootContext; +// +// public ServiceNewsImpl() throws WaoExceptionO { +// rootContext = WaoContextO.getTopiaRootContext(); +// } - public ServiceNewsImpl() throws WaoException { - rootContext = WaoContext.getTopiaRootContext(); - } - @Override - public List<News> getNews() throws WaoException { - TopiaContext transaction = null; - List<News> results = new ArrayList<News>(); - try { - long startTime = 0; - if (log.isDebugEnabled()) { - startTime = System.currentTimeMillis(); - } - transaction = rootContext.beginTransaction(); + public List<News> executeGetNews(TopiaContext transaction) throws TopiaException { +// TopiaContext transaction = null; +// List<News> results = new ArrayList<News>(); +// try { +// long startTime = 0; +// if (log.isDebugEnabled()) { +// startTime = System.currentTimeMillis(); +// } +// transaction = rootContext.beginTransaction(); - NewsDAO dao = WaoModelDAOHelper.getNewsDAO(transaction); + NewsDAO dao = WaoDAOHelper.getNewsDAO(transaction); - results = dao.findAllWithOrder(TopiaEntity.TOPIA_CREATE_DATE + " DESC"); + return dao.findAllWithOrder(TopiaEntity.TOPIA_CREATE_DATE + + " DESC"); - if (log.isDebugEnabled()) { - long stopTime = System.currentTimeMillis(); - log.debug("W:[ getNews ] Time = " + - DurationFormatUtils.formatDurationHMS( - stopTime - startTime)); - } - - //transaction.closeContext(); - } catch (Exception eee) { - WaoContext.serviceException(transaction, - "Impossible de récupérer l'ensemble des news", eee); - } finally { - WaoContext.closeTransaction(transaction); - } - return results; +// if (log.isDebugEnabled()) { +// long stopTime = System.currentTimeMillis(); +// log.debug("W:[ getNews ] Time = " + +// DurationFormatUtils.formatDurationHMS( +// stopTime - startTime)); +// } +// +// //transaction.closeContext(); +// } catch (Exception eee) { +// WaoContextO.serviceException(transaction, +// "Impossible de récupérer l'ensemble des news", eee); +// } finally { +// WaoContextO.closeTransaction(transaction); +// } +// return results; } @Override - public void saveNews(News news, boolean delete) throws WaoException { - TopiaContext transaction = null; - try { - long startTime = 0; - if (log.isDebugEnabled()) { - startTime = System.currentTimeMillis(); - } - transaction = rootContext.beginTransaction(); + public void executeSaveNews(TopiaContext transaction, + List<Object> errorArgs, News news, boolean delete) + throws TopiaException { +// TopiaContext transaction = null; +// try { +// long startTime = 0; +// if (log.isDebugEnabled()) { +// startTime = System.currentTimeMillis(); +// } +// transaction = rootContext.beginTransaction(); - NewsDAO dao = WaoModelDAOHelper.getNewsDAO(transaction); + errorArgs.add(news.getTitle()); + NewsDAO dao = WaoDAOHelper.getNewsDAO(transaction); + if (delete) { dao.delete(news); } else { - WaoContext.prepareTopiaId(News.class, news); + context.prepareTopiaId(News.class, news); dao.update(news); } transaction.commitTransaction(); - if (log.isDebugEnabled()) { - long stopTime = System.currentTimeMillis(); - log.debug("W:[ saveNews ] Time = " + - DurationFormatUtils.formatDurationHMS( - stopTime - startTime)); - } - //transaction.closeContext(); - } catch (Exception eee) { - WaoContext.serviceException(transaction, - "Impossible de récupérer l'ensemble des news", eee); - } finally { - WaoContext.closeTransaction(transaction); - } +// if (log.isDebugEnabled()) { +// long stopTime = System.currentTimeMillis(); +// log.debug("W:[ saveNews ] Time = " + +// DurationFormatUtils.formatDurationHMS( +// stopTime - startTime)); +// } +// //transaction.closeContext(); +// } catch (Exception eee) { +// WaoContextO.serviceException(transaction, +// "Impossible de récupérer l'ensemble des news", eee); +// } finally { +// WaoContextO.closeTransaction(transaction); +// } } } Modified: trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceReferentialImpl.java =================================================================== --- trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceReferentialImpl.java 2010-04-01 13:27:59 UTC (rev 401) +++ trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceReferentialImpl.java 2010-04-01 13:28:03 UTC (rev 402) @@ -22,9 +22,7 @@ package fr.ifremer.wao.service; import com.csvreader.CsvReader; -import fr.ifremer.wao.WaoException; -import fr.ifremer.wao.WaoModelDAOHelper; -import fr.ifremer.wao.WaoContext; +import fr.ifremer.wao.WaoDAOHelper; import fr.ifremer.wao.bean.SamplingFilter; import fr.ifremer.wao.entity.FishingZone; import fr.ifremer.wao.entity.FishingZoneDAO; @@ -33,12 +31,11 @@ import fr.ifremer.wao.entity.SampleRow; import fr.ifremer.wao.io.ImportHelper; import fr.ifremer.wao.io.WaoCsvHeader.FISHING_ZONE; +import java.io.IOException; import java.io.InputStream; -import java.util.ArrayList; import java.util.Arrays; import java.util.List; 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.framework.TopiaQuery; @@ -56,62 +53,65 @@ * Mise a jour: $Date$ * par : $Author$ */ -public class ServiceReferentialImpl implements ServiceReferential { +public class ServiceReferentialImpl extends ServiceReferentialAbstract { private static final Logger log = LoggerFactory.getLogger(ServiceReferentialImpl.class); - protected TopiaContext rootContext; +// protected TopiaContext rootContext; +// +// public ServiceReferentialImpl() throws WaoExceptionO { +// rootContext = WaoContextO.getTopiaRootContext(); +// } - public ServiceReferentialImpl() throws WaoException { - rootContext = WaoContext.getTopiaRootContext(); - } - @Override - public List<String> getFacades(SamplingFilter filter) throws WaoException { - TopiaContext transaction = null; - List<String> results = new ArrayList<String>(); - try { - long startTime = 0; - if (log.isDebugEnabled()) { - startTime = System.currentTimeMillis(); - } - transaction = rootContext.beginTransaction(); + public List<String> executeGetFacades(TopiaContext transaction, + SamplingFilter filter) throws TopiaException { +// TopiaContext transaction = null; +// List<String> results = new ArrayList<String>(); +// try { +// long startTime = 0; +// if (log.isDebugEnabled()) { +// startTime = System.currentTimeMillis(); +// } +// transaction = rootContext.beginTransaction(); - FishingZoneDAO dao = WaoModelDAOHelper.getFishingZoneDAO(transaction); + FishingZoneDAO dao = WaoDAOHelper.getFishingZoneDAO(transaction); TopiaQuery query = dao.createQuery("F"); query = prepareQueryForFishingZoneFilter(query, filter); - results = (List<String>)query.setSelect("DISTINCT F." + FishingZone.FACADE_NAME).execute(); + return (List<String>)query.addDistinct(). + setSelect("F." + FishingZone.FACADE_NAME).execute(); - if (log.isDebugEnabled()) { - long stopTime = System.currentTimeMillis(); - log.debug("W:[ getFacades ] Time = " + - DurationFormatUtils.formatDurationHMS( - stopTime - startTime)); - } - - //transaction.closeContext(); - } catch (Exception eee) { - WaoContext.serviceException(transaction, "Impossible de charger la liste des facades", eee); - } finally { - WaoContext.closeTransaction(transaction); - } - return results; +// if (log.isDebugEnabled()) { +// long stopTime = System.currentTimeMillis(); +// log.debug("W:[ getFacades ] Time = " + +// DurationFormatUtils.formatDurationHMS( +// stopTime - startTime)); +// } +// +// //transaction.closeContext(); +// } catch (Exception eee) { +// WaoContextO.serviceException(transaction, "Impossible de charger la liste des facades", eee); +// } finally { +// WaoContextO.closeTransaction(transaction); +// } +// return results; } @Override - public List<String> getSectors(SamplingFilter filter) throws WaoException { - TopiaContext transaction = null; - List<String> results = new ArrayList<String>(); - try { - long startTime = 0; - if (log.isDebugEnabled()) { - startTime = System.currentTimeMillis(); - } - transaction = rootContext.beginTransaction(); + public List<String> executeGetSectors(TopiaContext transaction, + SamplingFilter filter) throws TopiaException { +// TopiaContext transaction = null; +// List<String> results = new ArrayList<String>(); +// try { +// long startTime = 0; +// if (log.isDebugEnabled()) { +// startTime = System.currentTimeMillis(); +// } +// transaction = rootContext.beginTransaction(); - FishingZoneDAO dao = WaoModelDAOHelper.getFishingZoneDAO(transaction); + FishingZoneDAO dao = WaoDAOHelper.getFishingZoneDAO(transaction); TopiaQuery query = dao.createQuery("F"); query = prepareQueryForFishingZoneFilter(query, filter); @@ -120,22 +120,23 @@ query.add("F." + FishingZone.FACADE_NAME, filter.getFacadeName()); } - results = (List<String>)query.setSelect("DISTINCT F." + FishingZone.SECTOR_NAME).execute(); + return (List<String>)query.addDistinct(). + setSelect("F." + FishingZone.SECTOR_NAME).execute(); - if (log.isDebugEnabled()) { - long stopTime = System.currentTimeMillis(); - log.debug("W:[ getSectors ] Time = " + - DurationFormatUtils.formatDurationHMS( - stopTime - startTime)); - } - - //transaction.closeContext(); - } catch (Exception eee) { - WaoContext.serviceException(transaction, "Impossible de charger la liste des secteurs de pêche", eee); - } finally { - WaoContext.closeTransaction(transaction); - } - return results; +// if (log.isDebugEnabled()) { +// long stopTime = System.currentTimeMillis(); +// log.debug("W:[ getSectors ] Time = " + +// DurationFormatUtils.formatDurationHMS( +// stopTime - startTime)); +// } +// +// //transaction.closeContext(); +// } catch (Exception eee) { +// WaoContextO.serviceException(transaction, "Impossible de charger la liste des secteurs de pêche", eee); +// } finally { +// WaoContextO.closeTransaction(transaction); +// } +// return results; } protected TopiaQuery prepareQueryForFishingZoneFilter(TopiaQuery query, SamplingFilter filter) throws TopiaException { @@ -156,89 +157,95 @@ } @Override - public List<Profession> getProfessions() throws WaoException { - TopiaContext transaction = null; - List<Profession> results = new ArrayList<Profession>(); - try { - long startTime = 0; - if (log.isDebugEnabled()) { - startTime = System.currentTimeMillis(); - } - transaction = rootContext.beginTransaction(); + public List<Profession> executeGetProfessions(TopiaContext transaction) + throws TopiaException { +// TopiaContext transaction = null; +// List<Profession> results = new ArrayList<Profession>(); +// try { +// long startTime = 0; +// if (log.isDebugEnabled()) { +// startTime = System.currentTimeMillis(); +// } +// transaction = rootContext.beginTransaction(); - ProfessionDAO dao = WaoModelDAOHelper.getProfessionDAO(transaction); + ProfessionDAO dao = WaoDAOHelper.getProfessionDAO(transaction); - results = dao.findAll(); + return dao.findAll(); - if (log.isDebugEnabled()) { - long stopTime = System.currentTimeMillis(); - log.debug("W:[ getProfessions ] Time = " + - DurationFormatUtils.formatDurationHMS( - stopTime - startTime)); - } - - //transaction.closeContext(); - } catch (Exception eee) { - WaoContext.serviceException(transaction, - "Impossible de charger la liste des métiers", eee); - } finally { - WaoContext.closeTransaction(transaction); - } - return results; +// if (log.isDebugEnabled()) { +// long stopTime = System.currentTimeMillis(); +// log.debug("W:[ getProfessions ] Time = " + +// DurationFormatUtils.formatDurationHMS( +// stopTime - startTime)); +// } +// +// //transaction.closeContext(); +// } catch (Exception eee) { +// WaoContextO.serviceException(transaction, +// "Impossible de charger la liste des métiers", eee); +// } finally { +// WaoContextO.closeTransaction(transaction); +// } +// return results; } @Override - public List<FishingZone> getFishingZones() throws WaoException { - TopiaContext transaction = null; - List<FishingZone> results = new ArrayList<FishingZone>(); - try { - long startTime = 0; - if (log.isDebugEnabled()) { - startTime = System.currentTimeMillis(); - } - transaction = rootContext.beginTransaction(); + public List<FishingZone> executeGetFishingZones(TopiaContext transaction) + throws TopiaException { +// TopiaContext transaction = null; +// List<FishingZone> results = new ArrayList<FishingZone>(); +// try { +// long startTime = 0; +// if (log.isDebugEnabled()) { +// startTime = System.currentTimeMillis(); +// } +// transaction = rootContext.beginTransaction(); - FishingZoneDAO dao = WaoModelDAOHelper.getFishingZoneDAO(transaction); + FishingZoneDAO dao = WaoDAOHelper.getFishingZoneDAO(transaction); - results = dao.findAll(); + return dao.findAll(); - if (log.isDebugEnabled()) { - long stopTime = System.currentTimeMillis(); - log.debug("W:[ getFishingZones ] Time = " + - DurationFormatUtils.formatDurationHMS( - stopTime - startTime)); - } - - //transaction.closeContext(); - } catch (Exception eee) { - WaoContext.serviceException(transaction, - "Impossible de charger la liste des zones de pêche", eee); - } finally { - WaoContext.closeTransaction(transaction); - } - return results; +// if (log.isDebugEnabled()) { +// long stopTime = System.currentTimeMillis(); +// log.debug("W:[ getFishingZones ] Time = " + +// DurationFormatUtils.formatDurationHMS( +// stopTime - startTime)); +// } +// +// //transaction.closeContext(); +// } catch (Exception eee) { +// WaoContextO.serviceException(transaction, +// "Impossible de charger la liste des zones de pêche", eee); +// } finally { +// WaoContextO.closeTransaction(transaction); +// } +// return results; } @Override - public int importFishingZoneCsv(InputStream input) throws WaoException { - TopiaContext transaction = null; + public int executeImportFishingZoneCsv(TopiaContext transaction, + InputStream input) throws TopiaException, IOException { +// TopiaContext transaction = null; int result = 0; - try { - transaction = rootContext.beginTransaction(); +// try { +// transaction = rootContext.beginTransaction(); - CsvReader reader = new CsvReader(input, WaoContext.getCsvCharset()); + CsvReader reader = new CsvReader(input, context.getCsvCharset()); reader.readHeaders(); - FishingZoneDAO dao = WaoModelDAOHelper.getFishingZoneDAO(transaction); + FishingZoneDAO dao = WaoDAOHelper.getFishingZoneDAO(transaction); while(reader.readRecord()) { if (log.isTraceEnabled()) { log.trace(" " + Arrays.asList(reader.getValues())); } - String facadeName = ImportHelper.read(reader, FISHING_ZONE.PECHE_FACADE); - String sectorName = ImportHelper.read(reader, FISHING_ZONE.PECHE_ZONE); - String districtCode = ImportHelper.read(reader, FISHING_ZONE.PECHE_DIVISION); + String facadeName = + ImportHelper.read(reader, FISHING_ZONE.PECHE_FACADE); + String sectorName = + ImportHelper.read(reader, FISHING_ZONE.PECHE_ZONE); + String districtCode = + ImportHelper.read(reader, FISHING_ZONE.PECHE_DIVISION); FishingZone zone = dao.findByDistrictCode(districtCode); @@ -251,15 +258,15 @@ } transaction.commitTransaction(); - //transaction.closeContext(); - } catch (Exception eee) { - WaoContext.serviceException(transaction, - "Problème d'import du fichier CSV. Vérifiez l'en-tête du fichier : [ PECHE_DIVISION," + - "PECHE_ZONE,PECHE_FACADE ]. Voir documentation pour plus de détails.", - eee); - } finally { - WaoContext.closeTransaction(transaction); - } +// //transaction.closeContext(); +// } catch (Exception eee) { +// WaoContextO.serviceException(transaction, +// "Problème d'import du fichier CSV. Vérifiez l'en-tête du fichier : [ PECHE_DIVISION," + +// "PECHE_ZONE,PECHE_FACADE ]. Voir documentation pour plus de détails.", +// eee); +// } finally { +// WaoContextO.closeTransaction(transaction); +// } return result; } Modified: trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceSamplingImpl.java =================================================================== --- trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceSamplingImpl.java 2010-04-01 13:27:59 UTC (rev 401) +++ trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceSamplingImpl.java 2010-04-01 13:28:03 UTC (rev 402) @@ -26,9 +26,9 @@ import fr.ifremer.wao.io.ImportHelper; import fr.ifremer.wao.WaoBusinessException; import fr.ifremer.wao.WaoBusinessException.Type; -import fr.ifremer.wao.WaoException; -import fr.ifremer.wao.WaoModelDAOHelper; -import fr.ifremer.wao.WaoContext; +import fr.ifremer.wao.WaoExceptionO; +import fr.ifremer.wao.WaoDAOHelper; +import fr.ifremer.wao.WaoContextO; import fr.ifremer.wao.bean.FacadeRow; import fr.ifremer.wao.bean.FacadeRowImpl; import fr.ifremer.wao.bean.ImportResults; @@ -86,13 +86,13 @@ protected TopiaContext rootContext; - public ServiceSamplingImpl() throws WaoException { - rootContext = WaoContext.getTopiaRootContext(); + public ServiceSamplingImpl() throws WaoExceptionO { + rootContext = WaoContextO.getTopiaRootContext(); prepareBinderForProfession(); } @Override - public void createUpdateSampleRow(SampleRow row, List<Boat> boats, SampleRowLog rowLog) throws WaoException { + public void createUpdateSampleRow(SampleRow row, List<Boat> boats, SampleRowLog rowLog) throws WaoExceptionO { TopiaContext transaction = null; TopiaContext transaction2 = null; try { @@ -102,11 +102,11 @@ } transaction = rootContext.beginTransaction(); - SampleRowLogDAO logDAO = WaoModelDAOHelper.getSampleRowLogDAO(transaction); - WaoContext.prepareTopiaId(SampleRowLog.class, rowLog); + SampleRowLogDAO logDAO = WaoDAOHelper.getSampleRowLogDAO(transaction); + WaoContextO.prepareTopiaId(SampleRowLog.class, rowLog); logDAO.update(rowLog); - boolean newRow = WaoContext.prepareTopiaId(SampleRow.class, row); + boolean newRow = WaoContextO.prepareTopiaId(SampleRow.class, row); if (log.isDebugEnabled()) { log.debug("new sampleRow : " + newRow); @@ -125,7 +125,7 @@ // UPDATE if (!newRow) { // Prepare data for logging or deleting oldMonths - SampleRowDAO oldDAO = WaoModelDAOHelper.getSampleRowDAO(transaction2); + SampleRowDAO oldDAO = WaoDAOHelper.getSampleRowDAO(transaction2); oldRow = oldDAO.findByTopiaId(row.getTopiaId()); oldCompany = oldRow.getCompany(); oldProfession = oldRow.getProfession(); @@ -160,13 +160,13 @@ rowLog.addChangePeriod(oldPeriod, newPeriod, pattern); // Save Profession - ProfessionDAO professionDAO = WaoModelDAOHelper.getProfessionDAO(transaction); - WaoContext.prepareTopiaId(Profession.class, row.getProfession()); + ProfessionDAO professionDAO = WaoDAOHelper.getProfessionDAO(transaction); + WaoContextO.prepareTopiaId(Profession.class, row.getProfession()); rowLog.addChangeProfession(oldProfession, row.getProfession()); professionDAO.update(row.getProfession()); // Save sampleMonth - SampleMonthDAO monthDAO = WaoModelDAOHelper.getSampleMonthDAO(transaction); + SampleMonthDAO monthDAO = WaoDAOHelper.getSampleMonthDAO(transaction); // Delete oldMonths List<SampleMonth> newMonths = row.getSampleMonth(); @@ -181,7 +181,7 @@ } // Create or update months for (SampleMonth month : newMonths) { - boolean monthCreated = WaoContext.prepareTopiaId(SampleMonth.class, month); + boolean monthCreated = WaoContextO.prepareTopiaId(SampleMonth.class, month); String date = dateFormat.format(month.getPeriodDate()); if (monthCreated) { // log create month @@ -200,7 +200,7 @@ // Remove no longer elligibleBoats row.removeNoLongerElligibleBoats(boats); // Save new elligibleBoats - ElligibleBoatDAO dao = WaoModelDAOHelper.getElligibleBoatDAO(transaction); + ElligibleBoatDAO dao = WaoDAOHelper.getElligibleBoatDAO(transaction); for (Boat boat : boats) { if (!row.hasElligibleBoat(boat)) { ElligibleBoat elligibleBoat = dao.create(); @@ -220,7 +220,7 @@ List<FishingZone> newZones = row.getFishingZone(); for (FishingZone oldZone : oldZones) { if (!newZones.contains(oldZone)) { - updateFishingZones(transaction, oldZone.getTopiaId(), row, true); +// updateFishingZones(transaction, oldZone.getTopiaId(), row, true); rowLog.addChange("La zone de pêche " + oldZone.getCode() + " a été dissociée de la ligne"); } } @@ -228,13 +228,13 @@ // ConcurrentModificationException ???? for (FishingZone zone : new ArrayList<FishingZone>(newZones)) { if (!oldZones.contains(zone)) { - updateFishingZones(transaction, zone.getTopiaId(), row, false); +// updateFishingZones(transaction, zone.getTopiaId(), row, false); rowLog.addChange("La zone de pêche " + zone.getCode() + " a été associée à la ligne"); } } // Save sampleRow : create or update - SampleRowDAO rowDAO = WaoModelDAOHelper.getSampleRowDAO(transaction); + SampleRowDAO rowDAO = WaoDAOHelper.getSampleRowDAO(transaction); if (log.isDebugEnabled()) { log.debug("update row : " + row); } @@ -255,7 +255,7 @@ } //transaction.closeContext(); } catch (Exception eee) { - WaoContext.serviceException(transaction, + WaoContextO.serviceException(transaction, "Impossible de sauvegarder la ligne d'échantillon", eee); } finally { try { @@ -263,22 +263,22 @@ } catch (TopiaException eee) { log.error("Error closing transaction", eee); } - WaoContext.closeTransaction(transaction); + WaoContextO.closeTransaction(transaction); } } - protected void updateFishingZones(TopiaContext transaction, String zoneId, SampleRow row, boolean delete) throws TopiaException { - // FIXME find a way to avoid saving links from FishingZone instead of SampleRow : - // variable inverse="true" in hibernate mapping of FishingZone, how to set this variable to SampleRow instead - FishingZoneDAO fishingZoneDAO = WaoModelDAOHelper.getFishingZoneDAO(transaction); - FishingZone zoneFromDB = fishingZoneDAO.findByTopiaId(zoneId); - if (delete) { - zoneFromDB.removeSampleRow(row); - } else { - zoneFromDB.addSampleRow(row); - } - fishingZoneDAO.update(zoneFromDB); - } +// protected void updateFishingZones(TopiaContext transaction, String zoneId, SampleRow row, boolean delete) throws TopiaException { +// // FIXME find a way to avoid saving links from FishingZone instead of SampleRow : +// // variable inverse="true" in hibernate mapping of FishingZone, how to set this variable to SampleRow instead +// FishingZoneDAO fishingZoneDAO = WaoDAOHelper.getFishingZoneDAO(transaction); +// FishingZone zoneFromDB = fishingZoneDAO.findByTopiaId(zoneId); +// if (delete) { +// zoneFromDB.removeSampleRow(row); +// } else { +// zoneFromDB.addSampleRow(row); +// } +// fishingZoneDAO.update(zoneFromDB); +// } // @Override // public List<SampleRowLog> getSampleRowLogs(SampleRow sampleRow) throws WaoException { @@ -287,7 +287,7 @@ // try { // transaction = rootContext.beginTransaction(); // -// SampleRowLogDAO dao = WaoModelDAOHelper.getSampleRowLogDAO(transaction); +// SampleRowLogDAO dao = WaoDAOHelper.getSampleRowLogDAO(transaction); // results = dao.createQuery().add(SampleRowLog.SAMPLE_ROW, sampleRow).addOrderDesc(TopiaEntity.TOPIA_CREATE_DATE).executeToEntityList(); // // transaction.closeContext(); @@ -299,7 +299,7 @@ // } @Override - public FacadeRow getSampleRowsOrderedByFishingZone(PeriodDates period, Company company) throws WaoException { + public FacadeRow getSampleRowsOrderedByFishingZone(PeriodDates period, Company company) throws WaoExceptionO { TopiaContext transaction = null; FacadeRow result = new FacadeRowImpl(); try { @@ -312,7 +312,7 @@ } transaction = rootContext.beginTransaction(); - SampleRowDAO dao = WaoModelDAOHelper.getSampleRowDAO(transaction); + SampleRowDAO dao = WaoDAOHelper.getSampleRowDAO(transaction); TopiaQuery query = dao.createQuery("S").addDistinct(). addFrom(FishingZone.class.getName() + " F"). @@ -362,16 +362,16 @@ //transaction.closeContext(); } catch (Exception eee) { - WaoContext.serviceException(transaction, + WaoContextO.serviceException(transaction, "Impossible de récupérer la liste des lignes du plan d'échantillonnage", eee); } finally { - WaoContext.closeTransaction(transaction); + WaoContextO.closeTransaction(transaction); } return result; } @Override - public List<String> getPrograms(Company company) throws WaoException { + public List<String> getPrograms(Company company) throws WaoExceptionO { TopiaContext transaction = null; List<String> results = new ArrayList<String>(); try { @@ -381,7 +381,7 @@ } transaction = rootContext.beginTransaction(); - SampleRowDAO dao = WaoModelDAOHelper.getSampleRowDAO(transaction); + SampleRowDAO dao = WaoDAOHelper.getSampleRowDAO(transaction); TopiaQuery query = dao.createQuery(); if (company != null) { @@ -399,16 +399,16 @@ //transaction.closeContext(); } catch (Exception eee) { - WaoContext.serviceException(transaction, + WaoContextO.serviceException(transaction, "Impossible de charger la liste des programmes", eee); } finally { - WaoContext.closeTransaction(transaction); + WaoContextO.closeTransaction(transaction); } return results; } @Override - public List<SampleRow> getSampleRowsByFilter(SamplingFilter filter) throws WaoException { + public List<SampleRow> getSampleRowsByFilter(SamplingFilter filter) throws WaoExceptionO { TopiaContext transaction = null; List<SampleRow> results = new ArrayList<SampleRow>(); try { @@ -418,7 +418,7 @@ } transaction = rootContext.beginTransaction(); - SampleRowDAO dao = WaoModelDAOHelper.getSampleRowDAO(transaction); + SampleRowDAO dao = WaoDAOHelper.getSampleRowDAO(transaction); TopiaQuery query = dao.createQuery("S").addDistinct().addOrder("S." + SampleRow.CODE); @@ -448,16 +448,16 @@ //transaction.closeContext(); } catch (Exception eee) { - WaoContext.serviceException(transaction, + WaoContextO.serviceException(transaction, "Impossible de récupérer la liste des lignes du plan d'échantillonnage", eee); } finally { - WaoContext.closeTransaction(transaction); + WaoContextO.closeTransaction(transaction); } return results; } @Override - public SampleRow getSampleRow(String sampleRowId) throws WaoException { + public SampleRow getSampleRow(String sampleRowId) throws WaoExceptionO { TopiaContext transaction = null; SampleRow result = null; try { @@ -467,7 +467,7 @@ } transaction = rootContext.beginTransaction(); - SampleRowDAO dao = WaoModelDAOHelper.getSampleRowDAO(transaction); + SampleRowDAO dao = WaoDAOHelper.getSampleRowDAO(transaction); result = dao.findByTopiaId(sampleRowId); @@ -483,19 +483,19 @@ //transaction.closeContext(); } catch (Exception eee) { - WaoContext.serviceException(transaction, + WaoContextO.serviceException(transaction, "Impossible de charger la ligne d'échantillon ayant pour" + " identifiant : " + sampleRowId, eee); } finally { - WaoContext.closeTransaction(transaction); + WaoContextO.closeTransaction(transaction); } return result; } @Override public SampleRow getSampleRowByCode(WaoUser user, String sampleRowCode) - throws WaoException { + throws WaoExceptionO { TopiaContext transaction = null; SampleRow result = null; try { @@ -509,7 +509,7 @@ } transaction = rootContext.beginTransaction(); - SampleRowDAO dao = WaoModelDAOHelper.getSampleRowDAO(transaction); + SampleRowDAO dao = WaoDAOHelper.getSampleRowDAO(transaction); TopiaQuery query = dao.createQuery(). add(SampleRow.CODE, sampleRowCode); @@ -535,18 +535,18 @@ } } catch (Exception eee) { - WaoContext.serviceException(transaction, + WaoContextO.serviceException(transaction, "Impossible de charger la ligne " + "d'échantillon ayant pour code : " + sampleRowCode, eee); } finally { - WaoContext.closeTransaction(transaction); + WaoContextO.closeTransaction(transaction); } return result; } @Override - public void deleteSampleRow(SampleRow sampleRow) throws WaoException { + public void deleteSampleRow(SampleRow sampleRow) throws WaoExceptionO { TopiaContext transaction = null; try { long startTime = 0; @@ -555,7 +555,7 @@ } transaction = rootContext.beginTransaction(); - SampleRowDAO dao = WaoModelDAOHelper.getSampleRowDAO(transaction); + SampleRowDAO dao = WaoDAOHelper.getSampleRowDAO(transaction); SampleRow row = dao.findByTopiaId(sampleRow.getTopiaId()); @@ -571,16 +571,16 @@ } //transaction.closeContext(); } catch (Exception eee) { - WaoContext.serviceException(transaction, + WaoContextO.serviceException(transaction, "Impossible de supprimer la ligne d'échantillon : " + sampleRow.getCode(), eee); } finally { - WaoContext.closeTransaction(transaction); + WaoContextO.closeTransaction(transaction); } } @Override - public String getNewSampleRowCode(Date beginDate) throws WaoException { + public String getNewSampleRowCode(Date beginDate) throws WaoExceptionO { TopiaContext transaction = null; String result = null; if (beginDate == null) { @@ -597,7 +597,7 @@ begin.setTime(beginDate); int year = begin.get(Calendar.YEAR); - SampleRowDAO dao = WaoModelDAOHelper.getSampleRowDAO(transaction); + SampleRowDAO dao = WaoDAOHelper.getSampleRowDAO(transaction); TopiaQuery query = dao.createQuery().add(SampleRow.CODE, Op.LIKE, year + "_%"); String maxCode = query.executeToString("MAX(" + SampleRow.CODE + ")"); @@ -623,11 +623,11 @@ //transaction.closeContext(); } catch (Exception eee) { - WaoContext.serviceException(transaction, + WaoContextO.serviceException(transaction, "Impossible de récupérer un nouveau code pour une ligne d'échantillonnage", eee); } finally { - WaoContext.closeTransaction(transaction); + WaoContextO.closeTransaction(transaction); } return result; } @@ -690,7 +690,7 @@ } @Override - public InputStream exportSamplingPlanCsv(WaoUser user, PeriodDates period) throws WaoException { + public InputStream exportSamplingPlanCsv(WaoUser user, PeriodDates period) throws WaoExceptionO { TopiaContext transaction = null; InputStream result = null; CsvWriter writer = null; @@ -701,7 +701,7 @@ file.deleteOnExit(); FileOutputStream output = new FileOutputStream(file); - writer = new CsvWriter(output, ',', WaoContext.getCsvCharset()); + writer = new CsvWriter(output, ',', WaoContextO.getCsvCharset()); // Get min and max dates to have the biggest period // Date min = (Date)query.executeToObject("MIN(S." + SampleRow.PERIOD_BEGIN + ")"); @@ -717,7 +717,7 @@ // Get sampleRows from database filtered by company if needed // (only for user) and period - SampleRowDAO dao = WaoModelDAOHelper.getSampleRowDAO(transaction); + SampleRowDAO dao = WaoDAOHelper.getSampleRowDAO(transaction); TopiaQuery query = dao.createQuery("S"); if (!user.isAdmin()) { @@ -810,7 +810,7 @@ } catch (Exception eee) { DateFormat dateFormat = SAMPLING.getDateFormat(); - WaoContext.serviceException(transaction, + WaoContextO.serviceException(transaction, "Impossible d'exporter le plan d'échantillonnage sur la période du " + dateFormat.format(period.getFromDate()) + " au " + dateFormat.format(period.getThruDate()), eee); @@ -818,13 +818,13 @@ if (writer != null) { writer.close(); } - WaoContext.closeTransaction(transaction); + WaoContextO.closeTransaction(transaction); } return result; } @Override - public ImportResults importSamplingPlanCsv(InputStream input) throws WaoException { + public ImportResults importSamplingPlanCsv(InputStream input) throws WaoExceptionO { TopiaContext transaction = null; ImportResults result = new ImportResultsImpl(); //int[] result = new int[3]; @@ -833,10 +833,10 @@ try { transaction = rootContext.beginTransaction(); - CsvReader reader = new CsvReader(input, WaoContext.getCsvCharset()); + CsvReader reader = new CsvReader(input, WaoContextO.getCsvCharset()); reader.readHeaders(); - SampleRowDAO dao = WaoModelDAOHelper.getSampleRowDAO(transaction); + SampleRowDAO dao = WaoDAOHelper.getSampleRowDAO(transaction); //int nbImported = 0; //int nbRefused = 0; @@ -874,7 +874,7 @@ // Create link with company if set in file if (!StringUtils.isEmpty(companyName)) { - CompanyDAO companyDAO = WaoModelDAOHelper.getCompanyDAO(transaction); + CompanyDAO companyDAO = WaoDAOHelper.getCompanyDAO(transaction); Company company = companyDAO.findByName(companyName); if (company == null) { throw new WaoBusinessException(Type.IMPORT_ERROR, this.getClass(), @@ -902,19 +902,19 @@ //transaction.closeContext(); } catch (NumberFormatException eee) { - WaoContext.serviceException(transaction, + WaoContextO.serviceException(transaction, "Erreur à la ligne " + currRow + " [CODE = " + row.getCode() + "] : " + "Le format de la durée moyenne des marées est incorrect, il doit être de la forme : 1.9 ", eee); } catch (ParseException eee) { - WaoContext.serviceException(transaction, + WaoContextO.serviceException(transaction, "Erreur à la ligne " + currRow + " [CODE = " + row.getCode() + "] : " + "Le format des dates est incorrect, il doit être de la forme : MM/AAAA", eee); } catch (Exception eee) { - WaoContext.serviceException(transaction, + WaoContextO.serviceException(transaction, "Erreur à la ligne " + currRow + " [CODE = " + row.getCode() + "]", eee); } finally { - WaoContext.closeTransaction(transaction); + WaoContextO.closeTransaction(transaction); } return result; } @@ -940,7 +940,7 @@ String libelle = ImportHelper.read(reader, SAMPLING.METIER_LIBELLE); String especes = ImportHelper.read(reader, SAMPLING.METIER_ESPECES); - ProfessionDAO dao = WaoModelDAOHelper.getProfessionDAO(transaction); + ProfessionDAO dao = WaoDAOHelper.getProfessionDAO(transaction); // Map<String, Object> existParams = new HashMap<String, Object>(); // existParams.put(Profession.CODE_DCF5, codeDCF5); // existParams.put(Profession.MESH_SIZE, maillage); @@ -979,9 +979,9 @@ * @throws WaoException if a FishingZone doesn't exist. */ protected void importFishingZones(TopiaContext transaction, String districts, int currRow, SampleRow row) - throws TopiaException, WaoException { + throws TopiaException, WaoExceptionO { - FishingZoneDAO dao = WaoModelDAOHelper.getFishingZoneDAO(transaction); + FishingZoneDAO dao = WaoDAOHelper.getFishingZoneDAO(transaction); List<String> districtList = new ArrayList<String>(Arrays.asList(districts.split(FISHING_ZONE.getDistrictCodeSeparator()))); @@ -1083,7 +1083,7 @@ if (monthValue != null && DateUtils.between(monthDate, sampleRow.getPeriodBegin(), sampleRow.getPeriodEnd())) { SampleMonthDAO dao = - WaoModelDAOHelper.getSampleMonthDAO(transaction); + WaoDAOHelper.getSampleMonthDAO(transaction); SampleMonth month = sampleRow.getSampleMonth(monthDate); 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 13:27:59 UTC (rev 401) +++ trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceSynthesisImpl.java 2010-04-01 13:28:03 UTC (rev 402) @@ -21,9 +21,9 @@ package fr.ifremer.wao.service; -import fr.ifremer.wao.WaoContext; -import fr.ifremer.wao.WaoException; -import fr.ifremer.wao.WaoModelDAOHelper; +import fr.ifremer.wao.WaoContextO; +import fr.ifremer.wao.WaoExceptionO; +import fr.ifremer.wao.WaoDAOHelper; import fr.ifremer.wao.bean.ContactAverageReactivityImpl; import fr.ifremer.wao.bean.ContactAverageReactivity; import fr.ifremer.wao.bean.BoardingResult; @@ -78,12 +78,12 @@ protected TopiaContext rootContext; - public ServiceSynthesisImpl() throws WaoException { - rootContext = WaoContext.getTopiaRootContext(); + public ServiceSynthesisImpl() throws WaoExceptionO { + rootContext = WaoContextO.getTopiaRootContext(); } @Override - public List<SortedMap<Date, Integer>> getDataSampling(SamplingFilter filter) throws WaoException { + public List<SortedMap<Date, Integer>> getDataSampling(SamplingFilter filter) throws WaoExceptionO { TopiaContext transaction = null; List<SortedMap<Date, Integer>> results = new ArrayList<SortedMap<Date, Integer>>(); try { @@ -112,7 +112,7 @@ serie2.put(month, 0); } - SampleMonthDAO dao = WaoModelDAOHelper.getSampleMonthDAO(transaction); + SampleMonthDAO dao = WaoDAOHelper.getSampleMonthDAO(transaction); String periodDate = "M." + SampleMonth.PERIOD_DATE; TopiaQuery query = dao.createQuery("M"). setSelect(periodDate). @@ -151,10 +151,10 @@ //transaction.closeContext(); } catch (Exception eee) { - WaoContext.serviceException(transaction, + WaoContextO.serviceException(transaction, "Impossible de récupérer les données pour le graphique dynamique des efforts de marées", eee); } finally { - WaoContext.closeTransaction(transaction); + WaoContextO.closeTransaction(transaction); } return results; } @@ -175,7 +175,7 @@ */ @Override public BoardingResult getBoardingBoats(Company company, Date fromDate) - throws WaoException { + throws WaoExceptionO { TopiaContext transaction = null; Map<String, Integer> map = new LinkedHashMap<String, Integer>(); BoardingResult result = new BoardingResultImpl(); @@ -199,7 +199,7 @@ map.put(maxBoardingsKey, 0); ContactDAO dao = - WaoModelDAOHelper.getContactDAO(transaction); + WaoDAOHelper.getContactDAO(transaction); // The number of boardings is the number of finished contacts // Use fromDate to filter contacts finished from this date // No need to use boat filter for this method @@ -264,17 +264,17 @@ //transaction.closeContext(); } catch (Exception eee) { - WaoContext.serviceException(transaction, + WaoContextO.serviceException(transaction, "Impossible de récupérer les données pour le graphique " + "dynamique des efforts de marées", eee); } finally { - WaoContext.closeTransaction(transaction); + WaoContextO.closeTransaction(transaction); } return result; } @Override - public Map<String, Double> getNonComplianceBoardingIndicator(Company company) throws WaoException { + public Map<String, Double> getNonComplianceBoardingIndicator(Company company) throws WaoExceptionO { 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 @@ -286,7 +286,7 @@ } transaction = rootContext.beginTransaction(); - ContactDAO dao = WaoModelDAOHelper.getContactDAO(transaction); + ContactDAO dao = WaoDAOHelper.getContactDAO(transaction); // Only for done contacts with no constraint TopiaQuery query = @@ -298,7 +298,7 @@ String companyName = companyProp + "." + Company.NAME; // Only for unfinished sampleRows - Date current = WaoContext.getCurrentDate(); + Date current = WaoContextO.getCurrentDate(); query.add(sampleRow + "." + SampleRow.PERIOD_END, Op.GE, current); if (company != null) { @@ -365,17 +365,17 @@ if (company != null) { msgEnd = " pour la société " + company.getName(); } - WaoContext.serviceException(transaction, + WaoContextO.serviceException(transaction, "Impossible de récupérer l'indicateur de non respect du " + "nombre d'observateurs embarqués" + msgEnd, eee); } finally { - WaoContext.closeTransaction(transaction); + WaoContextO.closeTransaction(transaction); } return results; } @Override - public Collection<ContactStateStatistics> getContactStateStatistics(Company company, PeriodDates period) throws WaoException { + public Collection<ContactStateStatistics> getContactStateStatistics(Company company, PeriodDates period) throws WaoExceptionO { TopiaContext transaction = null; Map<String, ContactStateStatistics> results = new HashMap<String, ContactStateStatistics>(); try { @@ -385,7 +385,7 @@ } transaction = rootContext.beginTransaction(); - ContactDAO dao = WaoModelDAOHelper.getContactDAO(transaction); + ContactDAO dao = WaoDAOHelper.getContactDAO(transaction); // Only for contacts not refused by the program String contact = "C"; @@ -456,17 +456,17 @@ if (company != null) { msgEnd = " pour la société " + company.getName(); } - WaoContext.serviceException(transaction, + WaoContextO.serviceException(transaction, "Impossible de récupérer les statistiques sur les états des " + "contacts " + msgEnd, eee); } finally { - WaoContext.closeTransaction(transaction); + WaoContextO.closeTransaction(transaction); } return results.values(); } @Override - public Collection<ContactAverageReactivity> getContactDataInputDateReactivity(Company company, PeriodDates period) throws WaoException { + public Collection<ContactAverageReactivity> getContactDataInputDateReactivity(Company company, PeriodDates period) throws WaoExceptionO { 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 @@ -479,7 +479,7 @@ } transaction = rootContext.beginTransaction(); - ContactDAO dao = WaoModelDAOHelper.getContactDAO(transaction); + ContactDAO dao = WaoDAOHelper.getContactDAO(transaction); // String contact = "C"; // TopiaQuery query = dao.createQuery(contact); @@ -546,11 +546,11 @@ if (company != null) { msgEnd = " pour la société " + company.getName(); } - WaoContext.serviceException(transaction, + WaoContextO.serviceException(transaction, "Impossible de récupérer l'indicateur de réactivité sur " + "les dates de saisies dans Allegro" + msgEnd, eee); } finally { - WaoContext.closeTransaction(transaction); + WaoContextO.closeTransaction(transaction); } return results.values(); } Modified: trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceUserImpl.java =================================================================== --- trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceUserImpl.java 2010-04-01 13:27:59 UTC (rev 401) +++ trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceUserImpl.java 2010-04-01 13:28:03 UTC (rev 402) @@ -23,9 +23,10 @@ import fr.ifremer.wao.WaoBusinessException; import fr.ifremer.wao.WaoBusinessException.Type; -import fr.ifremer.wao.WaoException; -import fr.ifremer.wao.WaoModelDAOHelper; -import fr.ifremer.wao.WaoContext; +import fr.ifremer.wao.WaoExceptionO; +import fr.ifremer.wao.WaoDAOHelper; +import fr.ifremer.wao.WaoContextO; +import fr.ifremer.wao.WaoProperty; import fr.ifremer.wao.bean.UserRole; import fr.ifremer.wao.entity.Company; import fr.ifremer.wao.entity.CompanyDAO; @@ -61,12 +62,12 @@ protected TopiaContext rootContext; - public ServiceUserImpl() throws WaoException { - rootContext = WaoContext.getTopiaRootContext(); + public ServiceUserImpl() throws WaoExceptionO { + rootContext = WaoContextO.getTopiaRootContext(); } @Override - public WaoUser connect(String login, String password) throws WaoException { + public WaoUser connect(String login, String password) throws WaoExceptionO { TopiaContext transaction = null; WaoUser user = null; try { @@ -76,9 +77,9 @@ } transaction = rootContext.beginTransaction(); - WaoUserDAO dao = WaoModelDAOHelper.getWaoUserDAO(transaction); + WaoUserDAO dao = WaoDAOHelper.getWaoUserDAO(transaction); - String passwordEncoded = WaoContext.encodeString(password); + String passwordEncoded = WaoContextO.encodeString(password); user = dao.findByProperties(WaoUser.LOGIN, login, WaoUser.PASSWORD, passwordEncoded); if (user != null && user.getActive()) { @@ -101,15 +102,15 @@ //transaction.closeContext(); } catch (Exception eee) { - WaoContext.serviceException(transaction, "Une erreur est survenue lors de la demande de connexion", eee); + WaoContextO.serviceException(transaction, "Une erreur est survenue lors de la demande de connexion", eee); } finally { - WaoContext.closeTransaction(transaction); + WaoContextO.closeTransaction(transaction); } return user; } @Override - public void forgetPassword(String login) throws WaoException { + public void forgetPassword(String login) throws WaoExceptionO { TopiaContext transaction = null; try { long startTime = 0; @@ -123,7 +124,7 @@ transaction = rootContext.beginTransaction(); - WaoUserDAO dao = WaoModelDAOHelper.getWaoUserDAO(transaction); + WaoUserDAO dao = WaoDAOHelper.getWaoUserDAO(transaction); WaoUser user = dao.findByLogin(login); if (user == null) { @@ -131,8 +132,8 @@ "L'email '" + login + "' n'est pas référencé dans l'application."); } - String password = WaoContext.createRandomString(8); - String passwordEncoded = WaoContext.encodeString(password); + String password = WaoContextO.createRandomString(8); + String passwordEncoded = WaoContextO.encodeString(password); user.setPassword(passwordEncoded); String subject = "[WAO] Mot de passe oublié"; @@ -140,11 +141,11 @@ "\tUn nouveau mot de passe a été généré pour votre identifiant " + login + " :\n" + "\t\t * mot de passe = " + password + "\n\n" + "Vous pouvez modifier votre password en accédant à la page de gestion de votre profile utilisateur :\n\n" + - "\t\thttp://" + WaoContext.getProperty(WaoContext.PROP_SERVER) + "\n\n" + + "\t\thttp://" + WaoProperty.SERVER_PATH.getValue() + "\n\n" + "Cordialement,\n\n" + "L'Equipe WAO"; - WaoContext.sendEmail(user.getLogin(), subject, msg); + WaoContextO.sendEmail(user.getLogin(), subject, msg); if (log.isDebugEnabled()) { log.debug("send email to : " + user.getLogin()); } @@ -159,14 +160,14 @@ } //transaction.closeContext(); } catch (Exception eee) { - WaoContext.serviceException(transaction, "Impossible de créer ou de mettre à jour l'utilisateur", eee); + WaoContextO.serviceException(transaction, "Impossible de créer ou de mettre à jour l'utilisateur", eee); } finally { - WaoContext.closeTransaction(transaction); + WaoContextO.closeTransaction(transaction); } } @Override - public void createUpdateUser(WaoUser user, boolean generatePassword) throws WaoException { + public void createUpdateUser(WaoUser user, boolean generatePassword) throws WaoExceptionO { TopiaContext transaction = null; try { long startTime = 0; @@ -179,9 +180,9 @@ transaction = rootContext.beginTransaction(); - WaoUserDAO dao = WaoModelDAOHelper.getWaoUserDAO(transaction); + WaoUserDAO dao = WaoDAOHelper.getWaoUserDAO(transaction); - boolean newUser = WaoContext.prepareTopiaId(WaoUser.class, user); + boolean newUser = WaoContextO.prepareTopiaId(WaoUser.class, user); // Check for a new user if login already exists if (newUser) { @@ -195,7 +196,7 @@ String password = user.getPassword(); if (generatePassword) { - password = WaoContext.createRandomString(8); + password = WaoContextO.createRandomString(8); user.setPasswordChanged(true); // if (log.isDebugEnabled()) { // log.debug("show generated password : " + password); @@ -203,7 +204,7 @@ } // For a password set manually by user or generated if (user.isPasswordChanged()) { - String passwordEncoded = WaoContext.encodeString(password); + String passwordEncoded = WaoContextO.encodeString(password); user.setPassword(passwordEncoded); } @@ -220,7 +221,7 @@ "\t\t * identifiant = " + user.getLogin() + "\n" + "\t\t * mot de passe = " + password + "\n\n" + "Vous pouvez modifier votre mot de passe en accédant à la page de gestion de votre profil utilisateur:\n\n" + - "\t\thttp://" + WaoContext.getProperty(WaoContext.PROP_SERVER) + "\n\n"; + "\t\thttp://" + WaoProperty.SERVER_PATH.getValue() + "\n\n"; } else { subject += "Modification de votre compte"; if (generatePassword) { @@ -235,7 +236,7 @@ msg += "Cordialement,\n\n" + "L'Equipe WAO"; - WaoContext.sendEmail(user.getLogin(), subject, msg); + WaoContextO.sendEmail(user.getLogin(), subject, msg); // if (log.isDebugEnabled()) { // log.debug("send email to : " + user.getLogin()); // } @@ -251,14 +252,14 @@ } //transaction.closeContext(); } catch (Exception eee) { - WaoContext.serviceException(transaction, "Impossible de créer ou de mettre à jour l'utilisateur", eee); + WaoContextO.serviceException(transaction, "Impossible de créer ou de mettre à jour l'utilisateur", eee); } finally { - WaoContext.closeTransaction(transaction); + WaoContextO.closeTransaction(transaction); } } @Override - public void deleteUser(WaoUser user) throws WaoException { + public void deleteUser(WaoUser user) throws WaoExceptionO { TopiaContext transaction = null; try { long startTime = 0; @@ -279,7 +280,7 @@ if (user.isAdmin() || isCoordinator) { SampleRowLogDAO logDAO = - WaoModelDAOHelper.getSampleRowLogDAO(transaction); + WaoDAOHelper.getSampleRowLogDAO(transaction); List<SampleRowLog> results = logDAO.findAllByAuthor(user); if (!results.isEmpty()) { @@ -297,7 +298,7 @@ } else { ContactDAO contactDAO = - WaoModelDAOHelper.getContactDAO(transaction); + WaoDAOHelper.getContactDAO(transaction); List<Contact> results = contactDAO.findAllByObserver(user); if (!results.isEmpty()) { @@ -309,7 +310,7 @@ } - WaoUserDAO dao = WaoModelDAOHelper.getWaoUserDAO(transaction); + WaoUserDAO dao = WaoDAOHelper.getWaoUserDAO(transaction); dao.delete(user); @@ -323,15 +324,15 @@ } //transaction.closeContext(); } catch (Exception eee) { - WaoContext.serviceException(transaction, "Impossible de créer ou" + + WaoContextO.serviceException(transaction, "Impossible de créer ou" + " de mettre à jour l'utilisateur", eee); } finally { - WaoContext.closeTransaction(transaction); + WaoContextO.closeTransaction(transaction); } } @Override - public void createUpdateCompany(Company company) throws WaoException { + public void createUpdateCompany(Company company) throws WaoExceptionO { TopiaContext transaction = null; try { long startTime = 0; @@ -344,9 +345,9 @@ transaction = rootContext.beginTransaction(); - CompanyDAO dao = WaoModelDAOHelper.getCompanyDAO(transaction); + CompanyDAO dao = WaoDAOHelper.getCompanyDAO(transaction); - WaoContext.prepareTopiaId(Company.class, company); + WaoContextO.prepareTopiaId(Company.class, company); dao.update(company); transaction.commitTransaction(); @@ -359,14 +360,14 @@ } //transaction.closeContext(); } catch (Exception eee) { - WaoContext.serviceException(transaction, "Impossible de créer ou de mettre à jour la société", eee); + WaoContextO.serviceException(transaction, "Impossible de créer ou de mettre à jour la société", eee); } finally { - WaoContext.closeTransaction(transaction); + WaoContextO.closeTransaction(transaction); } } @Override - public List<Company> getCompanies(boolean activeOnly) throws WaoException { + public List<Company> getCompanies(boolean activeOnly) throws WaoExceptionO { TopiaContext transaction = null; List<Company> results = new ArrayList<Company>(); try { @@ -376,7 +377,7 @@ } transaction = rootContext.beginTransaction(); - CompanyDAO dao = WaoModelDAOHelper.getCompanyDAO(transaction); + CompanyDAO dao = WaoDAOHelper.getCompanyDAO(transaction); if (activeOnly) { results = dao.findAllByActive(activeOnly); @@ -391,15 +392,15 @@ stopTime - startTime)); } } catch (Exception eee) { - WaoContext.serviceException(transaction, "Impossible de récupérer la liste des sociétés", eee); + WaoContextO.serviceException(transaction, "Impossible de récupérer la liste des sociétés", eee); } finally { - WaoContext.closeTransaction(transaction); + WaoContextO.closeTransaction(transaction); } return results; } @Override - public List<WaoUser> getUsersByCompany(Company company) throws WaoException { + public List<WaoUser> getUsersByCompany(Company company) throws WaoExceptionO { TopiaContext transaction = null; List<WaoUser> results = new ArrayList<WaoUser>(); try { @@ -409,7 +410,7 @@ } transaction = rootContext.beginTransaction(); - WaoUserDAO dao = WaoModelDAOHelper.getWaoUserDAO(transaction); + WaoUserDAO dao = WaoDAOHelper.getWaoUserDAO(transaction); TopiaQuery query = dao.createQuery(). @@ -425,17 +426,17 @@ stopTime - startTime)); } } catch (Exception eee) { - WaoContext.serviceException(transaction, "Impossible de récupérer " + + WaoContextO.serviceException(transaction, "Impossible de récupérer " + "la liste des utilisateurs de la société " + company.getName(), eee); } finally { - WaoContext.closeTransaction(transaction); + WaoContextO.closeTransaction(transaction); } return results; } @Override - public List<WaoUser> getObservers(boolean activeOnly) throws WaoException { + public List<WaoUser> getObservers(boolean activeOnly) throws WaoExceptionO { TopiaContext transaction = null; List<WaoUser> results = new ArrayList<WaoUser>(); try { @@ -445,7 +446,7 @@ } transaction = rootContext.beginTransaction(); - WaoUserDAO dao = WaoModelDAOHelper.getWaoUserDAO(transaction); + WaoUserDAO dao = WaoDAOHelper.getWaoUserDAO(transaction); TopiaQuery query = dao.createQuery(). add(WaoUser.ROLE, UserRole.OBSERVER.ordinal(), UserRole.COORDINATOR.ordinal()); @@ -463,9 +464,9 @@ stopTime - startTime)); } } catch (Exception eee) { - WaoContext.serviceException(transaction, "Impossible de récupérer la liste des observateurs", eee); + WaoContextO.serviceException(transaction, "Impossible de récupérer la liste des observateurs", eee); } finally { - WaoContext.closeTransaction(transaction); + WaoContextO.closeTransaction(transaction); } return results; } Added: trunk/wao-business/src/main/resources/i18n/wao-business-en_GB.properties =================================================================== --- trunk/wao-business/src/main/resources/i18n/wao-business-en_GB.properties (rev 0) +++ trunk/wao-business/src/main/resources/i18n/wao-business-en_GB.properties 2010-04-01 13:28:03 UTC (rev 402) @@ -0,0 +1,26 @@ +wao.error.context.close= +wao.error.context.getRootContext= +wao.error.context.parse= +wao.error.context.rollback= +wao.error.context.start= +wao.error.context.stop= +wao.error.serviceBoat.createUpdateCompanyBoatInfos= +wao.error.serviceBoat.exportBoatCsv= +wao.error.serviceBoat.getActivityCalendarLogAccessFile= +wao.error.serviceBoat.getActivityCalendarLogFile= +wao.error.serviceBoat.getBoat= +wao.error.serviceBoat.getBoatNamesStartWith= +wao.error.serviceBoat.getBoatsByFilter= +wao.error.serviceBoat.getBoatsByImmatriculations= +wao.error.serviceBoat.getCompanyBoatInfos= +wao.error.serviceBoat.getLastActivityCalendar= +wao.error.serviceBoat.getNbBoatsByFilter= +wao.error.serviceBoat.importActivityCalendarCsv= +wao.error.serviceBoat.importBoatCsv= +wao.error.serviceNews.getNews= +wao.error.serviceNews.saveNews= +wao.error.serviceReferential.getFacades= +wao.error.serviceReferential.getFishingZones= +wao.error.serviceReferential.getProfessions= +wao.error.serviceReferential.getSectors= +wao.error.serviceReferential.importFishingZoneCsv= Added: trunk/wao-business/src/main/resources/i18n/wao-business-fr_FR.properties =================================================================== --- trunk/wao-business/src/main/resources/i18n/wao-business-fr_FR.properties (rev 0) +++ trunk/wao-business/src/main/resources/i18n/wao-business-fr_FR.properties 2010-04-01 13:28:03 UTC (rev 402) @@ -0,0 +1,26 @@ +wao.error.context.close= +wao.error.context.getRootContext= +wao.error.context.parse= +wao.error.context.rollback= +wao.error.context.start= +wao.error.context.stop= +wao.error.serviceBoat.createUpdateCompanyBoatInfos= +wao.error.serviceBoat.exportBoatCsv= +wao.error.serviceBoat.getActivityCalendarLogAccessFile= +wao.error.serviceBoat.getActivityCalendarLogFile= +wao.error.serviceBoat.getBoat= +wao.error.serviceBoat.getBoatNamesStartWith= +wao.error.serviceBoat.getBoatsByFilter= +wao.error.serviceBoat.getBoatsByImmatriculations= +wao.error.serviceBoat.getCompanyBoatInfos= +wao.error.serviceBoat.getLastActivityCalendar= +wao.error.serviceBoat.getNbBoatsByFilter= +wao.error.serviceBoat.importActivityCalendarCsv= +wao.error.serviceBoat.importBoatCsv= +wao.error.serviceNews.getNews= +wao.error.serviceNews.saveNews= +wao.error.serviceReferential.getFacades= +wao.error.serviceReferential.getFishingZones= +wao.error.serviceReferential.getProfessions= +wao.error.serviceReferential.getSectors= +wao.error.serviceReferential.importFishingZoneCsv= Added: trunk/wao-business/src/main/resources/oldmappings/Wao/1.1/fr/ifremer/wao/entity/ActivityCalendarImpl.hbm.xml =================================================================== --- trunk/wao-business/src/main/resources/oldmappings/Wao/1.1/fr/ifremer/wao/entity/ActivityCalendarImpl.hbm.xml (rev 0) +++ trunk/wao-business/src/main/resources/oldmappings/Wao/1.1/fr/ifremer/wao/entity/ActivityCalendarImpl.hbm.xml 2010-04-01 13:28:03 UTC (rev 402) @@ -0,0 +1,16 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> +<hibernate-mapping default-access="field" auto-import="true" package="fr.ifremer.wao.entity"> + <class name="fr.ifremer.wao.entity.ActivityCalendarImpl" table="activityCalendar" node="fr.ifremer.wao.entity.ActivityCalendarImpl" abstract="false" proxy="fr.ifremer.wao.entity.ActivityCalendar" > + <id name="topiaId" type="string" length="255" node="@topiaId"/> + <version name="topiaVersion" type="long" node="@topiaVersion"/> + <property name="topiaCreateDate" type="timestamp" node="@topiaCreateDate"/> + <property name="year" type="int" access="field" column="year" node="year"/> + <property name="fiability" type="int" access="field" column="fiability" node="fiability"/> + <bag name="activityMonth" inverse="true" order-by="month" lazy="true" cascade="all,delete-orphan" node="activityMonth" embed-xml="false"> + <key column="activityCalendar"/> + <one-to-many class="fr.ifremer.wao.entity.ActivityMonthImpl" node="topiaId" embed-xml="false"/> + </bag> + <many-to-one name="boat" class="fr.ifremer.wao.entity.BoatImpl" column="boat" node="boat/@topiaId" embed-xml="false"/> + </class> +</hibernate-mapping> Added: trunk/wao-business/src/main/resources/oldmappings/Wao/1.1/fr/ifremer/wao/entity/ActivityMonthImpl.hbm.xml =================================================================== --- trunk/wao-business/src/main/resources/oldmappings/Wao/1.1/fr/ifremer/wao/entity/ActivityMonthImpl.hbm.xml (rev 0) +++ trunk/wao-business/src/main/resources/oldmappings/Wao/1.1/fr/ifremer/wao/entity/ActivityMonthImpl.hbm.xml 2010-04-01 13:28:03 UTC (rev 402) @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> +<hibernate-mapping default-access="field" auto-import="true" package="fr.ifremer.wao.entity"> + <class name="fr.ifremer.wao.entity.ActivityMonthImpl" table="activityMonth" node="fr.ifremer.wao.entity.ActivityMonthImpl" abstract="false" proxy="fr.ifremer.wao.entity.ActivityMonth" > + <id name="topiaId" type="string" length="255" node="@topiaId"/> + <version name="topiaVersion" type="long" node="@topiaVersion"/> + <property name="topiaCreateDate" type="timestamp" node="@topiaCreateDate"/> + <property name="harbourLibelle" type="text" access="field" column="harbourLibelle" node="harbourLibelle"/> + <property name="active" type="boolean" access="field" column="active" node="active"/> + <property name="nbBoardingPersons" type="java.lang.Integer" access="field" column="nbBoardingPersons" node="nbBoardingPersons"/> + <property name="nbSeaDays" type="java.lang.Integer" access="field" column="nbSeaDays" node="nbSeaDays"/> + <property name="nbFishingDays" type="java.lang.Integer" access="field" column="nbFishingDays" node="nbFishingDays"/> + <property name="month" type="int" access="field" column="month" node="month"/> + <property name="harbourCode" type="text" access="field" column="harbourCode" node="harbourCode"/> + <property name="harbourId" type="int" access="field" column="harbourId" node="harbourId"/> + <bag name="activityProfession" inverse="true" order-by="professionOrder" lazy="true" cascade="all,delete-orphan" node="activityProfession" embed-xml="false"> + <key column="activityMonth"/> + <one-to-many class="fr.ifremer.wao.entity.ActivityProfessionImpl" node="topiaId" embed-xml="false"/> + </bag> + <many-to-one name="activityCalendar" class="fr.ifremer.wao.entity.ActivityCalendarImpl" column="activityCalendar" node="activityCalendar/@topiaId" embed-xml="false"/> + </class> +</hibernate-mapping> Added: trunk/wao-business/src/main/resources/oldmappings/Wao/1.1/fr/ifremer/wao/entity/ActivityProfessionImpl.hbm.xml =================================================================== --- trunk/wao-business/src/main/resources/oldmappings/Wao/1.1/fr/ifremer/wao/entity/ActivityProfessionImpl.hbm.xml (rev 0) +++ trunk/wao-business/src/main/resources/oldmappings/Wao/1.1/fr/ifremer/wao/entity/ActivityProfessionImpl.hbm.xml 2010-04-01 13:28:03 UTC (rev 402) @@ -0,0 +1,18 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> +<hibernate-mapping default-access="field" auto-import="true" package="fr.ifremer.wao.entity"> + <class name="fr.ifremer.wao.entity.ActivityProfessionImpl" table="activityProfession" node="fr.ifremer.wao.entity.ActivityProfessionImpl" abstract="false" proxy="fr.ifremer.wao.entity.ActivityProfession" > + <id name="topiaId" type="string" length="255" node="@topiaId"/> + <version name="topiaVersion" type="long" node="@topiaVersion"/> + <property name="topiaCreateDate" type="timestamp" node="@topiaCreateDate"/> + <property name="code" type="text" access="field" column="code" node="code"/> + <property name="libelle" type="text" access="field" column="libelle" node="libelle"/> + <property name="id" type="int" access="field" column="id" node="id"/> + <property name="professionOrder" type="int" access="field" column="professionOrder" node="professionOrder"/> + <many-to-one name="activityMonth" class="fr.ifremer.wao.entity.ActivityMonthImpl" column="activityMonth" node="activityMonth/@topiaId" embed-xml="false"/> + <bag name="activityZone" inverse="true" order-by="zoneId" lazy="true" cascade="all,delete-orphan" node="activityZone" embed-xml="false"> + <key column="activityProfession"/> + <one-to-many class="fr.ifremer.wao.entity.ActivityZoneImpl" node="topiaId" embed-xml="false"/> + </bag> + </class> +</hibernate-mapping> Added: trunk/wao-business/src/main/resources/oldmappings/Wao/1.1/fr/ifremer/wao/entity/ActivityZoneImpl.hbm.xml =================================================================== --- trunk/wao-business/src/main/resources/oldmappings/Wao/1.1/fr/ifremer/wao/entity/ActivityZoneImpl.hbm.xml (rev 0) +++ trunk/wao-business/src/main/resources/oldmappings/Wao/1.1/fr/ifremer/wao/entity/ActivityZoneImpl.hbm.xml 2010-04-01 13:28:03 UTC (rev 402) @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> +<hibernate-mapping default-access="field" auto-import="true" package="fr.ifremer.wao.entity"> + <class name="fr.ifremer.wao.entity.ActivityZoneImpl" table="activityZone" node="fr.ifremer.wao.entity.ActivityZoneImpl" abstract="false" proxy="fr.ifremer.wao.entity.ActivityZone" > + <id name="topiaId" type="string" length="255" node="@topiaId"/> + <version name="topiaVersion" type="long" node="@topiaVersion"/> + <property name="topiaCreateDate" type="timestamp" node="@topiaCreateDate"/> + <property name="zoneCode" type="text" access="field" column="zoneCode" node="zoneCode"/> + <property name="zoneLibelle" type="text" access="field" column="zoneLibelle" node="zoneLibelle"/> + <property name="zoneId" type="int" access="field" column="zoneId" node="zoneId"/> + <property name="gradiantCode" type="int" access="field" column="gradiantCode" node="gradiantCode"/> + <property name="gradiantLibelle" type="text" access="field" column="gradiantLibelle" node="gradiantLibelle"/> + <many-to-one name="activityProfession" class="fr.ifremer.wao.entity.ActivityProfessionImpl" column="activityProfession" node="activityProfession/@topiaId" embed-xml="false"/> + </class> +</hibernate-mapping> Added: trunk/wao-business/src/main/resources/oldmappings/Wao/1.1/fr/ifremer/wao/entity/BoatImpl.hbm.xml =================================================================== --- trunk/wao-business/src/main/resources/oldmappings/Wao/1.1/fr/ifremer/wao/entity/BoatImpl.hbm.xml (rev 0) +++ trunk/wao-business/src/main/resources/oldmappings/Wao/1.1/fr/ifremer/wao/entity/BoatImpl.hbm.xml 2010-04-01 13:28:03 UTC (rev 402) @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> +<hibernate-mapping default-access="field" auto-import="true" package="fr.ifremer.wao.entity"> + <class name="fr.ifremer.wao.entity.BoatImpl" table="boat" node="fr.ifremer.wao.entity.BoatImpl" abstract="false" proxy="fr.ifremer.wao.entity.Boat" > + <id name="topiaId" type="string" length="255" node="@topiaId"/> + <version name="topiaVersion" type="long" node="@topiaVersion"/> + <property name="topiaCreateDate" type="timestamp" node="@topiaCreateDate"/> + <property name="immatriculation" type="int" access="field" column="immatriculation" node="immatriculation" index="boat_immatriculation_idx" unique="true"/> + <property name="name" type="text" access="field" column="name" node="name"/> + <property name="districtCode" type="text" access="field" column="districtCode" node="districtCode"/> + <property name="boatLength" type="int" access="field" column="boatLength" node="boatLength"/> + <property name="buildYear" type="int" access="field" column="buildYear" node="buildYear"/> + <property name="active" type="boolean" access="field" column="active" node="active"/> + <many-to-one name="shipOwner" class="fr.ifremer.wao.entity.ShipOwnerImpl" column="shipOwner" lazy="false" node="shipOwner/@topiaId" embed-xml="false"/> + <bag name="companyBoatInfos" inverse="true" lazy="true" cascade="all,delete-orphan" node="companyBoatInfos" embed-xml="false"> + <key column="boat"/> + <one-to-many class="fr.ifremer.wao.entity.BoatInfosImpl" node="topiaId" embed-xml="false"/> + </bag> + <bag name="activityCalendar" inverse="true" lazy="true" cascade="all,delete-orphan" node="activityCalendar" embed-xml="false"> + <key column="boat"/> + <one-to-many class="fr.ifremer.wao.entity.ActivityCalendarImpl" node="topiaId" embed-xml="false"/> + </bag> + <bag name="elligibleBoat" inverse="true" order-by="companyActive" lazy="true" node="elligibleBoat" embed-xml="false"> + <key column="boat"/> + <one-to-many class="fr.ifremer.wao.entity.ElligibleBoatImpl" node="topiaId" embed-xml="false"/> + </bag> + </class> +</hibernate-mapping> Added: trunk/wao-business/src/main/resources/oldmappings/Wao/1.1/fr/ifremer/wao/entity/BoatInfosImpl.hbm.xml =================================================================== --- trunk/wao-business/src/main/resources/oldmappings/Wao/1.1/fr/ifremer/wao/entity/BoatInfosImpl.hbm.xml (rev 0) +++ trunk/wao-business/src/main/resources/oldmappings/Wao/1.1/fr/ifremer/wao/entity/BoatInfosImpl.hbm.xml 2010-04-01 13:28:03 UTC (rev 402) @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> +<hibernate-mapping default-access="field" auto-import="true" package="fr.ifremer.wao.entity"> + <class name="fr.ifremer.wao.entity.BoatInfosImpl" table="boatInfos" node="fr.ifremer.wao.entity.BoatInfosImpl" abstract="false" proxy="fr.ifremer.wao.entity.BoatInfos" > + <id name="topiaId" type="string" length="255" node="@topiaId"/> + <version name="topiaVersion" type="long" node="@topiaVersion"/> + <property name="topiaCreateDate" type="timestamp" node="@topiaCreateDate"/> + <property name="contactFirstName" type="text" access="field" column="contactFirstName" node="contactFirstName"/> + <property name="contactLastName" type="text" access="field" column="contactLastName" node="contactLastName"/> + <property name="contactEmail" type="text" access="field" column="contactEmail" node="contactEmail"/> + <property name="contactPhoneNumber" type="text" access="field" column="contactPhoneNumber" node="contactPhoneNumber"/> + <property name="dup" type="java.lang.Integer" access="field" column="dup" node="dup"/> + <property name="comment" type="text" access="field" column="comment" node="comment"/> + <many-to-one name="company" class="fr.ifremer.wao.entity.CompanyImpl" column="company" node="company/@topiaId" embed-xml="false" /> + <many-to-one name="boat" class="fr.ifremer.wao.entity.BoatImpl" column="boat" node="boat/@topiaId" embed-xml="false" /> + </class> +</hibernate-mapping> Added: trunk/wao-business/src/main/resources/oldmappings/Wao/1.1/fr/ifremer/wao/entity/CompanyImpl.hbm.xml =================================================================== --- trunk/wao-business/src/main/resources/oldmappings/Wao/1.1/fr/ifremer/wao/entity/CompanyImpl.hbm.xml (rev 0) +++ trunk/wao-business/src/main/resources/oldmappings/Wao/1.1/fr/ifremer/wao/entity/CompanyImpl.hbm.xml 2010-04-01 13:28:03 UTC (rev 402) @@ -0,0 +1,25 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> +<hibernate-mapping default-access="field" auto-import="true" package="fr.ifremer.wao.entity"> + <class name="fr.ifremer.wao.entity.CompanyImpl" table="company" node="fr.ifremer.wao.entity.CompanyImpl" abstract="false" proxy="fr.ifremer.wao.entity.Company" > + <id name="topiaId" type="string" length="255" node="@topiaId"/> + <version name="topiaVersion" type="long" node="@topiaVersion"/> + <property name="topiaCreateDate" type="timestamp" node="@topiaCreateDate"/> + <property name="name" type="text" access="field" column="name" node="name"/> + <property name="phoneNumber" type="text" access="field" column="phoneNumber" node="phoneNumber"/> + <property name="address1" type="text" access="field" column="address1" node="address1"/> + <property name="address2" type="text" access="field" column="address2" node="address2"/> + <property name="active" type="boolean" access="field" column="active" node="active"/> + <property name="email" type="text" access="field" column="email" node="email"/> + <property name="city" type="text" access="field" column="city" node="city"/> + <property name="postalCode" type="int" access="field" column="postalCode" node="postalCode"/> + <bag name="waoUser" inverse="true" lazy="true" cascade="all,delete-orphan" node="waoUser" embed-xml="false"> + <key column="company"/> + <one-to-many class="fr.ifremer.wao.entity.WaoUserImpl" node="topiaId" embed-xml="false"/> + </bag> + <bag name="boatBoatInfos" inverse="true" lazy="true" cascade="all,delete-orphan" node="boatBoatInfos" embed-xml="false"> + <key column="company"/> + <one-to-many class="fr.ifremer.wao.entity.BoatInfosImpl" node="topiaId" embed-xml="false"/> + </bag> + </class> +</hibernate-mapping> Added: trunk/wao-business/src/main/resources/oldmappings/Wao/1.1/fr/ifremer/wao/entity/ContactImpl.hbm.xml =================================================================== --- trunk/wao-business/src/main/resources/oldmappings/Wao/1.1/fr/ifremer/wao/entity/ContactImpl.hbm.xml (rev 0) +++ trunk/wao-business/src/main/resources/oldmappings/Wao/1.1/fr/ifremer/wao/entity/ContactImpl.hbm.xml 2010-04-01 13:28:03 UTC (rev 402) @@ -0,0 +1,23 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> +<hibernate-mapping default-access="field" auto-import="true" package="fr.ifremer.wao.entity"> + <class name="fr.ifremer.wao.entity.ContactImpl" table="contact" node="fr.ifremer.wao.entity.ContactImpl" abstract="false" proxy="fr.ifremer.wao.entity.Contact" > + <id name="topiaId" type="string" length="255" node="@topiaId"/> + <version name="topiaVersion" type="long" node="@topiaVersion"/> + <property name="topiaCreateDate" type="timestamp" node="@topiaCreateDate"/> + <property name="tideBeginDate" type="java.util.Date" access="field" column="tideBeginDate" node="tideBeginDate"/> + <property name="tideEndDate" type="java.util.Date" access="field" column="tideEndDate" node="tideEndDate"/> + <property name="nbObservants" type="int" access="field" column="nbObservants" node="nbObservants"/> + <property name="mammalsObservation" type="boolean" access="field" column="mammalsObservation" node="mammalsObservation"/> + <property name="mammalsCapture" type="boolean" access="field" column="mammalsCapture" node="mammalsCapture"/> + <property name="validationProgram" type="java.lang.Boolean" access="field" column="validationProgram" node="validationProgram"/> + <property name="validationCompany" type="java.lang.Boolean" access="field" column="validationCompany" node="validationCompany"/> + <property name="dataInputDate" type="java.util.Date" access="field" column="dataInputDate" node="dataInputDate"/> + <property name="comment" type="text" access="field" column="comment" node="comment"/> + <property name="state" type="int" access="field" column="state" node="state"/> + <property name="tideNbDays" type="int" access="field" column="tideNbDays" node="tideNbDays"/> + <many-to-one name="observer" class="fr.ifremer.wao.entity.WaoUserImpl" column="observer" node="observer/@topiaId" embed-xml="false"/> + <many-to-one name="sampleRow" class="fr.ifremer.wao.entity.SampleRowImpl" column="sampleRow" lazy="false" node="sampleRow/@topiaId" embed-xml="false"/> + <many-to-one name="boat" class="fr.ifremer.wao.entity.BoatImpl" column="boat" lazy="false" node="boat/@topiaId" embed-xml="false"/> + </class> +</hibernate-mapping> Added: trunk/wao-business/src/main/resources/oldmappings/Wao/1.1/fr/ifremer/wao/entity/ElligibleBoatImpl.hbm.xml =================================================================== --- trunk/wao-business/src/main/resources/oldmappings/Wao/1.1/fr/ifremer/wao/entity/ElligibleBoatImpl.hbm.xml (rev 0) +++ trunk/wao-business/src/main/resources/oldmappings/Wao/1.1/fr/ifremer/wao/entity/ElligibleBoatImpl.hbm.xml 2010-04-01 13:28:03 UTC (rev 402) @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> +<hibernate-mapping default-access="field" auto-import="true" package="fr.ifremer.wao.entity"> + <class name="fr.ifremer.wao.entity.ElligibleBoatImpl" table="elligibleBoat" node="fr.ifremer.wao.entity.ElligibleBoatImpl" abstract="false" proxy="fr.ifremer.wao.entity.ElligibleBoat" > + <id name="topiaId" type="string" length="255" node="@topiaId"/> + <version name="topiaVersion" type="long" node="@topiaVersion"/> + <property name="topiaCreateDate" type="timestamp" node="@topiaCreateDate"/> + <property name="globalActive" type="boolean" access="field" column="globalActive" node="globalActive"/> + <property name="companyActive" type="java.lang.Boolean" access="field" column="companyActive" node="companyActive"/> + <many-to-one name="boat" class="fr.ifremer.wao.entity.BoatImpl" column="boat" lazy="false" node="boat/@topiaId" embed-xml="false"/> + <many-to-one name="sampleRow" class="fr.ifremer.wao.entity.SampleRowImpl" column="sampleRow" node="sampleRow/@topiaId" embed-xml="false"/> + </class> +</hibernate-mapping> Added: trunk/wao-business/src/main/resources/oldmappings/Wao/1.1/fr/ifremer/wao/entity/FishingZoneImpl.hbm.xml =================================================================== --- trunk/wao-business/src/main/resources/oldmappings/Wao/1.1/fr/ifremer/wao/entity/FishingZoneImpl.hbm.xml (rev 0) +++ trunk/wao-business/src/main/resources/oldmappings/Wao/1.1/fr/ifremer/wao/entity/FishingZoneImpl.hbm.xml 2010-04-01 13:28:03 UTC (rev 402) @@ -0,0 +1,16 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> +<hibernate-mapping default-access="field" auto-import="true" package="fr.ifremer.wao.entity"> + <class name="fr.ifremer.wao.entity.FishingZoneImpl" table="fishingZone" node="fr.ifremer.wao.entity.FishingZoneImpl" abstract="false" proxy="fr.ifremer.wao.entity.FishingZone" > + <id name="topiaId" type="string" length="255" node="@topiaId"/> + <version name="topiaVersion" type="long" node="@topiaVersion"/> + <property name="topiaCreateDate" type="timestamp" node="@topiaCreateDate"/> + <property name="sectorName" type="text" access="field" column="sectorName" node="sectorName"/> + <property name="facadeName" type="text" access="field" column="facadeName" node="facadeName"/> + <property name="districtCode" type="text" access="field" column="districtCode" node="districtCode"/> + <bag name="sampleRow" table="fishingzone_samplerow" inverse="true" lazy="true" node="sampleRow" embed-xml="true"> + <key column="fishingZone"/> + <many-to-many class="fr.ifremer.wao.entity.SampleRowImpl" column="sampleRow" order-by="code" node="topiaId"/> + </bag> + </class> +</hibernate-mapping> Added: trunk/wao-business/src/main/resources/oldmappings/Wao/1.1/fr/ifremer/wao/entity/NewsImpl.hbm.xml =================================================================== --- trunk/wao-business/src/main/resources/oldmappings/Wao/1.1/fr/ifremer/wao/entity/NewsImpl.hbm.xml (rev 0) +++ trunk/wao-business/src/main/resources/oldmappings/Wao/1.1/fr/ifremer/wao/entity/NewsImpl.hbm.xml 2010-04-01 13:28:03 UTC (rev 402) @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> +<hibernate-mapping default-access="field" auto-import="true" package="fr.ifremer.wao.entity"> + <class name="fr.ifremer.wao.entity.NewsImpl" table="news" node="fr.ifremer.wao.entity.NewsImpl" abstract="false" proxy="fr.ifremer.wao.entity.News" > + <id name="topiaId" type="string" length="255" node="@topiaId"/> + <version name="topiaVersion" type="long" node="@topiaVersion"/> + <property name="topiaCreateDate" type="timestamp" node="@topiaCreateDate"/> + <property name="title" type="text" access="field" column="title" node="title"/> + <property name="content" type="text" access="field" column="content" node="content"/> + </class> +</hibernate-mapping> Added: trunk/wao-business/src/main/resources/oldmappings/Wao/1.1/fr/ifremer/wao/entity/ProfessionImpl.hbm.xml =================================================================== --- trunk/wao-business/src/main/resources/oldmappings/Wao/1.1/fr/ifremer/wao/entity/ProfessionImpl.hbm.xml (rev 0) +++ trunk/wao-business/src/main/resources/oldmappings/Wao/1.1/fr/ifremer/wao/entity/ProfessionImpl.hbm.xml 2010-04-01 13:28:03 UTC (rev 402) @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> +<hibernate-mapping default-access="field" auto-import="true" package="fr.ifremer.wao.entity"> + <class name="fr.ifremer.wao.entity.ProfessionImpl" table="profession" node="fr.ifremer.wao.entity.ProfessionImpl" abstract="false" proxy="fr.ifremer.wao.entity.Profession" > + <id name="topiaId" type="string" length="255" node="@topiaId"/> + <version name="topiaVersion" type="long" node="@topiaVersion"/> + <property name="topiaCreateDate" type="timestamp" node="@topiaCreateDate"/> + <property name="codeDCF5" type="text" access="field" column="codeDCF5" node="codeDCF5"/> + <property name="meshSize" type="text" access="field" column="meshSize" node="meshSize"/> + <property name="size" type="text" access="field" column="size" node="size"/> + <property name="other" type="text" access="field" column="other" node="other"/> + <property name="libelle" type="text" access="field" column="libelle" node="libelle"/> + <property name="species" type="text" access="field" column="species" node="species"/> + </class> +</hibernate-mapping> Added: trunk/wao-business/src/main/resources/oldmappings/Wao/1.1/fr/ifremer/wao/entity/SampleMonthImpl.hbm.xml =================================================================== --- trunk/wao-business/src/main/resources/oldmappings/Wao/1.1/fr/ifremer/wao/entity/SampleMonthImpl.hbm.xml (rev 0) +++ trunk/wao-business/src/main/resources/oldmappings/Wao/1.1/fr/ifremer/wao/entity/SampleMonthImpl.hbm.xml 2010-04-01 13:28:03 UTC (rev 402) @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> +<hibernate-mapping default-access="field" auto-import="true" package="fr.ifremer.wao.entity"> + <class name="fr.ifremer.wao.entity.SampleMonthImpl" table="sampleMonth" node="fr.ifremer.wao.entity.SampleMonthImpl" abstract="false" proxy="fr.ifremer.wao.entity.SampleMonth" > + <id name="topiaId" type="string" length="255" node="@topiaId"/> + <version name="topiaVersion" type="long" node="@topiaVersion"/> + <property name="topiaCreateDate" type="timestamp" node="@topiaCreateDate"/> + <property name="realTidesValue" type="int" access="field" column="realTidesValue" node="realTidesValue"/> + <property name="expectedTidesValue" type="int" access="field" column="expectedTidesValue" node="expectedTidesValue"/> + <property name="periodDate" type="java.util.Date" access="field" column="periodDate" node="periodDate"/> + <many-to-one name="sampleRow" class="fr.ifremer.wao.entity.SampleRowImpl" column="sampleRow" node="sampleRow/@topiaId" embed-xml="false"/> + </class> +</hibernate-mapping> Added: trunk/wao-business/src/main/resources/oldmappings/Wao/1.1/fr/ifremer/wao/entity/SampleRowImpl.hbm.xml =================================================================== --- trunk/wao-business/src/main/resources/oldmappings/Wao/1.1/fr/ifremer/wao/entity/SampleRowImpl.hbm.xml (rev 0) +++ trunk/wao-business/src/main/resources/oldmappings/Wao/1.1/fr/ifremer/wao/entity/SampleRowImpl.hbm.xml 2010-04-01 13:28:03 UTC (rev 402) @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> +<hibernate-mapping default-access="field" auto-import="true" package="fr.ifremer.wao.entity"> + <class name="fr.ifremer.wao.entity.SampleRowImpl" table="sampleRow" node="fr.ifremer.wao.entity.SampleRowImpl" abstract="false" proxy="fr.ifremer.wao.entity.SampleRow" > + <id name="topiaId" type="string" length="255" node="@topiaId"/> + <version name="topiaVersion" type="long" node="@topiaVersion"/> + <property name="topiaCreateDate" type="timestamp" node="@topiaCreateDate"/> + <property name="nbObservants" type="int" access="field" column="nbObservants" node="nbObservants"/> + <property name="averageTideTime" type="double" access="field" column="averageTideTime" node="averageTideTime"/> + <property name="code" type="text" access="field" column="code" node="code" index="sampleRow_code_idx" unique="true"/> + <property name="fishingZonesInfos" type="text" access="field" column="fishingZonesInfos" node="fishingZonesInfos"/> + <property name="comment" type="text" access="field" column="comment" node="comment"/> + <property name="programName" type="text" access="field" column="programName" node="programName"/> + <property name="periodBegin" type="java.util.Date" access="field" column="periodBegin" node="periodBegin"/> + <property name="periodEnd" type="java.util.Date" access="field" column="periodEnd" node="periodEnd"/> + <many-to-one name="profession" class="fr.ifremer.wao.entity.ProfessionImpl" column="profession" lazy="false" node="profession/@topiaId" embed-xml="false"/> + <bag name="sampleMonth" inverse="true" order-by="periodDate" lazy="true" cascade="all,delete-orphan" node="sampleMonth" embed-xml="false"> + <key column="sampleRow"/> + <one-to-many class="fr.ifremer.wao.entity.SampleMonthImpl" node="topiaId" embed-xml="false"/> + </bag> + <many-to-one name="company" class="fr.ifremer.wao.entity.CompanyImpl" column="company" lazy="false" node="company/@topiaId" embed-xml="false"/> + <bag name="sampleRowLog" inverse="true" order-by="topiaCreateDate desc" lazy="true" cascade="all,delete-orphan" node="sampleRowLog" embed-xml="false"> + <key column="sampleRow"/> + <one-to-many class="fr.ifremer.wao.entity.SampleRowLogImpl" node="topiaId" embed-xml="false"/> + </bag> + <bag name="elligibleBoat" inverse="true" order-by="companyActive" lazy="true" cascade="all,delete-orphan" node="elligibleBoat" embed-xml="false"> + <key column="sampleRow"/> + <one-to-many class="fr.ifremer.wao.entity.ElligibleBoatImpl" node="topiaId" embed-xml="false"/> + </bag> + <bag name="fishingZone" table="fishingzone_samplerow" lazy="false" node="fishingZone" embed-xml="true"> + <key column="sampleRow"/> + <many-to-many class="fr.ifremer.wao.entity.FishingZoneImpl" column="fishingZone" order-by="facadeName,sectorName,districtCode" node="topiaId"/> + </bag> + <bag name="contact" inverse="true" lazy="true" node="contact" embed-xml="false"> + <key column="sampleRow"/> + <one-to-many class="fr.ifremer.wao.entity.ContactImpl" node="topiaId" embed-xml="false"/> + </bag> + </class> +</hibernate-mapping> Added: trunk/wao-business/src/main/resources/oldmappings/Wao/1.1/fr/ifremer/wao/entity/SampleRowLogImpl.hbm.xml =================================================================== --- trunk/wao-business/src/main/resources/oldmappings/Wao/1.1/fr/ifremer/wao/entity/SampleRowLogImpl.hbm.xml (rev 0) +++ trunk/wao-business/src/main/resources/oldmappings/Wao/1.1/fr/ifremer/wao/entity/SampleRowLogImpl.hbm.xml 2010-04-01 13:28:03 UTC (rev 402) @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> +<hibernate-mapping default-access="field" auto-import="true" package="fr.ifremer.wao.entity"> + <class name="fr.ifremer.wao.entity.SampleRowLogImpl" table="sampleRowLog" node="fr.ifremer.wao.entity.SampleRowLogImpl" abstract="false" proxy="fr.ifremer.wao.entity.SampleRowLog" > + <id name="topiaId" type="string" length="255" node="@topiaId"/> + <version name="topiaVersion" type="long" node="@topiaVersion"/> + <property name="topiaCreateDate" type="timestamp" node="@topiaCreateDate"/> + <property name="logText" type="text" access="field" column="logText" node="logText"/> + <property name="comment" type="text" access="field" column="comment" node="comment"/> + <many-to-one name="sampleRow" class="fr.ifremer.wao.entity.SampleRowImpl" column="sampleRow" node="sampleRow/@topiaId" embed-xml="false"/> + <many-to-one name="author" class="fr.ifremer.wao.entity.WaoUserImpl" column="author" lazy="false" node="author/@topiaId" embed-xml="false"/> + </class> +</hibernate-mapping> Added: trunk/wao-business/src/main/resources/oldmappings/Wao/1.1/fr/ifremer/wao/entity/ShipOwnerImpl.hbm.xml =================================================================== --- trunk/wao-business/src/main/resources/oldmappings/Wao/1.1/fr/ifremer/wao/entity/ShipOwnerImpl.hbm.xml (rev 0) +++ trunk/wao-business/src/main/resources/oldmappings/Wao/1.1/fr/ifremer/wao/entity/ShipOwnerImpl.hbm.xml 2010-04-01 13:28:03 UTC (rev 402) @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> +<hibernate-mapping default-access="field" auto-import="true" package="fr.ifremer.wao.entity"> + <class name="fr.ifremer.wao.entity.ShipOwnerImpl" table="shipOwner" node="fr.ifremer.wao.entity.ShipOwnerImpl" abstract="false" proxy="fr.ifremer.wao.entity.ShipOwner" > + <id name="topiaId" type="string" length="255" node="@topiaId"/> + <version name="topiaVersion" type="long" node="@topiaVersion"/> + <property name="topiaCreateDate" type="timestamp" node="@topiaCreateDate"/> + <property name="code" type="text" access="field" column="code" node="code" index="shipOwner_code_idx" unique="true"/> + <property name="firstName" type="text" access="field" column="firstName" node="firstName"/> + <property name="lastName" type="text" access="field" column="lastName" node="lastName"/> + </class> +</hibernate-mapping> Added: trunk/wao-business/src/main/resources/oldmappings/Wao/1.1/fr/ifremer/wao/entity/WaoUserImpl.hbm.xml =================================================================== --- trunk/wao-business/src/main/resources/oldmappings/Wao/1.1/fr/ifremer/wao/entity/WaoUserImpl.hbm.xml (rev 0) +++ trunk/wao-business/src/main/resources/oldmappings/Wao/1.1/fr/ifremer/wao/entity/WaoUserImpl.hbm.xml 2010-04-01 13:28:03 UTC (rev 402) @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> +<hibernate-mapping default-access="field" auto-import="true" package="fr.ifremer.wao.entity"> + <class name="fr.ifremer.wao.entity.WaoUserImpl" table="waoUser" node="fr.ifremer.wao.entity.WaoUserImpl" abstract="false" proxy="fr.ifremer.wao.entity.WaoUser" > + <id name="topiaId" type="string" length="255" node="@topiaId"/> + <version name="topiaVersion" type="long" node="@topiaVersion"/> + <property name="topiaCreateDate" type="timestamp" node="@topiaCreateDate"/> + <property name="firstName" type="text" access="field" column="firstName" node="firstName"/> + <property name="lastName" type="text" access="field" column="lastName" node="lastName"/> + <property name="phoneNumber" type="text" access="field" column="phoneNumber" node="phoneNumber"/> + <property name="login" type="text" access="field" column="login" node="login"/> + <property name="password" type="text" access="field" column="password" node="password"/> + <property name="active" type="boolean" access="field" column="active" node="active"/> + <property name="role" type="int" access="field" column="role" node="role"/> + <property name="readOnly" type="boolean" access="field" column="readOnly" node="readOnly"/> + <many-to-one name="company" class="fr.ifremer.wao.entity.CompanyImpl" column="company" node="company/@topiaId" embed-xml="false"/> + <bag name="contact" inverse="true" lazy="true" node="contact" embed-xml="false"> + <key column="observer"/> + <one-to-many class="fr.ifremer.wao.entity.ContactImpl" node="topiaId" embed-xml="false"/> + </bag> + </class> +</hibernate-mapping> 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 13:27:59 UTC (rev 401) +++ trunk/wao-business/src/test/java/fr/ifremer/wao/ErrorDB1_0Test.java 2010-04-01 13:28:03 UTC (rev 402) @@ -49,7 +49,7 @@ @Ignore public class ErrorDB1_0Test { - private static WaoRunner runner; + private static TestManager manager; private static final Logger log = LoggerFactory.getLogger(ErrorDB1_0Test.class); @@ -58,7 +58,7 @@ private static Writer writerKos; public ErrorDB1_0Test() { - runner = new WaoRunnerImpl(); + manager = new TestManager(); } @BeforeClass @@ -80,25 +80,25 @@ } @Before - public void setUp() throws WaoException, ArgumentsParserException { - runner.start(); + public void setUp() throws WaoExceptionO, ArgumentsParserException { + manager.start(); } @After - public void tearDown() throws WaoException, TopiaException { - runner.stop(); + public void tearDown() throws WaoExceptionO, TopiaException { + manager.stop(); } @Test public void testExecute() throws Exception { TopiaContext transaction = - WaoContext.getTopiaRootContext().beginTransaction(); + manager.getContext().beginTransaction(); - ContactDAO dao = WaoModelDAOHelper.getContactDAO(transaction); + ContactDAO dao = WaoDAOHelper.getContactDAO(transaction); - SampleRowDAO rowDAO = WaoModelDAOHelper.getSampleRowDAO(transaction); + SampleRowDAO rowDAO = WaoDAOHelper.getSampleRowDAO(transaction); DateFormat dateFormat = new SimpleDateFormat("MM/yyyy"); Deleted: trunk/wao-business/src/test/java/fr/ifremer/wao/ImportHelperTest.java =================================================================== --- trunk/wao-business/src/test/java/fr/ifremer/wao/ImportHelperTest.java 2010-04-01 13:27:59 UTC (rev 401) +++ trunk/wao-business/src/test/java/fr/ifremer/wao/ImportHelperTest.java 2010-04-01 13:28:03 UTC (rev 402) @@ -1,249 +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 com.csvreader.CsvReader; -import fr.ifremer.wao.io.ImportHelper; -import fr.ifremer.wao.io.WaoCsvHeader.CONTACT; -import fr.ifremer.wao.io.WaoCsvHeader.SAMPLING; -import java.io.IOException; -import java.io.InputStream; -import java.nio.charset.Charset; -import java.text.DateFormat; -import java.util.Calendar; -import java.util.Date; -import java.util.GregorianCalendar; -import java.util.Locale; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import static org.junit.Assert.*; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * - * @author fdesbois - */ -public class ImportHelperTest { - - private static WaoRunner runner; - - private static final Logger log = LoggerFactory.getLogger(ImportHelperTest.class); - - private CsvReader reader; - - public ImportHelperTest() { - runner = new WaoRunnerTest(); - } - - @BeforeClass - public static void setUpClass() throws Exception { - - } - - @AfterClass - public static void tearDownClass() throws Exception { - - } - - @Before - public void setUp() throws WaoException, IOException { - runner.start(); - - InputStream input = getClass().getResourceAsStream("/import/misc.csv"); - reader = new CsvReader(input, Charset.forName("UTF-8")); - reader.readHeaders(); - } - - @After - public void tearDown() throws WaoException { - reader.close(); - - runner.stop(); - } - - /** - * Test of getHeaderForContactCsv method, of class ImportHelper. - */ - //@Test - public void testGetHeaderForContactCsv() { - System.out.println("getHeaderForContactCsv"); - } - - /** - * Test of formatContactValidation method, of class ImportHelper. - */ - //@Test - public void testFormatContactValidation() { - System.out.println("formatContactValidation"); - } - - /** - * Test of formatContactMammals method, of class ImportHelper. - */ - //@Test - public void testFormatContactMammals() { - System.out.println("formatContactMammals"); - } - - /** - * Test of parseContactMammals method, of class ImportHelper. - */ - //@Test - public void testParseContactMammals() { - System.out.println("parseContactMammals"); - } - - /** - * Test of formatContactCode method, of class ImportHelper. - */ - @Test - public void testFormatContactCode() { - log.info("formatContactCode"); - Date createDate = WaoContext.getCurrentDate(); - Calendar calendar = new GregorianCalendar(Locale.FRENCH); - calendar.setTime(createDate); - calendar.set(Calendar.HOUR_OF_DAY, 10); - calendar.set(Calendar.MINUTE, 1); - calendar.set(Calendar.SECOND, 50); - calendar.set(Calendar.MILLISECOND, 260); - String expResult = "100150260"; - DateFormat timeFormat = CONTACT.getTimeFormat(); - String result = timeFormat.format(calendar.getTime()); - assertEquals(expResult, result); - } - - /** - * Test of parseContactCreateDate method, of class ImportHelper. - */ - @Test - public void testParseContactCreateDate() throws Exception { - System.out.println("parseContactCreateDate"); - String code = "101250718"; - Date createDate = WaoContext.getCurrentDate(); - Calendar calendar = new GregorianCalendar(Locale.FRENCH); - calendar.setTime(createDate); - calendar.set(Calendar.HOUR_OF_DAY, 10); - calendar.set(Calendar.MINUTE, 12); - calendar.set(Calendar.SECOND, 50); - calendar.set(Calendar.MILLISECOND, 718); - Date expResult = calendar.getTime(); - Date result = ImportHelper.parseContactCreateDate(code, "23/10/2009"); - assertEquals(expResult, result); - } - - /** - * Test of logTimeAndMemory method, of class ImportHelper. - */ - //@Test - public void testLogTimeAndMemory() { - System.out.println("logTimeAndMemory"); - } - - /** - * Test of parseContactValidation method, of class ImportHelper. - */ - //@Test - public void testParseContactValidation() throws Exception { - System.out.println("parseContactValidation"); - } - - /** - * Test of readSampleRowCode method, of class ImportHelper. - */ - @Test - public void testReadSampleRowCode() throws Exception { - System.out.println("readSampleRowCode"); - - reader.readRecord(); - String code = ImportHelper.readSampleRowCode(reader); - assertEquals(code, "2009_0001"); - - reader.readRecord(); - code = ImportHelper.readSampleRowCode(reader); - assertEquals(code, "2009_0011"); - - reader.readRecord(); - code = ImportHelper.readSampleRowCode(reader); - assertEquals(code, "2009_0111"); - - reader.readRecord(); - code = ImportHelper.readSampleRowCode(reader); - assertEquals(code, "2009_1111"); - } - - /** - * Test of getContactDateFormat method, of class ImportHelper. - */ - //@Test - public void testGetContactDateFormat() { - System.out.println("getContactDateFormat"); - } - - /** - * Test of read method, of class ImportHelper. - */ - @Test - public void testRead() throws Exception { - log.info("read"); - - reader.readRecord(); - String code = ImportHelper.read(reader, SAMPLING.PLAN_CODE); - assertEquals(code, "2009_1"); - } - - /** - * Test of readInt method, of class ImportHelper. - */ - //@Test - public void testReadInt() throws Exception { - System.out.println("readInt"); - } - - /** - * Test of readInteger method, of class ImportHelper. - */ - //@Test - public void testReadInteger() throws Exception { - System.out.println("readInteger"); - } - - /** - * Test of readPeriod method, of class ImportHelper. - */ - //@Test - public void testReadPeriod() throws Exception { - System.out.println("readPeriod"); - } - - /** - * Test of readDate method, of class ImportHelper. - */ - //@Test - public void testReadDate() throws Exception { - System.out.println("readDate"); - } - -} Copied: trunk/wao-business/src/test/java/fr/ifremer/wao/TestManager.java (from rev 395, trunk/wao-business/src/test/java/fr/ifremer/wao/WaoRunnerTest.java) =================================================================== --- trunk/wao-business/src/test/java/fr/ifremer/wao/TestManager.java (rev 0) +++ trunk/wao-business/src/test/java/fr/ifremer/wao/TestManager.java 2010-04-01 13:28:03 UTC (rev 402) @@ -0,0 +1,197 @@ +/* + * *##% + * 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.service.ServiceBoat; +import fr.ifremer.wao.service.ServiceBoatImpl; +import fr.ifremer.wao.service.ServiceContact; +import fr.ifremer.wao.service.ServiceContactImpl; +import fr.ifremer.wao.service.ServiceNews; +import fr.ifremer.wao.service.ServiceNewsImpl; +import fr.ifremer.wao.service.ServiceReferential; +import fr.ifremer.wao.service.ServiceReferentialImpl; +import fr.ifremer.wao.service.ServiceSampling; +import fr.ifremer.wao.service.ServiceSamplingImpl; +import fr.ifremer.wao.service.ServiceSynthesis; +import fr.ifremer.wao.service.ServiceSynthesisImpl; +import fr.ifremer.wao.service.ServiceUser; +import fr.ifremer.wao.service.ServiceUserImpl; +import java.io.IOException; +import java.net.URISyntaxException; +import java.net.URL; +import java.util.Calendar; +import java.util.GregorianCalendar; +import java.util.Properties; +import org.junit.Ignore; +import org.nuiton.topia.TopiaException; +import org.nuiton.util.ApplicationConfig; +import org.nuiton.util.Resource; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * WaoRunnerTest + * + * Created: 23 nov. 2009 + * + * @author fdesbois + * @version $Revision$ + * + * Mise a jour: $Date$ + * par : $Author$ + */ + at Ignore +public class TestManager { + + private static final Logger log = LoggerFactory.getLogger(TestManager.class); + + private WaoContextImpl context; + + public TestManager() { + + } + + public void start() throws WaoException { + if (log.isDebugEnabled()) { + log.debug("TEST START"); + } + try { + context = new WaoContextImpl(); + ApplicationConfig configuration = new ApplicationConfig(); + configuration.setOptions(loadFileProperties("WaoTest.properties")); + + context.loadConfiguration(configuration); + + // Set currentDate to 23/10/2009 + Calendar calendar = new GregorianCalendar(2009, 9, 23); + context.setCurrentDate(calendar.getTime()); + + WaoContextO.setContext(context); + } catch (Exception eee) { + context.doCatch(eee, "Error during loadConfiguration from " + + "'WaoTest.properties' file"); + } + } + + public void stop() throws WaoException { + if (log.isDebugEnabled()) { + log.debug("TEST STOP : clearContext"); + } + try { + context.getTopiaRootContext().clear(true); + } catch (TopiaException eee) { + context.doCatch(eee, "Error during clear database"); + } + } + + public WaoContextImplementor getContext() { + return context; + } + + protected Properties loadFileProperties(String filename) + throws URISyntaxException, IOException { + Properties props = new Properties(); + URL url = Resource.getURL(filename); + if (log.isDebugEnabled()) { + log.debug(url.toString()); + } + props.load(url.openStream()); + return props; + } + + public ServiceBoat getServiceBoat() { + ServiceBoatImpl instance = new ServiceBoatImpl(); + instance.setContext(getContext()); + return instance; + } + + public ServiceReferential getServiceReferential() throws WaoExceptionO { + ServiceReferentialImpl instance = new ServiceReferentialImpl(); + instance.setContext(getContext()); + return instance; + } + + public ServiceNews getServiceNews() { + ServiceNewsImpl instance = new ServiceNewsImpl(); + instance.setContext(getContext()); + return instance; + } + + public ServiceSampling getServiceSampling() throws WaoExceptionO { + ServiceSamplingImpl instance = new ServiceSamplingImpl(); +// instance.setContext(context); + return instance; + } + + public ServiceSynthesis getServiceSynthesis() throws WaoExceptionO { + ServiceSynthesisImpl instance = new ServiceSynthesisImpl(); +// instance.setContext(context); + return instance; + } + + public ServiceUser getServiceUser() throws WaoExceptionO { + ServiceUserImpl instance = new ServiceUserImpl(); +// instance.setContext(context); + return instance; + } + + public ServiceContact getServiceContact() throws WaoExceptionO { + ServiceContactImpl instance = new ServiceContactImpl(); +// instance.setContext(context); + return instance; + } + +// public void prepareData() throws WaoExceptionO { +// ServiceBoat serviceBoat = new ServiceBoatImpl(); +// ServiceReferential serviceReferential = new ServiceReferentialImpl(); +// ServiceUser serviceUser = new ServiceUserImpl(); +// ServiceSampling serviceSampling = new ServiceSamplingImpl(); +// ServiceContact serviceContact = new ServiceContactImpl(); +// +// Company company = new CompanyImpl(); +// company.setName("TARTANPION"); +// company.setActive(true); +// serviceUser.createUpdateCompany(company); +// +// WaoUser observer = new WaoUserImpl(); +// observer.setCompany(company); +// observer.setFirstName("Jean"); +// observer.setLastName("Michmuche"); +// observer.setLogin("jmichmuche"); +// observer.setActive(true); +// serviceUser.createUpdateUser(observer, true); +// +// InputStream input = getClass().getResourceAsStream("/import/navires.csv"); +// serviceBoat.importBoatCsv(input); +// +// input = getClass().getResourceAsStream("/import/zonesPeche.csv"); +// serviceReferential.importFishingZoneCsv(input); +// +// input = getClass().getResourceAsStream("/import/echantillonnage.csv"); +// serviceSampling.importSamplingPlanCsv(input); +// +// input = getClass().getResourceAsStream("/import/contacts.csv"); +// // user import : no activation +// serviceContact.importContactCsv(observer, input); +// } + +} 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 13:27:59 UTC (rev 401) +++ trunk/wao-business/src/test/java/fr/ifremer/wao/WaoGlobalTest.java 2010-04-01 13:28:03 UTC (rev 402) @@ -48,12 +48,12 @@ */ public class WaoGlobalTest { - private static WaoRunner runner; + private static TestManager manager; private static final Logger log = LoggerFactory.getLogger(WaoGlobalTest.class); public WaoGlobalTest() { - runner = new WaoRunnerTest(); + manager = new TestManager(); } @BeforeClass @@ -67,13 +67,13 @@ } @Before - public void setUp() throws WaoException { - runner.start(); + public void setUp() throws WaoExceptionO { + manager.start(); } @After - public void tearDown() throws WaoException { - runner.stop(); + public void tearDown() throws WaoExceptionO { + manager.stop(); } /** Deleted: trunk/wao-business/src/test/java/fr/ifremer/wao/WaoRunnerTest.java =================================================================== --- trunk/wao-business/src/test/java/fr/ifremer/wao/WaoRunnerTest.java 2010-04-01 13:27:59 UTC (rev 401) +++ trunk/wao-business/src/test/java/fr/ifremer/wao/WaoRunnerTest.java 2010-04-01 13:28:03 UTC (rev 402) @@ -1,150 +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.Company; -import fr.ifremer.wao.entity.CompanyImpl; -import fr.ifremer.wao.entity.WaoUser; -import fr.ifremer.wao.entity.WaoUserImpl; -import fr.ifremer.wao.service.*; -import java.io.IOException; -import java.io.InputStream; -import java.net.URISyntaxException; -import java.net.URL; -import java.util.Calendar; -import java.util.Date; -import java.util.GregorianCalendar; -import java.util.Properties; -import org.junit.Ignore; -import org.nuiton.topia.TopiaException; -import org.nuiton.util.ApplicationConfig; -import org.nuiton.util.Resource; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * WaoRunnerTest - * - * Created: 23 nov. 2009 - * - * @author fdesbois - * @version $Revision$ - * - * Mise a jour: $Date$ - * par : $Author$ - */ - at Ignore -public class WaoRunnerTest implements WaoRunner { - - private static final Logger log = LoggerFactory.getLogger(WaoRunnerTest.class); - - private ApplicationConfig _configuration; - - @Override - public void start() throws WaoException { - if (log.isDebugEnabled()) { - log.debug("TEST START : loadConfiguration"); - } - try { - Properties options = loadFileProperties("WaoTest.properties"); - options.setProperty("topia.persistence.classes", - WaoModelDAOHelper.getImplementationClassesAsString()); - - _configuration = new ApplicationConfig(); - _configuration.setOptions(options); - - WaoContext.setRunner(this); - } catch (Exception eee) { - WaoContext.serviceException(null, "Error during loadConfiguration from " + - "'WaoTest.properties' file", eee); - } - } - - @Override - public void stop() throws WaoException { - if (log.isDebugEnabled()) { - log.debug("TEST STOP : clearContext"); - } - try { - WaoContext.getTopiaRootContext().clear(true); - } catch (TopiaException eee) { - WaoContext.serviceException(null, "Error during clear database", eee); - } - } - - private static Properties loadFileProperties(String filename) - throws URISyntaxException, IOException { - Properties props = new Properties(); - URL url = Resource.getURL(filename); - if (log.isDebugEnabled()) { - log.debug(url.toString()); - } - props.load(url.openStream()); - return props; - } - - @Override - public Date getCurrentDate() { - Calendar calendar = new GregorianCalendar(2009, 9, 23); // 23/10/2009 - return calendar.getTime(); - } - - @Override - public ApplicationConfig getConfiguration() { - return _configuration; - } - - public void prepareData() throws WaoException { - ServiceBoat serviceBoat = new ServiceBoatImpl(); - ServiceReferential serviceReferential = new ServiceReferentialImpl(); - ServiceUser serviceUser = new ServiceUserImpl(); - ServiceSampling serviceSampling = new ServiceSamplingImpl(); - ServiceContact serviceContact = new ServiceContactImpl(); - - Company company = new CompanyImpl(); - company.setName("TARTANPION"); - company.setActive(true); - serviceUser.createUpdateCompany(company); - - WaoUser observer = new WaoUserImpl(); - observer.setCompany(company); - observer.setFirstName("Jean"); - observer.setLastName("Michmuche"); - observer.setLogin("jmichmuche"); - observer.setActive(true); - serviceUser.createUpdateUser(observer, true); - - InputStream input = getClass().getResourceAsStream("/import/navires.csv"); - serviceBoat.importBoatCsv(input); - - input = getClass().getResourceAsStream("/import/zonesPeche.csv"); - serviceReferential.importFishingZoneCsv(input); - - input = getClass().getResourceAsStream("/import/echantillonnage.csv"); - serviceSampling.importSamplingPlanCsv(input); - - input = getClass().getResourceAsStream("/import/contacts.csv"); - // user import : no activation - serviceContact.importContactCsv(observer, input); - } - -} 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 13:27:59 UTC (rev 401) +++ trunk/wao-business/src/test/java/fr/ifremer/wao/WaoUtilsTest.java 2010-04-01 13:28:03 UTC (rev 402) @@ -45,12 +45,12 @@ */ public class WaoUtilsTest { - private static WaoRunner runner; + private static TestManager manager; private static final Logger log = LoggerFactory.getLogger(WaoUtilsTest.class); public WaoUtilsTest() { - runner = new WaoRunnerTest(); + manager = new TestManager(); } @BeforeClass @@ -64,13 +64,13 @@ } @Before - public void setUp() throws WaoException { - runner.start(); + public void setUp() throws WaoExceptionO { + manager.start(); } @After - public void tearDown() throws WaoException { - runner.stop(); + public void tearDown() throws WaoExceptionO { + manager.stop(); } /** @@ -130,7 +130,7 @@ Company company = new CompanyImpl(); - WaoContext.prepareTopiaId(Company.class, company); + manager.getContext().prepareTopiaId(Company.class, company); assertNotNull(company.getTopiaId()); log.debug("topiaId for Company : " + company.getTopiaId()); } Modified: trunk/wao-business/src/test/java/fr/ifremer/wao/entity/BoatImplTest.java =================================================================== --- trunk/wao-business/src/test/java/fr/ifremer/wao/entity/BoatImplTest.java 2010-04-01 13:27:59 UTC (rev 401) +++ trunk/wao-business/src/test/java/fr/ifremer/wao/entity/BoatImplTest.java 2010-04-01 13:28:03 UTC (rev 402) @@ -21,12 +21,9 @@ package fr.ifremer.wao.entity; -import fr.ifremer.wao.WaoContext; -import fr.ifremer.wao.WaoModelDAOHelper; -import fr.ifremer.wao.WaoRunner; +import fr.ifremer.wao.WaoDAOHelper; import fr.ifremer.wao.bean.ContactState; -import fr.ifremer.wao.WaoRunnerTest; -import fr.ifremer.wao.service.ServiceBoatImpl; +import fr.ifremer.wao.TestManager; import fr.ifremer.wao.service.ServiceContactImpl; import fr.ifremer.wao.service.ServiceSamplingImpl; import fr.ifremer.wao.service.ServiceUserImpl; @@ -61,7 +58,7 @@ */ public class BoatImplTest { - private static WaoRunner runner; + private static TestManager manager; private static final Logger log = LoggerFactory.getLogger(BoatImplTest.class); @@ -70,7 +67,7 @@ @BeforeClass public static void setUpClass() throws Exception { - runner = new WaoRunnerTest(); + manager = new TestManager(); } @AfterClass @@ -79,12 +76,12 @@ @Before public void setUp() throws Exception { - runner.start(); + manager.start(); } @After public void tearDown() throws Exception { - runner.stop(); + manager.stop(); } /** @@ -110,14 +107,14 @@ serviceUser.createUpdateUser(user, true); InputStream input = getClass().getResourceAsStream("/import/navires.csv"); - ServiceBoat serviceBoat = new ServiceBoatImpl(); + ServiceBoat serviceBoat = manager.getServiceBoat(); serviceBoat.importBoatCsv(input); List<Boat> boats = serviceBoat.getBoatsByImmatriculations("174258"); Boat boat = boats.get(0); - TopiaContext transaction = WaoContext.getTopiaRootContext().beginTransaction(); + TopiaContext transaction = manager.getContext().beginTransaction(); - FishingZoneDAO zoneDAO = WaoModelDAOHelper.getFishingZoneDAO(transaction); + FishingZoneDAO zoneDAO = WaoDAOHelper.getFishingZoneDAO(transaction); FishingZone zoneIId = zoneDAO.create(FishingZone.DISTRICT_CODE, "IId"); FishingZone zoneIV = zoneDAO.create(FishingZone.DISTRICT_CODE, "IV"); FishingZone zoneI = zoneDAO.create(FishingZone.DISTRICT_CODE, "I"); @@ -128,7 +125,7 @@ input = getClass().getResourceAsStream("/import/echantillonnage.csv"); serviceSampling.importSamplingPlanCsv(input); - SampleRowDAO rowDAO = WaoModelDAOHelper.getSampleRowDAO(transaction); + SampleRowDAO rowDAO = WaoDAOHelper.getSampleRowDAO(transaction); SampleRow row = rowDAO.findByCode("2010_0001"); row.getCompany(); row.getProfession(); @@ -188,18 +185,18 @@ /** PREPARE DATA **/ InputStream input = getClass().getResourceAsStream("/import/navires.csv"); - ServiceBoat serviceBoat = new ServiceBoatImpl(); + ServiceBoat serviceBoat = manager.getServiceBoat(); serviceBoat.importBoatCsv(input); List<Boat> boats = serviceBoat.getBoatsByImmatriculations("174258"); Boat boat = boats.get(0); - TopiaContext transaction = WaoContext.getTopiaRootContext().beginTransaction(); + TopiaContext transaction = manager.getContext().beginTransaction(); - CompanyDAO companyDAO = WaoModelDAOHelper.getCompanyDAO(transaction); + CompanyDAO companyDAO = WaoDAOHelper.getCompanyDAO(transaction); Company company = companyDAO.create(Company.NAME, "TARTANPION"); Company company2 = companyDAO.create(Company.NAME, "BIS"); - WaoUserDAO userDAO = WaoModelDAOHelper.getWaoUserDAO(transaction); + WaoUserDAO userDAO = WaoDAOHelper.getWaoUserDAO(transaction); WaoUser user = userDAO.create(WaoUser.FIRST_NAME,"Jean", WaoUser.LAST_NAME, "Michmuche", WaoUser.COMPANY, company); company.addWaoUser(user); @@ -207,7 +204,7 @@ WaoUser.COMPANY, company2); company2.addWaoUser(user2); -// BoatInfosDAO boatInfosDAO = WaoModelDAOHelper.getBoatInfosDAO(transaction); +// BoatInfosDAO boatInfosDAO = WaoDAOHelper.getBoatInfosDAO(transaction); // BoatInfos boatInfos = boatInfosDAO.create(BoatInfos.BOAT, boat, BoatInfos.COMPANY, company); transaction.commitTransaction(); Modified: trunk/wao-business/src/test/java/fr/ifremer/wao/entity/BoatInfosImplTest.java =================================================================== --- trunk/wao-business/src/test/java/fr/ifremer/wao/entity/BoatInfosImplTest.java 2010-04-01 13:27:59 UTC (rev 401) +++ trunk/wao-business/src/test/java/fr/ifremer/wao/entity/BoatInfosImplTest.java 2010-04-01 13:28:03 UTC (rev 402) @@ -22,9 +22,7 @@ package fr.ifremer.wao.entity; import fr.ifremer.wao.WaoRunner; -import fr.ifremer.wao.WaoRunnerTest; -import fr.ifremer.wao.service.ServiceBoatImpl; -import fr.ifremer.wao.service.ServiceContactImpl; +import fr.ifremer.wao.TestManager; import org.junit.After; import org.junit.AfterClass; import org.junit.Before; @@ -46,7 +44,7 @@ */ public class BoatInfosImplTest { - private static WaoRunner runner; + private static TestManager manager; private static final Logger log = LoggerFactory.getLogger(BoatInfosImplTest.class); @@ -55,7 +53,7 @@ @BeforeClass public static void setUpClass() throws Exception { - runner = new WaoRunnerTest(); + manager = new TestManager(); } @AfterClass @@ -64,12 +62,12 @@ @Before public void setUp() throws Exception { - runner.start(); + manager.start(); } @After public void tearDown() throws Exception { - runner.stop(); + 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 13:27:59 UTC (rev 401) +++ trunk/wao-business/src/test/java/fr/ifremer/wao/entity/SampleRowImplTest.java 2010-04-01 13:28:03 UTC (rev 402) @@ -21,11 +21,11 @@ package fr.ifremer.wao.entity; -import fr.ifremer.wao.WaoException; -import fr.ifremer.wao.WaoModelDAOHelper; +import fr.ifremer.wao.WaoExceptionO; +import fr.ifremer.wao.WaoDAOHelper; import fr.ifremer.wao.WaoRunner; -import fr.ifremer.wao.WaoContext; -import fr.ifremer.wao.WaoRunnerTest; +import fr.ifremer.wao.WaoContextO; +import fr.ifremer.wao.TestManager; import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; @@ -54,7 +54,7 @@ */ public class SampleRowImplTest { - private static WaoRunner runner; + private static TestManager manager; private static final Logger log = LoggerFactory.getLogger(SampleRowImplTest.class); @@ -63,7 +63,7 @@ @BeforeClass public static void setUpClass() throws Exception { - runner = new WaoRunnerTest(); + manager = new TestManager(); } @AfterClass @@ -72,23 +72,23 @@ @Before public void setUp() throws Exception { - runner.start(); + manager.start(); } @After public void tearDown() throws Exception { - runner.stop(); + manager.stop(); } - private SampleRow prepareData() throws WaoException, TopiaException { - TopiaContext transaction = WaoContext.getTopiaRootContext().beginTransaction(); + private SampleRow prepareData() throws WaoExceptionO, TopiaException { + TopiaContext transaction = manager.getContext().beginTransaction(); - SampleRowDAO dao = WaoModelDAOHelper.getSampleRowDAO(transaction); + SampleRowDAO dao = WaoDAOHelper.getSampleRowDAO(transaction); SampleRow row = dao.create(); row.setCode("2010_1"); - SampleMonthDAO monthDAO = WaoModelDAOHelper.getSampleMonthDAO(transaction); + SampleMonthDAO monthDAO = WaoDAOHelper.getSampleMonthDAO(transaction); SampleMonth month = monthDAO.create(SampleMonth.SAMPLE_ROW, row); Calendar calendar = new GregorianCalendar(2009, 3, 1); @@ -103,9 +103,9 @@ return myRow; } - private SampleRow getRowFromContext() throws WaoException, TopiaException { - TopiaContext transaction = WaoContext.getTopiaRootContext().beginTransaction(); - SampleRowDAO dao = WaoModelDAOHelper.getSampleRowDAO(transaction); + private SampleRow getRowFromContext() throws WaoExceptionO, TopiaException { + TopiaContext transaction = manager.getContext().beginTransaction(); + SampleRowDAO dao = WaoDAOHelper.getSampleRowDAO(transaction); SampleRow resultRow = dao.findByCode("2010_1"); resultRow.sizeElligibleBoat(); resultRow.sizeSampleMonth(); Deleted: 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 13:27:59 UTC (rev 401) +++ trunk/wao-business/src/test/java/fr/ifremer/wao/io/ImportHelperTest.java 2010-04-01 13:28:03 UTC (rev 402) @@ -1,201 +0,0 @@ - -package fr.ifremer.wao.io; - -import com.csvreader.CsvReader; -import fr.ifremer.wao.io.WaoCsvHeader.DatedHeader; -import java.io.InputStream; -import java.nio.charset.Charset; -import java.util.Date; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.nuiton.util.DateUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * - * @author fdesbois - */ -public class ImportHelperTest { - - private static final Logger logger = - LoggerFactory.getLogger(ImportHelperTest.class); - - public ImportHelperTest() { - } - - @BeforeClass - public static void setUpClass() throws Exception { - } - - @AfterClass - public static void tearDownClass() throws Exception { - } - - @Before - public void setUp() { - } - - @After - public void tearDown() { - } - - /** - * Test of parseContactValidation method, of class ImportHelper. - */ - //@Test - public void testParseContactValidation() throws Exception { - System.out.println("parseContactValidation"); - } - - /** - * Test of parseContactMammals method, of class ImportHelper. - */ - //@Test - public void testParseContactMammals() throws Exception { - System.out.println("parseContactMammals"); - } - - /** - * Test of parseContactCreateDate method, of class ImportHelper. - */ - //@Test - public void testParseContactCreateDate() throws Exception { - System.out.println("parseContactCreateDate"); - } - - /** - * Test of readSampleRowCode method, of class ImportHelper. - */ - //@Test - public void testReadSampleRowCode() throws Exception { - System.out.println("readSampleRowCode"); - } - - /** - * Test of read method, of class ImportHelper. - */ - //@Test - public void testRead() throws Exception { - System.out.println("read"); - } - - /** - * Test of readInt method, of class ImportHelper. - */ - //@Test - public void testReadInt() throws Exception { - System.out.println("readInt"); - } - - /** - * Test of readInteger method, of class ImportHelper. - */ - //@Test - public void testReadInteger() throws Exception { - System.out.println("readInteger"); - } - - /** - * Test of readPeriod method, of class ImportHelper. - */ - //@Test - public void testReadPeriod() throws Exception { - System.out.println("readPeriod"); - } - - /** - * Test of readDate method, of class ImportHelper. - */ - @Test - public void testReadDate() throws Exception { - logger.info("readDate"); - - InputStream stream = - getClass().getResourceAsStream("/import/dates.csv"); - CsvReader reader = new CsvReader(stream, Charset.forName("UTF-8")); - reader.readHeaders(); - - reader.readRecord(); - - // TEST1 : Date like JJ/MM/AAAA - // normal pattern : dd/MM/yyyy - DatedHeader header1 = new DatedHeader() { - - @Override - public String datePattern() { - return "dd/MM/yyyy"; - } - - @Override - public String name() { - return "DATE_1"; - } - }; - - Date res = ImportHelper.readDate(reader, header1); - Date ref = DateUtils.createDate(10, 2, 2010); - Assert.assertEquals(ref, res); - - // TEST2 : Date like JJ/MM/AA - // same pattern as header1 : dd/MM/yyyy - DatedHeader header2 = new DatedHeader() { - - @Override - public String datePattern() { - return "dd/MM/yyyy"; - } - - @Override - public String name() { - return "DATE_2"; - } - }; - - res = ImportHelper.readDate(reader, header2); - Assert.assertEquals(ref, res); - - // TEST3: date like MM/AAAA - // pattern without day : MM/yyyy - DatedHeader header3 = new DatedHeader() { - - @Override - public String datePattern() { - return "MM/yyyy"; - } - - @Override - public String name() { - return "DATE_3"; - } - }; - - res = ImportHelper.readDate(reader, header3); - Date ref2 = DateUtils.createDate(1, 2, 2010); - Assert.assertEquals(ref2, res); - - // TEST4: date like JJ/MM/AA - // same pattern as header3 : MM/yyyy - DatedHeader header4 = new DatedHeader() { - - @Override - public String datePattern() { - return "MM/yyyy"; - } - - @Override - public String name() { - return "DATE_4"; - } - }; - - res = ImportHelper.readDate(reader, header4); - Assert.assertEquals(ref2, res); - - } - -} \ No newline at end of file Copied: trunk/wao-business/src/test/java/fr/ifremer/wao/io/ImportHelperTest.java (from rev 395, trunk/wao-business/src/test/java/fr/ifremer/wao/ImportHelperTest.java) =================================================================== --- trunk/wao-business/src/test/java/fr/ifremer/wao/io/ImportHelperTest.java (rev 0) +++ trunk/wao-business/src/test/java/fr/ifremer/wao/io/ImportHelperTest.java 2010-04-01 13:28:03 UTC (rev 402) @@ -0,0 +1,334 @@ +/* + * *##% + * 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.io; + +import fr.ifremer.wao.*; +import com.csvreader.CsvReader; +import fr.ifremer.wao.io.WaoCsvHeader.CONTACT; +import fr.ifremer.wao.io.WaoCsvHeader.DatedHeader; +import fr.ifremer.wao.io.WaoCsvHeader.SAMPLING; +import java.io.IOException; +import java.io.InputStream; +import java.nio.charset.Charset; +import java.text.DateFormat; +import java.util.Calendar; +import java.util.Date; +import java.util.GregorianCalendar; +import java.util.Locale; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import org.nuiton.util.DateUtils; +import static org.junit.Assert.*; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * + * @author fdesbois + */ +public class ImportHelperTest { + + private static TestManager manager; + + private static final Logger log = LoggerFactory.getLogger(ImportHelperTest.class); + + private CsvReader reader; + + public ImportHelperTest() { + manager = new TestManager(); + } + + @BeforeClass + public static void setUpClass() throws Exception { + + } + + @AfterClass + public static void tearDownClass() throws Exception { + + } + + @Before + public void setUp() throws WaoExceptionO, IOException { + manager.start(); + + InputStream input = getClass().getResourceAsStream("/import/misc.csv"); + reader = new CsvReader(input, Charset.forName("UTF-8")); + reader.readHeaders(); + } + + @After + public void tearDown() throws WaoExceptionO { + reader.close(); + + manager.stop(); + } + + /** + * Test of getHeaderForContactCsv method, of class ImportHelper. + */ + //@Test + public void testGetHeaderForContactCsv() { + System.out.println("getHeaderForContactCsv"); + } + + /** + * Test of formatContactValidation method, of class ImportHelper. + */ + //@Test + public void testFormatContactValidation() { + System.out.println("formatContactValidation"); + } + + /** + * Test of formatContactMammals method, of class ImportHelper. + */ + //@Test + public void testFormatContactMammals() { + System.out.println("formatContactMammals"); + } + + /** + * Test of parseContactMammals method, of class ImportHelper. + */ + //@Test + public void testParseContactMammals() { + System.out.println("parseContactMammals"); + } + + /** + * Test of formatContactCode method, of class ImportHelper. + */ + @Test + public void testFormatContactCode() { + log.info("formatContactCode"); + Date createDate = manager.getContext().getCurrentDate(); + Calendar calendar = new GregorianCalendar(Locale.FRENCH); + calendar.setTime(createDate); + calendar.set(Calendar.HOUR_OF_DAY, 10); + calendar.set(Calendar.MINUTE, 1); + calendar.set(Calendar.SECOND, 50); + calendar.set(Calendar.MILLISECOND, 260); + String expResult = "100150260"; + DateFormat timeFormat = CONTACT.getTimeFormat(); + String result = timeFormat.format(calendar.getTime()); + assertEquals(expResult, result); + } + + /** + * Test of parseContactCreateDate method, of class ImportHelper. + */ + @Test + public void testParseContactCreateDate() throws Exception { + System.out.println("parseContactCreateDate"); + String code = "101250718"; + Date createDate = manager.getContext().getCurrentDate(); + Calendar calendar = new GregorianCalendar(Locale.FRENCH); + calendar.setTime(createDate); + calendar.set(Calendar.HOUR_OF_DAY, 10); + calendar.set(Calendar.MINUTE, 12); + calendar.set(Calendar.SECOND, 50); + calendar.set(Calendar.MILLISECOND, 718); + Date expResult = calendar.getTime(); + Date result = ImportHelper.parseContactCreateDate(code, "23/10/2009"); + assertEquals(expResult, result); + } + + /** + * Test of logTimeAndMemory method, of class ImportHelper. + */ + //@Test + public void testLogTimeAndMemory() { + System.out.println("logTimeAndMemory"); + } + + /** + * Test of parseContactValidation method, of class ImportHelper. + */ + //@Test + public void testParseContactValidation() throws Exception { + System.out.println("parseContactValidation"); + } + + /** + * Test of readSampleRowCode method, of class ImportHelper. + */ + @Test + public void testReadSampleRowCode() throws Exception { + System.out.println("readSampleRowCode"); + + reader.readRecord(); + String code = ImportHelper.readSampleRowCode(reader); + assertEquals(code, "2009_0001"); + + reader.readRecord(); + code = ImportHelper.readSampleRowCode(reader); + assertEquals(code, "2009_0011"); + + reader.readRecord(); + code = ImportHelper.readSampleRowCode(reader); + assertEquals(code, "2009_0111"); + + reader.readRecord(); + code = ImportHelper.readSampleRowCode(reader); + assertEquals(code, "2009_1111"); + } + + /** + * Test of getContactDateFormat method, of class ImportHelper. + */ + //@Test + public void testGetContactDateFormat() { + System.out.println("getContactDateFormat"); + } + + /** + * Test of read method, of class ImportHelper. + */ + @Test + public void testRead() throws Exception { + log.info("read"); + + reader.readRecord(); + String code = ImportHelper.read(reader, SAMPLING.PLAN_CODE); + assertEquals(code, "2009_1"); + } + + /** + * Test of readInt method, of class ImportHelper. + */ + //@Test + public void testReadInt() throws Exception { + System.out.println("readInt"); + } + + /** + * Test of readInteger method, of class ImportHelper. + */ + //@Test + public void testReadInteger() throws Exception { + System.out.println("readInteger"); + } + + /** + * Test of readPeriod method, of class ImportHelper. + */ + //@Test + public void testReadPeriod() throws Exception { + System.out.println("readPeriod"); + } + + /** + * Test of readDate method, of class ImportHelper. + */ + @Test + public void testReadDate() throws Exception { + log.info("readDate"); + + InputStream stream = + getClass().getResourceAsStream("/import/dates.csv"); + reader = new CsvReader(stream, Charset.forName("UTF-8")); + reader.readHeaders(); + + reader.readRecord(); + + // TEST1 : Date like JJ/MM/AAAA + // normal pattern : dd/MM/yyyy + DatedHeader header1 = new DatedHeader() { + + @Override + public String datePattern() { + return "dd/MM/yyyy"; + } + + @Override + public String name() { + return "DATE_1"; + } + }; + + Date res = ImportHelper.readDate(reader, header1); + Date ref = DateUtils.createDate(10, 2, 2010); + Assert.assertEquals(ref, res); + + // TEST2 : Date like JJ/MM/AA + // same pattern as header1 : dd/MM/yyyy + DatedHeader header2 = new DatedHeader() { + + @Override + public String datePattern() { + return "dd/MM/yyyy"; + } + + @Override + public String name() { + return "DATE_2"; + } + }; + + res = ImportHelper.readDate(reader, header2); + Assert.assertEquals(ref, res); + + // TEST3: date like MM/AAAA + // pattern without day : MM/yyyy + DatedHeader header3 = new DatedHeader() { + + @Override + public String datePattern() { + return "MM/yyyy"; + } + + @Override + public String name() { + return "DATE_3"; + } + }; + + res = ImportHelper.readDate(reader, header3); + Date ref2 = DateUtils.createDate(1, 2, 2010); + Assert.assertEquals(ref2, res); + + // TEST4: date like JJ/MM/AA + // same pattern as header3 : MM/yyyy + DatedHeader header4 = new DatedHeader() { + + @Override + public String datePattern() { + return "MM/yyyy"; + } + + @Override + public String name() { + return "DATE_4"; + } + }; + + res = ImportHelper.readDate(reader, header4); + Assert.assertEquals(ref2, res); + + } + +} Property changes on: trunk/wao-business/src/test/java/fr/ifremer/wao/io/ImportHelperTest.java ___________________________________________________________________ Added: svn:keywords + "Author Date Id Revision HeadURL" Added: svn:mergeinfo + 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 13:27:59 UTC (rev 401) +++ trunk/wao-business/src/test/java/fr/ifremer/wao/service/ActivityCalendarImportTest.java 2010-04-01 13:28:03 UTC (rev 402) @@ -21,10 +21,9 @@ package fr.ifremer.wao.service; -import fr.ifremer.wao.WaoContext; -import fr.ifremer.wao.WaoException; -import fr.ifremer.wao.WaoRunner; -import fr.ifremer.wao.WaoRunnerTest; +import fr.ifremer.wao.WaoExceptionO; +import fr.ifremer.wao.WaoProperty; +import fr.ifremer.wao.TestManager; import java.io.BufferedReader; import java.io.File; import java.io.FileReader; @@ -54,7 +53,7 @@ */ public class ActivityCalendarImportTest { - private static WaoRunner runner; + private static TestManager manager; private static final Logger log = LoggerFactory.getLogger(ActivityCalendarImportTest.class); @@ -63,7 +62,7 @@ @BeforeClass public static void setUpClass() throws Exception { - runner = new WaoRunnerTest(); + manager = new TestManager(); } @AfterClass @@ -71,37 +70,37 @@ } @Before - public void setUp() throws WaoException { - runner.start(); + public void setUp() throws WaoExceptionO { + manager.start(); } @After - public void tearDown() throws WaoException { - runner.stop(); + public void tearDown() throws WaoExceptionO { + manager.stop(); } /** * Test of run method, of class ActivityCalendarImport. */ @Test - public void testRun() throws IOException, InterruptedException, WaoException { + public void testRun() throws IOException, InterruptedException, WaoExceptionO { log.info("run"); - ServiceBoat serviceBoat = new ServiceBoatImpl(); + ServiceBoat serviceBoat = manager.getServiceBoat(); InputStream input = getClass().getResourceAsStream("/import/navires.csv"); serviceBoat.importBoatCsv(input); input = getClass().getResourceAsStream("/import/activity.csv.gz"); input = new GZIPInputStream(input); - ActivityCalendarImport instance = new ActivityCalendarImport(input); + ActivityCalendarImport instance = + new ActivityCalendarImport(manager.getContext(), input); Thread t = new Thread(instance); t.start(); t.join(); - String filename = WaoContext.getProperty( - WaoContext.PROP_FILENAME_LOG_ACTIVITY_IMPORT); + String filename = WaoProperty.FILENAME_LOG_ACTIVITY_IMPORT.getValue(); File file = new File(filename); Assert.assertTrue(file.exists()); 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 13:27:59 UTC (rev 401) +++ trunk/wao-business/src/test/java/fr/ifremer/wao/service/ServiceBoatImplTest.java 2010-04-01 13:28:03 UTC (rev 402) @@ -21,12 +21,11 @@ package fr.ifremer.wao.service; -import fr.ifremer.wao.WaoException; -import fr.ifremer.wao.WaoModelDAOHelper; -import fr.ifremer.wao.WaoRunner; -import fr.ifremer.wao.WaoContext; +import fr.ifremer.wao.WaoExceptionO; +import fr.ifremer.wao.WaoDAOHelper; +import fr.ifremer.wao.WaoProperty; import fr.ifremer.wao.bean.BoatFilterImpl; -import fr.ifremer.wao.WaoRunnerTest; +import fr.ifremer.wao.TestManager; import fr.ifremer.wao.bean.BoatFilter; import fr.ifremer.wao.bean.CompanyBoatInfos; import fr.ifremer.wao.bean.ContactState; @@ -72,18 +71,18 @@ */ public class ServiceBoatImplTest { - private static WaoRunner runner; + private static TestManager manager; private static final Logger log = LoggerFactory.getLogger(ServiceBoatImplTest.class); - private ServiceBoatImpl service; + private ServiceBoat service; public ServiceBoatImplTest() { } @BeforeClass public static void setUpClass() throws Exception { - runner = new WaoRunnerTest(); + manager = new TestManager(); } @AfterClass @@ -92,13 +91,13 @@ @Before public void setUp() throws Exception { - runner.start(); - service = new ServiceBoatImpl(); + manager.start(); + service = manager.getServiceBoat(); } @After public void tearDown() throws Exception { - runner.stop(); + manager.stop(); } /** @@ -112,7 +111,7 @@ InputStream input = getClass().getResourceAsStream("/import/navires.csv"); service.importBoatCsv(input); - ServiceUser serviceUser = new ServiceUserImpl(); + ServiceUser serviceUser = manager.getServiceUser(); Company company = new CompanyImpl(); company.setName("TARTANPION"); serviceUser.createUpdateCompany(company); @@ -205,25 +204,25 @@ } private List<SampleRow> prepareSampleRows(Company company) - throws WaoException, TopiaException { - ServiceReferential serviceReferential = new ServiceReferentialImpl(); + throws WaoExceptionO, TopiaException { + ServiceReferential serviceReferential = manager.getServiceReferential(); InputStream input = getClass().getResourceAsStream("/import/zonesPeche.csv"); serviceReferential.importFishingZoneCsv(input); - TopiaContext transaction = WaoContext.getTopiaRootContext().beginTransaction(); + TopiaContext transaction = manager.getContext().beginTransaction(); // Create a company - CompanyDAO companyDAO = WaoModelDAOHelper.getCompanyDAO(transaction); - WaoContext.prepareTopiaId(Company.class, company); + CompanyDAO companyDAO = WaoDAOHelper.getCompanyDAO(transaction); + manager.getContext().prepareTopiaId(Company.class, company); companyDAO.update(company); companyDAO.create(Company.NAME, "BIS"); transaction.commitTransaction(); - ServiceSampling serviceSampling = new ServiceSamplingImpl(); + ServiceSampling serviceSampling = manager.getServiceSampling(); input = getClass().getResourceAsStream("/import/echantillonnage.csv"); serviceSampling.importSamplingPlanCsv(input); // Get two SampleRows : 2009_3 & 2010_4 - SampleRowDAO rowDAO = WaoModelDAOHelper.getSampleRowDAO(transaction); + SampleRowDAO rowDAO = WaoDAOHelper.getSampleRowDAO(transaction); SampleRow row1 = rowDAO.findByCode("2009_0003"); row1.getProfession(); row1.sizeElligibleBoat(); @@ -260,7 +259,7 @@ Boat boat = boats.get(0); // Two rows created : 2009_3 & 2010_4 and one Company : "TARTANPION" - ServiceUser serviceUser = new ServiceUserImpl(); + ServiceUser serviceUser = manager.getServiceUser(); Company company = new CompanyImpl(); company.setName("TARTANPION"); serviceUser.createUpdateCompany(company); @@ -272,14 +271,14 @@ serviceUser.createUpdateUser(user, true); List<SampleRow> rows = prepareSampleRows(company); - TopiaContext transaction = WaoContext.getTopiaRootContext().beginTransaction(); - SampleRowDAO rowDAO = WaoModelDAOHelper.getSampleRowDAO(transaction); + TopiaContext transaction = manager.getContext().beginTransaction(); + SampleRowDAO rowDAO = WaoDAOHelper.getSampleRowDAO(transaction); SampleRow row = rowDAO.findByCode("2010_0001"); row.getCompany(); row.getProfession(); transaction.closeContext(); - ServiceContact serviceContact = new ServiceContactImpl(); + ServiceContact serviceContact = manager.getServiceContact(); Contact contact1 = serviceContact.getNewContact(user, row, boat); contact1.setContactState(ContactState.CONTACT_START); serviceContact.saveContact(contact1, false); @@ -360,14 +359,14 @@ log.info("getLastActivityCalendar"); /** PREPARE DATA **/ - TopiaContext transaction = WaoContext.getTopiaRootContext().beginTransaction(); + TopiaContext transaction = manager.getContext().beginTransaction(); - BoatDAO boatDAO = WaoModelDAOHelper.getBoatDAO(transaction); + BoatDAO boatDAO = WaoDAOHelper.getBoatDAO(transaction); Boat boat = boatDAO.create( Boat.NAME, "TESTBOAT", Boat.IMMATRICULATION, 174592); - ActivityCalendarDAO dao = WaoModelDAOHelper.getActivityCalendarDAO(transaction); + ActivityCalendarDAO dao = WaoDAOHelper.getActivityCalendarDAO(transaction); ActivityCalendar calendar1 = dao.create( ActivityCalendar.BOAT, boat, @@ -399,9 +398,12 @@ Assert.assertNotNull(result); Assert.assertEquals(2009, result.getYear()); - String filename = WaoContext.getProperty( - WaoContext.PROP_FILENAME_LOG_ACTIVITY_ACCESS); + String filename = WaoProperty.FILENAME_LOG_ACTIVITY_ACCESS.getValue(); + if (log.isDebugEnabled()) { + log.debug("ActivityCalendar filename for access : " + filename); + } + File file = new File(filename); Assert.assertTrue(file.exists()); 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 13:27:59 UTC (rev 401) +++ trunk/wao-business/src/test/java/fr/ifremer/wao/service/ServiceReferentialImplTest.java 2010-04-01 13:28:03 UTC (rev 402) @@ -21,9 +21,9 @@ package fr.ifremer.wao.service; -import fr.ifremer.wao.WaoException; +import fr.ifremer.wao.WaoExceptionO; import fr.ifremer.wao.WaoRunner; -import fr.ifremer.wao.WaoRunnerTest; +import fr.ifremer.wao.TestManager; import fr.ifremer.wao.bean.SamplingFilter; import fr.ifremer.wao.bean.SamplingFilterImpl; import fr.ifremer.wao.entity.FishingZone; @@ -44,18 +44,18 @@ */ public class ServiceReferentialImplTest { - private static WaoRunner runner; + private static TestManager manager; private static final Logger log = LoggerFactory.getLogger(ServiceReferentialImplTest.class); - private ServiceReferentialImpl service; + private ServiceReferential service; public ServiceReferentialImplTest() { } @BeforeClass public static void setUpClass() throws Exception { - runner = new WaoRunnerTest(); + manager = new TestManager(); } @AfterClass @@ -64,13 +64,13 @@ @Before public void setUp() throws Exception { - runner.start(); - service = new ServiceReferentialImpl(); + manager.start(); + service = manager.getServiceReferential(); } @After public void tearDown() throws Exception { - runner.stop(); + manager.stop(); } /** @@ -128,7 +128,7 @@ * @throws WaoException if error during import or getFishingZones */ @Test - public void testGetFishingZones() throws WaoException { + public void testGetFishingZones() throws WaoExceptionO { log.info("getFishingZones"); InputStream input = getClass().getResourceAsStream("/import/zonesPeche.csv"); @@ -144,7 +144,7 @@ * @throws WaoException if import error */ @Test - public void testImportFishingZoneCsv() throws WaoException { + public void testImportFishingZoneCsv() throws WaoExceptionO { 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 13:27:59 UTC (rev 401) +++ trunk/wao-business/src/test/java/fr/ifremer/wao/service/ServiceSamplingImplTest.java 2010-04-01 13:28:03 UTC (rev 402) @@ -21,14 +21,13 @@ package fr.ifremer.wao.service; -import fr.ifremer.wao.WaoException; -import fr.ifremer.wao.WaoModelDAOHelper; -import fr.ifremer.wao.WaoRunner; -import fr.ifremer.wao.WaoContext; +import fr.ifremer.wao.WaoExceptionO; +import fr.ifremer.wao.WaoDAOHelper; +import fr.ifremer.wao.WaoContextO; import fr.ifremer.wao.bean.ImportResults; import fr.ifremer.wao.bean.SamplingFilter; import fr.ifremer.wao.bean.SamplingFilterImpl; -import fr.ifremer.wao.WaoRunnerTest; +import fr.ifremer.wao.TestManager; import fr.ifremer.wao.bean.FacadeRow; import fr.ifremer.wao.entity.Boat; import fr.ifremer.wao.entity.Company; @@ -79,18 +78,18 @@ */ public class ServiceSamplingImplTest { - private static WaoRunner runner; + private static TestManager manager; private static final Logger log = LoggerFactory.getLogger(ServiceSamplingImplTest.class); - private ServiceSamplingImpl service; + private ServiceSampling service; public ServiceSamplingImplTest() { } @BeforeClass public static void setUpClass() throws Exception { - runner = new WaoRunnerTest(); + manager = new TestManager(); } @AfterClass @@ -99,13 +98,13 @@ @Before public void setUp() throws Exception { - runner.start(); - service = new ServiceSamplingImpl(); + manager.start(); + service = manager.getServiceSampling(); } @After public void tearDown() throws Exception { - runner.stop(); + manager.stop(); } @Test @@ -113,12 +112,12 @@ log.info("createUpdateSampleRow"); /** PREPARE DATA **/ - TopiaContext transaction = WaoContext.getTopiaRootContext().beginTransaction(); + TopiaContext transaction = manager.getContext().beginTransaction(); List<FishingZone> zones = prepareFishingZones(transaction); InputStream input = getClass().getResourceAsStream("/import/navires.csv"); - ServiceBoat serviceBoat = new ServiceBoatImpl(); + ServiceBoatImpl serviceBoat = (ServiceBoatImpl) manager.getServiceBoat(); serviceBoat.importBoatCsv(input); transaction.closeContext(); @@ -175,6 +174,14 @@ result = service.getSampleRow(row.getTopiaId()); assertEquals(2, result.getElligibleBoat().size()); + // TEST FOR REMOVE FISHING ZONE + //FishingZone zone = result.getFishingZone().get(0); + result.getFishingZone().remove(0); + service.createUpdateSampleRow(result, boats, new SampleRowLogImpl()); + + result = service.getSampleRow(row.getTopiaId()); + assertEquals(2, result.getFishingZone().size()); + } /** @@ -187,7 +194,7 @@ /** PREPARE DATA **/ - TopiaContext transaction = WaoContext.getTopiaRootContext().beginTransaction(); + TopiaContext transaction = manager.getContext().beginTransaction(); List<FishingZone> zones = prepareFishingZones(transaction); @@ -201,7 +208,7 @@ Date dateEnd2 = DateUtils.createDate(1, 12, 2008); PeriodDates period2 = new PeriodDates(dateBegin2, dateEnd2); - SampleRowDAO dao = WaoModelDAOHelper.getSampleRowDAO(transaction); + SampleRowDAO dao = WaoDAOHelper.getSampleRowDAO(transaction); SampleRow row1 = dao.create(); row1.setCode("2010_0001"); @@ -291,9 +298,9 @@ } - private List<FishingZone> prepareFishingZones(TopiaContext transaction) throws WaoException, TopiaException { + private List<FishingZone> prepareFishingZones(TopiaContext transaction) throws WaoExceptionO, TopiaException { - FishingZoneDAO fishingZoneDAO = WaoModelDAOHelper.getFishingZoneDAO(transaction); + FishingZoneDAO fishingZoneDAO = WaoDAOHelper.getFishingZoneDAO(transaction); FishingZone fishingZone1 = fishingZoneDAO.create(); fishingZone1.setFacadeName("Atlantique"); @@ -318,18 +325,18 @@ public void testGetSampleRowsForUser() throws Exception { log.info("getSampleRowsForUser"); /** PREPARE DATA **/ - TopiaContext transaction = WaoContext.getTopiaRootContext().beginTransaction(); + TopiaContext transaction = manager.getContext().beginTransaction(); - FishingZoneDAO zoneDAO = WaoModelDAOHelper.getFishingZoneDAO(transaction); + FishingZoneDAO zoneDAO = WaoDAOHelper.getFishingZoneDAO(transaction); FishingZone zoneIId = zoneDAO.create(FishingZone.DISTRICT_CODE, "IId"); FishingZone zoneIV = zoneDAO.create(FishingZone.DISTRICT_CODE, "IV"); FishingZone zoneI = zoneDAO.create(FishingZone.DISTRICT_CODE, "I"); - CompanyDAO companyDAO = WaoModelDAOHelper.getCompanyDAO(transaction); + CompanyDAO companyDAO = WaoDAOHelper.getCompanyDAO(transaction); Company company = companyDAO.create(Company.NAME, "TARTANPION"); Calendar begin = new GregorianCalendar(2009,8,1); Calendar end = new GregorianCalendar(2010,11,31); - SampleRowDAO sampleRowDAO = WaoModelDAOHelper.getSampleRowDAO(transaction); + SampleRowDAO sampleRowDAO = WaoDAOHelper.getSampleRowDAO(transaction); SampleRow row = sampleRowDAO.create( SampleRow.CODE,"2010_178", SampleRow.COMPANY,company, @@ -383,9 +390,9 @@ /** PREPARE DATA **/ - TopiaContext transaction = WaoContext.getTopiaRootContext().beginTransaction(); + TopiaContext transaction = manager.getContext().beginTransaction(); - ProfessionDAO dao = WaoModelDAOHelper.getProfessionDAO(transaction); + ProfessionDAO dao = WaoDAOHelper.getProfessionDAO(transaction); Profession profession = dao.create( Profession.CODE_DCF5, "OBR", @@ -413,14 +420,14 @@ log.info("deleteSampleRow"); /** PREPARE DATA **/ - TopiaContext transaction = WaoContext.getTopiaRootContext().beginTransaction(); + TopiaContext transaction = manager.getContext().beginTransaction(); - FishingZoneDAO zoneDAO = WaoModelDAOHelper.getFishingZoneDAO(transaction); + FishingZoneDAO zoneDAO = WaoDAOHelper.getFishingZoneDAO(transaction); FishingZone zoneIId = zoneDAO.create(FishingZone.DISTRICT_CODE, "IId"); FishingZone zoneIV = zoneDAO.create(FishingZone.DISTRICT_CODE, "IV"); FishingZone zoneI = zoneDAO.create(FishingZone.DISTRICT_CODE, "I"); - CompanyDAO companyDAO = WaoModelDAOHelper.getCompanyDAO(transaction); + CompanyDAO companyDAO = WaoDAOHelper.getCompanyDAO(transaction); companyDAO.create(Company.NAME, "TARTANPION"); companyDAO.create(Company.NAME, "BIS"); transaction.commitTransaction(); @@ -429,7 +436,7 @@ InputStream input = getClass().getResourceAsStream("/import/echantillonnage.csv"); service.importSamplingPlanCsv(input); - SampleRowDAO rowDAO = WaoModelDAOHelper.getSampleRowDAO(transaction); + SampleRowDAO rowDAO = WaoDAOHelper.getSampleRowDAO(transaction); SampleRow row = rowDAO.findByCode("2010_0001"); row.getProfession(); row.getCompany(); @@ -438,7 +445,7 @@ transaction.closeContext(); input = getClass().getResourceAsStream("/import/navires.csv"); - ServiceBoat serviceBoat = new ServiceBoatImpl(); + ServiceBoat serviceBoat = manager.getServiceBoat(); serviceBoat.importBoatCsv(input); List<Boat> boats = serviceBoat.getBoatsByImmatriculations("174592 978419 273129"); @@ -446,30 +453,30 @@ /** EXEC METHOD **/ service.deleteSampleRow(row); - transaction = WaoContext.getTopiaRootContext().beginTransaction(); - rowDAO = WaoModelDAOHelper.getSampleRowDAO(transaction); + transaction = manager.getContext().beginTransaction(); + rowDAO = WaoDAOHelper.getSampleRowDAO(transaction); row = rowDAO.findByCode("2010_0001"); assertNull(row); - ElligibleBoatDAO elligibleDAO = WaoModelDAOHelper.getElligibleBoatDAO(transaction); + ElligibleBoatDAO elligibleDAO = WaoDAOHelper.getElligibleBoatDAO(transaction); List<ElligibleBoat> elligibles = elligibleDAO.findAll(); assertEquals(0, elligibles.size()); transaction.closeContext(); } @Test - public void testImportSamplingPlanCsv() throws WaoException, TopiaException { + public void testImportSamplingPlanCsv() throws WaoExceptionO, TopiaException { log.info("importSamplingPlanCsv"); /** PREPARE DATA **/ - TopiaContext transaction = WaoContext.getTopiaRootContext().beginTransaction(); + TopiaContext transaction = manager.getContext().beginTransaction(); - FishingZoneDAO zoneDAO = WaoModelDAOHelper.getFishingZoneDAO(transaction); + FishingZoneDAO zoneDAO = WaoDAOHelper.getFishingZoneDAO(transaction); FishingZone zoneIId = zoneDAO.create(FishingZone.DISTRICT_CODE, "IId"); FishingZone zoneIV = zoneDAO.create(FishingZone.DISTRICT_CODE, "IV"); FishingZone zoneI = zoneDAO.create(FishingZone.DISTRICT_CODE, "I"); - CompanyDAO companyDAO = WaoModelDAOHelper.getCompanyDAO(transaction); + CompanyDAO companyDAO = WaoDAOHelper.getCompanyDAO(transaction); companyDAO.create(Company.NAME, "TARTANPION"); companyDAO.create(Company.NAME, "BIS"); transaction.commitTransaction(); @@ -485,9 +492,9 @@ assertEquals(1, result.getNbRowsRefused()); /** CHECK VALUES **/ - transaction = WaoContext.getTopiaRootContext().beginTransaction(); + transaction = manager.getContext().beginTransaction(); - SampleRowDAO rowDAO = WaoModelDAOHelper.getSampleRowDAO(transaction); + SampleRowDAO rowDAO = WaoDAOHelper.getSampleRowDAO(transaction); // Error #2221 : don't keep the same profession for two different rows SampleRow row2 = rowDAO.findByCode("2010_0010"); @@ -495,7 +502,7 @@ assertNotSame(row2.getProfession(), row3.getProfession()); ProfessionDAO professionDAO = - WaoModelDAOHelper.getProfessionDAO(transaction); + WaoDAOHelper.getProfessionDAO(transaction); List<Profession> professions = professionDAO.findAll(); assertEquals(12, professions.size()); @@ -526,14 +533,14 @@ @Test public void testGetPrograms() throws Exception { /** PREPARE DATA **/ - TopiaContext transaction = WaoContext.getTopiaRootContext().beginTransaction(); + TopiaContext transaction = manager.getContext().beginTransaction(); - FishingZoneDAO zoneDAO = WaoModelDAOHelper.getFishingZoneDAO(transaction); + FishingZoneDAO zoneDAO = WaoDAOHelper.getFishingZoneDAO(transaction); zoneDAO.create(FishingZone.DISTRICT_CODE, "IId"); zoneDAO.create(FishingZone.DISTRICT_CODE, "IV"); zoneDAO.create(FishingZone.DISTRICT_CODE, "I"); - CompanyDAO companyDAO = WaoModelDAOHelper.getCompanyDAO(transaction); + CompanyDAO companyDAO = WaoDAOHelper.getCompanyDAO(transaction); companyDAO.create(Company.NAME, "TARTANPION"); companyDAO.create(Company.NAME, "BIS"); transaction.commitTransaction(); @@ -553,19 +560,19 @@ log.info("getNewSampleRowCode"); /** PREPARE DATA **/ - TopiaContext transaction = WaoContext.getTopiaRootContext().beginTransaction(); + TopiaContext transaction = manager.getContext().beginTransaction(); - FishingZoneDAO zoneDAO = WaoModelDAOHelper.getFishingZoneDAO(transaction); + FishingZoneDAO zoneDAO = WaoDAOHelper.getFishingZoneDAO(transaction); FishingZone zoneIId = zoneDAO.create(FishingZone.DISTRICT_CODE, "IId"); FishingZone zoneIV = zoneDAO.create(FishingZone.DISTRICT_CODE, "IV"); FishingZone zoneI = zoneDAO.create(FishingZone.DISTRICT_CODE, "I"); - CompanyDAO companyDAO = WaoModelDAOHelper.getCompanyDAO(transaction); + CompanyDAO companyDAO = WaoDAOHelper.getCompanyDAO(transaction); companyDAO.create(Company.NAME, "TARTANPION"); companyDAO.create(Company.NAME, "BIS"); transaction.commitTransaction(); - ServiceSampling serviceSampling = new ServiceSamplingImpl(); + ServiceSampling serviceSampling = manager.getServiceSampling(); InputStream input = getClass().getResourceAsStream("/import/echantillonnage.csv"); serviceSampling.importSamplingPlanCsv(input); Modified: trunk/wao-business/src/test/java/fr/ifremer/wao/service/ServiceSynthesisImplTest.java =================================================================== --- trunk/wao-business/src/test/java/fr/ifremer/wao/service/ServiceSynthesisImplTest.java 2010-04-01 13:27:59 UTC (rev 401) +++ trunk/wao-business/src/test/java/fr/ifremer/wao/service/ServiceSynthesisImplTest.java 2010-04-01 13:28:03 UTC (rev 402) @@ -21,10 +21,8 @@ package fr.ifremer.wao.service; -import fr.ifremer.wao.WaoContext; -import fr.ifremer.wao.WaoModelDAOHelper; -import fr.ifremer.wao.WaoRunner; -import fr.ifremer.wao.WaoRunnerTest; +import fr.ifremer.wao.WaoDAOHelper; +import fr.ifremer.wao.TestManager; import fr.ifremer.wao.bean.BoardingResult; import fr.ifremer.wao.bean.ContactAverageReactivity; import fr.ifremer.wao.bean.ContactState; @@ -48,7 +46,6 @@ import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; -import org.junit.Ignore; import org.junit.Test; import org.nuiton.topia.TopiaContext; import org.nuiton.util.DateUtils; @@ -63,18 +60,18 @@ */ public class ServiceSynthesisImplTest { - private static WaoRunner runner; + private static TestManager manager; private static final Logger log = LoggerFactory.getLogger(ServiceSynthesisImplTest.class); - private ServiceSynthesisImpl service; + private ServiceSynthesis service; public ServiceSynthesisImplTest() { } @BeforeClass public static void setUpClass() throws Exception { - runner = new WaoRunnerTest(); + manager = new TestManager(); } @AfterClass @@ -83,13 +80,13 @@ @Before public void setUp() throws Exception { - runner.start(); - service = new ServiceSynthesisImpl(); + manager.start(); + service = manager.getServiceSynthesis(); } @After public void tearDown() throws Exception { - runner.stop(); + manager.stop(); } /** @@ -108,7 +105,7 @@ log.info("getBoardingBoats"); /** PREPARE DATA **/ InputStream input = getClass().getResourceAsStream("/import/navires.csv"); - ServiceBoat serviceBoat = new ServiceBoatImpl(); + ServiceBoat serviceBoat = manager.getServiceBoat(); serviceBoat.importBoatCsv(input); List<Boat> boats = serviceBoat.getBoatsByImmatriculations("174258"); Boat boat = boats.get(0); @@ -116,13 +113,13 @@ List<Boat> boats2 = serviceBoat.getBoatsByImmatriculations("177474"); Boat boat2 = boats2.get(0); - TopiaContext transaction = WaoContext.getTopiaRootContext().beginTransaction(); + TopiaContext transaction = manager.getContext().beginTransaction(); - CompanyDAO companyDAO = WaoModelDAOHelper.getCompanyDAO(transaction); + CompanyDAO companyDAO = WaoDAOHelper.getCompanyDAO(transaction); Company company = companyDAO.create(Company.NAME, "TARTANPION"); Company company2 = companyDAO.create(Company.NAME, "BIS"); - WaoUserDAO userDAO = WaoModelDAOHelper.getWaoUserDAO(transaction); + WaoUserDAO userDAO = WaoDAOHelper.getWaoUserDAO(transaction); WaoUser user = userDAO.create(WaoUser.FIRST_NAME,"Jean", WaoUser.LAST_NAME, "Michmuche", WaoUser.COMPANY, company); company.addWaoUser(user); @@ -133,20 +130,20 @@ transaction.commitTransaction(); input = getClass().getResourceAsStream("/import/zonesPeche.csv"); - ServiceReferential serviceReferential = new ServiceReferentialImpl(); + ServiceReferential serviceReferential = manager.getServiceReferential(); serviceReferential.importFishingZoneCsv(input); input = getClass().getResourceAsStream("/import/echantillonnage.csv"); - ServiceSampling serviceSampling = new ServiceSamplingImpl(); + ServiceSampling serviceSampling = manager.getServiceSampling(); serviceSampling.importSamplingPlanCsv(input); - SampleRowDAO rowDAO = WaoModelDAOHelper.getSampleRowDAO(transaction); + SampleRowDAO rowDAO = WaoDAOHelper.getSampleRowDAO(transaction); SampleRow row = rowDAO.findByCode("2010_0001"); transaction.closeContext(); - ServiceContact serviceContact = new ServiceContactImpl(); + ServiceContact serviceContact = manager.getServiceContact(); // First contact : OK Contact contact1 = new ContactImpl(); contact1.setBoat(boat); @@ -196,7 +193,7 @@ log.info("getNonComplianceBoardingIndicator"); /** PREPARE DATA **/ InputStream input = getClass().getResourceAsStream("/import/navires.csv"); - ServiceBoat serviceBoat = new ServiceBoatImpl(); + ServiceBoat serviceBoat = manager.getServiceBoat(); serviceBoat.importBoatCsv(input); List<Boat> boats = serviceBoat.getBoatsByImmatriculations("174258"); Boat boat = boats.get(0); @@ -204,13 +201,13 @@ List<Boat> boats2 = serviceBoat.getBoatsByImmatriculations("177474"); Boat boat2 = boats2.get(0); - TopiaContext transaction = WaoContext.getTopiaRootContext().beginTransaction(); + TopiaContext transaction = manager.getContext().beginTransaction(); - CompanyDAO companyDAO = WaoModelDAOHelper.getCompanyDAO(transaction); + CompanyDAO companyDAO = WaoDAOHelper.getCompanyDAO(transaction); Company company = companyDAO.create(Company.NAME, "TARTANPION"); Company company2 = companyDAO.create(Company.NAME, "BIS"); - WaoUserDAO userDAO = WaoModelDAOHelper.getWaoUserDAO(transaction); + WaoUserDAO userDAO = WaoDAOHelper.getWaoUserDAO(transaction); WaoUser user = userDAO.create(WaoUser.FIRST_NAME,"Jean", WaoUser.LAST_NAME, "Michmuche", WaoUser.COMPANY, company); company.addWaoUser(user); @@ -221,21 +218,21 @@ transaction.commitTransaction(); input = getClass().getResourceAsStream("/import/zonesPeche.csv"); - ServiceReferential serviceReferential = new ServiceReferentialImpl(); + ServiceReferential serviceReferential = manager.getServiceReferential(); serviceReferential.importFishingZoneCsv(input); input = getClass().getResourceAsStream("/import/echantillonnage.csv"); - ServiceSampling serviceSampling = new ServiceSamplingImpl(); + ServiceSampling serviceSampling = manager.getServiceSampling(); serviceSampling.importSamplingPlanCsv(input); - SampleRowDAO rowDAO = WaoModelDAOHelper.getSampleRowDAO(transaction); + SampleRowDAO rowDAO = WaoDAOHelper.getSampleRowDAO(transaction); SampleRow row = rowDAO.findByCode("2010_0001"); SampleRow row2 = rowDAO.findByCode("2009_0006"); transaction.closeContext(); - ServiceContact serviceContact = new ServiceContactImpl(); + ServiceContact serviceContact = manager.getServiceContact(); // First contact : OK Contact contact1 = new ContactImpl(); contact1.setBoat(boat); @@ -303,7 +300,7 @@ log.info("getContactStateStatistics"); /** PREPARE DATA **/ InputStream input = getClass().getResourceAsStream("/import/navires.csv"); - ServiceBoat serviceBoat = new ServiceBoatImpl(); + ServiceBoat serviceBoat = manager.getServiceBoat(); serviceBoat.importBoatCsv(input); List<Boat> boats = serviceBoat.getBoatsByImmatriculations("174258"); Boat boat = boats.get(0); @@ -311,13 +308,13 @@ List<Boat> boats2 = serviceBoat.getBoatsByImmatriculations("177474"); Boat boat2 = boats2.get(0); - TopiaContext transaction = WaoContext.getTopiaRootContext().beginTransaction(); + TopiaContext transaction = manager.getContext().beginTransaction(); - CompanyDAO companyDAO = WaoModelDAOHelper.getCompanyDAO(transaction); + CompanyDAO companyDAO = WaoDAOHelper.getCompanyDAO(transaction); Company company = companyDAO.create(Company.NAME, "TARTANPION"); Company company2 = companyDAO.create(Company.NAME, "BIS"); - WaoUserDAO userDAO = WaoModelDAOHelper.getWaoUserDAO(transaction); + WaoUserDAO userDAO = WaoDAOHelper.getWaoUserDAO(transaction); WaoUser user = userDAO.create(WaoUser.FIRST_NAME,"Jean", WaoUser.LAST_NAME, "Michmuche", WaoUser.COMPANY, company); company.addWaoUser(user); @@ -328,20 +325,20 @@ transaction.commitTransaction(); input = getClass().getResourceAsStream("/import/zonesPeche.csv"); - ServiceReferential serviceReferential = new ServiceReferentialImpl(); + ServiceReferential serviceReferential = manager.getServiceReferential(); serviceReferential.importFishingZoneCsv(input); input = getClass().getResourceAsStream("/import/echantillonnage.csv"); - ServiceSampling serviceSampling = new ServiceSamplingImpl(); + ServiceSampling serviceSampling = manager.getServiceSampling(); serviceSampling.importSamplingPlanCsv(input); - SampleRowDAO rowDAO = WaoModelDAOHelper.getSampleRowDAO(transaction); + SampleRowDAO rowDAO = WaoDAOHelper.getSampleRowDAO(transaction); SampleRow row = rowDAO.findByCode("2010_0001"); transaction.closeContext(); - ServiceContact serviceContact = new ServiceContactImpl(); + ServiceContact serviceContact = manager.getServiceContact(); // Contacts for company TARTANPION Contact contact1 = new ContactImpl(); @@ -446,7 +443,7 @@ log.info("getContactDataInputDateReactivity"); /** PREPARE DATA **/ InputStream input = getClass().getResourceAsStream("/import/navires.csv"); - ServiceBoat serviceBoat = new ServiceBoatImpl(); + ServiceBoat serviceBoat = manager.getServiceBoat(); serviceBoat.importBoatCsv(input); List<Boat> boats = serviceBoat.getBoatsByImmatriculations("174258"); Boat boat = boats.get(0); @@ -454,13 +451,13 @@ List<Boat> boats2 = serviceBoat.getBoatsByImmatriculations("177474"); Boat boat2 = boats2.get(0); - TopiaContext transaction = WaoContext.getTopiaRootContext().beginTransaction(); + TopiaContext transaction = manager.getContext().beginTransaction(); - CompanyDAO companyDAO = WaoModelDAOHelper.getCompanyDAO(transaction); + CompanyDAO companyDAO = WaoDAOHelper.getCompanyDAO(transaction); Company company = companyDAO.create(Company.NAME, "TARTANPION"); Company company2 = companyDAO.create(Company.NAME, "BIS"); - WaoUserDAO userDAO = WaoModelDAOHelper.getWaoUserDAO(transaction); + WaoUserDAO userDAO = WaoDAOHelper.getWaoUserDAO(transaction); WaoUser user = userDAO.create(WaoUser.FIRST_NAME,"Jean", WaoUser.LAST_NAME, "Michmuche", WaoUser.COMPANY, company); company.addWaoUser(user); @@ -471,21 +468,21 @@ transaction.commitTransaction(); input = getClass().getResourceAsStream("/import/zonesPeche.csv"); - ServiceReferential serviceReferential = new ServiceReferentialImpl(); + ServiceReferential serviceReferential = manager.getServiceReferential(); serviceReferential.importFishingZoneCsv(input); input = getClass().getResourceAsStream("/import/echantillonnage.csv"); - ServiceSampling serviceSampling = new ServiceSamplingImpl(); + ServiceSampling serviceSampling = manager.getServiceSampling(); serviceSampling.importSamplingPlanCsv(input); - SampleRowDAO rowDAO = WaoModelDAOHelper.getSampleRowDAO(transaction); + SampleRowDAO rowDAO = WaoDAOHelper.getSampleRowDAO(transaction); SampleRow row = rowDAO.findByCode("2010_0001"); SampleRow row2 = rowDAO.findByCode("2009_0006"); transaction.closeContext(); - ServiceContact serviceContact = new ServiceContactImpl(); + ServiceContact serviceContact = manager.getServiceContact(); // First contact : OK Contact contact1 = new ContactImpl(); contact1.setObserver(user); Modified: trunk/wao-business/src/test/java/fr/ifremer/wao/service/ServiceUserImplTest.java =================================================================== --- trunk/wao-business/src/test/java/fr/ifremer/wao/service/ServiceUserImplTest.java 2010-04-01 13:27:59 UTC (rev 401) +++ trunk/wao-business/src/test/java/fr/ifremer/wao/service/ServiceUserImplTest.java 2010-04-01 13:28:03 UTC (rev 402) @@ -1,8 +1,7 @@ package fr.ifremer.wao.service; -import fr.ifremer.wao.WaoRunner; -import fr.ifremer.wao.WaoRunnerTest; +import fr.ifremer.wao.TestManager; import fr.ifremer.wao.bean.UserRole; import fr.ifremer.wao.entity.Company; import fr.ifremer.wao.entity.CompanyImpl; @@ -24,19 +23,19 @@ */ public class ServiceUserImplTest { - private static WaoRunner runner; + private static TestManager manager; private static final Logger logger = LoggerFactory.getLogger(ServiceUserImplTest.class); - private ServiceUserImpl service; + private ServiceUser service; public ServiceUserImplTest() { } @BeforeClass public static void setUpClass() throws Exception { - runner = new WaoRunnerTest(); + manager = new TestManager(); } @AfterClass @@ -45,13 +44,13 @@ @Before public void setUp() throws Exception { - runner.start(); - service = new ServiceUserImpl(); + manager.start(); + service = manager.getServiceUser(); } @After public void tearDown() throws Exception { - runner.stop(); + manager.stop(); } /** Modified: trunk/wao-business/src/test/resources/log4j.properties =================================================================== --- trunk/wao-business/src/test/resources/log4j.properties 2010-04-01 13:27:59 UTC (rev 401) +++ trunk/wao-business/src/test/resources/log4j.properties 2010-04-01 13:28:03 UTC (rev 402) @@ -8,6 +8,6 @@ log4j.appender.A1.layout=org.apache.log4j.PatternLayout log4j.appender.A1.layout.ConversionPattern=%d [%p] %c{2} %m%n -log4j.logger.fr.ifremer.wao=INFO +log4j.logger.fr.ifremer.wao=DEBUG log4j.logger.org.nuiton.util=INFO log4j.logger.org.nuiton.util.beans.BinderProvider=ERROR 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 13:27:59 UTC (rev 401) +++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/base/AbstractFilteredPage.java 2010-04-01 13:28:03 UTC (rev 402) @@ -21,7 +21,7 @@ package fr.ifremer.wao.ui.base; -import fr.ifremer.wao.WaoException; +import fr.ifremer.wao.WaoExceptionO; 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 WaoException { + protected void initSelectFilters(boolean companySelect, boolean observerSelect, boolean programSelect) throws WaoExceptionO { this.observerSelect = observerSelect; this.programSelect = programSelect; @@ -185,22 +185,22 @@ resetSampleRowSelect(); } - protected void resetCompanySelect() throws WaoException { + protected void resetCompanySelect() throws WaoExceptionO { companySelectModel = null; getCompanySelectModel(); } - protected void resetFacadeSelect() throws WaoException { + protected void resetFacadeSelect() throws WaoExceptionO { facadeSelectModel = null; getFacadeSelectModel(); } - protected void resetSectorSelect() throws WaoException { + protected void resetSectorSelect() throws WaoExceptionO { sectorSelectModel = null; getSectorSelectModel(); } - protected void resetSampleRowSelect() throws WaoException { + protected void resetSampleRowSelect() throws WaoExceptionO { sampleRowSelectModel = null; getSampleRowSelectModel(); } @@ -212,11 +212,8 @@ * @return the SelectModel for facade names * @throws WaoException */ - public SelectModel getFacadeSelectModel() throws WaoException { + public SelectModel getFacadeSelectModel() throws WaoExceptionO { if (facadeSelectModel == null) { - if (log.isInfoEnabled()) { - log.info("BUSINESS REQUEST [getFacades]"); - } List<OptionModel> options = new ArrayList<OptionModel>(); for (String facadeName : serviceReferential.getFacades(getFilter())) { options.add(new OptionModelImpl(facadeName,facadeName)); @@ -233,11 +230,8 @@ * @return the SelectModel for sector names * @throws WaoException */ - public SelectModel getSectorSelectModel() throws WaoException { + public SelectModel getSectorSelectModel() throws WaoExceptionO { if (sectorSelectModel == null) { - if (log.isInfoEnabled()) { - log.info("BUSINESS REQUEST [getSectors]"); - } List<OptionModel> options = new ArrayList<OptionModel>(); for (String sectorName : serviceReferential.getSectors(getFilter())) { options.add(new OptionModelImpl(sectorName,sectorName)); @@ -255,12 +249,8 @@ * @return the GenericSelectModel<SampleRow> for sampleRows * @throws WaoException */ - public GenericSelectModel<SampleRow> getSampleRowSelectModel() throws WaoException { + public GenericSelectModel<SampleRow> getSampleRowSelectModel() throws WaoExceptionO { if (sampleRowSelectModel == null) { - if (log.isInfoEnabled()) { - log.info("BUSINESS REQUEST [getSampleRowsByFilter]"); - } - // WARN : no use of sampleRow filter SampleRow rowFiltered = getFilter().getSampleRow(); getFilter().setSampleRow(null); @@ -281,11 +271,8 @@ * @return the GenericSelectModel<Company> for companies * @throws WaoException */ - public GenericSelectModel<Company> getCompanySelectModel() throws WaoException { + public GenericSelectModel<Company> getCompanySelectModel() throws WaoExceptionO { if (companySelectModel == null) { - if (log.isDebugEnabled()) { - log.debug("BUSINESS REQUEST [getCompanies]"); - } List<Company> companies = serviceUser.getCompanies(isAvailableDataForFiltersOnly()); companySelectModel = new GenericSelectModel<Company>(companies,Company.class, "name","topiaId",propertyAccess); @@ -301,15 +288,12 @@ * @return the GenericSelectModel<WaoUser> for observers * @throws WaoException */ - public GenericSelectModel<WaoUser> getObserverSelectModel() throws WaoException { + public GenericSelectModel<WaoUser> getObserverSelectModel() throws WaoExceptionO { if (observerSelectModel == null) { List<WaoUser> observers = new ArrayList<WaoUser>(); if (getFilter().getCompany() != null) { observers = getFilter().getCompany().getWaoUser(); } else if (user.isAdmin()) { - if (log.isInfoEnabled()) { - log.info("BUSINESS REQUEST [getObservers]"); - } observers = serviceUser.getObservers(isAvailableDataForFiltersOnly()); } observerSelectModel = new GenericSelectModel<WaoUser>(observers,WaoUser.class, @@ -325,11 +309,8 @@ * @return the SelectModel for program names * @throws WaoException */ - public SelectModel getProgramSelectModel() throws WaoException { + public SelectModel getProgramSelectModel() throws WaoExceptionO { if (programSelectModel == null) { - if (log.isInfoEnabled()) { - log.info("BUSINESS REQUEST [getPrograms]"); - } List<OptionModel> options = new ArrayList<OptionModel>(); for (String programName : serviceSampling.getPrograms(getFilter().getCompany())) { options.add(new OptionModelImpl(programName, programName)); @@ -339,7 +320,7 @@ return programSelectModel; } - protected abstract BoatFilter getFilter() throws WaoException; + protected abstract BoatFilter getFilter() throws WaoExceptionO; /** * Used to show only active company and observers. @@ -348,10 +329,7 @@ */ protected abstract boolean isAvailableDataForFiltersOnly(); - public String[] onProvideCompletionsFromBoatName(String input) throws WaoException { - if (log.isInfoEnabled()) { - log.info("BUSINESS REQUEST [getBoatNamesStartWith]"); - } + public String[] onProvideCompletionsFromBoatName(String input) throws WaoExceptionO { List<String> results = serviceBoat.getBoatNamesStartWith(input); return results.toArray(new String[0]); } @@ -362,7 +340,7 @@ * * @throws WaoException */ - public void onSelectedFromSearch() throws WaoException { + public void onSelectedFromSearch() throws WaoExceptionO { if (log.isDebugEnabled()) { log.debug("REFRESH FILTERS DATA"); } @@ -392,7 +370,7 @@ * @throws WaoException * @see AbstractFilteredPage#onSelectedFromRefreshByProgram() */ - public void onSelectedFromRefreshByCompany() throws WaoException { + public void onSelectedFromRefreshByCompany() throws WaoExceptionO { // Reset programs (the behavior is needed even if programSelect is false) getFilter().setProgramName(null); onSelectedFromRefreshByProgram(); @@ -418,7 +396,7 @@ * @throws WaoException * @see AbstractFilteredPage#onSelectedFromRefreshByFacade() */ - public void onSelectedFromRefreshByProgram() throws WaoException { + public void onSelectedFromRefreshByProgram() throws WaoExceptionO { // Reset facades getFilter().setFacadeName(null); onSelectedFromRefreshByFacade(); @@ -434,7 +412,7 @@ * @throws WaoException * @see AbstractFilteredPage#onSelectedFromRefreshBySector() */ - public void onSelectedFromRefreshByFacade() throws WaoException { + public void onSelectedFromRefreshByFacade() throws WaoExceptionO { // Reset sectors getFilter().setSectorName(null); onSelectedFromRefreshBySector(); @@ -450,7 +428,7 @@ * @throws WaoException * @see AbstractFilteredPage#onSelectedFromSearch() */ - public void onSelectedFromRefreshBySector() throws WaoException { + public void onSelectedFromRefreshBySector() throws WaoExceptionO { // Update selected data onSelectedFromSearch(); // Reset sampleRows; Modified: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/components/FeedBack.java =================================================================== --- trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/components/FeedBack.java 2010-04-01 13:27:59 UTC (rev 401) +++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/components/FeedBack.java 2010-04-01 13:28:03 UTC (rev 402) @@ -125,9 +125,11 @@ * * @param message le message */ - public void addError(String message) { - if (!errorMessages.contains(message)) { - errorMessages.add(message); + public void addError(String... message) { + for (String str : message) { + if (!errorMessages.contains(str)) { + errorMessages.add(str); + } } } 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 13:27:59 UTC (rev 401) +++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/components/Layout.java 2010-04-01 13:28:03 UTC (rev 402) @@ -23,19 +23,17 @@ import fr.ifremer.wao.WaoBusinessException; import fr.ifremer.wao.WaoBusinessException.Type; -import fr.ifremer.wao.WaoContext; -import fr.ifremer.wao.WaoException; +import fr.ifremer.wao.WaoExceptionO; +import fr.ifremer.wao.WaoProperty; import fr.ifremer.wao.entity.WaoUser; import fr.ifremer.wao.service.ServiceUser; import fr.ifremer.wao.ui.base.WaoPage; -import fr.ifremer.wao.ui.pages.Administration; import fr.ifremer.wao.ui.pages.Index; import org.apache.commons.lang.StringUtils; import org.apache.tapestry5.BindingConstants; import org.apache.tapestry5.PersistenceConstants; import org.apache.tapestry5.annotations.InjectComponent; import org.apache.tapestry5.annotations.InjectContainer; -import org.apache.tapestry5.annotations.InjectPage; import org.apache.tapestry5.annotations.Log; import org.apache.tapestry5.annotations.Parameter; import org.apache.tapestry5.annotations.Persist; @@ -140,7 +138,7 @@ } public String getVersion() { - return WaoContext.getProperty(WaoContext.PROP_VERSION); + return WaoProperty.APP_VERSION.getValue(); } /** @@ -237,7 +235,7 @@ * * @param message of the error */ - public void addError(String message) { + public void addError(String... message) { contentFeedback.addError(message); } @@ -252,7 +250,7 @@ } @Log - Object onSuccessFromConnexionForm() throws WaoException { + Object onSuccessFromConnexionForm() throws WaoExceptionO { try { // FIXME-FD20100120 Problem with NPE in Topia --> see Ano #243 on nuiton.org if (login != null && password != null) { @@ -272,7 +270,7 @@ public boolean hasConnexionErrors() { return connexionFeedback.hasErrors(); } - void onSuccessFromForgetPassword() throws WaoException { + void onSuccessFromForgetPassword() throws WaoExceptionO { 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 13:27:59 UTC (rev 401) +++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/data/AbstractMappedGridDataSource.java 2010-04-01 13:28:03 UTC (rev 402) @@ -21,7 +21,7 @@ package fr.ifremer.wao.ui.data; -import fr.ifremer.wao.WaoException; +import fr.ifremer.wao.WaoExceptionO; import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -68,7 +68,7 @@ if (log.isTraceEnabled()) { log.trace("Count : " + nbRows); } - } catch (WaoException eee) { + } catch (WaoExceptionO eee) { throw new TapestryException("", eee); } } @@ -87,14 +87,14 @@ // FIXME manage sort columns in execute ???? seems obvious --> needed for Contacts, done for Boats //sortResults(sortConstraints); - } catch (WaoException eee) { + } catch (WaoExceptionO eee) { throw new TapestryException("", eee); } } - protected abstract Map<K, E> execute(int startIndex, int endIndex, SortConstraint orderBy) throws WaoException; + protected abstract Map<K, E> execute(int startIndex, int endIndex, SortConstraint orderBy) throws WaoExceptionO; - protected abstract int count() throws WaoException; + protected abstract int count() throws WaoExceptionO; 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 13:27:59 UTC (rev 401) +++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/data/BoatDataSource.java 2010-04-01 13:28:03 UTC (rev 402) @@ -21,7 +21,7 @@ package fr.ifremer.wao.ui.data; -import fr.ifremer.wao.WaoException; +import fr.ifremer.wao.WaoExceptionO; import fr.ifremer.wao.bean.BoatFilter; import fr.ifremer.wao.entity.Boat; import fr.ifremer.wao.service.ServiceBoat; @@ -58,7 +58,7 @@ @Override - protected Map<Integer, Boat> execute(int startIndex, int endIndex, SortConstraint orderBy) throws WaoException { + protected Map<Integer, Boat> execute(int startIndex, int endIndex, SortConstraint orderBy) throws WaoExceptionO { if (log.isInfoEnabled()) { log.info("BUSINESS REQUEST [getBoatsByFilter]"); } @@ -84,7 +84,7 @@ } @Override - protected int count() throws WaoException { + protected int count() throws WaoExceptionO { if (log.isInfoEnabled()) { log.info("BUSINESS REQUEST [getNbBoatsByFilter]"); } Modified: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/data/BusinessUtils.java =================================================================== --- trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/data/BusinessUtils.java 2010-04-01 13:27:59 UTC (rev 401) +++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/data/BusinessUtils.java 2010-04-01 13:28:03 UTC (rev 402) @@ -21,6 +21,8 @@ package fr.ifremer.wao.ui.data; +import fr.ifremer.wao.WaoBusinessException; +import fr.ifremer.wao.WaoException; import fr.ifremer.wao.bean.ContactState; import fr.ifremer.wao.bean.SamplingFilter; import fr.ifremer.wao.entity.Boat; @@ -32,6 +34,8 @@ import java.text.SimpleDateFormat; import org.apache.commons.lang.BooleanUtils; import org.apache.commons.lang.StringUtils; +import org.apache.tapestry5.ioc.Messages; +import org.slf4j.Logger; /** * DataUtils @@ -145,4 +149,43 @@ } return result; } + + public static String[] getErrorMessages(WaoException eee, Messages messages, + Logger logger) { + + String[] results = null; + String cause = null; + if (eee.getCause() != null) { + cause = eee.getCause().getClass().getSimpleName() + + " : " + eee.getCause().getMessage(); + results = new String[2]; + results[1] = cause; + } else { + results = new String[1]; + } + + + if (logger.isDebugEnabled()) { + logger.debug("ERROR from business : " + eee.getMessage() + + " _ args = " + eee.getArgs()); + if (cause != null) { + logger.debug("ERROR caused by : " + cause); + } + } + + if (eee.getArgs() != null) { + results[0] = messages.format(eee.getMessage(), eee.getArgs()); + } else { + results[0] = messages.get(eee.getMessage()); + } + return results; + } + + public static String getErrorMessage(WaoBusinessException eee, Messages messages, + Logger logger) { + if (logger.isDebugEnabled()) { + logger.debug("ERROR from business : " + eee.getMessage()); + } + return eee.getMessage(); + } } 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 13:27:59 UTC (rev 401) +++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/data/ContactDataSource.java 2010-04-01 13:28:03 UTC (rev 402) @@ -21,7 +21,7 @@ package fr.ifremer.wao.ui.data; -import fr.ifremer.wao.WaoException; +import fr.ifremer.wao.WaoExceptionO; import fr.ifremer.wao.bean.ContactFilter; import fr.ifremer.wao.entity.Contact; import fr.ifremer.wao.service.ServiceContact; @@ -60,7 +60,7 @@ } @Override - protected Map<String, Contact> execute(int startIndex, int endIndex, SortConstraint orderBy) throws WaoException { + protected Map<String, Contact> execute(int startIndex, int endIndex, SortConstraint orderBy) throws WaoExceptionO { if (log.isInfoEnabled()) { log.info("BUSINESS REQUEST [getContactsByFilter]"); } @@ -70,7 +70,7 @@ } @Override - protected int count() throws WaoException { + protected int count() throws WaoExceptionO { if (log.isInfoEnabled()) { log.info("BUSINESS REQUEST [getNbContacts]"); } Modified: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/data/ExportStreamResponse.java =================================================================== --- trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/data/ExportStreamResponse.java 2010-04-01 13:27:59 UTC (rev 401) +++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/data/ExportStreamResponse.java 2010-04-01 13:28:03 UTC (rev 402) @@ -21,7 +21,7 @@ package fr.ifremer.wao.ui.data; -import fr.ifremer.wao.WaoContext; +import fr.ifremer.wao.WaoContextO; import java.util.Date; import org.apache.tapestry5.StreamResponse; import org.apache.tapestry5.services.Response; @@ -68,7 +68,7 @@ */ @Override public void prepareResponse(Response response) { - Date current = WaoContext.getCurrentDate(); + Date current = WaoContextO.getCurrentDate(); filename += "-" + DateUtils.formatDate(current, "dd-MM-yyyy") + ".csv"; response.setHeader("Content-Disposition", "attachment; filename=\"" + filename +"\""); 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 13:27:59 UTC (rev 401) +++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Administration.java 2010-04-01 13:28:03 UTC (rev 402) @@ -23,6 +23,7 @@ import fr.ifremer.wao.WaoBusinessException; import fr.ifremer.wao.WaoException; +import fr.ifremer.wao.WaoExceptionO; import fr.ifremer.wao.bean.UserRole; import fr.ifremer.wao.entity.Company; import fr.ifremer.wao.entity.CompanyImpl; @@ -33,6 +34,7 @@ import fr.ifremer.wao.ui.base.GenericSelectModel; import fr.ifremer.wao.ui.base.WaoPage; import fr.ifremer.wao.ui.components.Layout; +import fr.ifremer.wao.ui.data.BusinessUtils; import java.util.List; import org.apache.commons.lang.StringUtils; import org.apache.tapestry5.EventContext; @@ -42,6 +44,7 @@ import org.apache.tapestry5.annotations.Persist; import org.apache.tapestry5.annotations.Property; import org.apache.tapestry5.annotations.SessionState; +import org.apache.tapestry5.ioc.Messages; import org.apache.tapestry5.ioc.annotations.Inject; import org.apache.tapestry5.ioc.services.PropertyAccess; import org.apache.tapestry5.ioc.services.TypeCoercer; @@ -124,7 +127,7 @@ private boolean addNewUserSelected; private boolean deleteUserSelected; - void setupRender() throws WaoException { + void setupRender() throws WaoExceptionO { companies = null; getCompanies(); user = null; @@ -151,19 +154,25 @@ @Property private UploadedFile fishingZoneCsvFile; + @Inject + private Messages messages; + @Log void onSuccessFromImportFishingZones() { try { - int result = serviceReferential.importFishingZoneCsv(fishingZoneCsvFile.getStream()); + int result = serviceReferential.importFishingZoneCsv( + fishingZoneCsvFile.getStream()); layout.addInfo(result + " zones de pêche importées"); } catch (WaoException eee) { - layout.addError(eee.getMessage()); + String[] errors = + BusinessUtils.getErrorMessages(eee, messages, log); + layout.addError(errors); } } /**************************** FORMS ****************************************/ - public List<Company> getCompanies() throws WaoException { + public List<Company> getCompanies() throws WaoExceptionO { if (companies == null) { if (log.isInfoEnabled()) { log.info("BUSINESS REQUEST [getCompanies]"); @@ -173,14 +182,14 @@ return companies; } - public GenericSelectModel<Company> getCompaniesSelectModel() throws WaoException { + public GenericSelectModel<Company> getCompaniesSelectModel() throws WaoExceptionO { if (companiesSelectModel == null) { companiesSelectModel = new GenericSelectModel<Company>(getCompanies(), Company.class, Company.NAME, "id", propertyAccess); } return companiesSelectModel; } - public Company getCompany() throws WaoException { + public Company getCompany() throws WaoExceptionO { if (company == null) { if (companyId != null) { company = getCompaniesSelectModel().findObject(companyId); @@ -191,7 +200,7 @@ return company; } - public boolean isUsersAvailable() throws WaoException { + public boolean isUsersAvailable() throws WaoExceptionO { return !StringUtils.isEmpty(getCompany().getId()) && getCompany().getActive(); } @@ -207,13 +216,13 @@ user = null; } - void onSuccessFromCompany() throws WaoException { + void onSuccessFromCompany() throws WaoExceptionO { serviceUser.createUpdateCompany(company); companyId = company.getId(); } @Log - public GenericSelectModel<WaoUser> getUsersSelectModel() throws WaoException { + public GenericSelectModel<WaoUser> getUsersSelectModel() throws WaoExceptionO { if (usersSelectModel == null) { List<WaoUser> users = serviceUser.getUsersByCompany(getCompany()); if (log.isDebugEnabled()) { @@ -225,7 +234,7 @@ } @Log - public WaoUser getUser() throws WaoException { + public WaoUser getUser() throws WaoExceptionO { if (user == null) { if (userId != null) { if (log.isDebugEnabled()) { @@ -254,7 +263,7 @@ deleteUserSelected = true; } - void onSuccessFromUserActionsForm() throws WaoException { + void onSuccessFromUserActionsForm() throws WaoExceptionO { if (addNewUserSelected) { userId = null; } else if (deleteUserSelected && userId != null) { @@ -271,7 +280,7 @@ } @Log - void onSuccessFromUser() throws WaoException { + void onSuccessFromUser() throws WaoExceptionO { 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 13:27:59 UTC (rev 401) +++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/BoatActivityCalendar.java 2010-04-01 13:28:03 UTC (rev 402) @@ -21,7 +21,7 @@ package fr.ifremer.wao.ui.pages; -import fr.ifremer.wao.WaoException; +import fr.ifremer.wao.WaoExceptionO; import fr.ifremer.wao.entity.ActivityCalendar; import fr.ifremer.wao.entity.ActivityMonth; import fr.ifremer.wao.entity.ActivityProfession; @@ -108,7 +108,7 @@ return Collections.singletonList(boat); } - public ActivityCalendar getActivityCalendar() throws WaoException { + public ActivityCalendar getActivityCalendar() throws WaoExceptionO { if (activityCalendar == null) { if (log.isInfoEnabled()) { log.info("BUSINESS REQUEST [getLastActivityCalendar]"); @@ -118,7 +118,7 @@ return activityCalendar; } - public ActivityMonth getActivityMonth() throws WaoException { + public ActivityMonth getActivityMonth() throws WaoExceptionO { return getActivityCalendar().getActivityMonth(month); } @@ -142,7 +142,7 @@ return getProfessionIndexMax() != -1; } - public ActivityProfession getActivityProfession() throws WaoException { + public ActivityProfession getActivityProfession() throws WaoExceptionO { if (getActivityMonth() == null) { return null; } @@ -152,7 +152,7 @@ return getActivityMonth().getActivityProfession().get(professionIndex); } - public int getZoneIndexMax() throws WaoException { + public int getZoneIndexMax() throws WaoExceptionO { int result = 0; for (ActivityMonth activityMonth : activityCalendar.getActivityMonth()) { month = activityMonth.getMonth(); @@ -179,7 +179,7 @@ // return getZoneIndexMax() != -1; // } - public ActivityZone getActivityZone() throws WaoException { + public ActivityZone getActivityZone() throws WaoExceptionO { 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 13:27:59 UTC (rev 401) +++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Boats.java 2010-04-01 13:28:03 UTC (rev 402) @@ -21,8 +21,9 @@ package fr.ifremer.wao.ui.pages; -import fr.ifremer.wao.WaoContext; -import fr.ifremer.wao.WaoException; +import fr.ifremer.wao.WaoBusinessException; +import fr.ifremer.wao.WaoContextO; +import fr.ifremer.wao.WaoExceptionO; import fr.ifremer.wao.bean.BoatFilterImpl; import fr.ifremer.wao.entity.Boat; import fr.ifremer.wao.bean.BoatFilter; @@ -70,6 +71,7 @@ import org.apache.tapestry5.annotations.Property; import org.apache.tapestry5.annotations.SessionState; import org.apache.tapestry5.corelib.components.Zone; +import org.apache.tapestry5.ioc.Messages; import org.apache.tapestry5.ioc.annotations.Inject; import org.apache.tapestry5.ioc.services.PropertyAccess; import org.apache.tapestry5.services.Response; @@ -140,7 +142,7 @@ @InjectComponent private FeedBack filterFeedback; - void setupRender() throws WaoException { + void setupRender() throws WaoExceptionO { sampleRow = null; getSampleRow(); // Profession select reset @@ -179,6 +181,9 @@ /**************************** Import Forms ********************************/ + @Inject + private Messages messages; + /** Csv file for boats import */ @Property private UploadedFile boatsCsvFile; @@ -207,8 +212,10 @@ boats = null; layout.addInfo(result[0] + " navires importés dont " + result[1] + " nouveaux"); - } catch (WaoException eee) { - layout.addError(eee.getMessage()); + } catch (WaoBusinessException eee) { + String error = + BusinessUtils.getErrorMessage(eee, messages, log); + layout.addError(error); } } } @@ -261,7 +268,7 @@ @Log void onSuccessFromImportActivityCalendarsForm() - throws WaoException, IOException { + throws WaoExceptionO, IOException { if (canImportReferentials()) { InputStream input = activityCalendarsCsvFile.getStream(); if (log.isDebugEnabled()) { @@ -350,7 +357,7 @@ * @see AbstractFilteredPage */ @Override - public BoatFilter getFilter() throws WaoException { + public BoatFilter getFilter() throws WaoExceptionO { if (boatFilter == null) { if (log.isDebugEnabled()) { log.debug("Create filter"); @@ -374,7 +381,7 @@ * @return the sampleRow from business * @throws WaoException */ - public SampleRow getSampleRow() throws WaoException { + public SampleRow getSampleRow() throws WaoExceptionO { if (sampleRow == null && !StringUtils.isEmpty(sampleRowContextId)) { if (log.isInfoEnabled()) { log.info("BUSINESS REQUEST [getSampleRow]"); @@ -384,11 +391,11 @@ return sampleRow; } - public boolean isSampleRowExists() throws WaoException { + public boolean isSampleRowExists() throws WaoExceptionO { return getSampleRow() != null; } - public GenericSelectModel<Profession> getProfessionSelectModel() throws WaoException { + public GenericSelectModel<Profession> getProfessionSelectModel() throws WaoExceptionO { if (professionSelectModel == null) { if (log.isInfoEnabled()) { log.info("BUSINESS REQUEST [getProfessions]"); @@ -435,7 +442,7 @@ * @see AbstractFilteredPage#onSelectedFromSearch() */ @Override - public void onSelectedFromSearch() throws WaoException { + public void onSelectedFromSearch() throws WaoExceptionO { super.onSelectedFromSearch(); if (log.isDebugEnabled()) { log.debug("FILTER : facadeName=" + boatFilter.getFacadeName()); @@ -457,7 +464,7 @@ * @return the filtersZone if it's a refresh data for select, or the page otherwise * @throws WaoException for business errors */ - Object onSuccessFromFiltersForm() throws WaoException { + Object onSuccessFromFiltersForm() throws WaoExceptionO { if (isEdited()) { return filtersZone.getBody(); } @@ -495,7 +502,7 @@ * @throws WaoException * @see BoatDataSource */ - public BoatDataSource getBoats() throws WaoException { + public BoatDataSource getBoats() throws WaoExceptionO { if (boats == null) { boats = new BoatDataSource(getFilter(), serviceBoat); } @@ -525,7 +532,7 @@ return new SimpleDateFormat("dd/MM/yyyy"); } - public boolean canCreateNewContactFromList() throws WaoException { + public boolean canCreateNewContactFromList() throws WaoExceptionO { if (!user.isAdmin() && !user.getReadOnly() && isSampleRowExists()) { return boat.canCreateContact(user.getCompany()); } @@ -543,7 +550,7 @@ log.debug("Filter sampleRow : " + getFilter().getSampleRow()); } result = serviceBoat.exportBoatCsv(getFilter()); - } catch (WaoException eee) { + } catch (WaoExceptionO eee) { throw new IOException(eee); } return result; @@ -551,7 +558,7 @@ }; } - Block onActionFromShowBoatInfos(Integer boatImma) throws WaoException { + Block onActionFromShowBoatInfos(Integer boatImma) throws WaoExceptionO { boatSelectedImmatriculation = boatImma; // Suppress persistant boat informations companyBoatInfos = null; @@ -607,7 +614,7 @@ /** /////////////////////// GLOBAL TO THE BLOCK /////////////////////// **/ public boolean isActivityCalendarImportRun() { - return WaoContext.isActivityCalendarImportRun(); + return WaoContextO.isActivityCalendarImportRun(); } public Block getActiveBoatInfosBlock() { @@ -617,7 +624,7 @@ return displayBoatInfos; } - public CompanyBoatInfos getCompanyBoatInfos() throws WaoException { + public CompanyBoatInfos getCompanyBoatInfos() throws WaoExceptionO { if (companyBoatInfos == null && boatSelectedImmatriculation != null && getCompany() != null) { if (log.isInfoEnabled()) { log.info("BUSINESS REQUEST [getElligibleBoats]"); @@ -634,7 +641,7 @@ * @return the GenericSelectModel<Company> * @throws WaoException */ - public GenericSelectModel<Company> getCompanies() throws WaoException { + public GenericSelectModel<Company> getCompanies() throws WaoExceptionO { if (companies == null) { if (log.isDebugEnabled()) { log.debug("BUSINESS REQUEST [getCompanies]"); @@ -652,7 +659,7 @@ * @return the current Company * @throws WaoException */ - public Company getCompany() throws WaoException { + public Company getCompany() throws WaoExceptionO { if (company == null) { if (StringUtils.isNotEmpty(companySelectedId)) { company = getCompanies().findObject(companySelectedId); @@ -669,7 +676,7 @@ * @return the selected boat from the grid * @throws WaoException */ - public Boat getBoatSelected() throws WaoException { + public Boat getBoatSelected() throws WaoExceptionO { if (log.isDebugEnabled()) { log.debug("selected imma : " + boatSelectedImmatriculation); log.debug("exist boat ? : " + getBoats().contains(boatSelectedImmatriculation)); @@ -701,7 +708,7 @@ this.boardingFromDate = boardingFromDate; } - public BoatInfos getBoatInfos() throws WaoException { + public BoatInfos getBoatInfos() throws WaoExceptionO { if (getCompanyBoatInfos() == null) { return null; } @@ -715,7 +722,7 @@ * @throws WaoException * @see BusinessUtils#getContactStyle(Contact, boolean) */ - public String getlastContactStyle() throws WaoException { + public String getlastContactStyle() throws WaoExceptionO { Contact contact = getCompanyBoatInfos().getLastContact(); return BusinessUtils.getContactStyle(contact, user.isAdmin()); } @@ -730,7 +737,7 @@ return BooleanUtils.isFalse(elligibleBoat.getCompanyActive()); } - public boolean canCreateNewContactFromElligibleBoat() throws WaoException { + public boolean canCreateNewContactFromElligibleBoat() throws WaoExceptionO { if (!user.isAdmin() && !user.getReadOnly() && !isElligibleBoatCompanyActiveFalse()) { Boat currentBoat = getBoatInfos().getBoat(); @@ -755,19 +762,19 @@ return !user.getReadOnly(); } - void onSuccess() throws WaoException { + void onSuccess() throws WaoExceptionO { if (getBoatInfos() != null) { boatSelectedImmatriculation = getBoatInfos().getBoat().getImmatriculation(); } } - Block onSuccessFromCompanySelectForm() throws WaoException { + Block onSuccessFromCompanySelectForm() throws WaoExceptionO { companyBoatInfos = null; getCompanyBoatInfos(); return boatInfosZone.getBody(); } - Block onActionFromEditBoatInfos() throws WaoException { + Block onActionFromEditBoatInfos() throws WaoExceptionO { if (canEditBoatInfos()) { boatInfosEditable = true; // WARNING :: Reset sampleRow select for edition mode, no limit for @@ -779,7 +786,7 @@ return boatInfosZone.getBody(); } - Block onActionFromCancelEditBoatInfos() throws WaoException { + Block onActionFromCancelEditBoatInfos() throws WaoExceptionO { /*if (propertyChange.isChanged()) { if (log.isDebugEnabled()) { log.debug("Change property"); @@ -793,7 +800,7 @@ return boatInfosZone.getBody(); } - void onSelectedFromAddBoatInfosSampleRow() throws WaoException { + void onSelectedFromAddBoatInfosSampleRow() throws WaoExceptionO { // We stay in edition mode boatInfosEditable = true; if (StringUtils.isNotEmpty(boatInfosSampleRowId)) { @@ -802,17 +809,17 @@ } } - void onSelectedFromRemoveBoatInfosSampleRow(String sampleRowCode) throws WaoException { + void onSelectedFromRemoveBoatInfosSampleRow(String sampleRowCode) throws WaoExceptionO { boatInfosEditable = true; companyBoatInfos.removeElligibleBoat(sampleRowCode); } - void onSelectedFromActiveBoatInfosSampleRow(String sampleRowCode) throws WaoException { + void onSelectedFromActiveBoatInfosSampleRow(String sampleRowCode) throws WaoExceptionO { boatInfosEditable = true; companyBoatInfos.activeElligibleBoat(sampleRowCode); } - Block onSuccessFromBoatInfosForm() throws WaoException { + Block onSuccessFromBoatInfosForm() throws WaoExceptionO { if (!boatInfosEditable && canEditBoatInfos()) { // Save data serviceBoat.createUpdateCompanyBoatInfos(companyBoatInfos); @@ -821,7 +828,7 @@ return boatInfosZone.getBody(); } - Block onSuccessFromCalculateBoardings() throws WaoException { + Block onSuccessFromCalculateBoardings() throws WaoExceptionO { //boatSelectedImmatriculation = getBoatInfos().getBoat().getImmatriculation(); return boatInfosZone.getBody(); } @@ -831,7 +838,7 @@ @InjectPage private Contacts contacts; - Object onActionFromAddNewContactFromBoat(int boatImmatriculation) throws WaoException { + Object onActionFromAddNewContactFromBoat(int boatImmatriculation) throws WaoExceptionO { // Get selected sampleRow sampleRow = getSampleRow(); // Get boat from list @@ -840,7 +847,7 @@ return contacts; } - Object onActionFromAddNewContactFromSampleRow(String sampleRowCode) throws WaoException { + Object onActionFromAddNewContactFromSampleRow(String sampleRowCode) throws WaoExceptionO { // Get sampleRow from elligibleBoat list ElligibleBoat elligible = getCompanyBoatInfos().getElligibleBoat(sampleRowCode); sampleRow = elligible.getSampleRow(); @@ -853,11 +860,11 @@ @InjectPage private BoatActivityCalendar calendarPage; - public boolean hasActivityCalendar() throws WaoException { + public boolean hasActivityCalendar() throws WaoExceptionO { return getBoatSelected().sizeActivityCalendar() != 0; } - Object onActionFromShowLastActivityCalendar() throws WaoException { + Object onActionFromShowLastActivityCalendar() throws WaoExceptionO { 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 13:27:59 UTC (rev 401) +++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Contacts.java 2010-04-01 13:28:03 UTC (rev 402) @@ -22,8 +22,8 @@ package fr.ifremer.wao.ui.pages; import fr.ifremer.wao.WaoBusinessException; -import fr.ifremer.wao.WaoContext; -import fr.ifremer.wao.WaoException; +import fr.ifremer.wao.WaoContextO; +import fr.ifremer.wao.WaoExceptionO; import fr.ifremer.wao.bean.BoatFilter; import fr.ifremer.wao.bean.ContactFilter; import fr.ifremer.wao.bean.ContactFilterImpl; @@ -120,7 +120,7 @@ // private String contactEditedId; @Log - void setupRender() throws WaoException { + void setupRender() throws WaoExceptionO { // if (contactEdited == null) { if (log.isDebugEnabled()) { log.debug("RESET DATA"); @@ -148,7 +148,7 @@ @Property private ContactState stateFilter; - public ContactFilter getContactFilter() throws WaoException { + public ContactFilter getContactFilter() throws WaoExceptionO { if (contactFilter == null) { if (log.isDebugEnabled()) { log.debug("Init contactFilter"); @@ -167,7 +167,7 @@ } @Override - protected BoatFilter getFilter() throws WaoException { + protected BoatFilter getFilter() throws WaoExceptionO { return getContactFilter(); } @@ -190,7 +190,7 @@ } @Log - Object onSuccessFromFiltersForm() throws WaoException { + Object onSuccessFromFiltersForm() throws WaoExceptionO { if (isEdited()) { return filtersZone.getBody(); } @@ -221,7 +221,7 @@ } @Log - void onSuccessFromImportContacts() throws WaoException { + void onSuccessFromImportContacts() throws WaoExceptionO { if (canImportExport()) { try { ImportResults result = serviceContact.importContactCsv(user, @@ -250,7 +250,7 @@ try { result = serviceContact.exportContactCsv( getContactFilter()); - } catch (WaoException eee) { + } catch (WaoExceptionO eee) { throw new IOException(eee); } return result; @@ -291,7 +291,7 @@ private boolean even = true; - public ContactDataSource getContacts() throws WaoException { + public ContactDataSource getContacts() throws WaoExceptionO { if (contacts == null) { if (log.isInfoEnabled()) { log.info("Create DataSource"); @@ -340,7 +340,7 @@ return BusinessUtils.getTooltipBoat(contact.getBoat()); } - public String getTooltipExportFrom() throws WaoException { + public String getTooltipExportFrom() throws WaoExceptionO { if (getContactFilter().getFromDate() != null) { return "depuis le " + getDateFormat().format(getContactFilter().getFromDate()); } @@ -442,7 +442,7 @@ } } - void onSelectedFromAcceptContact(String contactId) throws WaoException { + void onSelectedFromAcceptContact(String contactId) throws WaoExceptionO { if (log.isDebugEnabled()) { log.debug("Accept contact : " + contactId); } @@ -456,7 +456,7 @@ } } - void onSelectedFromRefuseContact(String contactId) throws WaoException { + void onSelectedFromRefuseContact(String contactId) throws WaoExceptionO { if (log.isDebugEnabled()) { log.debug("Refuse contact : " + contactId); } @@ -470,7 +470,7 @@ } } - void onSelectedFromUnvalidateContact(String contactId) throws WaoException { + void onSelectedFromUnvalidateContact(String contactId) throws WaoExceptionO { if (log.isDebugEnabled()) { log.debug("Unvalidate contact : " + contactId); } @@ -491,7 +491,7 @@ } } - void onSelectedFromEditContact(String contactId) throws WaoException { + void onSelectedFromEditContact(String contactId) throws WaoExceptionO { if (log.isDebugEnabled()) { log.debug("Edit contact : " + contactId); } @@ -503,7 +503,7 @@ edited = true; } - void onSelectedFromDeleteContact(String contactId) throws WaoException { + void onSelectedFromDeleteContact(String contactId) throws WaoExceptionO { if (log.isDebugEnabled()) { log.debug("Delete contact : " + contactId); } @@ -511,7 +511,7 @@ deleted = true; } - void onSelectedFromSaveContact(String contactId) throws WaoException { + void onSelectedFromSaveContact(String contactId) throws WaoExceptionO { if (log.isDebugEnabled()) { log.debug("Save contact : " + contactId); } @@ -525,7 +525,7 @@ } } - void onSelectedFromCancelEditContact() throws WaoException { + void onSelectedFromCancelEditContact() throws WaoExceptionO { contactEdited = null; edited = true; } @@ -584,7 +584,7 @@ " ne peut pas être antérieure à celle de début"); } - Date current = WaoContext.getCurrentDate(); + Date current = WaoContextO.getCurrentDate(); if (end != null && end.after(current)) { contactsForm.recordError(endDate, "La date de fin de la marée" + @@ -652,7 +652,7 @@ contactSelectedId = contactEdited.getTopiaId(); oldComment = null; contactEdited = null; - } catch (WaoException eee) { + } catch (WaoExceptionO eee) { layout.addError(eee.getMessage()); } } @@ -671,7 +671,7 @@ //return gridZone; } - public void createNewContact(Boat boat, SampleRow sampleRow) throws WaoException { + public void createNewContact(Boat boat, SampleRow sampleRow) throws WaoExceptionO { 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 13:27:59 UTC (rev 401) +++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/ExceptionReport.java 2010-04-01 13:28:03 UTC (rev 402) @@ -22,10 +22,13 @@ 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; import org.apache.tapestry5.annotations.InjectComponent; import org.apache.tapestry5.annotations.Property; +import org.apache.tapestry5.ioc.Messages; import org.apache.tapestry5.ioc.annotations.Inject; import org.apache.tapestry5.services.ExceptionReporter; import org.slf4j.Logger; @@ -58,21 +61,34 @@ @Inject private Logger log; + @Inject + private Messages messages; + @Property private Throwable exception; @Override public void reportException(Throwable eee) { - this.exception = getWaoException(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 = eee; - log.error("Unexpected exception", eee); + this.exception = getWaoException(eee); + if (exception != null) { + String[] errors = + BusinessUtils.getErrorMessages( + (WaoException)exception, messages, log); + layout.addError(errors); + } else { + log.error("Unexpected exception", eee); + layout.addError("Erreur : " + + this.exception.getClass().getSimpleName() + + " : " + this.exception.getMessage()); + } } - layout.addError("Erreur : " + this.exception.getClass().getSimpleName() - + " : " + this.exception.getMessage()); } protected Throwable getWaoException(Throwable eee) { @@ -84,5 +100,15 @@ } return getWaoException(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 13:27:59 UTC (rev 401) +++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Index.java 2010-04-01 13:28:03 UTC (rev 402) @@ -21,7 +21,7 @@ package fr.ifremer.wao.ui.pages; -import fr.ifremer.wao.WaoException; +import fr.ifremer.wao.WaoExceptionO; 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 WaoException { + void setupRender() throws WaoExceptionO { if (editedId == null || !"NEW".equals(editedId)) { newsList = null; getNewsList(); @@ -114,7 +114,7 @@ // return editedId; // } - public List<News> getNewsList() throws WaoException { + public List<News> getNewsList() throws WaoExceptionO { if (newsList == null) { newsList = serviceNews.getNews(); } @@ -140,7 +140,7 @@ return dateFormat; } - void onActionFromAddNews() throws WaoException { + void onActionFromAddNews() throws WaoExceptionO { 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 WaoException { + void onActionFromEditNews(int rowIndex) throws WaoExceptionO { news = getNewsList().get(rowIndex); this.editedId = news.getTopiaId(); } - void onActionFromDeleteNews(int rowIndex) throws WaoException { + void onActionFromDeleteNews(int rowIndex) throws WaoExceptionO { news = getNewsList().get(rowIndex); serviceNews.saveNews(news, true); //newsList = null; @@ -164,11 +164,11 @@ void onActionFromCancelEdit() { } - void onSelectedFromSaveNews(int rowIndex) throws WaoException { + void onSelectedFromSaveNews(int rowIndex) throws WaoExceptionO { news = getNewsList().get(rowIndex); } - void onSuccessFromNewsForm() throws WaoException { + void onSuccessFromNewsForm() throws WaoExceptionO { 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 13:27:59 UTC (rev 401) +++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/SampleRowForm.java 2010-04-01 13:28:03 UTC (rev 402) @@ -22,8 +22,8 @@ package fr.ifremer.wao.ui.pages; import fr.ifremer.wao.WaoBusinessException; -import fr.ifremer.wao.WaoContext; -import fr.ifremer.wao.WaoException; +import fr.ifremer.wao.WaoContextO; +import fr.ifremer.wao.WaoExceptionO; import fr.ifremer.wao.entity.Boat; import fr.ifremer.wao.entity.Company; import fr.ifremer.wao.entity.FishingZone; @@ -125,7 +125,7 @@ return sampleRowId; } - void setupRender() throws WaoException { + void setupRender() throws WaoExceptionO { // Reset data sampleRow = null; getSampleRow(); @@ -186,7 +186,7 @@ * @return a GenericSelectModel<Profession> * @throws WaoException */ - public GenericSelectModel<Profession> getProfessionSelectModel() throws WaoException { + public GenericSelectModel<Profession> getProfessionSelectModel() throws WaoExceptionO { if (professionSelectModel == null) { if (log.isInfoEnabled()) { log.info("BUSINESS REQUEST [getProfessions]"); @@ -212,7 +212,7 @@ * * @throws WaoException */ - void onSelectedFromAddNewProfession() throws WaoException { + void onSelectedFromAddNewProfession() throws WaoExceptionO { Profession profession = new ProfessionImpl(); if (!StringUtils.isEmpty(professionId)) { Profession professionSelected = getProfessionSelectModel().findObject(professionId); @@ -253,7 +253,7 @@ * @return a GenericSelectModel<FishingZone> * @throws WaoException */ - public GenericSelectModel<FishingZone> getFishingZoneSelectModel() throws WaoException { + public GenericSelectModel<FishingZone> getFishingZoneSelectModel() throws WaoExceptionO { if (fishingZoneSelectModel == null) { if (log.isInfoEnabled()) { log.info("BUSINESS REQUEST [getFishingZones]"); @@ -271,7 +271,7 @@ * @return a List of FishingZone linked with the SampleRow * @throws WaoException */ - public List<FishingZone> getFishingZones() throws WaoException { + public List<FishingZone> getFishingZones() throws WaoExceptionO { return getSampleRow().getFishingZone(); } @@ -280,7 +280,7 @@ * * @throws WaoException */ - void onSelectedFromAddFishingZone() throws WaoException { + void onSelectedFromAddFishingZone() throws WaoExceptionO { fishingZone = getFishingZoneSelectModel().findObject(fishingZoneId); if (!getFishingZones().contains(fishingZone)) { if (log.isDebugEnabled()) { @@ -297,7 +297,7 @@ * @param index of the FishingZone in the list (from loop component) * @throws WaoException */ - void onSelectedFromRemoveFishingZone(int index) throws WaoException { + void onSelectedFromRemoveFishingZone(int index) throws WaoExceptionO { if (log.isDebugEnabled()) { log.debug("Remove fishingZone at position : " + index); } @@ -344,7 +344,7 @@ private boolean periodChanged; - public SelectModel getProgramSelectModel() throws WaoException { + public SelectModel getProgramSelectModel() throws WaoExceptionO { if (programSelectModel == null) { if (log.isInfoEnabled()) { log.info("BUSINESS REQUEST [getPrograms]"); @@ -374,7 +374,7 @@ // return getSampleRow().getProgram(); // } - public PeriodDates getPeriod() throws WaoException { + public PeriodDates getPeriod() throws WaoExceptionO { if (period == null) { Date begin = getSampleRow().getPeriodBegin(); Date end = getSampleRow().getPeriodEnd(); @@ -383,7 +383,7 @@ return period; } - public List<SampleMonth> getSampleMonths() throws WaoException { + public List<SampleMonth> getSampleMonths() throws WaoExceptionO { if (sampleMonths == null) { sampleMonths = new ArrayList<SampleMonth>(); for (Date currMonth : getPeriod().getMonths()) { @@ -409,7 +409,7 @@ public String getMonthStyle() { String style = " "; - Date current = WaoContext.getCurrentDate(); + Date current = WaoContextO.getCurrentDate(); if (sampleMonth.isCurrentMonth()) { style += "selected"; } else if (current.after(sampleMonth.getPeriodDate())) { @@ -443,7 +443,7 @@ * @throws WaoException */ @Log - void onSelectedFromRefreshMonths() throws WaoException { + void onSelectedFromRefreshMonths() throws WaoExceptionO { getSampleRow().setPeriod(period); periodChanged = true; // Reset sampleMonths for new period @@ -452,7 +452,7 @@ saveProgram(); } - protected void saveProgram() throws WaoException { + protected void saveProgram() throws WaoExceptionO { // Save programName if (StringUtils.isNotEmpty(programName)) { getSampleRow().setProgramName(programName); @@ -466,7 +466,7 @@ } @Log - void onSelectedFromDeleteMonth(int index) throws WaoException { + void onSelectedFromDeleteMonth(int index) throws WaoExceptionO { getSampleMonths().remove(index); edited = true; } @@ -504,7 +504,7 @@ @Persist private WaoPropertyChangeListener propertyChange; - public SampleRow getSampleRow() throws WaoException { + public SampleRow getSampleRow() throws WaoExceptionO { if (sampleRow == null) { if (!StringUtils.isEmpty(sampleRowId)) { if (log.isInfoEnabled()) { @@ -523,7 +523,7 @@ return sampleRow; } - public SampleRowLog getSampleRowLog() throws WaoException { + public SampleRowLog getSampleRowLog() throws WaoExceptionO { if (sampleRowLog == null) { sampleRowLog = getSampleRow().getNewSampleRowLog(user); } @@ -540,7 +540,7 @@ return sampleRowModel; } - public GenericSelectModel<Company> getCompanySelectModel() throws WaoException { + public GenericSelectModel<Company> getCompanySelectModel() throws WaoExceptionO { if (companySelectModel == null) { if (log.isInfoEnabled()) { log.info("BUSINESS REQUEST [getCompanies]"); @@ -552,7 +552,7 @@ return companySelectModel; } - public boolean isCreateMode() throws WaoException { + public boolean isCreateMode() throws WaoExceptionO { return StringUtils.isEmpty(getSampleRow().getTopiaId()); } @@ -560,12 +560,12 @@ cancel = true; } - void onSelectedFromSaveData() throws WaoException { + void onSelectedFromSaveData() throws WaoExceptionO { saveProgram(); } @Log - void onValidateFormFromSampleRowForm() throws WaoException { + void onValidateFormFromSampleRowForm() throws WaoExceptionO { sampleRowForm.clearErrors(); try { // Only for save or periodChanged (refreshMonth) @@ -656,7 +656,7 @@ } @Log - Object onSuccessFromSampleRowForm() throws WaoException { + Object onSuccessFromSampleRowForm() throws WaoExceptionO { if (cancel) { return this; } @@ -670,11 +670,6 @@ } // Save sampleMonths - - if (log.isDebugEnabled()) { - log.debug("SampleMonths : " + getSampleMonths()); - } - getSampleRow().setSampleMonth(getSampleMonths()); serviceSampling.createUpdateSampleRow(sampleRow, boats, getSampleRowLog()); 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 13:27:59 UTC (rev 401) +++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/SampleRowHistoric.java 2010-04-01 13:28:03 UTC (rev 402) @@ -22,7 +22,7 @@ package fr.ifremer.wao.ui.pages; import fr.ifremer.wao.WaoBusinessException; -import fr.ifremer.wao.WaoException; +import fr.ifremer.wao.WaoExceptionO; 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 WaoException { + void setupRender() throws WaoExceptionO { 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 WaoException { + public SampleRow getSampleRow() throws WaoExceptionO { if (sampleRow == null) { sampleRow = serviceSampling.getSampleRowByCode(user, sampleRowCode); } @@ -142,7 +142,7 @@ return content; } - public SampleRowLog getNewLog() throws WaoException { + public SampleRowLog getNewLog() throws WaoExceptionO { if (newLog == null) { newLog = getSampleRow().getNewSampleRowLog(user); } @@ -154,7 +154,7 @@ !user.getReadOnly(); } - public void onSuccessFromAddComment() throws WaoException { + public void onSuccessFromAddComment() throws WaoExceptionO { 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 13:27:59 UTC (rev 401) +++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/SamplingPlan.java 2010-04-01 13:28:03 UTC (rev 402) @@ -23,7 +23,7 @@ import fr.ifremer.wao.WaoBusinessException; -import fr.ifremer.wao.WaoException; +import fr.ifremer.wao.WaoExceptionO; import fr.ifremer.wao.bean.FacadeRow; import fr.ifremer.wao.bean.ImportResults; import fr.ifremer.wao.entity.Company; @@ -120,7 +120,7 @@ } @Log - void onSuccessFromImportSamplingPlan() throws WaoException { + void onSuccessFromImportSamplingPlan() throws WaoExceptionO { if (canImportSamplingPlan()) { try { ImportResults result = serviceSampling.importSamplingPlanCsv( @@ -147,7 +147,7 @@ InputStream result = null; try { result = serviceSampling.exportSamplingPlanCsv(user, getPeriod()); - } catch (WaoException eee) { + } catch (WaoExceptionO eee) { throw new IOException(eee); } return result; @@ -211,7 +211,7 @@ * @return List of SampleRow * @throws WaoException */ - public List<SampleRow> getData() throws WaoException { + public List<SampleRow> getData() throws WaoExceptionO { if (data == null) { if (log.isInfoEnabled()) { log.info("BUSINESS REQUEST [getSampleRowsOrderedByFishingZone]"); @@ -398,13 +398,13 @@ * @param rowIndex index of the row in the table * @throws WaoException for a data problem */ - void onActionFromFilterPeriodDates(int rowIndex) throws WaoException { + void onActionFromFilterPeriodDates(int rowIndex) throws WaoExceptionO { row = getData().get(rowIndex); period.setFromDate(row.getPeriodBegin()); period.setThruDate(row.getPeriodEnd()); } - void onActionFromDeleteSampleRow(int rowIndex) throws WaoException { + void onActionFromDeleteSampleRow(int rowIndex) throws WaoExceptionO { 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 13:27:59 UTC (rev 401) +++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Synthesis.java 2010-04-01 13:28:03 UTC (rev 402) @@ -21,7 +21,7 @@ package fr.ifremer.wao.ui.pages; -import fr.ifremer.wao.WaoException; +import fr.ifremer.wao.WaoExceptionO; 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 WaoException { + public Block getActiveBlock() throws WaoExceptionO { if (activeSynthesis == null) { // Initialize default synthesis by Data Sampling activeSynthesis = SynthesisId.GRAPH_SAMPLING; @@ -165,12 +165,12 @@ private boolean reset; - private void initSamplingBlock() throws WaoException { + private void initSamplingBlock() throws WaoExceptionO { initSelectFilters(true, false, true); } @Override - public BoatFilter getFilter() throws WaoException { + public BoatFilter getFilter() throws WaoExceptionO { if (dataSamplingFilter == null) { dataSamplingFilter = new BoatFilterImpl(); if (!user.isAdmin()) { @@ -180,7 +180,7 @@ return dataSamplingFilter; } - public PeriodDates getPeriod() throws WaoException { + public PeriodDates getPeriod() throws WaoExceptionO { if (getFilter().getPeriod() == null) { PeriodDates period = PeriodDates.createMonthsPeriodFromToday(-12); if (log.isDebugEnabled()) { @@ -196,7 +196,7 @@ return false; } - public JFreeChart getDataSamplingChart() throws WaoException { + public JFreeChart getDataSamplingChart() throws WaoExceptionO { if (log.isInfoEnabled()) { log.info("BUSINESS REQUEST [getDataSampling]"); } @@ -243,7 +243,7 @@ @Property private String companyIdForBoarding; - private void initBoardingBlock() throws WaoException { + private void initBoardingBlock() throws WaoExceptionO { resetCompanySelect(); // Set the companyIdForBoarding is only necessary for an admin which // have access to a select with all active companies (from Filters : @@ -256,7 +256,7 @@ } } - public JFreeChart getBoardingBoatsChart() throws WaoException { + public JFreeChart getBoardingBoatsChart() throws WaoExceptionO { Map<String, Map<?, Integer>> data = new HashMap<String, Map<?, Integer>>(); data.put("Navires", getBoardingResult().getData()); @@ -272,7 +272,7 @@ "Nb embarquements", ChartType.BAR, data); } - public BoardingResult getBoardingResult() throws WaoException { + public BoardingResult getBoardingResult() throws WaoExceptionO { if (boardingResult == null) { if (log.isInfoEnabled()) { log.info("BUSINESS REQUEST [getBoardingBoats]"); @@ -300,7 +300,7 @@ } @Log - void onSuccessFromFilterCompanyForBoarding() throws WaoException { + void onSuccessFromFilterCompanyForBoarding() throws WaoExceptionO { companyForBoarding = getCompanySelectModel().findObject(companyIdForBoarding); } @@ -320,7 +320,7 @@ * @throws WaoException */ public Map<String, Double> getNonComplianceBoarding() - throws WaoException { + throws WaoExceptionO { if (nonComplianceBoarding == null) { Company company = !user.isAdmin() ? user.getCompany() : null; nonComplianceBoarding = @@ -336,7 +336,7 @@ * @return the value of the indicator * @throws WaoException */ - public Double getNonComplianceBoardingValue() throws WaoException { + public Double getNonComplianceBoardingValue() throws WaoExceptionO { return getNonComplianceBoarding().get(user.getCompany().getName()); } @@ -370,7 +370,7 @@ * @throws WaoException */ public Collection<ContactStateStatistics> getContactStateStatistics() - throws WaoException { + throws WaoExceptionO { if (contactStateStatistics == null) { Company company = !user.isAdmin() ? user.getCompany() : null; contactStateStatistics = @@ -421,7 +421,7 @@ private ContactAverageReactivity allegroReactivityEntry; public Collection<ContactAverageReactivity> getAllegroReactivity() - throws WaoException { + throws WaoExceptionO { if (allegroReactivity == null) { Company company = !user.isAdmin() ? user.getCompany() : null; allegroReactivity = @@ -438,7 +438,7 @@ return periodForAllegroReactivity; } - public Double getAllegroReactivityValue() throws WaoException { + public Double getAllegroReactivityValue() throws WaoExceptionO { if (!getAllegroReactivity().isEmpty()) { ContactAverageReactivity entry = (ContactAverageReactivity) CollectionUtils.get(getAllegroReactivity(), 0); @@ -448,7 +448,7 @@ } } - public String getAllegroReactivityStyle() throws WaoException { + public String getAllegroReactivityStyle() throws WaoExceptionO { 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 13:27:59 UTC (rev 401) +++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/UserProfile.java 2010-04-01 13:28:03 UTC (rev 402) @@ -22,7 +22,7 @@ package fr.ifremer.wao.ui.pages; import fr.ifremer.wao.WaoBusinessException; -import fr.ifremer.wao.WaoException; +import fr.ifremer.wao.WaoExceptionO; 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 WaoException { + void onSuccessFromUserForm() throws WaoExceptionO { 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 13:27:59 UTC (rev 401) +++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/services/AppModule.java 2010-04-01 13:28:03 UTC (rev 402) @@ -19,20 +19,25 @@ package fr.ifremer.wao.ui.services; +import fr.ifremer.wao.WaoContextImpl; import fr.ifremer.wao.entity.WaoUser; import fr.ifremer.wao.entity.WaoUserImpl; import fr.ifremer.wao.service.*; +import java.io.IOException; import org.apache.tapestry5.SymbolConstants; import org.apache.tapestry5.ioc.MappedConfiguration; -import org.apache.tapestry5.ioc.OrderedConfiguration; import org.apache.tapestry5.ioc.ServiceBinder; import org.apache.tapestry5.ioc.annotations.EagerLoad; import org.apache.tapestry5.ioc.annotations.InjectService; import org.apache.tapestry5.ioc.services.RegistryShutdownHub; -import org.apache.tapestry5.ioc.services.RegistryShutdownListener; import org.apache.tapestry5.services.ApplicationStateContribution; import org.apache.tapestry5.services.ApplicationStateCreator; +import org.apache.tapestry5.services.Request; +import org.apache.tapestry5.services.RequestFilter; +import org.apache.tapestry5.services.RequestHandler; +import org.apache.tapestry5.services.Response; +import org.slf4j.Logger; /** * This module is automatically included as part of the Tapestry IoC Registry, @@ -50,18 +55,41 @@ // Use service builder methods (example below) when the implementation // is provided inline, or requires more initialization than simply // invoking the constructor. - binder.bind(ServiceNews.class, ServiceNewsImpl.class); +// binder.bind(ServiceNews.class, ServiceNewsImpl.class); binder.bind(ServiceUser.class, ServiceUserImpl.class); binder.bind(ServiceSampling.class, ServiceSamplingImpl.class); - binder.bind(ServiceReferential.class, ServiceReferentialImpl.class); - binder.bind(ServiceBoat.class, ServiceBoatImpl.class); +// binder.bind(ServiceReferential.class, ServiceReferentialImpl.class); +// binder.bind(ServiceBoat.class, ServiceBoatImpl.class); binder.bind(ServiceContact.class, ServiceContactImpl.class); binder.bind(ContactModelFactory.class); binder.bind(ServiceSynthesis.class, ServiceSynthesisImpl.class); -// binder.bind(WaoModelDAOHelper.getContractClass(User.class), -// WaoModelDAOHelper.getImplementationClass(User.class)); } + @EagerLoad + public WaoManager buildWaoManager(RegistryShutdownHub hub) { + WaoManager manager = new WaoManager(new WaoContextImpl()); + hub.addRegistryShutdownListener(manager); + return manager; + } + + public ServiceNews buildServiceNews(WaoManager manager) { + ServiceNewsImpl instance = new ServiceNewsImpl(); + instance.setContext(manager.getContext()); + return instance; + } + + public ServiceReferential buildServiceReferential(WaoManager manager) { + ServiceReferentialImpl instance = new ServiceReferentialImpl(); + instance.setContext(manager.getContext()); + return instance; + } + + public ServiceBoat buildServiceBoat(WaoManager manager) { + ServiceBoatImpl instance = new ServiceBoatImpl(); + instance.setContext(manager.getContext()); + return instance; + } + public static void contributeApplicationDefaults( MappedConfiguration<String, String> configuration) { // Contributions to ApplicationDefaults will override any contributions to @@ -96,9 +124,12 @@ * the service interface and would be "RequestFilter". Since Tapestry * already defines a service named "RequestFilter" we use an explicit * service id that we can reference inside the contribution method. + * @param log + * @return */ - /*public RequestFilter buildTimingFilter(final Logger log) { + public RequestFilter buildTimingFilter(final Logger log) { return new RequestFilter() { + @Override public boolean service(Request request, Response response, RequestHandler handler) throws IOException { long startTime = System.currentTimeMillis(); @@ -116,40 +147,45 @@ } } }; - }*/ - - /** - * This is the Shutdown service definition. This service is used when the - * server shutdown. It detects the Tapestry registry shutdown. - * @param hub - * @return - */ - @EagerLoad - public RegistryShutdownListener buildWaoShutdown( - @InjectService("RegistryShutdownHub") RegistryShutdownHub hub) { - RegistryShutdownListener listener = new WaoManager(); - hub.addRegistryShutdownListener(listener); - return listener; } - public static void contributeRegistryStartup(OrderedConfiguration<Runnable> configuration) { - configuration.add("WaoStartup", new WaoManager()); - } +// /** +// * This is the Shutdown service definition. This service is used when the +// * server shutdown. It detects the Tapestry registry shutdown. +// * @param hub +// * @param context +// * @return +// */ +// @EagerLoad +// public RegistryShutdownListener buildWaoShutdown( +// @InjectService("RegistryShutdownHub") RegistryShutdownHub hub, +// WaoContext context) { +// RegistryShutdownListener listener = new WaoManager(context); +// hub.addRegistryShutdownListener(listener); +// return listener; +// } +// public static void contributeRegistryStartup(OrderedConfiguration<Runnable> configuration) { +// configuration.add("WaoStartup", new WaoManager()); +// } + /** * Used to instanciate SessionState WaoUser when session expires. * * @param configuration to add the ApplicationStateCreator. */ - public void contributeApplicationStateManager(MappedConfiguration<Class<?>, ApplicationStateContribution> configuration) { - ApplicationStateCreator<WaoUser> creator = new ApplicationStateCreator<WaoUser>() { + public void contributeApplicationStateManager(MappedConfiguration<Class<?>, + ApplicationStateContribution> configuration) { + ApplicationStateCreator<WaoUser> creator = + new ApplicationStateCreator<WaoUser>() { @Override public WaoUser create() { return new WaoUserImpl(); } }; - configuration.add(WaoUser.class, new ApplicationStateContribution("session", creator)); + configuration.add(WaoUser.class, + new ApplicationStateContribution("session", creator)); } } Modified: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/services/WaoManager.java =================================================================== --- trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/services/WaoManager.java 2010-04-01 13:27:59 UTC (rev 401) +++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/services/WaoManager.java 2010-04-01 13:28:03 UTC (rev 402) @@ -21,10 +21,10 @@ package fr.ifremer.wao.ui.services; -import fr.ifremer.wao.WaoException; -import fr.ifremer.wao.WaoRunner; -import fr.ifremer.wao.WaoRunnerImpl; +import fr.ifremer.wao.WaoContextImplementor; +import fr.ifremer.wao.WaoProperty; import org.apache.tapestry5.ioc.services.RegistryShutdownListener; +import org.nuiton.util.ApplicationConfig; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -43,37 +43,38 @@ private static final Logger log = LoggerFactory.getLogger(WaoManager.class); - private WaoRunner runner; + private WaoContextImplementor context; + public WaoManager(WaoContextImplementor context) { + this.context = context; + this.context.start(); + } + @Override public void run() { - runner = new WaoRunnerImpl(); - try { - if (log.isInfoEnabled()) { - log.info("Start Wao"); - } - runner.start(); - } catch (WaoException eee) { - if (log.isErrorEnabled()) { - log.error("Error on start", eee); - } - } } @Override public void registryDidShutdown() { - // No problem with reinstanciate the runner, all context is in WaoContext which is static - runner = new WaoRunnerImpl(); - try { - if (log.isInfoEnabled()) { - log.info("Stop Wao"); - } - runner.stop(); - } catch (WaoException eee) { - if (log.isErrorEnabled()) { - log.error("Error on stop", eee); - } - } + context.stop(); } + WaoContextImplementor getContext() { + return context; + } + + public boolean isActivityCalendarImportRun() { + return context.isActivityCalendarImportRun(); + } + + public String getProperty(WaoProperty property) { + return context.getProperty(property); + } + + public ApplicationConfig getConfiguration() { + return context.getConfiguration(); + } + + + }
Le Thu, 1 Apr 2010 15:28:03 +0200 (CEST), fdesbois at users.labs.libre-entreprise.org a écrit :
- <topia.version>2.3.1-SNAPSHOT</topia.version> + <topia.version>2.3.2-SNAPSHOT</topia.version> je vois pas pk tu es sur une snapshot si t'en a pas besoin.
Vu que j'ai vu aucun commit passé sur ToPIA, je présume que tu pourrais être sur la version stable... De manière général, on est sur les snapshot uniquement si nécessaire... et ça t'empèchera peut-être de partir en R&D sur ToPIA si pas besoin... donc en stable si possible -- Tony Chemit -------------------- tél: +33 (0) 2 40 50 29 28 email: chemit at codelutin.com http://www.codelutin.com
Le Thu, 1 Apr 2010 15:28:03 +0200 (CEST), fdesbois at users.labs.libre-entreprise.org a écrit :
Author: fdesbois Date: 2010-04-01 13:28:03 +0000 (Thu, 01 Apr 2010) New Revision: 402
Added: trunk/wao-business/nbactions.xml trunk/wao-business/src/main/java/fr/ifremer/wao/WaoContextImpl.java 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/WaoProperty.java trunk/wao-business/src/main/resources/i18n/ 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/resources/oldmappings/Wao/ trunk/wao-business/src/main/resources/oldmappings/Wao/1.1/ trunk/wao-business/src/main/resources/oldmappings/Wao/1.1/fr/ trunk/wao-business/src/main/resources/oldmappings/Wao/1.1/fr/ifremer/ trunk/wao-business/src/main/resources/oldmappings/Wao/1.1/fr/ifremer/wao/ trunk/wao-business/src/main/resources/oldmappings/Wao/1.1/fr/ifremer/wao/entity/ trunk/wao-business/src/main/resources/oldmappings/Wao/1.1/fr/ifremer/wao/entity/ActivityCalendarImpl.hbm.xml trunk/wao-business/src/main/resources/oldmappings/Wao/1.1/fr/ifremer/wao/entity/ActivityMonthImpl.hbm.xml trunk/wao-business/src/main/resources/oldmappings/Wao/1.1/fr/ifremer/wao/entity/ActivityProfessionImpl.hbm.xml trunk/wao-business/src/main/resources/oldmappings/Wao/1.1/fr/ifremer/wao/entity/ActivityZoneImpl.hbm.xml trunk/wao-business/src/main/resources/oldmappings/Wao/1.1/fr/ifremer/wao/entity/BoatImpl.hbm.xml trunk/wao-business/src/main/resources/oldmappings/Wao/1.1/fr/ifremer/wao/entity/BoatInfosImpl.hbm.xml trunk/wao-business/src/main/resources/oldmappings/Wao/1.1/fr/ifremer/wao/entity/CompanyImpl.hbm.xml trunk/wao-business/src/main/resources/oldmappings/Wao/1.1/fr/ifremer/wao/entity/ContactImpl.hbm.xml trunk/wao-business/src/main/resources/oldmappings/Wao/1.1/fr/ifremer/wao/entity/ElligibleBoatImpl.hbm.xml trunk/wao-business/src/main/resources/oldmappings/Wao/1.1/fr/ifremer/wao/entity/FishingZoneImpl.hbm.xml trunk/wao-business/src/main/resources/oldmappings/Wao/1.1/fr/ifremer/wao/entity/NewsImpl.hbm.xml trunk/wao-business/src/main/resources/oldmappings/Wao/1.1/fr/ifremer/wao/entity/ProfessionImpl.hbm.xml trunk/wao-business/src/main/resources/oldmappings/Wao/1.1/fr/ifremer/wao/entity/SampleMonthImpl.hbm.xml trunk/wao-business/src/main/resources/oldmappings/Wao/1.1/fr/ifremer/wao/entity/SampleRowImpl.hbm.xml trunk/wao-business/src/main/resources/oldmappings/Wao/1.1/fr/ifremer/wao/entity/SampleRowLogImpl.hbm.xml trunk/wao-business/src/main/resources/oldmappings/Wao/1.1/fr/ifremer/wao/entity/ShipOwnerImpl.hbm.xml trunk/wao-business/src/main/resources/oldmappings/Wao/1.1/fr/ifremer/wao/entity/WaoUserImpl.hbm.xml trunk/wao-business/src/test/java/fr/ifremer/wao/TestManager.java trunk/wao-business/src/test/java/fr/ifremer/wao/io/ImportHelperTest.java Removed: trunk/wao-business/src/main/java/fr/ifremer/wao/WaoContext.java trunk/wao-business/src/main/java/fr/ifremer/wao/WaoException.java trunk/wao-business/src/main/java/fr/ifremer/wao/mock/ServiceNewsMock.java trunk/wao-business/src/test/java/fr/ifremer/wao/ImportHelperTest.java trunk/wao-business/src/test/java/fr/ifremer/wao/WaoRunnerTest.java trunk/wao-business/src/test/java/fr/ifremer/wao/io/ImportHelperTest.java Modified: trunk/changelog.txt trunk/pom.xml trunk/wao-business/pom.xml trunk/wao-business/src/main/java/fr/ifremer/wao/WaoBusinessException.java trunk/wao-business/src/main/java/fr/ifremer/wao/WaoGlobal.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/bean/SamplingFilterImpl.java trunk/wao-business/src/main/java/fr/ifremer/wao/entity/BoatImpl.java trunk/wao-business/src/main/java/fr/ifremer/wao/entity/BoatInfosImpl.java trunk/wao-business/src/main/java/fr/ifremer/wao/entity/CompanyImpl.java trunk/wao-business/src/main/java/fr/ifremer/wao/entity/SampleMonthImpl.java trunk/wao-business/src/main/java/fr/ifremer/wao/entity/SampleRowImpl.java trunk/wao-business/src/main/java/fr/ifremer/wao/entity/WaoUserImpl.java trunk/wao-business/src/main/java/fr/ifremer/wao/io/ImportHelper.java trunk/wao-business/src/main/java/fr/ifremer/wao/service/ActivityCalendarImport.java trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceBoatImpl.java trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceContactImpl.java trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceNewsImpl.java trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceReferentialImpl.java trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceSamplingImpl.java trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceSynthesisImpl.java trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceUserImpl.java 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/WaoGlobalTest.java trunk/wao-business/src/test/java/fr/ifremer/wao/WaoUtilsTest.java trunk/wao-business/src/test/java/fr/ifremer/wao/entity/BoatImplTest.java trunk/wao-business/src/test/java/fr/ifremer/wao/entity/BoatInfosImplTest.java trunk/wao-business/src/test/java/fr/ifremer/wao/entity/SampleRowImplTest.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-business/src/test/java/fr/ifremer/wao/service/ServiceSynthesisImplTest.java trunk/wao-business/src/test/java/fr/ifremer/wao/service/ServiceUserImplTest.java trunk/wao-business/src/test/resources/log4j.properties trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/base/AbstractFilteredPage.java trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/components/FeedBack.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/BusinessUtils.java trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/data/ContactDataSource.java trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/data/ExportStreamResponse.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 trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/services/WaoManager.java Log: - Use ServiceTransformer (refactor Context managment + service implementations) - Remove updateFishingZone in createUpdateSampleRow, the topia evol on inverse tagValue resolve issue on saving fishingZone directly in sampleRow (Ano #2237)
De manière générale, essaye de faire des commits plus petits car là c'est impossible de savoir ce que tu as fait. En plus le message n'est pas correct : par exemple : tu te mets à utiliser i18n mais c'est nulle part dans le message vu que c'est noyé dans ton commit. -- Tony Chemit -------------------- tél: +33 (0) 2 40 50 29 28 email: chemit at codelutin.com http://www.codelutin.com
participants (2)
-
chemit@codelutin.com -
fdesbois@users.labs.libre-entreprise.org