Wao-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
February 2010
- 2 participants
- 65 discussions
16 Feb '10
Author: fdesbois
Date: 2010-02-16 13:56:07 +0000 (Tue, 16 Feb 2010)
New Revision: 355
Added:
trunk/wao-business/
trunk/wao-business/README.txt
trunk/wao-business/pom.xml
trunk/wao-business/src/main/filters/Wao.properties
trunk/wao-business/src/main/java/fr/ifremer/wao/
trunk/wao-business/src/main/java/fr/ifremer/wao/MD5.java
trunk/wao-business/src/main/java/fr/ifremer/wao/WaoBusinessException.java
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/WaoGlobal.java
trunk/wao-business/src/main/java/fr/ifremer/wao/WaoMigrationCallBack.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/BoatFilterImpl.java
trunk/wao-business/src/main/java/fr/ifremer/wao/bean/CompanyBoatInfosImpl.java
trunk/wao-business/src/main/java/fr/ifremer/wao/bean/ContactAverageReactivityImpl.java
trunk/wao-business/src/main/java/fr/ifremer/wao/bean/ContactFilterImpl.java
trunk/wao-business/src/main/java/fr/ifremer/wao/bean/ContactState.java
trunk/wao-business/src/main/java/fr/ifremer/wao/bean/ContactStateStatisticsImpl.java
trunk/wao-business/src/main/java/fr/ifremer/wao/bean/FacadeRowImpl.java
trunk/wao-business/src/main/java/fr/ifremer/wao/bean/ImportResultsImpl.java
trunk/wao-business/src/main/java/fr/ifremer/wao/bean/SamplingFilterImpl.java
trunk/wao-business/src/main/java/fr/ifremer/wao/bean/UserFilterImpl.java
trunk/wao-business/src/main/java/fr/ifremer/wao/entity/ActivityCalendarImpl.java
trunk/wao-business/src/main/java/fr/ifremer/wao/entity/ActivityMonthImpl.java
trunk/wao-business/src/main/java/fr/ifremer/wao/entity/ActivityProfessionImpl.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/ContactDAOImpl.java
trunk/wao-business/src/main/java/fr/ifremer/wao/entity/ContactImpl.java
trunk/wao-business/src/main/java/fr/ifremer/wao/entity/FishingZoneImpl.java
trunk/wao-business/src/main/java/fr/ifremer/wao/entity/ProfessionImpl.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/SampleRowLogImpl.java
trunk/wao-business/src/main/java/fr/ifremer/wao/entity/WaoUserImpl.java
trunk/wao-business/src/main/java/fr/ifremer/wao/io/ExportHelper.java
trunk/wao-business/src/main/java/fr/ifremer/wao/io/ImportHelper.java
trunk/wao-business/src/main/java/fr/ifremer/wao/io/SamplingExport.java
trunk/wao-business/src/main/java/fr/ifremer/wao/io/WaoCsvHeader.java
trunk/wao-business/src/main/java/fr/ifremer/wao/mock/ServiceNewsMock.java
trunk/wao-business/src/main/java/fr/ifremer/wao/service/
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/resources/oldmappings/WaoModel/
trunk/wao-business/src/main/xmi/wao.properties
trunk/wao-business/src/main/xmi/wao.zargo
trunk/wao-business/src/test/java/fr/ifremer/wao/
trunk/wao-business/src/test/java/fr/ifremer/wao/ImportHelperTest.java
trunk/wao-business/src/test/java/fr/ifremer/wao/WaoGlobalTest.java
trunk/wao-business/src/test/java/fr/ifremer/wao/WaoRunnerTest.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/services/ActivityCalendarImportTest.java
trunk/wao-business/src/test/java/fr/ifremer/wao/services/ServiceBoatImplTest.java
trunk/wao-business/src/test/java/fr/ifremer/wao/services/ServiceReferentialImplTest.java
trunk/wao-business/src/test/java/fr/ifremer/wao/services/ServiceSamplingImplTest.java
trunk/wao-business/src/test/java/fr/ifremer/wao/services/ServiceSynthesisImplTest.java
trunk/wao-business/src/test/resources/WaoTest.properties
trunk/wao-ui/
trunk/wao-ui/pom.xml
trunk/wao-ui/src/main/java/fr/ifremer/wao/
trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/base/AbstractFilteredPage.java
trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/base/GenericSelectModel.java
trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/base/WaoPage.java
trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/components/BooleanImage.java
trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/components/Chart.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/components/SubmitContext.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/ChartUtils.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/data/SynthesisId.java
trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/data/WaoPropertyChangeListener.java
trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/mixins/Confirm.java
trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/mixins/PopupPageLink.java
trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/mixins/ZoneUpdater.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/ContactModelFactory.java
trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/services/WaoManager.java
trunk/wao-ui/src/main/resources/fr/ifremer/suiviobsmer/ui/components/Layout.tml
trunk/wao-ui/src/main/resources/fr/ifremer/suiviobsmer/ui/pages/Synthesis.properties
trunk/wao-ui/src/main/resources/log4j.properties
trunk/wao-ui/src/main/webapp/Synthesis.tml
trunk/wao-ui/src/main/webapp/WEB-INF/web.xml
trunk/wao-ui/src/main/webapp/css/common.css
Removed:
trunk/suiviobsmer-business/
trunk/suiviobsmer-ui/
trunk/wao-business/README.txt
trunk/wao-business/pom.xml
trunk/wao-business/src/main/filters/SuiviObsmer.properties
trunk/wao-business/src/main/java/fr/ifremer/suiviobsmer/
trunk/wao-business/src/main/java/fr/ifremer/wao/MD5.java
trunk/wao-business/src/main/java/fr/ifremer/wao/SuiviObsmerBusinessException.java
trunk/wao-business/src/main/java/fr/ifremer/wao/SuiviObsmerContext.java
trunk/wao-business/src/main/java/fr/ifremer/wao/SuiviObsmerException.java
trunk/wao-business/src/main/java/fr/ifremer/wao/SuiviObsmerGlobal.java
trunk/wao-business/src/main/java/fr/ifremer/wao/SuiviObsmerMigrationCallBack.java
trunk/wao-business/src/main/java/fr/ifremer/wao/SuiviObsmerRunner.java
trunk/wao-business/src/main/java/fr/ifremer/wao/SuiviObsmerRunnerImpl.java
trunk/wao-business/src/main/java/fr/ifremer/wao/bean/BoatFilterImpl.java
trunk/wao-business/src/main/java/fr/ifremer/wao/bean/CompanyBoatInfosImpl.java
trunk/wao-business/src/main/java/fr/ifremer/wao/bean/ContactFilterImpl.java
trunk/wao-business/src/main/java/fr/ifremer/wao/bean/ContactState.java
trunk/wao-business/src/main/java/fr/ifremer/wao/bean/ContactStateStatisticsImpl.java
trunk/wao-business/src/main/java/fr/ifremer/wao/bean/FacadeRowImpl.java
trunk/wao-business/src/main/java/fr/ifremer/wao/bean/ImportResultsImpl.java
trunk/wao-business/src/main/java/fr/ifremer/wao/bean/SamplingFilterImpl.java
trunk/wao-business/src/main/java/fr/ifremer/wao/bean/UserFilterImpl.java
trunk/wao-business/src/main/java/fr/ifremer/wao/entity/ActivityCalendarImpl.java
trunk/wao-business/src/main/java/fr/ifremer/wao/entity/ActivityMonthImpl.java
trunk/wao-business/src/main/java/fr/ifremer/wao/entity/ActivityProfessionImpl.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/ContactDAOImpl.java
trunk/wao-business/src/main/java/fr/ifremer/wao/entity/ContactImpl.java
trunk/wao-business/src/main/java/fr/ifremer/wao/entity/FishingZoneImpl.java
trunk/wao-business/src/main/java/fr/ifremer/wao/entity/ProfessionImpl.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/SampleRowLogImpl.java
trunk/wao-business/src/main/java/fr/ifremer/wao/entity/WaoUserImpl.java
trunk/wao-business/src/main/java/fr/ifremer/wao/io/ExportHelper.java
trunk/wao-business/src/main/java/fr/ifremer/wao/io/ImportHelper.java
trunk/wao-business/src/main/java/fr/ifremer/wao/io/SamplingExport.java
trunk/wao-business/src/main/java/fr/ifremer/wao/io/WaoCsvHeader.java
trunk/wao-business/src/main/java/fr/ifremer/wao/mock/ServiceNewsMock.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/java/fr/ifremer/wao/services/
trunk/wao-business/src/main/xmi/suiviobsmer.properties
trunk/wao-business/src/main/xmi/suiviobsmer.zargo
trunk/wao-business/src/test/java/fr/ifremer/suiviobsmer/
trunk/wao-business/src/test/java/fr/ifremer/wao/ImportHelperTest.java
trunk/wao-business/src/test/java/fr/ifremer/wao/SuiviObsmerGlobalTest.java
trunk/wao-business/src/test/java/fr/ifremer/wao/SuiviObsmerRunnerTest.java
trunk/wao-business/src/test/java/fr/ifremer/wao/SuiviObsmerUtilsTest.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/services/ActivityCalendarImportTest.java
trunk/wao-business/src/test/java/fr/ifremer/wao/services/ServiceBoatImplTest.java
trunk/wao-business/src/test/java/fr/ifremer/wao/services/ServiceReferentialImplTest.java
trunk/wao-business/src/test/java/fr/ifremer/wao/services/ServiceSamplingImplTest.java
trunk/wao-business/src/test/java/fr/ifremer/wao/services/ServiceSynthesisImplTest.java
trunk/wao-business/src/test/resources/TopiaContextSuiviObsmer.properties
trunk/wao-ui/pom.xml
trunk/wao-ui/src/main/java/fr/ifremer/suiviobsmer/
trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/base/AbstractFilteredPage.java
trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/base/GenericSelectModel.java
trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/base/SuiviObsmerPage.java
trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/components/BooleanImage.java
trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/components/Chart.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/components/SubmitContext.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/ChartUtils.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/data/SuiviObsmerPropertyChangeListener.java
trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/data/SynthesisId.java
trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/mixins/Confirm.java
trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/mixins/PopupPageLink.java
trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/mixins/ZoneUpdater.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/ContactModelFactory.java
trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/services/SuiviObsmerManager.java
trunk/wao-ui/src/main/resources/fr/ifremer/suiviobsmer/ui/components/Layout.tml
trunk/wao-ui/src/main/resources/fr/ifremer/suiviobsmer/ui/pages/Synthesis.properties
trunk/wao-ui/src/main/resources/log4j.properties
trunk/wao-ui/src/main/webapp/Synthesis.tml
trunk/wao-ui/src/main/webapp/WEB-INF/web.xml
trunk/wao-ui/src/main/webapp/css/common.css
Modified:
trunk/changelog.txt
trunk/pom.xml
trunk/src/site/rst/installation.rst
trunk/wao-business/src/main/resources/oldmappings/SuiviObsmerModel/0.4/fr/ifremer/suiviobsmer/entity/ActivityCalendarImpl.hbm.xml
trunk/wao-business/src/main/resources/oldmappings/SuiviObsmerModel/0.4/fr/ifremer/suiviobsmer/entity/ActivityMonthImpl.hbm.xml
trunk/wao-business/src/main/resources/oldmappings/SuiviObsmerModel/0.4/fr/ifremer/suiviobsmer/entity/ActivityProfessionImpl.hbm.xml
trunk/wao-business/src/main/resources/oldmappings/SuiviObsmerModel/0.4/fr/ifremer/suiviobsmer/entity/ActivityZoneImpl.hbm.xml
trunk/wao-business/src/main/resources/oldmappings/SuiviObsmerModel/0.4/fr/ifremer/suiviobsmer/entity/BoatImpl.hbm.xml
trunk/wao-business/src/main/resources/oldmappings/SuiviObsmerModel/0.4/fr/ifremer/suiviobsmer/entity/BoatInfosImpl.hbm.xml
trunk/wao-business/src/main/resources/oldmappings/SuiviObsmerModel/0.4/fr/ifremer/suiviobsmer/entity/CompanyImpl.hbm.xml
trunk/wao-business/src/main/resources/oldmappings/SuiviObsmerModel/0.4/fr/ifremer/suiviobsmer/entity/ContactImpl.hbm.xml
trunk/wao-business/src/main/resources/oldmappings/SuiviObsmerModel/0.4/fr/ifremer/suiviobsmer/entity/ElligibleBoatImpl.hbm.xml
trunk/wao-business/src/main/resources/oldmappings/SuiviObsmerModel/0.4/fr/ifremer/suiviobsmer/entity/FishingZoneImpl.hbm.xml
trunk/wao-business/src/main/resources/oldmappings/SuiviObsmerModel/0.4/fr/ifremer/suiviobsmer/entity/NewsImpl.hbm.xml
trunk/wao-business/src/main/resources/oldmappings/SuiviObsmerModel/0.4/fr/ifremer/suiviobsmer/entity/ProfessionImpl.hbm.xml
trunk/wao-business/src/main/resources/oldmappings/SuiviObsmerModel/0.4/fr/ifremer/suiviobsmer/entity/SampleMonthImpl.hbm.xml
trunk/wao-business/src/main/resources/oldmappings/SuiviObsmerModel/0.4/fr/ifremer/suiviobsmer/entity/SampleRowImpl.hbm.xml
trunk/wao-business/src/main/resources/oldmappings/SuiviObsmerModel/0.4/fr/ifremer/suiviobsmer/entity/SampleRowLogImpl.hbm.xml
trunk/wao-business/src/main/resources/oldmappings/SuiviObsmerModel/0.4/fr/ifremer/suiviobsmer/entity/ShipOwnerImpl.hbm.xml
trunk/wao-business/src/main/resources/oldmappings/SuiviObsmerModel/0.4/fr/ifremer/suiviobsmer/entity/WaoUserImpl.hbm.xml
trunk/wao-business/src/main/resources/oldmappings/SuiviObsmerModel/0/fr/ifremer/suiviobsmer/entity/ActivityCalendarImpl.hbm.xml
trunk/wao-business/src/main/resources/oldmappings/SuiviObsmerModel/0/fr/ifremer/suiviobsmer/entity/ActivityMonthImpl.hbm.xml
trunk/wao-business/src/main/resources/oldmappings/SuiviObsmerModel/0/fr/ifremer/suiviobsmer/entity/ActivityProfessionImpl.hbm.xml
trunk/wao-business/src/main/resources/oldmappings/SuiviObsmerModel/0/fr/ifremer/suiviobsmer/entity/ActivityZoneImpl.hbm.xml
trunk/wao-business/src/main/resources/oldmappings/SuiviObsmerModel/0/fr/ifremer/suiviobsmer/entity/BoatImpl.hbm.xml
trunk/wao-business/src/main/resources/oldmappings/SuiviObsmerModel/0/fr/ifremer/suiviobsmer/entity/BoatInfosImpl.hbm.xml
trunk/wao-business/src/main/resources/oldmappings/SuiviObsmerModel/0/fr/ifremer/suiviobsmer/entity/CompanyImpl.hbm.xml
trunk/wao-business/src/main/resources/oldmappings/SuiviObsmerModel/0/fr/ifremer/suiviobsmer/entity/ContactImpl.hbm.xml
trunk/wao-business/src/main/resources/oldmappings/SuiviObsmerModel/0/fr/ifremer/suiviobsmer/entity/ElligibleBoatImpl.hbm.xml
trunk/wao-business/src/main/resources/oldmappings/SuiviObsmerModel/0/fr/ifremer/suiviobsmer/entity/FishingZoneImpl.hbm.xml
trunk/wao-business/src/main/resources/oldmappings/SuiviObsmerModel/0/fr/ifremer/suiviobsmer/entity/NewsImpl.hbm.xml
trunk/wao-business/src/main/resources/oldmappings/SuiviObsmerModel/0/fr/ifremer/suiviobsmer/entity/ProfessionImpl.hbm.xml
trunk/wao-business/src/main/resources/oldmappings/SuiviObsmerModel/0/fr/ifremer/suiviobsmer/entity/SampleMonthImpl.hbm.xml
trunk/wao-business/src/main/resources/oldmappings/SuiviObsmerModel/0/fr/ifremer/suiviobsmer/entity/SampleRowImpl.hbm.xml
trunk/wao-business/src/main/resources/oldmappings/SuiviObsmerModel/0/fr/ifremer/suiviobsmer/entity/SampleRowLogImpl.hbm.xml
trunk/wao-business/src/main/resources/oldmappings/SuiviObsmerModel/0/fr/ifremer/suiviobsmer/entity/ShipOwnerImpl.hbm.xml
trunk/wao-business/src/main/resources/oldmappings/SuiviObsmerModel/0/fr/ifremer/suiviobsmer/entity/WaoUserImpl.hbm.xml
trunk/wao-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/ActivityCalendarImpl.hbm.xml
trunk/wao-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/ActivityMonthImpl.hbm.xml
trunk/wao-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/ActivityProfessionImpl.hbm.xml
trunk/wao-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/ActivityZoneImpl.hbm.xml
trunk/wao-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/BoatImpl.hbm.xml
trunk/wao-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/BoatInfosImpl.hbm.xml
trunk/wao-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/CompanyImpl.hbm.xml
trunk/wao-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/ContactImpl.hbm.xml
trunk/wao-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/ElligibleBoatImpl.hbm.xml
trunk/wao-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/FishingZoneImpl.hbm.xml
trunk/wao-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/NewsImpl.hbm.xml
trunk/wao-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/ProfessionImpl.hbm.xml
trunk/wao-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/SampleMonthImpl.hbm.xml
trunk/wao-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/SampleRowImpl.hbm.xml
trunk/wao-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/SampleRowLogImpl.hbm.xml
trunk/wao-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/ShipOwnerImpl.hbm.xml
trunk/wao-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/WaoUserImpl.hbm.xml
trunk/wao-business/src/test/resources/log4j.properties
Log:
refactor packages and artifactId
Modified: trunk/changelog.txt
===================================================================
--- trunk/changelog.txt 2010-02-16 12:00:05 UTC (rev 354)
+++ trunk/changelog.txt 2010-02-16 13:56:07 UTC (rev 355)
@@ -9,6 +9,8 @@
Evolutions
++++++++++
+- [fdesbois] Renommage des packages et artifact maven en **wao** au lieu de
+ **suiviobsmer**
- [fdesbois] Evo #1985 : Synthèse : indicateur nombre de jour moyen entre date
de saisie dans Allegro et date de fin de marée des contacts
- [fdesbois] Evo #2022 : Plan d'échantillonnage : Export CSV
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2010-02-16 12:00:05 UTC (rev 354)
+++ trunk/pom.xml 2010-02-16 13:56:07 UTC (rev 355)
@@ -18,8 +18,8 @@
<version>1.0-SNAPSHOT</version>
<modules>
- <module>suiviobsmer-ui</module>
- <module>suiviobsmer-business</module>
+ <module>wao-ui</module>
+ <module>wao-business</module>
</modules>
<dependencyManagement>
Modified: trunk/src/site/rst/installation.rst
===================================================================
--- trunk/src/site/rst/installation.rst 2010-02-16 12:00:05 UTC (rev 354)
+++ trunk/src/site/rst/installation.rst 2010-02-16 13:56:07 UTC (rev 355)
@@ -93,7 +93,7 @@
Note
Le niveau de log par défaut est placé à DEBUG pour l'ensemble de l'application
- (package : **log4j.logger.fr.ifremer.suiviobsmer=DEBUG**)
+ (package : **log4j.logger.fr.ifremer.wao=DEBUG**)
Références
Property changes on: trunk/wao-business
___________________________________________________________________
Added: svn:ignore
+ target
*.iml
*.ipr
*.iws
Added: svn:mergeinfo
+
Deleted: trunk/wao-business/README.txt
===================================================================
--- trunk/suiviobsmer-business/README.txt 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-business/README.txt 2010-02-16 13:56:07 UTC (rev 355)
@@ -1 +0,0 @@
-Look at README.txt in SuiviObsmer-ui to launch the application
Copied: trunk/wao-business/README.txt (from rev 354, trunk/suiviobsmer-business/README.txt)
===================================================================
--- trunk/wao-business/README.txt (rev 0)
+++ trunk/wao-business/README.txt 2010-02-16 13:56:07 UTC (rev 355)
@@ -0,0 +1 @@
+Look at README.txt in Wao-ui to launch the application
Deleted: trunk/wao-business/pom.xml
===================================================================
--- trunk/suiviobsmer-business/pom.xml 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-business/pom.xml 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,176 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-
- <modelVersion>4.0.0</modelVersion>
-
- <!-- ************************************************************* -->
- <!-- *** POM Relationships *************************************** -->
- <!-- ************************************************************* -->
-
- <parent>
- <groupId>fr.ifremer</groupId>
- <artifactId>suiviobsmer</artifactId>
- <version>1.0.0-SNAPSHOT</version>
- </parent>
-
- <groupId>fr.ifremer.suiviobsmer</groupId>
- <artifactId>suiviobsmer-business</artifactId>
-
-
- <dependencies>
- <dependency>
- <groupId>commons-lang</groupId>
- <artifactId>commons-lang</artifactId>
- </dependency>
- <dependency>
- <groupId>commons-io</groupId>
- <artifactId>commons-io</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.commons</groupId>
- <artifactId>commons-email</artifactId>
- </dependency>
- <dependency>
- <groupId>org.nuiton</groupId>
- <artifactId>nuiton-utils</artifactId>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-log4j12</artifactId>
- </dependency>
- <dependency>
- <groupId>log4j</groupId>
- <artifactId>log4j</artifactId>
- </dependency>
- <dependency>
- <groupId>org.nuiton</groupId>
- <artifactId>nuiton-utils</artifactId>
- </dependency>
- <dependency>
- <groupId>net.sourceforge.javacsv</groupId>
- <artifactId>javacsv</artifactId>
- </dependency>
- <!-- ToPIA -->
- <dependency>
- <groupId>org.nuiton.topia</groupId>
- <artifactId>topia-persistence</artifactId>
- </dependency>
- <dependency>
- <groupId>org.nuiton.topia</groupId>
- <artifactId>topia-service-migration</artifactId>
- </dependency>
-
- <!-- base h2 -->
- <dependency>
- <groupId>com.h2database</groupId>
- <artifactId>h2</artifactId>
- </dependency>
- <dependency>
- <groupId>postgresql</groupId>
- <artifactId>postgresql</artifactId>
- </dependency>
-
- <!-- base postgres -->
- <!--dependency>
- <groupId>postgresql</groupId>
- <artifactId>postgresql</artifactId>
- </dependency-->
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- </dependency>
- </dependencies>
-
- <!-- ************************************************************* -->
- <!-- *** Project Information ************************************* -->
- <!-- ************************************************************* -->
-
- <name>SuiviObsmer :: Business</name>
- <description>Métier de l'application SuiviObsmer</description>
-
- <!-- ************************************************************* -->
- <!-- *** Build Settings ****************************************** -->
- <!-- ************************************************************* -->
-
- <packaging>jar</packaging>
-
- <!-- ************************************************************* -->
- <!-- *** Build Environment ************************************** -->
- <!-- ************************************************************* -->
-
- <build>
- <!-- FIXME les filtres ne fonctionnent pas ! -->
- <!-- Filter for resolving maven properties in SuiviObsmer.properties in resource folder -->
- <resources>
- <resource>
- <directory>src/main/filters</directory>
- <filtering>true</filtering>
- <includes>
- <include>SuiviObsmer.properties</include>
- </includes>
- </resource>
- <resource>
- <directory>src/main/resources</directory>
- <filtering>false</filtering>
- <includes>
- <include>**/*</include>
- </includes>
- </resource>
-
- </resources>
- <plugins>
- <plugin>
- <groupId>org.nuiton.eugene</groupId>
- <artifactId>maven-eugene-plugin</artifactId>
- <executions>
- <execution>
- <id>generate-entities</id>
- <phase>generate-sources</phase>
- <!-- By default, generation from ObjectModel -->
- <configuration>
- <!--<inputs>zargo</inputs>-->
- <!-- Corresponding to extracted package from zargo file -->
- <fullPackagePath>fr.ifremer.suiviobsmer</fullPackagePath>
- <!-- DefaultPackage used for DAOHelper generation -->
- <defaultPackage>fr.ifremer.suiviobsmer</defaultPackage>
- <templates>
- org.nuiton.topia.generator.TopiaMetaTransformer,
- org.nuiton.topia.generator.InterfaceTransformer,
- org.nuiton.topia.generator.BeanTransformer
- </templates>
- </configuration>
- <goals>
- <goal>smart-generate</goal>
- </goals>
- </execution>
- <execution>
- <phase>generate-sources</phase>
- <id>copy-version-files</id>
- <configuration>
- <includes>**/suiviobsmer.objectmodel</includes>
- <copyVersionDir>${basedir}/src/main/resources/oldmappings/%MODELNAME%
- </copyVersionDir>
- <copyVersionFiles>**/*.hbm.xml</copyVersionFiles>
- <overwrite>true</overwrite>
- </configuration>
- <goals>
- <goal>copyVersionFiles</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-
- <scm>
- <url>http://labs.libre-entreprise.org/scm/viewvc.php/trunk/suiviobsmer-business/…</url>
- <connection>scm:svn:svn://anonymous at labs.libre-entreprise.org/svnroot/suiviobsmer/trunk/suiviobsmer-business</connection>
- <developerConnection>scm:svn:svn+ssh://fdesbois at labs.libre-entreprise.org/svnroot/suiviobsmer/trunk/suiviobsmer-business</developerConnection>
- </scm>
-
-</project>
-
Copied: trunk/wao-business/pom.xml (from rev 354, trunk/suiviobsmer-business/pom.xml)
===================================================================
--- trunk/wao-business/pom.xml (rev 0)
+++ trunk/wao-business/pom.xml 2010-02-16 13:56:07 UTC (rev 355)
@@ -0,0 +1,169 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <!-- ************************************************************* -->
+ <!-- *** POM Relationships *************************************** -->
+ <!-- ************************************************************* -->
+
+ <parent>
+ <groupId>fr.ifremer</groupId>
+ <artifactId>wao</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </parent>
+
+ <groupId>fr.ifremer.wao</groupId>
+ <artifactId>wao-business</artifactId>
+
+
+ <dependencies>
+ <dependency>
+ <groupId>commons-lang</groupId>
+ <artifactId>commons-lang</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-email</artifactId>
+ </dependency>
+ <!-- Utils -->
+ <dependency>
+ <groupId>org.nuiton</groupId>
+ <artifactId>nuiton-utils</artifactId>
+ </dependency>
+ <!-- Logging -->
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ </dependency>
+ <!-- CSV lib -->
+ <dependency>
+ <groupId>net.sourceforge.javacsv</groupId>
+ <artifactId>javacsv</artifactId>
+ </dependency>
+ <!-- ToPIA -->
+ <dependency>
+ <groupId>org.nuiton.topia</groupId>
+ <artifactId>topia-persistence</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.nuiton.topia</groupId>
+ <artifactId>topia-service-migration</artifactId>
+ </dependency>
+ <!-- SGBD -->
+ <dependency>
+ <groupId>com.h2database</groupId>
+ <artifactId>h2</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>postgresql</groupId>
+ <artifactId>postgresql</artifactId>
+ </dependency>
+ <!-- Tests -->
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </dependency>
+ </dependencies>
+
+ <!-- ************************************************************* -->
+ <!-- *** Project Information ************************************* -->
+ <!-- ************************************************************* -->
+
+ <name>Wao :: Business</name>
+ <description>Métier de l'application Wao</description>
+
+ <!-- ************************************************************* -->
+ <!-- *** Build Settings ****************************************** -->
+ <!-- ************************************************************* -->
+
+ <packaging>jar</packaging>
+
+ <!-- ************************************************************* -->
+ <!-- *** Build Environment ************************************** -->
+ <!-- ************************************************************* -->
+
+ <build>
+ <!-- FIXME les filtres ne fonctionnent pas ! -->
+ <!-- Filter for resolving maven properties in Wao.properties in resource folder -->
+ <resources>
+ <resource>
+ <directory>src/main/filters</directory>
+ <filtering>true</filtering>
+ <includes>
+ <include>Wao.properties</include>
+ </includes>
+ </resource>
+ <resource>
+ <directory>src/main/resources</directory>
+ <filtering>false</filtering>
+ <includes>
+ <include>**/*</include>
+ </includes>
+ </resource>
+
+ </resources>
+ <plugins>
+ <plugin>
+ <groupId>org.nuiton.eugene</groupId>
+ <artifactId>maven-eugene-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>generate-entities</id>
+ <phase>generate-sources</phase>
+ <!-- By default, generation from ObjectModel -->
+ <configuration>
+ <!--<inputs>zargo</inputs>-->
+ <!-- Corresponding to extracted package from zargo file -->
+ <fullPackagePath>fr.ifremer.wao</fullPackagePath>
+ <!-- DefaultPackage used for DAOHelper generation -->
+ <defaultPackage>fr.ifremer.wao</defaultPackage>
+ <templates>
+ org.nuiton.topia.generator.TopiaMetaTransformer,
+ org.nuiton.topia.generator.InterfaceTransformer,
+ org.nuiton.topia.generator.BeanTransformer
+ </templates>
+ </configuration>
+ <goals>
+ <goal>smart-generate</goal>
+ </goals>
+ </execution>
+ <execution>
+ <phase>generate-sources</phase>
+ <id>copy-version-files</id>
+ <configuration>
+ <includes>**/wao.objectmodel</includes>
+ <copyVersionDir>${basedir}/src/main/resources/oldmappings/%MODELNAME%
+ </copyVersionDir>
+ <copyVersionFiles>**/*.hbm.xml</copyVersionFiles>
+ <overwrite>true</overwrite>
+ </configuration>
+ <goals>
+ <goal>copyVersionFiles</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+ <scm>
+ <url>http://labs.libre-entreprise.org/scm/viewvc.php/trunk/suiviobsmer-business/…</url>
+ <connection>scm:svn:svn://anonymous at labs.libre-entreprise.org/svnroot/suiviobsmer/trunk/suiviobsmer-business</connection>
+ <developerConnection>scm:svn:svn+ssh://fdesbois at labs.libre-entreprise.org/svnroot/suiviobsmer/trunk/suiviobsmer-business</developerConnection>
+ </scm>
+
+</project>
+
Deleted: trunk/wao-business/src/main/filters/SuiviObsmer.properties
===================================================================
--- trunk/suiviobsmer-business/src/main/filters/SuiviObsmer.properties 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-business/src/main/filters/SuiviObsmer.properties 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,20 +0,0 @@
-## Default properties for H2 database
-hibernate.hbm2ddl.auto=create
-hibernate.show_sql=false
-
-hibernate.dialect=org.hibernate.dialect.H2Dialect
-hibernate.connection.username=sa
-hibernate.connection.password=
-hibernate.connection.driver_class=org.h2.Driver
-hibernate.connection.url=jdbc:h2:file:~/.local/wao/h2data
-
-suiviobsmer.log.activityCalendar.access=${user.home}/.local/wao/log/activity-access.log
-suiviobsmer.log.activityCalendar.import=${user.home}/.local/wao/log/activity.log
-
-## Config for sending Email
-suiviobsmer.email.host=smtp.free.fr
-suiviobsmer.email.port=25
-suiviobsmer.email.from=admin at wao.org
-
-## Version
-suiviobsmer.version=1.0
\ No newline at end of file
Copied: trunk/wao-business/src/main/filters/Wao.properties (from rev 354, trunk/suiviobsmer-business/src/main/filters/Wao.properties)
===================================================================
--- trunk/wao-business/src/main/filters/Wao.properties (rev 0)
+++ trunk/wao-business/src/main/filters/Wao.properties 2010-02-16 13:56:07 UTC (rev 355)
@@ -0,0 +1,24 @@
+## Default properties for H2 database
+hibernate.hbm2ddl.auto=create
+hibernate.show_sql=false
+hibernate.dialect=org.hibernate.dialect.H2Dialect
+hibernate.connection.username=sa
+hibernate.connection.password=
+hibernate.connection.driver_class=org.h2.Driver
+## Database location in user home
+hibernate.connection.url=jdbc:h2:file:~/.local/wao/h2data
+
+## Logs for activityCalendar in user home
+wao.log.activityCalendar.access=${user.home}/.local/wao/log/activity-access.log
+wao.log.activityCalendar.import=${user.home}/.local/wao/log/activity.log
+
+## Config for sending Email
+wao.email.host=smtp
+wao.email.port=25
+wao.email.from=admin at wao.org
+
+## Server path for link in mails (must be override)
+wao.server.path=localhost:8080/wao
+
+## Version (not necessary to override it)
+wao.version=1.0
\ No newline at end of file
Property changes on: trunk/wao-business/src/main/java/fr/ifremer/wao
___________________________________________________________________
Added: svn:mergeinfo
+
Deleted: trunk/wao-business/src/main/java/fr/ifremer/wao/MD5.java
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/MD5.java 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/MD5.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,64 +0,0 @@
-/* *##%
- * SuiviObsmer :: 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.suiviobsmer;
-
-import java.security.MessageDigest;
-import java.security.NoSuchAlgorithmException;
-
-/**
- * Classe utilitaire permettant d'encoder des chaîne en MD5.
- *
- * @version $Id$
- */
-public class MD5 {
-
- /**
- * Encode la chaine passé en paramètre avec l’algorithme MD5
- *
- * @param key : la chaine à encoder
- * @return la valeur (string) hexadécimale sur 32 bits
- */
- public static String encode(String key) {
- if (key == null) {
- return key;
- }
- byte[] uniqueKey = key.getBytes();
- byte[] hash = null;
-
- try {
- // on récupère un objet qui permettra de crypter la chaine
- hash = MessageDigest.getInstance("MD5").digest(uniqueKey);
- } catch (NoSuchAlgorithmException eee) {
- throw new RuntimeException("no MD5 support in this VM", eee);
- }
-
- StringBuffer hashString = new StringBuffer();
- for (int i = 0; i < hash.length; ++i) {
- String hex = Integer.toHexString(hash[i]);
- if (hex.length() == 1) {
- hashString.append("0");
- hashString.append(hex.charAt(hex.length() - 1));
- } else {
- hashString.append(hex.substring(hex.length() - 2));
- }
- }
- return hashString.toString();
- }
-}
Copied: trunk/wao-business/src/main/java/fr/ifremer/wao/MD5.java (from rev 354, trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/MD5.java)
===================================================================
--- trunk/wao-business/src/main/java/fr/ifremer/wao/MD5.java (rev 0)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/MD5.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -0,0 +1,64 @@
+/* *##%
+ * 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.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+
+/**
+ * Classe utilitaire permettant d'encoder des chaîne en MD5.
+ *
+ * @version $Id$
+ */
+public class MD5 {
+
+ /**
+ * Encode la chaine passé en paramètre avec l’algorithme MD5
+ *
+ * @param key : la chaine à encoder
+ * @return la valeur (string) hexadécimale sur 32 bits
+ */
+ public static String encode(String key) {
+ if (key == null) {
+ return key;
+ }
+ byte[] uniqueKey = key.getBytes();
+ byte[] hash = null;
+
+ try {
+ // on récupère un objet qui permettra de crypter la chaine
+ hash = MessageDigest.getInstance("MD5").digest(uniqueKey);
+ } catch (NoSuchAlgorithmException eee) {
+ throw new RuntimeException("no MD5 support in this VM", eee);
+ }
+
+ StringBuffer hashString = new StringBuffer();
+ for (int i = 0; i < hash.length; ++i) {
+ String hex = Integer.toHexString(hash[i]);
+ if (hex.length() == 1) {
+ hashString.append("0");
+ hashString.append(hex.charAt(hex.length() - 1));
+ } else {
+ hashString.append(hex.substring(hex.length() - 2));
+ }
+ }
+ return hashString.toString();
+ }
+}
Deleted: trunk/wao-business/src/main/java/fr/ifremer/wao/SuiviObsmerBusinessException.java
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/SuiviObsmerBusinessException.java 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/SuiviObsmerBusinessException.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,66 +0,0 @@
-/*
- * *##%
- * SuiviObsmer :: 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.suiviobsmer;
-
-/**
- * SuiviObsmerBusinessException
- *
- * Created: 22 déc. 2009
- *
- * @param <T>
- * @author fdesbois
- * @version $Revision$
- *
- * Mise a jour: $Date$
- * par : $Author$
- */
-public class SuiviObsmerBusinessException extends SuiviObsmerException {
-
- protected Type type;
-
- protected Class<?> serviceClass;
-
- public SuiviObsmerBusinessException(Type type, Class<?> serviceClass, String msg) {
- super(msg);
- this.type = type;
- this.serviceClass = serviceClass;
- }
-
- public SuiviObsmerBusinessException(Type type, Class<?> serviceClass, String msg, Throwable cause) {
- super(msg, cause);
- this.type = type;
- this.serviceClass = serviceClass;
- }
-
- public static enum Type {
- IMPORT_ERROR, NOT_EXISTS, ALREADY_EXISTS, SYNTAX, BAD_CONNECTION, ILLEGAL_CONNECTION;
- }
-
- public Type getType() {
- return this.type;
- }
-
- public String getServiceName() {
- return this.serviceClass.getSimpleName();
- }
-
-}
Deleted: trunk/wao-business/src/main/java/fr/ifremer/wao/SuiviObsmerContext.java
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/SuiviObsmerContext.java 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/SuiviObsmerContext.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,243 +0,0 @@
-/**
- * *##%
- * SuiviObsmer :: 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.suiviobsmer;
-
-
-import fr.ifremer.suiviobsmer.entity.ActivityCalendar;
-import java.io.IOException;
-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;
-
-/**
- * ContextUtilSuiviObsmer.java
- *
- * Created on 2009-11-23
- *
- * @author fdesbois
- * @version $Revision$
- *
- * Last update: $Date$
- * by : $Author$
- */
-public class SuiviObsmerContext {
-
- private static final Logger log = LoggerFactory.getLogger(SuiviObsmerContext.class);
-
- public static final String PROP_FILENAME_LOG_ACTIVITY_IMPORT =
- "suiviobsmer.log.activityCalendar.import";
- public static final String PROP_FILENAME_LOG_ACTIVITY_ACCESS =
- "suiviobsmer.log.activityCalendar.access";
- public static final String PROP_EMAIL_HOST = "suiviobsmer.email.host";
- public static final String PROP_EMAIL_PORT = "suiviobsmer.email.port";
- public static final String PROP_EMAIL_FROM = "suiviobsmer.email.from";
- public static final String PROP_VERSION = "suiviobsmer.version";
- public static final String PROP_SERVER = "suiviobsmer.server.path";
-
- private static SuiviObsmerRunner runner;
-
- private static boolean activityCalendarImport;
-
- private static org.apache.log4j.Logger activityCalendarAccessLogger;
-
- public static void setRunner(SuiviObsmerRunner 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 SuiviObsmerException {
- if (runner.getConfiguration() == null) {
- throw new SuiviObsmerException("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 SuiviObsmerException {
- if (log.isDebugEnabled()) {
- log.debug("An error occured",eee);
- }
- if (!(eee instanceof SuiviObsmerException)) {
- //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 SuiviObsmerException("Fatal topia error when close context", eeee);
- }
- //}
- if (eee instanceof SQLGrammarException && log.isErrorEnabled()) {
- log.error("SQL executed with error : " + ((SQLGrammarException)eee).getSQL());
- }
- throw new SuiviObsmerException(message,eee);
- } else {
- throw (SuiviObsmerException)eee;
- }
- }
-
- public static void closeTransaction(TopiaContext transaction) throws SuiviObsmerException {
- try {
- if (transaction != null) {
- transaction.closeContext();
- }
- } catch (TopiaException eee) {
- throw new SuiviObsmerException("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 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();
- }
-}
Deleted: trunk/wao-business/src/main/java/fr/ifremer/wao/SuiviObsmerException.java
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/SuiviObsmerException.java 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/SuiviObsmerException.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,44 +0,0 @@
-/*
- * *##%
- * SuiviObsmer :: 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.suiviobsmer;
-
-/**
- * SuiviObsmerException
- *
- * Created: 7 nov. 2009
- *
- * @author fdesbois
- * @version $Revision$
- *
- * Mise a jour: $Date$
- * par : $Author$
- */
-public class SuiviObsmerException extends Exception {
-
- public SuiviObsmerException(String msg) {
- super(msg);
- }
-
- public SuiviObsmerException(String msg, Throwable cause) {
- super(msg, cause);
- }
-}
Deleted: trunk/wao-business/src/main/java/fr/ifremer/wao/SuiviObsmerGlobal.java
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/SuiviObsmerGlobal.java 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/SuiviObsmerGlobal.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,98 +0,0 @@
-/*
- * *##%
- * SuiviObsmer :: 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.suiviobsmer;
-
-import fr.ifremer.suiviobsmer.entity.Company;
-import fr.ifremer.suiviobsmer.entity.CompanyDAO;
-import fr.ifremer.suiviobsmer.entity.WaoUser;
-import fr.ifremer.suiviobsmer.entity.WaoUserDAO;
-import org.nuiton.topia.TopiaContext;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * SuiviObsmerGlobal
- *
- * Created: 27 nov. 2009
- *
- * @author fdesbois
- * @version $Revision$
- *
- * Mise a jour: $Date$
- * par : $Author$
- */
-public class SuiviObsmerGlobal {
-
- private static final Logger log = LoggerFactory.getLogger(SuiviObsmerGlobal.class);
-
- /**
- * Create a default admin user if no user already exist.
- *
- * @throws SuiviObsmerException
- */
- static void createDefaultAdmin() throws SuiviObsmerException {
- TopiaContext transaction = null;
- try {
- transaction = SuiviObsmerContext.getTopiaRootContext().beginTransaction();
-
- WaoUserDAO dao = SuiviObsmerModelDAOHelper.getWaoUserDAO(transaction);
-
- long nbUsers = dao.size();
-
- if (log.isInfoEnabled()) {
- log.info("Nb existing users : " + nbUsers);
- }
-
- if (nbUsers == 0) {
-
- CompanyDAO companyDAO = SuiviObsmerModelDAOHelper.getCompanyDAO(transaction);
-
- if (log.isInfoEnabled()) {
- log.info("Create first admin : login=\"admin\" / password=\"password\"");
- }
-
- Company company = companyDAO.create(Company.ACTIVE, false, Company.NAME, "ADMIN");
-
- String password = SuiviObsmerContext.encodeString("password");
-
- WaoUser user = dao.create(
- WaoUser.ADMIN, true,
- WaoUser.ACTIVE, true,
- WaoUser.LOGIN, "admin",
- WaoUser.PASSWORD, password,
- WaoUser.FIRST_NAME, "Super",
- WaoUser.LAST_NAME, "Admin");
- company.addWaoUser(user);
- user.setCompany(company);
-
- transaction.commitTransaction();
- }
-
- //transaction.closeContext();
- } catch (Exception eee) {
- SuiviObsmerContext.serviceException(null, "Error during database initialization", eee);
- } finally {
- SuiviObsmerContext.closeTransaction(transaction);
- }
- }
-
-}
Deleted: trunk/wao-business/src/main/java/fr/ifremer/wao/SuiviObsmerMigrationCallBack.java
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/SuiviObsmerMigrationCallBack.java 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/SuiviObsmerMigrationCallBack.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,44 +0,0 @@
-package fr.ifremer.suiviobsmer;
-
-import fr.ifremer.suiviobsmer.entity.SampleRow;
-import fr.ifremer.suiviobsmer.entity.SampleRowDAO;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.nuiton.topia.TopiaException;
-import org.nuiton.topia.framework.TopiaContextImplementor;
-import org.nuiton.topia.migration.ManualMigrationCallback;
-import org.nuiton.util.Version;
-
-import java.util.List;
-
-public class SuiviObsmerMigrationCallBack extends ManualMigrationCallback {
-
- /**
- * Logger
- */
- private static final Log log = LogFactory.getLog(SuiviObsmerMigrationCallBack.class);
-
- public void migrateTo_0_4(TopiaContextImplementor tx,
- boolean showSql,
- boolean showProgression) throws TopiaException {
-
- if (log.isInfoEnabled()) {
- log.info("Migrate to version 0.4");
- }
-
- SampleRowDAO dao = SuiviObsmerModelDAOHelper.getSampleRowDAO(tx);
- for (SampleRow row : dao.findAll()) {
- String newCode = SuiviObsmerContext.prepareSampleRowCode(row.getCode());
- row.setCode(newCode);
- }
- }
-
-
- @Override
- public boolean askUser(Version dbVersion,
- Version applicationVersion,
- List<Version> versions) {
- // Always migrate the database
- return true;
- }
-}
\ No newline at end of file
Deleted: trunk/wao-business/src/main/java/fr/ifremer/wao/SuiviObsmerRunner.java
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/SuiviObsmerRunner.java 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/SuiviObsmerRunner.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,68 +0,0 @@
-/*
- * *##%
- * SuiviObsmer :: 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.suiviobsmer;
-
-import java.util.Date;
-import org.nuiton.util.ApplicationConfig;
-
-/**
- * SuiviObsmerRun
- *
- * Created: 24 nov. 2009
- *
- * @author fdesbois
- * @version $Revision$
- *
- * Mise a jour: $Date$
- * par : $Author$
- */
-public interface SuiviObsmerRunner {
-
- /**
- * Start the application.
- *
- * @throws SuiviObsmerException
- */
- void start() throws SuiviObsmerException;
-
- /**
- * Stop the application.
- *
- * @throws SuiviObsmerException
- */
- void stop() throws SuiviObsmerException;
-
- /**
- * Return the current date, depends on environment.
- *
- * @return the current Date
- */
- Date getCurrentDate();
-
- /**
- * Return the configuration depends on environment.
- *
- * @return the ApplicationConfig which contains the application properties
- */
- ApplicationConfig getConfiguration();
-
-}
Deleted: trunk/wao-business/src/main/java/fr/ifremer/wao/SuiviObsmerRunnerImpl.java
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/SuiviObsmerRunnerImpl.java 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/SuiviObsmerRunnerImpl.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,97 +0,0 @@
-/*
- * *##%
- * SuiviObsmer :: 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.suiviobsmer;
-
-import java.util.Date;
-import java.util.Locale;
-
-import org.nuiton.i18n.I18n;
-import org.nuiton.topia.TopiaException;
-import org.nuiton.topia.migration.ManualMigrationEngine;
-import org.nuiton.util.ApplicationConfig;
-
-/**
- * StartSuiviObsmer
- *
- * Created: 24 nov. 2009
- *
- * @author fdesbois
- * @version $Revision$
- *
- * Mise a jour: $Date$
- * par : $Author$
- */
-public class SuiviObsmerRunnerImpl implements SuiviObsmerRunner {
-
- private ApplicationConfig configuration;
-
- public SuiviObsmerRunnerImpl() {
- }
-
- @Override
- public void start() throws SuiviObsmerException {
- try {
- configuration = new ApplicationConfig();
- configuration.setConfigFileName("SuiviObsmer.properties");
- configuration.parse(new String[]{});
- configuration.setOption("topia.persistence.classes",
- SuiviObsmerModelDAOHelper.getImplementationClassesAsString());
-
- // migration configuration
- configuration.setOption(ManualMigrationEngine.MIGRATION_APPLICATION_VERSION, SuiviObsmerModelDAOHelper.getModelVersion());
- configuration.setOption(ManualMigrationEngine.MIGRATION_MAPPING_DIRECTORY, "oldmappings");
- configuration.setOption(ManualMigrationEngine.MIGRATION_MODEL_NAME, "SuiviObsmerModel");
- configuration.setOption("topia.service.migration", ManualMigrationEngine.class.getName());
- configuration.setOption(ManualMigrationEngine.MIGRATION_CALLBACK, SuiviObsmerMigrationCallBack.class.getName());
-
- configuration.printConfig();
-
- I18n.init(Locale.FRANCE);
- // Use the context to set the runner for default environment.
- SuiviObsmerContext.setRunner(this);
- // Create the default admin in database
- SuiviObsmerGlobal.createDefaultAdmin();
- } catch (Exception eee) {
- SuiviObsmerContext.serviceException(null, "Error during loadConfiguration from " +
- "'SuiviObsmer.properties' file", eee);
- }
- }
-
- @Override
- public void stop() throws SuiviObsmerException {
- try {
- SuiviObsmerContext.getTopiaRootContext().closeContext();
- } catch (TopiaException eee) {
- SuiviObsmerContext.serviceException(null, "Error when closing Topia root context", eee);
- }
- }
-
- @Override
- public Date getCurrentDate() {
- return new Date();
- }
-
- @Override
- public ApplicationConfig getConfiguration() {
- return configuration;
- }
-}
Copied: trunk/wao-business/src/main/java/fr/ifremer/wao/WaoBusinessException.java (from rev 354, trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/WaoBusinessException.java)
===================================================================
--- trunk/wao-business/src/main/java/fr/ifremer/wao/WaoBusinessException.java (rev 0)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/WaoBusinessException.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -0,0 +1,66 @@
+/*
+ * *##%
+ * 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;
+
+/**
+ * WaoBusinessException
+ *
+ * Created: 22 déc. 2009
+ *
+ * @param <T>
+ * @author fdesbois
+ * @version $Revision$
+ *
+ * Mise a jour: $Date$
+ * par : $Author$
+ */
+public class WaoBusinessException extends WaoException {
+
+ protected Type type;
+
+ protected Class<?> serviceClass;
+
+ public WaoBusinessException(Type type, Class<?> serviceClass, String msg) {
+ super(msg);
+ this.type = type;
+ this.serviceClass = serviceClass;
+ }
+
+ public WaoBusinessException(Type type, Class<?> serviceClass, String msg, Throwable cause) {
+ super(msg, cause);
+ this.type = type;
+ this.serviceClass = serviceClass;
+ }
+
+ public static enum Type {
+ IMPORT_ERROR, NOT_EXISTS, ALREADY_EXISTS, SYNTAX, BAD_CONNECTION, ILLEGAL_CONNECTION;
+ }
+
+ public Type getType() {
+ return this.type;
+ }
+
+ public String getServiceName() {
+ return this.serviceClass.getSimpleName();
+ }
+
+}
Copied: trunk/wao-business/src/main/java/fr/ifremer/wao/WaoContext.java (from rev 354, trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/WaoContext.java)
===================================================================
--- trunk/wao-business/src/main/java/fr/ifremer/wao/WaoContext.java (rev 0)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/WaoContext.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -0,0 +1,243 @@
+/**
+ * *##%
+ * 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.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 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();
+ }
+}
Copied: trunk/wao-business/src/main/java/fr/ifremer/wao/WaoException.java (from rev 354, trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/WaoException.java)
===================================================================
--- trunk/wao-business/src/main/java/fr/ifremer/wao/WaoException.java (rev 0)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/WaoException.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -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 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/WaoGlobal.java (from rev 354, trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/WaoGlobal.java)
===================================================================
--- trunk/wao-business/src/main/java/fr/ifremer/wao/WaoGlobal.java (rev 0)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/WaoGlobal.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -0,0 +1,98 @@
+/*
+ * *##%
+ * 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.CompanyDAO;
+import fr.ifremer.wao.entity.WaoUser;
+import fr.ifremer.wao.entity.WaoUserDAO;
+import org.nuiton.topia.TopiaContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * WaoGlobal
+ *
+ * Created: 27 nov. 2009
+ *
+ * @author fdesbois
+ * @version $Revision$
+ *
+ * Mise a jour: $Date$
+ * par : $Author$
+ */
+public class WaoGlobal {
+
+ private static final Logger log = LoggerFactory.getLogger(WaoGlobal.class);
+
+ /**
+ * Create a default admin user if no user already exist.
+ *
+ * @throws WaoException
+ */
+ static void createDefaultAdmin() throws WaoException {
+ TopiaContext transaction = null;
+ try {
+ transaction = WaoContext.getTopiaRootContext().beginTransaction();
+
+ WaoUserDAO dao = WaoModelDAOHelper.getWaoUserDAO(transaction);
+
+ long nbUsers = dao.size();
+
+ if (log.isInfoEnabled()) {
+ log.info("Nb existing users : " + nbUsers);
+ }
+
+ if (nbUsers == 0) {
+
+ CompanyDAO companyDAO = WaoModelDAOHelper.getCompanyDAO(transaction);
+
+ if (log.isInfoEnabled()) {
+ log.info("Create first admin : login=\"admin\" / password=\"password\"");
+ }
+
+ Company company = companyDAO.create(Company.ACTIVE, false, Company.NAME, "ADMIN");
+
+ String password = WaoContext.encodeString("password");
+
+ WaoUser user = dao.create(
+ WaoUser.ADMIN, true,
+ WaoUser.ACTIVE, true,
+ WaoUser.LOGIN, "admin",
+ WaoUser.PASSWORD, password,
+ WaoUser.FIRST_NAME, "Super",
+ WaoUser.LAST_NAME, "Admin");
+ company.addWaoUser(user);
+ user.setCompany(company);
+
+ transaction.commitTransaction();
+ }
+
+ //transaction.closeContext();
+ } catch (Exception eee) {
+ WaoContext.serviceException(null, "Error during database initialization", eee);
+ } finally {
+ WaoContext.closeTransaction(transaction);
+ }
+ }
+
+}
Copied: trunk/wao-business/src/main/java/fr/ifremer/wao/WaoMigrationCallBack.java (from rev 354, trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/WaoMigrationCallBack.java)
===================================================================
--- trunk/wao-business/src/main/java/fr/ifremer/wao/WaoMigrationCallBack.java (rev 0)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/WaoMigrationCallBack.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -0,0 +1,64 @@
+/*
+ * *##%
+ * 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.SampleRow;
+import fr.ifremer.wao.entity.SampleRowDAO;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.topia.TopiaException;
+import org.nuiton.topia.framework.TopiaContextImplementor;
+import org.nuiton.topia.migration.ManualMigrationCallback;
+import org.nuiton.util.Version;
+
+import java.util.List;
+
+public class WaoMigrationCallBack extends ManualMigrationCallback {
+
+ /**
+ * Logger
+ */
+ private static final Log log = LogFactory.getLog(WaoMigrationCallBack.class);
+
+ public void migrateTo_0_4(TopiaContextImplementor tx,
+ boolean showSql,
+ boolean showProgression) throws TopiaException {
+
+ if (log.isInfoEnabled()) {
+ log.info("Migrate to version 0.4");
+ }
+
+ SampleRowDAO dao = WaoModelDAOHelper.getSampleRowDAO(tx);
+ for (SampleRow row : dao.findAll()) {
+ String newCode = WaoContext.prepareSampleRowCode(row.getCode());
+ row.setCode(newCode);
+ }
+ }
+
+
+ @Override
+ public boolean askUser(Version dbVersion,
+ Version applicationVersion,
+ List<Version> versions) {
+ // Always migrate the database
+ return true;
+ }
+}
\ No newline at end of file
Copied: trunk/wao-business/src/main/java/fr/ifremer/wao/WaoRunner.java (from rev 354, trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/WaoRunner.java)
===================================================================
--- trunk/wao-business/src/main/java/fr/ifremer/wao/WaoRunner.java (rev 0)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/WaoRunner.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -0,0 +1,68 @@
+/*
+ * *##%
+ * Wao :: Business
+ * Copyright (C) 2009 - 2010 Ifremer
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * ##%*
+ */
+
+package fr.ifremer.wao;
+
+import java.util.Date;
+import org.nuiton.util.ApplicationConfig;
+
+/**
+ * WaoRun
+ *
+ * Created: 24 nov. 2009
+ *
+ * @author fdesbois
+ * @version $Revision$
+ *
+ * Mise a jour: $Date$
+ * par : $Author$
+ */
+public interface WaoRunner {
+
+ /**
+ * Start the application.
+ *
+ * @throws WaoException
+ */
+ void start() throws WaoException;
+
+ /**
+ * Stop the application.
+ *
+ * @throws WaoException
+ */
+ void stop() throws WaoException;
+
+ /**
+ * Return the current date, depends on environment.
+ *
+ * @return the current Date
+ */
+ Date getCurrentDate();
+
+ /**
+ * Return the configuration depends on environment.
+ *
+ * @return the ApplicationConfig which contains the application properties
+ */
+ ApplicationConfig getConfiguration();
+
+}
Copied: trunk/wao-business/src/main/java/fr/ifremer/wao/WaoRunnerImpl.java (from rev 354, trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/WaoRunnerImpl.java)
===================================================================
--- trunk/wao-business/src/main/java/fr/ifremer/wao/WaoRunnerImpl.java (rev 0)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/WaoRunnerImpl.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -0,0 +1,97 @@
+/*
+ * *##%
+ * Wao :: Business
+ * Copyright (C) 2009 - 2010 Ifremer
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * ##%*
+ */
+
+package fr.ifremer.wao;
+
+import java.util.Date;
+import java.util.Locale;
+
+import org.nuiton.i18n.I18n;
+import org.nuiton.topia.TopiaException;
+import org.nuiton.topia.migration.ManualMigrationEngine;
+import org.nuiton.util.ApplicationConfig;
+
+/**
+ * StartWao
+ *
+ * Created: 24 nov. 2009
+ *
+ * @author fdesbois
+ * @version $Revision$
+ *
+ * Mise a jour: $Date$
+ * par : $Author$
+ */
+public class WaoRunnerImpl implements WaoRunner {
+
+ private ApplicationConfig configuration;
+
+ public WaoRunnerImpl() {
+ }
+
+ @Override
+ public void start() throws WaoException {
+ try {
+ configuration = new ApplicationConfig();
+ configuration.setConfigFileName("Wao.properties");
+ configuration.parse(new String[]{});
+ configuration.setOption("topia.persistence.classes",
+ WaoModelDAOHelper.getImplementationClassesAsString());
+
+ // migration configuration
+ configuration.setOption(ManualMigrationEngine.MIGRATION_APPLICATION_VERSION, WaoModelDAOHelper.getModelVersion());
+ configuration.setOption(ManualMigrationEngine.MIGRATION_MAPPING_DIRECTORY, "oldmappings");
+ configuration.setOption(ManualMigrationEngine.MIGRATION_MODEL_NAME, "WaoModel");
+ configuration.setOption("topia.service.migration", ManualMigrationEngine.class.getName());
+ configuration.setOption(ManualMigrationEngine.MIGRATION_CALLBACK, WaoMigrationCallBack.class.getName());
+
+ configuration.printConfig();
+
+ I18n.init(Locale.FRANCE);
+ // Use the context to set the runner for default environment.
+ WaoContext.setRunner(this);
+ // Create the default admin in database
+ WaoGlobal.createDefaultAdmin();
+ } catch (Exception eee) {
+ WaoContext.serviceException(null, "Error during loadConfiguration from " +
+ "'Wao.properties' file", eee);
+ }
+ }
+
+ @Override
+ public void stop() throws WaoException {
+ try {
+ WaoContext.getTopiaRootContext().closeContext();
+ } catch (TopiaException eee) {
+ WaoContext.serviceException(null, "Error when closing Topia root context", eee);
+ }
+ }
+
+ @Override
+ public Date getCurrentDate() {
+ return new Date();
+ }
+
+ @Override
+ public ApplicationConfig getConfiguration() {
+ return configuration;
+ }
+}
Deleted: trunk/wao-business/src/main/java/fr/ifremer/wao/bean/BoatFilterImpl.java
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/bean/BoatFilterImpl.java 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/bean/BoatFilterImpl.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,71 +0,0 @@
-/*
- * *##%
- * SuiviObsmer :: 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.suiviobsmer.bean;
-
-import fr.ifremer.suiviobsmer.entity.Boat;
-import org.apache.commons.lang.StringUtils;
-import org.nuiton.topia.framework.TopiaQuery;
-import org.nuiton.topia.framework.TopiaQuery.Op;
-
-/**
- * BoatFilterImpl
- *
- * Created: 2 déc. 2009
- *
- * @author fdesbois
- * @version $Revision$
- *
- * Mise a jour: $Date$
- * par : $Author$
- */
-public class BoatFilterImpl extends BoatFilter {
-
- @Override
- public TopiaQuery prepareQueryForBoat(TopiaQuery query, String boat) {
-
- // Limit
- query = prepareQueryForLimit(query);
-
- if (StringUtils.isNotEmpty(getBoatName())) {
- query.add(boat + "." + Boat.NAME, Op.LIKE, getBoatName().trim() + "%");
- }
-
- if (StringUtils.isNotEmpty(getBoatDistrictCode())) {
- query.add(boat + "." + Boat.DISTRICT_CODE, getBoatDistrictCode().trim());
- }
-
- if (getBoatImmatriculation() != null) {
- query.add(boat + "." + Boat.IMMATRICULATION, getBoatImmatriculation());
- }
- return query;
- }
-
- @Override
- public boolean isBoatFiltered() {
- return StringUtils.isNotEmpty(getBoatName()) || StringUtils.isNotEmpty(getBoatDistrictCode()) || getBoatImmatriculation() != null;
- }
-
-// @Override
-// public boolean isFiltered() {
-// return super.isFiltered() || isBoatFiltered();
-// }
-}
Copied: trunk/wao-business/src/main/java/fr/ifremer/wao/bean/BoatFilterImpl.java (from rev 354, trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/bean/BoatFilterImpl.java)
===================================================================
--- trunk/wao-business/src/main/java/fr/ifremer/wao/bean/BoatFilterImpl.java (rev 0)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/bean/BoatFilterImpl.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -0,0 +1,71 @@
+/*
+ * *##%
+ * 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.bean;
+
+import fr.ifremer.wao.entity.Boat;
+import org.apache.commons.lang.StringUtils;
+import org.nuiton.topia.framework.TopiaQuery;
+import org.nuiton.topia.framework.TopiaQuery.Op;
+
+/**
+ * BoatFilterImpl
+ *
+ * Created: 2 déc. 2009
+ *
+ * @author fdesbois
+ * @version $Revision$
+ *
+ * Mise a jour: $Date$
+ * par : $Author$
+ */
+public class BoatFilterImpl extends BoatFilter {
+
+ @Override
+ public TopiaQuery prepareQueryForBoat(TopiaQuery query, String boat) {
+
+ // Limit
+ query = prepareQueryForLimit(query);
+
+ if (StringUtils.isNotEmpty(getBoatName())) {
+ query.add(boat + "." + Boat.NAME, Op.LIKE, getBoatName().trim() + "%");
+ }
+
+ if (StringUtils.isNotEmpty(getBoatDistrictCode())) {
+ query.add(boat + "." + Boat.DISTRICT_CODE, getBoatDistrictCode().trim());
+ }
+
+ if (getBoatImmatriculation() != null) {
+ query.add(boat + "." + Boat.IMMATRICULATION, getBoatImmatriculation());
+ }
+ return query;
+ }
+
+ @Override
+ public boolean isBoatFiltered() {
+ return StringUtils.isNotEmpty(getBoatName()) || StringUtils.isNotEmpty(getBoatDistrictCode()) || getBoatImmatriculation() != null;
+ }
+
+// @Override
+// public boolean isFiltered() {
+// return super.isFiltered() || isBoatFiltered();
+// }
+}
Deleted: trunk/wao-business/src/main/java/fr/ifremer/wao/bean/CompanyBoatInfosImpl.java
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/bean/CompanyBoatInfosImpl.java 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/bean/CompanyBoatInfosImpl.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,107 +0,0 @@
-/*
- * *##%
- * SuiviObsmer :: 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.suiviobsmer.bean;
-
-import fr.ifremer.suiviobsmer.entity.ElligibleBoat;
-import fr.ifremer.suiviobsmer.entity.ElligibleBoatImpl;
-import fr.ifremer.suiviobsmer.entity.SampleRow;
-import java.util.Collection;
-import java.util.Iterator;
-import org.apache.commons.lang.StringUtils;
-
-/**
- * ElligibleBoatsCompanyImpl
- *
- * Created: 7 déc. 2009
- *
- * @author fdesbois
- * @version $Revision$
- *
- * Mise a jour: $Date$
- * par : $Author$
- */
-public class CompanyBoatInfosImpl extends CompanyBoatInfos {
-
- @Override
- public void removeElligibleBoat(String sampleRowCode) {
- ElligibleBoat elligible = elligibleBoats.get(sampleRowCode);
- // ElligibleBoat set by an admin
- if (elligible.getGlobalActive()) {
- elligible.setCompanyActive(Boolean.FALSE);
- } else {
- if (!deletedElligibleBoats.contains(elligible) && !StringUtils.isEmpty(elligible.getTopiaId())) {
- deletedElligibleBoats.add(elligible);
- }
- elligibleBoats.remove(sampleRowCode);
- }
- }
-
- @Override
- public ElligibleBoat getElligibleBoat(String sampleRowCode) {
- return elligibleBoats.get(sampleRowCode);
- }
-
- @Override
- public ElligibleBoat setNewElligibleBoat(SampleRow row) {
- if (row == null) {
- return null;
- }
- ElligibleBoat elligible = elligibleBoats.get(row.getCode());
- if (elligible == null) {
- elligible = new ElligibleBoatImpl();
- elligible.setBoat(boatInfos.getBoat());
- elligible.setSampleRow(row);
- elligibleBoats.put(row.getCode(), elligible);
- removePreviouslyDeleted(row.getCode());
- }
- elligible.setCompanyActive(Boolean.TRUE);
- return elligible;
- }
-
- protected void removePreviouslyDeleted(String sampleRowCode) {
- Iterator<ElligibleBoat> it = deletedElligibleBoats.iterator();
- while (it.hasNext()) {
- ElligibleBoat current = it.next();
- if (current.getSampleRow().getCode().equals(sampleRowCode)) {
- it.remove();
- }
- }
- }
-
- /**
- * Active only element wich is inactive. So element which is linked by admin in SamplingRowForm.
- * The Boolean CompanyActive is set to null : no specific modification for company.
- *
- * @param sampleRowCode code of the element to reactivate
- */
- @Override
- public void activeElligibleBoat(String sampleRowCode) {
- ElligibleBoat elligible = getElligibleBoat(sampleRowCode);
- elligible.setCompanyActive(null);
- }
-
- @Override
- public Collection<ElligibleBoat> getElligibleBoatsValues() {
- return elligibleBoats.values();
- }
-
-}
Copied: trunk/wao-business/src/main/java/fr/ifremer/wao/bean/CompanyBoatInfosImpl.java (from rev 354, trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/bean/CompanyBoatInfosImpl.java)
===================================================================
--- trunk/wao-business/src/main/java/fr/ifremer/wao/bean/CompanyBoatInfosImpl.java (rev 0)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/bean/CompanyBoatInfosImpl.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -0,0 +1,107 @@
+/*
+ * *##%
+ * 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.bean;
+
+import fr.ifremer.wao.entity.ElligibleBoat;
+import fr.ifremer.wao.entity.ElligibleBoatImpl;
+import fr.ifremer.wao.entity.SampleRow;
+import java.util.Collection;
+import java.util.Iterator;
+import org.apache.commons.lang.StringUtils;
+
+/**
+ * ElligibleBoatsCompanyImpl
+ *
+ * Created: 7 déc. 2009
+ *
+ * @author fdesbois
+ * @version $Revision$
+ *
+ * Mise a jour: $Date$
+ * par : $Author$
+ */
+public class CompanyBoatInfosImpl extends CompanyBoatInfos {
+
+ @Override
+ public void removeElligibleBoat(String sampleRowCode) {
+ ElligibleBoat elligible = elligibleBoats.get(sampleRowCode);
+ // ElligibleBoat set by an admin
+ if (elligible.getGlobalActive()) {
+ elligible.setCompanyActive(Boolean.FALSE);
+ } else {
+ if (!deletedElligibleBoats.contains(elligible) && !StringUtils.isEmpty(elligible.getTopiaId())) {
+ deletedElligibleBoats.add(elligible);
+ }
+ elligibleBoats.remove(sampleRowCode);
+ }
+ }
+
+ @Override
+ public ElligibleBoat getElligibleBoat(String sampleRowCode) {
+ return elligibleBoats.get(sampleRowCode);
+ }
+
+ @Override
+ public ElligibleBoat setNewElligibleBoat(SampleRow row) {
+ if (row == null) {
+ return null;
+ }
+ ElligibleBoat elligible = elligibleBoats.get(row.getCode());
+ if (elligible == null) {
+ elligible = new ElligibleBoatImpl();
+ elligible.setBoat(boatInfos.getBoat());
+ elligible.setSampleRow(row);
+ elligibleBoats.put(row.getCode(), elligible);
+ removePreviouslyDeleted(row.getCode());
+ }
+ elligible.setCompanyActive(Boolean.TRUE);
+ return elligible;
+ }
+
+ protected void removePreviouslyDeleted(String sampleRowCode) {
+ Iterator<ElligibleBoat> it = deletedElligibleBoats.iterator();
+ while (it.hasNext()) {
+ ElligibleBoat current = it.next();
+ if (current.getSampleRow().getCode().equals(sampleRowCode)) {
+ it.remove();
+ }
+ }
+ }
+
+ /**
+ * Active only element wich is inactive. So element which is linked by admin in SamplingRowForm.
+ * The Boolean CompanyActive is set to null : no specific modification for company.
+ *
+ * @param sampleRowCode code of the element to reactivate
+ */
+ @Override
+ public void activeElligibleBoat(String sampleRowCode) {
+ ElligibleBoat elligible = getElligibleBoat(sampleRowCode);
+ elligible.setCompanyActive(null);
+ }
+
+ @Override
+ public Collection<ElligibleBoat> getElligibleBoatsValues() {
+ return elligibleBoats.values();
+ }
+
+}
Copied: trunk/wao-business/src/main/java/fr/ifremer/wao/bean/ContactAverageReactivityImpl.java (from rev 354, trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/bean/ContactAverageReactivityImpl.java)
===================================================================
--- trunk/wao-business/src/main/java/fr/ifremer/wao/bean/ContactAverageReactivityImpl.java (rev 0)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/bean/ContactAverageReactivityImpl.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -0,0 +1,52 @@
+/*
+ * *##%
+ * 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.bean;
+
+/**
+ * ContactAverageReactivityImpl
+ *
+ * Created: 12 févr. 2010
+ *
+ * @author fdesbois
+ * @version $Revision$
+ *
+ * Mise a jour: $Date$
+ * par : $Author$
+ */
+public class ContactAverageReactivityImpl extends ContactAverageReactivity {
+
+ @Override
+ public void addValue(int nbDays) {
+ nbResults++;
+ if (nbDays < 0) {
+ // Not normal, problem with some existing data (maybe from import)
+ nbDays = 0;
+ }
+ totalDays += nbDays;
+ }
+
+ @Override
+ public double getResult() {
+ return (double)totalDays / (double)nbResults;
+ }
+
+}
Deleted: trunk/wao-business/src/main/java/fr/ifremer/wao/bean/ContactFilterImpl.java
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/bean/ContactFilterImpl.java 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/bean/ContactFilterImpl.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,113 +0,0 @@
-/*
- * *##%
- * SuiviObsmer :: 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.suiviobsmer.bean;
-
-import fr.ifremer.suiviobsmer.entity.Contact;
-import java.util.ArrayList;
-import java.util.List;
-import org.nuiton.topia.TopiaException;
-import org.nuiton.topia.framework.TopiaQuery;
-import org.nuiton.topia.persistence.TopiaEntity;
-
-/**
- * ContactFilterImpl
- *
- * Created: 14 janv. 2010
- *
- * @author fdesbois
- * @version $Revision$
- *
- * Mise a jour: $Date$
- * par : $Author$
- */
-public class ContactFilterImpl extends ContactFilter {
-
- @Override
- public TopiaQuery prepareQueryForContact(TopiaQuery query) {
-
- String contact = query.getMainAlias();
-
- if (getObserver() != null) {
- query.add(contact + "." + Contact.OBSERVER, getObserver());
- }
- // Company filter is managed by SamplingFilter because the company is
- // linked with the sampleRow instead of contact user
-
- if (isSamplingFiltered() || getFromDate() != null || getCompany() != null) {
- // Seems to be necessary to have distinct on sampleRows in case of
- // fishingZone join. Otherwise multiple contacts for sames sampleRow
- // will be returned (Bad count).
- query = prepareQueryForSampling(query, contact + "." + Contact.SAMPLE_ROW);
- }
- query = prepareQueryForBoat(query, contact + "." + Contact.BOAT);
-
- if (getMammalsObservation() && getMammalsCapture()) {
- query.add(contact + "." + Contact.MAMMALS_OBSERVATION + " = :mammals OR " + contact + "." + Contact.MAMMALS_CAPTURE + " = :mammals").
- addParam("mammals", Boolean.TRUE);
- } else if (getMammalsObservation()) {
- query.add(contact + "." + Contact.MAMMALS_OBSERVATION, Boolean.TRUE);
- } else if (getMammalsCapture()) {
- query.add(contact + "." + Contact.MAMMALS_CAPTURE, Boolean.TRUE);
- }
-
- List<Object> programValidValues = new ArrayList<Object>();
- if (getProgramAccepted()) {
- programValidValues.add(Boolean.TRUE);
- }
- if (getProgramRefused()) {
- programValidValues.add(Boolean.FALSE);
- }
- query.add(contact + "." + Contact.VALIDATION_PROGRAM, programValidValues, getProgramUndefined());
-
- List<Object> companyValidValues = new ArrayList<Object>();
- if (getCompanyAccepted()) {
- companyValidValues.add(Boolean.TRUE);
- }
- if (getCompanyRefused()) {
- companyValidValues.add(Boolean.FALSE);
- }
- query.add(contact + "." + Contact.VALIDATION_COMPANY, companyValidValues, getCompanyUndefined());
-
- if (getState() != null) {
- query.add(contact + "." + Contact.STATE, getState().toString());
- }
-
- if (getFromDate() != null) {
- String tideBeginDate = contact + "." + Contact.TIDE_BEGIN_DATE;
- String createDate = contact + "." + TopiaEntity.TOPIA_CREATE_DATE;
- query.add("(" + tideBeginDate + " IS NOT NULL AND " + tideBeginDate + " >= :fromDate)" +
- " OR (" + tideBeginDate + " IS NULL AND " + createDate + " >= :fromDate)");
- query.addParam("fromDate", getFromDate());
- }
-
- return query;
- }
-
- @Override
- public boolean isFiltered() {
- return isBoatFiltered() || isSamplingFiltered() || getObserver() != null ||
- getMammalsObservation() || getMammalsCapture() ||
- getProgramAccepted() || getProgramRefused() || getProgramUndefined() ||
- getCompanyAccepted() || getCompanyRefused() || getCompanyUndefined() ||
- getState() != null;
- }
-}
Copied: trunk/wao-business/src/main/java/fr/ifremer/wao/bean/ContactFilterImpl.java (from rev 354, trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/bean/ContactFilterImpl.java)
===================================================================
--- trunk/wao-business/src/main/java/fr/ifremer/wao/bean/ContactFilterImpl.java (rev 0)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/bean/ContactFilterImpl.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -0,0 +1,113 @@
+/*
+ * *##%
+ * 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.bean;
+
+import fr.ifremer.wao.entity.Contact;
+import java.util.ArrayList;
+import java.util.List;
+import org.nuiton.topia.TopiaException;
+import org.nuiton.topia.framework.TopiaQuery;
+import org.nuiton.topia.persistence.TopiaEntity;
+
+/**
+ * ContactFilterImpl
+ *
+ * Created: 14 janv. 2010
+ *
+ * @author fdesbois
+ * @version $Revision$
+ *
+ * Mise a jour: $Date$
+ * par : $Author$
+ */
+public class ContactFilterImpl extends ContactFilter {
+
+ @Override
+ public TopiaQuery prepareQueryForContact(TopiaQuery query) {
+
+ String contact = query.getMainAlias();
+
+ if (getObserver() != null) {
+ query.add(contact + "." + Contact.OBSERVER, getObserver());
+ }
+ // Company filter is managed by SamplingFilter because the company is
+ // linked with the sampleRow instead of contact user
+
+ if (isSamplingFiltered() || getFromDate() != null || getCompany() != null) {
+ // Seems to be necessary to have distinct on sampleRows in case of
+ // fishingZone join. Otherwise multiple contacts for sames sampleRow
+ // will be returned (Bad count).
+ query = prepareQueryForSampling(query, contact + "." + Contact.SAMPLE_ROW);
+ }
+ query = prepareQueryForBoat(query, contact + "." + Contact.BOAT);
+
+ if (getMammalsObservation() && getMammalsCapture()) {
+ query.add(contact + "." + Contact.MAMMALS_OBSERVATION + " = :mammals OR " + contact + "." + Contact.MAMMALS_CAPTURE + " = :mammals").
+ addParam("mammals", Boolean.TRUE);
+ } else if (getMammalsObservation()) {
+ query.add(contact + "." + Contact.MAMMALS_OBSERVATION, Boolean.TRUE);
+ } else if (getMammalsCapture()) {
+ query.add(contact + "." + Contact.MAMMALS_CAPTURE, Boolean.TRUE);
+ }
+
+ List<Object> programValidValues = new ArrayList<Object>();
+ if (getProgramAccepted()) {
+ programValidValues.add(Boolean.TRUE);
+ }
+ if (getProgramRefused()) {
+ programValidValues.add(Boolean.FALSE);
+ }
+ query.add(contact + "." + Contact.VALIDATION_PROGRAM, programValidValues, getProgramUndefined());
+
+ List<Object> companyValidValues = new ArrayList<Object>();
+ if (getCompanyAccepted()) {
+ companyValidValues.add(Boolean.TRUE);
+ }
+ if (getCompanyRefused()) {
+ companyValidValues.add(Boolean.FALSE);
+ }
+ query.add(contact + "." + Contact.VALIDATION_COMPANY, companyValidValues, getCompanyUndefined());
+
+ if (getState() != null) {
+ query.add(contact + "." + Contact.STATE, getState().toString());
+ }
+
+ if (getFromDate() != null) {
+ String tideBeginDate = contact + "." + Contact.TIDE_BEGIN_DATE;
+ String createDate = contact + "." + TopiaEntity.TOPIA_CREATE_DATE;
+ query.add("(" + tideBeginDate + " IS NOT NULL AND " + tideBeginDate + " >= :fromDate)" +
+ " OR (" + tideBeginDate + " IS NULL AND " + createDate + " >= :fromDate)");
+ query.addParam("fromDate", getFromDate());
+ }
+
+ return query;
+ }
+
+ @Override
+ public boolean isFiltered() {
+ return isBoatFiltered() || isSamplingFiltered() || getObserver() != null ||
+ getMammalsObservation() || getMammalsCapture() ||
+ getProgramAccepted() || getProgramRefused() || getProgramUndefined() ||
+ getCompanyAccepted() || getCompanyRefused() || getCompanyUndefined() ||
+ getState() != null;
+ }
+}
Deleted: trunk/wao-business/src/main/java/fr/ifremer/wao/bean/ContactState.java
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/bean/ContactState.java 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/bean/ContactState.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,101 +0,0 @@
-/*
- * *##%
- * SuiviObsmer :: 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.suiviobsmer.bean;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * ContactState
- *
- * Created: 3 déc. 2009
- *
- * @author fdesbois
- * @version $Revision$
- *
- * Mise a jour: $Date$
- * par : $Author: fdesbois $
- */
-public enum ContactState {
- CONTACT_START("Contact pris", false, false),
-
- BOARDING_EXPECTED("Embarquement programmé", false, false),
-
- BOARDING_DONE("Embarquement réalisé", true, false),
-
- BOAT_UNAVAILABLE("Non abouti", true, true),
-
- BOAT_REFUSED("Refus", true ,true),
-
- BOAT_DEFINITIVE_REFUSED("Refus définitif", true, true);
-
- private String value;
-
- private boolean finalState;
-
- private boolean unfinishedState;
-
- ContactState(String value, boolean finalState, boolean unfinishedState) {
- this.value = value;
- this.finalState = finalState;
- this.unfinishedState = unfinishedState;
- }
-
- @Override
- public String toString() {
- return this.value;
- }
-
- public boolean isFinalState() {
- return this.finalState;
- }
-
- public boolean isUnfinishedState() {
- return this.unfinishedState;
- }
-
- public static ContactState createContactStateEnum(String value) {
- if (value.equals(CONTACT_START.toString())) {
- return CONTACT_START;
- } else if (value.equals(BOARDING_EXPECTED.toString())) {
- return BOARDING_EXPECTED;
- } else if (value.equals(BOARDING_DONE.toString())) {
- return BOARDING_DONE;
- } else if (value.equals(BOAT_UNAVAILABLE.toString())) {
- return BOAT_UNAVAILABLE;
- } else if (value.equals(BOAT_REFUSED.toString())) {
- return BOAT_REFUSED;
- } else if (value.equals(BOAT_DEFINITIVE_REFUSED.toString())) {
- return BOAT_DEFINITIVE_REFUSED;
- }
- return null;
- }
-
- public static List<String> availableStates() {
- List<String> results = new ArrayList<String>();
- for (ContactState state : values()) {
- results.add(state.toString());
- }
- return results;
- }
-
-}
Copied: trunk/wao-business/src/main/java/fr/ifremer/wao/bean/ContactState.java (from rev 354, trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/bean/ContactState.java)
===================================================================
--- trunk/wao-business/src/main/java/fr/ifremer/wao/bean/ContactState.java (rev 0)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/bean/ContactState.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -0,0 +1,101 @@
+/*
+ * *##%
+ * 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.bean;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * ContactState
+ *
+ * Created: 3 déc. 2009
+ *
+ * @author fdesbois
+ * @version $Revision$
+ *
+ * Mise a jour: $Date$
+ * par : $Author: fdesbois $
+ */
+public enum ContactState {
+ CONTACT_START("Contact pris", false, false),
+
+ BOARDING_EXPECTED("Embarquement programmé", false, false),
+
+ BOARDING_DONE("Embarquement réalisé", true, false),
+
+ BOAT_UNAVAILABLE("Non abouti", true, true),
+
+ BOAT_REFUSED("Refus", true ,true),
+
+ BOAT_DEFINITIVE_REFUSED("Refus définitif", true, true);
+
+ private String value;
+
+ private boolean finalState;
+
+ private boolean unfinishedState;
+
+ ContactState(String value, boolean finalState, boolean unfinishedState) {
+ this.value = value;
+ this.finalState = finalState;
+ this.unfinishedState = unfinishedState;
+ }
+
+ @Override
+ public String toString() {
+ return this.value;
+ }
+
+ public boolean isFinalState() {
+ return this.finalState;
+ }
+
+ public boolean isUnfinishedState() {
+ return this.unfinishedState;
+ }
+
+ public static ContactState createContactStateEnum(String value) {
+ if (value.equals(CONTACT_START.toString())) {
+ return CONTACT_START;
+ } else if (value.equals(BOARDING_EXPECTED.toString())) {
+ return BOARDING_EXPECTED;
+ } else if (value.equals(BOARDING_DONE.toString())) {
+ return BOARDING_DONE;
+ } else if (value.equals(BOAT_UNAVAILABLE.toString())) {
+ return BOAT_UNAVAILABLE;
+ } else if (value.equals(BOAT_REFUSED.toString())) {
+ return BOAT_REFUSED;
+ } else if (value.equals(BOAT_DEFINITIVE_REFUSED.toString())) {
+ return BOAT_DEFINITIVE_REFUSED;
+ }
+ return null;
+ }
+
+ public static List<String> availableStates() {
+ List<String> results = new ArrayList<String>();
+ for (ContactState state : values()) {
+ results.add(state.toString());
+ }
+ return results;
+ }
+
+}
Deleted: trunk/wao-business/src/main/java/fr/ifremer/wao/bean/ContactStateStatisticsImpl.java
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/bean/ContactStateStatisticsImpl.java 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/bean/ContactStateStatisticsImpl.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,48 +0,0 @@
-
-package fr.ifremer.suiviobsmer.bean;
-
-import fr.ifremer.suiviobsmer.entity.Company;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * ContactStateStatisticsImpl
- *
- * Created: 5 févr. 2010
- *
- * @author fdesbois
- * @version $Revision$
- *
- * Mise a jour: $Date$
- * par : $Author$
- */
-public class ContactStateStatisticsImpl extends ContactStateStatistics {
-
- @Override
- public void addResult(String state, int nbResults) {
-
- ContactState stateEnum = ContactState.createContactStateEnum(state);
- getData().put(stateEnum, nbResults);
-
- total += nbResults;
- }
-
- @Override
- public Map<ContactState, Integer> getData() {
- if (data == null) {
- data = new HashMap<ContactState, Integer>();
-
- // Initialize all contact states
- for (ContactState state : ContactState.values()) {
- data.put(state, 0);
- }
- }
- return data;
- }
-
- @Override
- public boolean isDefined() {
- return total != 0;
- }
-
-}
Copied: trunk/wao-business/src/main/java/fr/ifremer/wao/bean/ContactStateStatisticsImpl.java (from rev 354, trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/bean/ContactStateStatisticsImpl.java)
===================================================================
--- trunk/wao-business/src/main/java/fr/ifremer/wao/bean/ContactStateStatisticsImpl.java (rev 0)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/bean/ContactStateStatisticsImpl.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -0,0 +1,68 @@
+/*
+ * *##%
+ * 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.bean;
+
+import fr.ifremer.wao.entity.Company;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * ContactStateStatisticsImpl
+ *
+ * Created: 5 févr. 2010
+ *
+ * @author fdesbois
+ * @version $Revision$
+ *
+ * Mise a jour: $Date$
+ * par : $Author$
+ */
+public class ContactStateStatisticsImpl extends ContactStateStatistics {
+
+ @Override
+ public void addResult(String state, int nbResults) {
+
+ ContactState stateEnum = ContactState.createContactStateEnum(state);
+ getData().put(stateEnum, nbResults);
+
+ total += nbResults;
+ }
+
+ @Override
+ public Map<ContactState, Integer> getData() {
+ if (data == null) {
+ data = new HashMap<ContactState, Integer>();
+
+ // Initialize all contact states
+ for (ContactState state : ContactState.values()) {
+ data.put(state, 0);
+ }
+ }
+ return data;
+ }
+
+ @Override
+ public boolean isDefined() {
+ return total != 0;
+ }
+
+}
Deleted: trunk/wao-business/src/main/java/fr/ifremer/wao/bean/FacadeRowImpl.java
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/bean/FacadeRowImpl.java 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/bean/FacadeRowImpl.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,61 +0,0 @@
-
-package fr.ifremer.suiviobsmer.bean;
-
-import fr.ifremer.suiviobsmer.entity.SampleRow;
-import java.util.ArrayList;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * FacadeRowImpl
- *
- * Created: 1 févr. 2010
- *
- * @author fdesbois
- * @version $Revision$
- *
- * Mise a jour: $Date$
- * par : $Author$
- */
-public class FacadeRowImpl extends FacadeRow {
-
- @Override
- public Map<String, Map<String, List<SampleRow>>> getData() {
- if (data == null) {
- data = new LinkedHashMap<String, Map<String, List<SampleRow>>>();
- }
- return data;
- }
-
- @Override
- public void addRow(SampleRow row) {
- String facade = row.getFacade();
- String sectors = row.getSectors();
- // Prepare sectors Map
- Map<String, List<SampleRow>> sectorMap = getData().get(facade);
- if (sectorMap == null) {
- sectorMap = new LinkedHashMap<String, List<SampleRow>>();
- getData().put(facade, sectorMap);
- }
- // Prepare list of rows for the sectors of the SampleRow in argument
- List<SampleRow> rows = sectorMap.get(sectors);
- if (rows == null) {
- rows = new ArrayList<SampleRow>();
- sectorMap.put(sectors, rows);
- }
- // Add the row to the list
- rows.add(row);
- }
-
- @Override
- public List<SampleRow> getValues() {
- List<SampleRow> results = new ArrayList<SampleRow>();
- for (Map<String, List<SampleRow>> sector : getData().values()) {
- for (List<SampleRow> rows : sector.values()) {
- results.addAll(rows);
- }
- }
- return results;
- }
-}
Copied: trunk/wao-business/src/main/java/fr/ifremer/wao/bean/FacadeRowImpl.java (from rev 354, trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/bean/FacadeRowImpl.java)
===================================================================
--- trunk/wao-business/src/main/java/fr/ifremer/wao/bean/FacadeRowImpl.java (rev 0)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/bean/FacadeRowImpl.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -0,0 +1,81 @@
+/*
+ * *##%
+ * 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.bean;
+
+import fr.ifremer.wao.entity.SampleRow;
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * FacadeRowImpl
+ *
+ * Created: 1 févr. 2010
+ *
+ * @author fdesbois
+ * @version $Revision$
+ *
+ * Mise a jour: $Date$
+ * par : $Author$
+ */
+public class FacadeRowImpl extends FacadeRow {
+
+ @Override
+ public Map<String, Map<String, List<SampleRow>>> getData() {
+ if (data == null) {
+ data = new LinkedHashMap<String, Map<String, List<SampleRow>>>();
+ }
+ return data;
+ }
+
+ @Override
+ public void addRow(SampleRow row) {
+ String facade = row.getFacade();
+ String sectors = row.getSectors();
+ // Prepare sectors Map
+ Map<String, List<SampleRow>> sectorMap = getData().get(facade);
+ if (sectorMap == null) {
+ sectorMap = new LinkedHashMap<String, List<SampleRow>>();
+ getData().put(facade, sectorMap);
+ }
+ // Prepare list of rows for the sectors of the SampleRow in argument
+ List<SampleRow> rows = sectorMap.get(sectors);
+ if (rows == null) {
+ rows = new ArrayList<SampleRow>();
+ sectorMap.put(sectors, rows);
+ }
+ // Add the row to the list
+ rows.add(row);
+ }
+
+ @Override
+ public List<SampleRow> getValues() {
+ List<SampleRow> results = new ArrayList<SampleRow>();
+ for (Map<String, List<SampleRow>> sector : getData().values()) {
+ for (List<SampleRow> rows : sector.values()) {
+ results.addAll(rows);
+ }
+ }
+ return results;
+ }
+}
Deleted: trunk/wao-business/src/main/java/fr/ifremer/wao/bean/ImportResultsImpl.java
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/bean/ImportResultsImpl.java 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/bean/ImportResultsImpl.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,64 +0,0 @@
-/*
- * *##%
- * SuiviObsmer :: 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.suiviobsmer.bean;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * ImportResultsImpl
- *
- * Created: 11 janv. 2010
- *
- * @author fdesbois
- * @version $Revision$
- *
- * Mise a jour: $Date$
- * par : $Author$
- */
-public class ImportResultsImpl extends ImportResults {
-
- @Override
- public void addError(int rowNum, String msg) {
- String str = "Ligne " + rowNum + " : " + msg;
- getErrors().add(str);
- }
-
- @Override
- public List<String> getErrors() {
- if (errors == null) {
- errors = new ArrayList<String>();
- }
- return errors;
- }
-
- @Override
- public void incNbRefused() {
- nbRowsRefused++;
- }
-
- @Override
- public void incNbImported() {
- nbRowsImported++;
- }
-
-}
Copied: trunk/wao-business/src/main/java/fr/ifremer/wao/bean/ImportResultsImpl.java (from rev 354, trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/bean/ImportResultsImpl.java)
===================================================================
--- trunk/wao-business/src/main/java/fr/ifremer/wao/bean/ImportResultsImpl.java (rev 0)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/bean/ImportResultsImpl.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -0,0 +1,64 @@
+/*
+ * *##%
+ * 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.bean;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * ImportResultsImpl
+ *
+ * Created: 11 janv. 2010
+ *
+ * @author fdesbois
+ * @version $Revision$
+ *
+ * Mise a jour: $Date$
+ * par : $Author$
+ */
+public class ImportResultsImpl extends ImportResults {
+
+ @Override
+ public void addError(int rowNum, String msg) {
+ String str = "Ligne " + rowNum + " : " + msg;
+ getErrors().add(str);
+ }
+
+ @Override
+ public List<String> getErrors() {
+ if (errors == null) {
+ errors = new ArrayList<String>();
+ }
+ return errors;
+ }
+
+ @Override
+ public void incNbRefused() {
+ nbRowsRefused++;
+ }
+
+ @Override
+ public void incNbImported() {
+ nbRowsImported++;
+ }
+
+}
Deleted: trunk/wao-business/src/main/java/fr/ifremer/wao/bean/SamplingFilterImpl.java
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/bean/SamplingFilterImpl.java 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/bean/SamplingFilterImpl.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,118 +0,0 @@
-/*
- * *##%
- * SuiviObsmer :: 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.suiviobsmer.bean;
-
-import fr.ifremer.suiviobsmer.SuiviObsmerContext;
-import fr.ifremer.suiviobsmer.entity.FishingZone;
-import fr.ifremer.suiviobsmer.entity.SampleRow;
-import java.util.Calendar;
-import java.util.GregorianCalendar;
-import org.apache.commons.lang.StringUtils;
-import org.nuiton.topia.TopiaException;
-import org.nuiton.topia.framework.TopiaQuery;
-import org.nuiton.topia.framework.TopiaQuery.Op;
-
-/**
- * SamplingFilterImpl
- *
- * Created: 14 janv. 2010
- *
- * @author fdesbois
- * @version $Revision$
- *
- * Mise a jour: $Date$
- * par : $Author$
- */
-public class SamplingFilterImpl extends SamplingFilter {
-
- @Override
- public TopiaQuery prepareQueryForSampling(TopiaQuery query, String main) {
-
- // SampleRow filter depends on SampleRow or sectorName or facadeName
- if (getSampleRow() != null) {
- query.add(main, getSampleRow());
- } else if (StringUtils.isNotEmpty(getSectorName())) {
-
- TopiaQuery subquery = new TopiaQuery(SampleRow.class, "SR").
- addFrom(FishingZone.class, "F");
-
- subquery.add("F." + FishingZone.SECTOR_NAME, getSectorName()).
- add("F IN elements(SR." + SampleRow.FISHING_ZONE + ")");
-
- query.add(main + " IN (" + subquery.fullQuery() + ")").addParams(subquery.getParams());
- } else if (StringUtils.isNotEmpty(getFacadeName())) {
- TopiaQuery subquery = new TopiaQuery(SampleRow.class, "SR").
- addFrom(FishingZone.class, "F");
- subquery.add("F." + FishingZone.FACADE_NAME, getFacadeName()).add("F IN elements(SR." + SampleRow.FISHING_ZONE + ")");
-
- query.add(main + " IN (" + subquery.fullQuery() + ")").addParams(subquery.getParams());
- }
-
- // Profession filter
- if (getProfession() != null) {
- query.add(main + "." + SampleRow.PROFESSION, getProfession());
- }
-
- // Program filter
- if (getProgramName() != null) {
- query.add(main + "." + SampleRow.PROGRAM_NAME, getProgramName());
- }
-
- // Period filter on sampleRow dates
- if (getPeriod() != null) {
- getPeriod().initDayOfMonthExtremities();
- query.add(main + "." + SampleRow.PERIOD_BEGIN, Op.LT, getPeriod().getThruDate()).
- add(main + "." + SampleRow.PERIOD_END, Op.GT, getPeriod().getFromDate());
- } else if (getFromDate() != null) {
- query.add(main + "." + SampleRow.PERIOD_END, Op.GE, getFromDate());
- }
-
- // Company
- if (getCompany() != null) {
- query.add(main + "." + SampleRow.COMPANY, getCompany());
- }
-
- if (getNbMonthFinishedFromToday() != null) {
- // Only rows which are not finished will be kept
- // Date current = SuiviObsmerContext.getCurrentDate();
- Calendar calendar = new GregorianCalendar();
- calendar.setTime(SuiviObsmerContext.getCurrentDate());
- calendar.add(Calendar.MONTH, getNbMonthFinishedFromToday());
- query.add(main + "." + SampleRow.PERIOD_END, Op.GE, calendar.getTime());
- }
-
- return query;
- }
-
- @Override
- public boolean isSamplingFiltered() {
- // all field except fromDate
- return getSampleRow() != null || StringUtils.isNotEmpty(getSectorName()) || StringUtils.isNotEmpty(getFacadeName()) ||
- getPeriod() != null || getProfession() != null;
- }
-
-// @Override
-// public boolean isFiltered() {
-// return super.isFiltered() || isSamplingFiltered();
-// }
-
-}
Copied: trunk/wao-business/src/main/java/fr/ifremer/wao/bean/SamplingFilterImpl.java (from rev 354, trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/bean/SamplingFilterImpl.java)
===================================================================
--- trunk/wao-business/src/main/java/fr/ifremer/wao/bean/SamplingFilterImpl.java (rev 0)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/bean/SamplingFilterImpl.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -0,0 +1,118 @@
+/*
+ * *##%
+ * 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.bean;
+
+import fr.ifremer.wao.WaoContext;
+import fr.ifremer.wao.entity.FishingZone;
+import fr.ifremer.wao.entity.SampleRow;
+import java.util.Calendar;
+import java.util.GregorianCalendar;
+import org.apache.commons.lang.StringUtils;
+import org.nuiton.topia.TopiaException;
+import org.nuiton.topia.framework.TopiaQuery;
+import org.nuiton.topia.framework.TopiaQuery.Op;
+
+/**
+ * SamplingFilterImpl
+ *
+ * Created: 14 janv. 2010
+ *
+ * @author fdesbois
+ * @version $Revision$
+ *
+ * Mise a jour: $Date$
+ * par : $Author$
+ */
+public class SamplingFilterImpl extends SamplingFilter {
+
+ @Override
+ public TopiaQuery prepareQueryForSampling(TopiaQuery query, String main) {
+
+ // SampleRow filter depends on SampleRow or sectorName or facadeName
+ if (getSampleRow() != null) {
+ query.add(main, getSampleRow());
+ } else if (StringUtils.isNotEmpty(getSectorName())) {
+
+ TopiaQuery subquery = new TopiaQuery(SampleRow.class, "SR").
+ addFrom(FishingZone.class, "F");
+
+ subquery.add("F." + FishingZone.SECTOR_NAME, getSectorName()).
+ add("F IN elements(SR." + SampleRow.FISHING_ZONE + ")");
+
+ query.add(main + " IN (" + subquery.fullQuery() + ")").addParams(subquery.getParams());
+ } else if (StringUtils.isNotEmpty(getFacadeName())) {
+ TopiaQuery subquery = new TopiaQuery(SampleRow.class, "SR").
+ addFrom(FishingZone.class, "F");
+ subquery.add("F." + FishingZone.FACADE_NAME, getFacadeName()).add("F IN elements(SR." + SampleRow.FISHING_ZONE + ")");
+
+ query.add(main + " IN (" + subquery.fullQuery() + ")").addParams(subquery.getParams());
+ }
+
+ // Profession filter
+ if (getProfession() != null) {
+ query.add(main + "." + SampleRow.PROFESSION, getProfession());
+ }
+
+ // Program filter
+ if (getProgramName() != null) {
+ query.add(main + "." + SampleRow.PROGRAM_NAME, getProgramName());
+ }
+
+ // Period filter on sampleRow dates
+ if (getPeriod() != null) {
+ getPeriod().initDayOfMonthExtremities();
+ query.add(main + "." + SampleRow.PERIOD_BEGIN, Op.LT, getPeriod().getThruDate()).
+ add(main + "." + SampleRow.PERIOD_END, Op.GT, getPeriod().getFromDate());
+ } else if (getFromDate() != null) {
+ query.add(main + "." + SampleRow.PERIOD_END, Op.GE, getFromDate());
+ }
+
+ // Company
+ if (getCompany() != null) {
+ query.add(main + "." + SampleRow.COMPANY, getCompany());
+ }
+
+ if (getNbMonthFinishedFromToday() != null) {
+ // Only rows which are not finished will be kept
+ // Date current = WaoContext.getCurrentDate();
+ Calendar calendar = new GregorianCalendar();
+ calendar.setTime(WaoContext.getCurrentDate());
+ calendar.add(Calendar.MONTH, getNbMonthFinishedFromToday());
+ query.add(main + "." + SampleRow.PERIOD_END, Op.GE, calendar.getTime());
+ }
+
+ return query;
+ }
+
+ @Override
+ public boolean isSamplingFiltered() {
+ // all field except fromDate
+ return getSampleRow() != null || StringUtils.isNotEmpty(getSectorName()) || StringUtils.isNotEmpty(getFacadeName()) ||
+ getPeriod() != null || getProfession() != null;
+ }
+
+// @Override
+// public boolean isFiltered() {
+// return super.isFiltered() || isSamplingFiltered();
+// }
+
+}
Deleted: trunk/wao-business/src/main/java/fr/ifremer/wao/bean/UserFilterImpl.java
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/bean/UserFilterImpl.java 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/bean/UserFilterImpl.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,27 +0,0 @@
-
-package fr.ifremer.suiviobsmer.bean;
-
-import org.nuiton.topia.framework.TopiaQuery;
-
-/**
- * UserFilterImpl
- *
- * Created: 18 janv. 2010
- *
- * @author fdesbois
- * @version $Revision$
- *
- * Mise a jour: $Date$
- * par : $Author$
- */
-public class UserFilterImpl extends UserFilter {
-
- @Override
- public TopiaQuery prepareQueryForLimit(TopiaQuery query) {
- if (getStartIndex() != null && getEndIndex() != null) {
- query.setLimit(getStartIndex(), getEndIndex());
- }
- return query;
- }
-
-}
Copied: trunk/wao-business/src/main/java/fr/ifremer/wao/bean/UserFilterImpl.java (from rev 354, trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/bean/UserFilterImpl.java)
===================================================================
--- trunk/wao-business/src/main/java/fr/ifremer/wao/bean/UserFilterImpl.java (rev 0)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/bean/UserFilterImpl.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -0,0 +1,47 @@
+/*
+ * *##%
+ * 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.bean;
+
+import org.nuiton.topia.framework.TopiaQuery;
+
+/**
+ * UserFilterImpl
+ *
+ * Created: 18 janv. 2010
+ *
+ * @author fdesbois
+ * @version $Revision$
+ *
+ * Mise a jour: $Date$
+ * par : $Author$
+ */
+public class UserFilterImpl extends UserFilter {
+
+ @Override
+ public TopiaQuery prepareQueryForLimit(TopiaQuery query) {
+ if (getStartIndex() != null && getEndIndex() != null) {
+ query.setLimit(getStartIndex(), getEndIndex());
+ }
+ return query;
+ }
+
+}
Deleted: trunk/wao-business/src/main/java/fr/ifremer/wao/entity/ActivityCalendarImpl.java
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/ActivityCalendarImpl.java 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/entity/ActivityCalendarImpl.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,57 +0,0 @@
-/*
- * *##%
- * SuiviObsmer :: 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.suiviobsmer.entity;
-
-import java.io.Serializable;
-
-/**
- * ActivityCalendarImpl
- *
- * Created: 11 déc. 2009
- *
- * @author fdesbois
- * @version $Revision$
- *
- * Mise a jour: $Date$
- * par : $Author$
- */
-public class ActivityCalendarImpl extends fr.ifremer.suiviobsmer.entity.ActivityCalendarAbstract implements Serializable, fr.ifremer.suiviobsmer.entity.ActivityCalendar {
-
- private static final long serialVersionUID = 1L;
-
- /**
- * Return the ActivityMonth whith this {@code monthNumber}
- *
- * @param monthNumber the number of the month of the ActivityMonth
- * @return the ActivityMonth if it's found or null otherwise
- */
- @Override
- public ActivityMonth getActivityMonth(int monthNumber) {
- for (ActivityMonth month : getActivityMonth()) {
- if (month.getMonth() == monthNumber) {
- return month;
- }
- }
- return null;
- }
-
-} //ActivityCalendarImpl
Copied: trunk/wao-business/src/main/java/fr/ifremer/wao/entity/ActivityCalendarImpl.java (from rev 354, trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/ActivityCalendarImpl.java)
===================================================================
--- trunk/wao-business/src/main/java/fr/ifremer/wao/entity/ActivityCalendarImpl.java (rev 0)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/entity/ActivityCalendarImpl.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -0,0 +1,57 @@
+/*
+ * *##%
+ * 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.entity;
+
+import java.io.Serializable;
+
+/**
+ * ActivityCalendarImpl
+ *
+ * Created: 11 déc. 2009
+ *
+ * @author fdesbois
+ * @version $Revision$
+ *
+ * Mise a jour: $Date$
+ * par : $Author$
+ */
+public class ActivityCalendarImpl extends fr.ifremer.wao.entity.ActivityCalendarAbstract implements Serializable, fr.ifremer.wao.entity.ActivityCalendar {
+
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * Return the ActivityMonth whith this {@code monthNumber}
+ *
+ * @param monthNumber the number of the month of the ActivityMonth
+ * @return the ActivityMonth if it's found or null otherwise
+ */
+ @Override
+ public ActivityMonth getActivityMonth(int monthNumber) {
+ for (ActivityMonth month : getActivityMonth()) {
+ if (month.getMonth() == monthNumber) {
+ return month;
+ }
+ }
+ return null;
+ }
+
+} //ActivityCalendarImpl
Deleted: trunk/wao-business/src/main/java/fr/ifremer/wao/entity/ActivityMonthImpl.java
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/ActivityMonthImpl.java 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/entity/ActivityMonthImpl.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,56 +0,0 @@
-/*
- * *##%
- * SuiviObsmer :: 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.suiviobsmer.entity;
-
-import java.io.Serializable;
-
-/**
- * ActivityMonthImpl
- *
- * Created: 11 déc. 2009
- *
- * @author fdesbois
- * @version $Revision$
- *
- * Mise a jour: $Date$
- * par : $Author$
- */
-public class ActivityMonthImpl extends ActivityMonthAbstract implements Serializable, ActivityMonth {
-
- private static final long serialVersionUID = 1L;
-
- /**
- * Return the ActivityProfession whith this {@code professionOrder}
- *
- * @param professionOrder the order of the profession (unique)
- * @return the ActivityProfession if it's found or null otherwise
- */
- @Override
- public ActivityProfession getActivityProfession(int professionOrder) {
- for (ActivityProfession profession : getActivityProfession()) {
- if (profession.getProfessionOrder() == professionOrder) {
- return profession;
- }
- }
- return null;
- }
-
-} //ActivityProfessionImpl
Copied: trunk/wao-business/src/main/java/fr/ifremer/wao/entity/ActivityMonthImpl.java (from rev 354, trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/ActivityMonthImpl.java)
===================================================================
--- trunk/wao-business/src/main/java/fr/ifremer/wao/entity/ActivityMonthImpl.java (rev 0)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/entity/ActivityMonthImpl.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -0,0 +1,56 @@
+/*
+ * *##%
+ * 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.entity;
+
+import java.io.Serializable;
+
+/**
+ * ActivityMonthImpl
+ *
+ * Created: 11 déc. 2009
+ *
+ * @author fdesbois
+ * @version $Revision$
+ *
+ * Mise a jour: $Date$
+ * par : $Author$
+ */
+public class ActivityMonthImpl extends ActivityMonthAbstract implements Serializable, ActivityMonth {
+
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * Return the ActivityProfession whith this {@code professionOrder}
+ *
+ * @param professionOrder the order of the profession (unique)
+ * @return the ActivityProfession if it's found or null otherwise
+ */
+ @Override
+ public ActivityProfession getActivityProfession(int professionOrder) {
+ for (ActivityProfession profession : getActivityProfession()) {
+ if (profession.getProfessionOrder() == professionOrder) {
+ return profession;
+ }
+ }
+ return null;
+ }
+
+} //ActivityProfessionImpl
Deleted: trunk/wao-business/src/main/java/fr/ifremer/wao/entity/ActivityProfessionImpl.java
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/ActivityProfessionImpl.java 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/entity/ActivityProfessionImpl.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,56 +0,0 @@
-/*
- * *##%
- * SuiviObsmer :: 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.suiviobsmer.entity;
-
-import java.io.Serializable;
-
-/**
- * ActivityZoneImpl
- *
- * Created: 11 déc. 2009
- *
- * @author fdesbois
- * @version $Revision$
- *
- * Mise a jour: $Date$
- * par : $Author$
- */
-public class ActivityProfessionImpl extends ActivityProfessionAbstract implements Serializable, ActivityProfession {
-
- private static final long serialVersionUID = 1L;
-
- /**
- * Return the ActivityZone whith this {@code zoneCode}
- *
- * @param zoneCode the zone code
- * @return the ActivityZone if it's found or null otherwise
- */
- @Override
- public ActivityZone getActivityZone(String zoneCode) {
- for (ActivityZone zone : getActivityZone()) {
- if (zone.getZoneCode().equals(zoneCode)) {
- return zone;
- }
- }
- return null;
- }
-}
Copied: trunk/wao-business/src/main/java/fr/ifremer/wao/entity/ActivityProfessionImpl.java (from rev 354, trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/ActivityProfessionImpl.java)
===================================================================
--- trunk/wao-business/src/main/java/fr/ifremer/wao/entity/ActivityProfessionImpl.java (rev 0)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/entity/ActivityProfessionImpl.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -0,0 +1,56 @@
+/*
+ * *##%
+ * 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.entity;
+
+import java.io.Serializable;
+
+/**
+ * ActivityZoneImpl
+ *
+ * Created: 11 déc. 2009
+ *
+ * @author fdesbois
+ * @version $Revision$
+ *
+ * Mise a jour: $Date$
+ * par : $Author$
+ */
+public class ActivityProfessionImpl extends ActivityProfessionAbstract implements Serializable, ActivityProfession {
+
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * Return the ActivityZone whith this {@code zoneCode}
+ *
+ * @param zoneCode the zone code
+ * @return the ActivityZone if it's found or null otherwise
+ */
+ @Override
+ public ActivityZone getActivityZone(String zoneCode) {
+ for (ActivityZone zone : getActivityZone()) {
+ if (zone.getZoneCode().equals(zoneCode)) {
+ return zone;
+ }
+ }
+ return null;
+ }
+}
Deleted: trunk/wao-business/src/main/java/fr/ifremer/wao/entity/BoatImpl.java
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/BoatImpl.java 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/entity/BoatImpl.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,127 +0,0 @@
-/*
- * *##%
- * SuiviObsmer :: 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.suiviobsmer.entity;
-
-import fr.ifremer.suiviobsmer.SuiviObsmerException;
-import fr.ifremer.suiviobsmer.SuiviObsmerContext;
-import fr.ifremer.suiviobsmer.SuiviObsmerModelDAOHelper;
-import fr.ifremer.suiviobsmer.bean.ContactState;
-import java.io.Serializable;
-import java.util.Date;
-import org.nuiton.topia.TopiaContext;
-import org.nuiton.topia.framework.TopiaQuery;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * BoatImpl
- *
- * Created: 26 nov. 2009
- *
- * @author fdesbois
- * @version $Revision$
- *
- * Mise a jour: $Date$
- * par : $Author$
- */
-public class BoatImpl extends BoatAbstract implements Serializable, Boat {
-
- private static final Logger log = LoggerFactory.getLogger(BoatImpl.class);
-
- private static final long serialVersionUID = 1L;
-
- /**
- * Check if a contact for this boat and company can be created.
- * The state is tested on the last created contact.
- * A new contact can be created only if the last state is final.
- *
- * @param company which is the creator of the contact
- * @return true if the contact can be created, false otherwise
- * @throws SuiviObsmerException
- * @see fr.ifremer.suiviobsmer.bean.ContactState#isFinalState()
- */
- @Override
- public boolean canCreateContact(Company company) throws SuiviObsmerException {
- boolean result = true;
- if (!getActive()) {
- result = false;
- } else {
- TopiaContext transaction = null;
- try {
- transaction = SuiviObsmerContext.getTopiaRootContext().beginTransaction();
-
- ContactDAO dao = SuiviObsmerModelDAOHelper.getContactDAO(transaction);
- Contact contact = dao.findByQuery(dao.createQueryLastContactForBoat(this, company));
-
- if (contact != null) {
- ContactState state = ContactState.createContactStateEnum(contact.getState());
- result = state.isFinalState();
- }
-
- //transaction.closeContext();
- } catch (Exception eee) {
- SuiviObsmerContext.serviceException(transaction,
- "Impossible de récupérer les informations privées du navire lié à la société " +
- "'" + company.getName() + "'",
- eee);
- } finally {
- SuiviObsmerContext.closeTransaction(transaction);
- }
- }
- return result;
- }
-
- /**
- * Calculate the number of boarding done on the boat since the
- * {@code fromDate}. Only validated contacts by company will be counted.
- *
- * @param fromDate the date to start calcul
- * @return a number of boarding done on the boat for all companies
- * @throws SuiviObsmerException
- * @see fr.ifremer.suiviobsmer.entity.ContactDAO#createQueryDoneContactsFromDate(Boat, Date)
- */
- @Override
- public int getNbBoarding(Date fromDate) throws SuiviObsmerException {
- TopiaContext transaction = null;
- int result = 0;
- try {
- transaction = SuiviObsmerContext.getTopiaRootContext().beginTransaction();
-
- ContactDAO dao = SuiviObsmerModelDAOHelper.getContactDAO(transaction);
-
- TopiaQuery query = dao.createQueryDoneContactsFromDate(this, fromDate);
- result = query.executeCount(transaction);
-
- //transaction.closeContext();
- } catch (Exception eee) {
- SuiviObsmerContext.serviceException(transaction,
- "Impossible de récupérer le nombre d'embarquements réels depuis le " +
- "'" + fromDate + "'",
- eee);
- } finally {
- SuiviObsmerContext.closeTransaction(transaction);
- }
- return result;
- }
-
-
-}
Copied: trunk/wao-business/src/main/java/fr/ifremer/wao/entity/BoatImpl.java (from rev 354, trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/BoatImpl.java)
===================================================================
--- trunk/wao-business/src/main/java/fr/ifremer/wao/entity/BoatImpl.java (rev 0)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/entity/BoatImpl.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -0,0 +1,127 @@
+/*
+ * *##%
+ * 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.entity;
+
+import fr.ifremer.wao.WaoException;
+import fr.ifremer.wao.WaoContext;
+import fr.ifremer.wao.WaoModelDAOHelper;
+import fr.ifremer.wao.bean.ContactState;
+import java.io.Serializable;
+import java.util.Date;
+import org.nuiton.topia.TopiaContext;
+import org.nuiton.topia.framework.TopiaQuery;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * BoatImpl
+ *
+ * Created: 26 nov. 2009
+ *
+ * @author fdesbois
+ * @version $Revision$
+ *
+ * Mise a jour: $Date$
+ * par : $Author$
+ */
+public class BoatImpl extends BoatAbstract implements Serializable, Boat {
+
+ private static final Logger log = LoggerFactory.getLogger(BoatImpl.class);
+
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * Check if a contact for this boat and company can be created.
+ * The state is tested on the last created contact.
+ * A new contact can be created only if the last state is final.
+ *
+ * @param company which is the creator of the contact
+ * @return true if the contact can be created, false otherwise
+ * @throws WaoException
+ * @see fr.ifremer.wao.bean.ContactState#isFinalState()
+ */
+ @Override
+ public boolean canCreateContact(Company company) throws WaoException {
+ boolean result = true;
+ if (!getActive()) {
+ result = false;
+ } else {
+ TopiaContext transaction = null;
+ try {
+ transaction = WaoContext.getTopiaRootContext().beginTransaction();
+
+ ContactDAO dao = WaoModelDAOHelper.getContactDAO(transaction);
+ Contact contact = dao.findByQuery(dao.createQueryLastContactForBoat(this, company));
+
+ if (contact != null) {
+ ContactState state = ContactState.createContactStateEnum(contact.getState());
+ result = state.isFinalState();
+ }
+
+ //transaction.closeContext();
+ } catch (Exception eee) {
+ WaoContext.serviceException(transaction,
+ "Impossible de récupérer les informations privées du navire lié à la société " +
+ "'" + company.getName() + "'",
+ eee);
+ } finally {
+ WaoContext.closeTransaction(transaction);
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Calculate the number of boarding done on the boat since the
+ * {@code fromDate}. Only validated contacts by company will be counted.
+ *
+ * @param fromDate the date to start calcul
+ * @return a number of boarding done on the boat for all companies
+ * @throws WaoException
+ * @see fr.ifremer.wao.entity.ContactDAO#createQueryDoneContactsFromDate(Boat, Date)
+ */
+ @Override
+ public int getNbBoarding(Date fromDate) throws WaoException {
+ TopiaContext transaction = null;
+ int result = 0;
+ try {
+ transaction = WaoContext.getTopiaRootContext().beginTransaction();
+
+ ContactDAO dao = WaoModelDAOHelper.getContactDAO(transaction);
+
+ TopiaQuery query = dao.createQueryDoneContactsFromDate(this, fromDate);
+ result = query.executeCount(transaction);
+
+ //transaction.closeContext();
+ } catch (Exception eee) {
+ WaoContext.serviceException(transaction,
+ "Impossible de récupérer le nombre d'embarquements réels depuis le " +
+ "'" + fromDate + "'",
+ eee);
+ } finally {
+ WaoContext.closeTransaction(transaction);
+ }
+ return result;
+ }
+
+
+}
Deleted: trunk/wao-business/src/main/java/fr/ifremer/wao/entity/BoatInfosImpl.java
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/BoatInfosImpl.java 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/entity/BoatInfosImpl.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,85 +0,0 @@
-/*
- * *##%
- * SuiviObsmer :: 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.suiviobsmer.entity;
-
-import fr.ifremer.suiviobsmer.SuiviObsmerContext;
-import fr.ifremer.suiviobsmer.SuiviObsmerException;
-import fr.ifremer.suiviobsmer.SuiviObsmerModelDAOHelper;
-import org.nuiton.topia.framework.TopiaQuery;
-import java.io.Serializable;
-import org.nuiton.topia.TopiaContext;
-import java.util.Date;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * BoatInfosImpl
- *
- * Created: 25 nov. 2009
- *
- * @author fdesbois
- * @version $Revision$
- *
- * Mise a jour: $Date$
- * par : $Author$
- */
-public class BoatInfosImpl extends BoatInfosAbstract implements Serializable, BoatInfos {
-
- private static final Logger log = LoggerFactory.getLogger(BoatInfosImpl.class);
-
- private static final long serialVersionUID = 1L;
-
- /**
- * Calculate the number of boarding done on the boat since the
- * {@code fromDate}. Only validated contacts by company will be counted.
- *
- * @param fromDate the date to start calcul
- * @return a number of boarding done on the boat for the current company
- * @throws SuiviObsmerException
- * @see fr.ifremer.suiviobsmer.entity.ContactDAO#createQueryDoneContactsFromDate(Boat, Date)
- */
- @Override
- public int getNbBoardingForCompany(Date fromDate) throws SuiviObsmerException {
- TopiaContext transaction = null;
- int result = 0;
- try {
- transaction = SuiviObsmerContext.getTopiaRootContext().beginTransaction();
-
- ContactDAO dao = SuiviObsmerModelDAOHelper.getContactDAO(transaction);
-
- TopiaQuery query = dao.createQueryDoneContactsFromDate(getBoat(), fromDate);
- query.add(Contact.OBSERVER + "." + WaoUser.COMPANY, getCompany());
-
- result = query.executeCount();
-
- //transaction.closeContext();
- } catch (Exception eee) {
- SuiviObsmerContext.serviceException(transaction,
- "Impossible de récupérer le nombre d'embarquements réels depuis le " +
- "'" + fromDate + "' pour la société '" + getCompany().getName() + "'",
- eee);
- } finally {
- SuiviObsmerContext.closeTransaction(transaction);
- }
- return result;
- }
-}
Copied: trunk/wao-business/src/main/java/fr/ifremer/wao/entity/BoatInfosImpl.java (from rev 354, trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/BoatInfosImpl.java)
===================================================================
--- trunk/wao-business/src/main/java/fr/ifremer/wao/entity/BoatInfosImpl.java (rev 0)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/entity/BoatInfosImpl.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -0,0 +1,85 @@
+/*
+ * *##%
+ * 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.entity;
+
+import fr.ifremer.wao.WaoContext;
+import fr.ifremer.wao.WaoException;
+import fr.ifremer.wao.WaoModelDAOHelper;
+import org.nuiton.topia.framework.TopiaQuery;
+import java.io.Serializable;
+import org.nuiton.topia.TopiaContext;
+import java.util.Date;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * BoatInfosImpl
+ *
+ * Created: 25 nov. 2009
+ *
+ * @author fdesbois
+ * @version $Revision$
+ *
+ * Mise a jour: $Date$
+ * par : $Author$
+ */
+public class BoatInfosImpl extends BoatInfosAbstract implements Serializable, BoatInfos {
+
+ private static final Logger log = LoggerFactory.getLogger(BoatInfosImpl.class);
+
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * Calculate the number of boarding done on the boat since the
+ * {@code fromDate}. Only validated contacts by company will be counted.
+ *
+ * @param fromDate the date to start calcul
+ * @return a number of boarding done on the boat for the current company
+ * @throws WaoException
+ * @see fr.ifremer.wao.entity.ContactDAO#createQueryDoneContactsFromDate(Boat, Date)
+ */
+ @Override
+ public int getNbBoardingForCompany(Date fromDate) throws WaoException {
+ TopiaContext transaction = null;
+ int result = 0;
+ try {
+ transaction = WaoContext.getTopiaRootContext().beginTransaction();
+
+ ContactDAO dao = WaoModelDAOHelper.getContactDAO(transaction);
+
+ TopiaQuery query = dao.createQueryDoneContactsFromDate(getBoat(), fromDate);
+ query.add(Contact.OBSERVER + "." + WaoUser.COMPANY, getCompany());
+
+ result = query.executeCount();
+
+ //transaction.closeContext();
+ } catch (Exception eee) {
+ WaoContext.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);
+ }
+ return result;
+ }
+}
Deleted: trunk/wao-business/src/main/java/fr/ifremer/wao/entity/CompanyImpl.java
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/CompanyImpl.java 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/entity/CompanyImpl.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,55 +0,0 @@
-/*
- * *##%
- * SuiviObsmer :: 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.suiviobsmer.entity;
-
-import fr.ifremer.suiviobsmer.SuiviObsmerContext;
-import java.io.Serializable;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * CompanyImpl
- *
- * Created: 27 nov. 2009
- *
- * @author fdesbois
- * @version $Revision$
- *
- * Mise a jour: $Date$
- * par : $Author$
- */
-public class CompanyImpl extends CompanyAbstract implements Serializable, Company {
-
- private static final Logger log = LoggerFactory.getLogger(CompanyImpl.class);
-
- private static final long serialVersionUID = 1L;
-
- /**
- * Return a simplified id instead of using topiaId
- * @return a simplified id
- * @see SuiviObsmerUtils#convertId(java.lang.String)
- */
- @Override
- public String getId() {
- return SuiviObsmerContext.convertId(getTopiaId());
- }
-}
Copied: trunk/wao-business/src/main/java/fr/ifremer/wao/entity/CompanyImpl.java (from rev 354, trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/CompanyImpl.java)
===================================================================
--- trunk/wao-business/src/main/java/fr/ifremer/wao/entity/CompanyImpl.java (rev 0)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/entity/CompanyImpl.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -0,0 +1,55 @@
+/*
+ * *##%
+ * 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.entity;
+
+import fr.ifremer.wao.WaoContext;
+import java.io.Serializable;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * CompanyImpl
+ *
+ * Created: 27 nov. 2009
+ *
+ * @author fdesbois
+ * @version $Revision$
+ *
+ * Mise a jour: $Date$
+ * par : $Author$
+ */
+public class CompanyImpl extends CompanyAbstract implements Serializable, Company {
+
+ private static final Logger log = LoggerFactory.getLogger(CompanyImpl.class);
+
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * Return a simplified id instead of using topiaId
+ * @return a simplified id
+ * @see WaoUtils#convertId(java.lang.String)
+ */
+ @Override
+ public String getId() {
+ return WaoContext.convertId(getTopiaId());
+ }
+}
Deleted: trunk/wao-business/src/main/java/fr/ifremer/wao/entity/ContactDAOImpl.java
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/ContactDAOImpl.java 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/entity/ContactDAOImpl.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,95 +0,0 @@
-/*
- * *##%
- * SuiviObsmer :: 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.suiviobsmer.entity;
-
-import fr.ifremer.suiviobsmer.bean.ContactState;
-import java.util.Date;
-import org.nuiton.topia.framework.TopiaQuery;
-import org.nuiton.topia.framework.TopiaQuery.Op;
-import org.nuiton.topia.persistence.TopiaEntity;
-
-
-/**
- * ContactDAOImpl
- *
- * Created: 21 déc. 2009
- *
- * @param <E>
- * @author fdesbois
- * @version $Revision$
- *
- * Mise a jour: $Date$
- * par : $Author$
- */
-public class ContactDAOImpl<E extends Contact> extends ContactDAOAbstract<E> {
-
- /**
- * Create the query for the last contact of the boat and company.
- *
- * @param boat the boat concerned by the contact
- * @param company the company concerned by the user who create the contact
- * @return the TopiaQuery created
- */
- @Override
- public TopiaQuery createQueryLastContactForBoat(Boat boat, Company company) {
- TopiaQuery query = createQuery("C1").
- add("C1." + Contact.BOAT, boat).
- add("C1." + Contact.OBSERVER + "." + WaoUser.COMPANY + " = :company").
- addParam("company", company);
-
- TopiaQuery subquery = createQuery("C2").
- setSelect("MAX(C2." + TopiaEntity.TOPIA_CREATE_DATE + ")").
- add("C2." + Contact.BOAT + " = C1." + Contact.BOAT).
- add("C2." + Contact.OBSERVER + "." + WaoUser.COMPANY + " = :company");
-
- query.add("C1." + TopiaEntity.TOPIA_CREATE_DATE + " = (" + subquery.fullQuery() + ")");
- return query;
- }
-
- /**
- * Create the query for contacts linked with a boat with BoardingDone state since the fromDate.
- * This query is used to get all boarding dones with the boat for all companies.
- * Only the validate contacts by company will be count. The param fromDate can be null,
- * in this case, all contacts will be given (no matter which date then started).
- *
- * @param boat the boat concerned by the contact
- * @param fromDate the date to start
- * @return the TopiaQuery created
- */
- @Override
- public TopiaQuery createQueryDoneContactsFromDate(Boat boat, Date fromDate) {
- TopiaQuery query = createQuery("C").
- add("C." + Contact.STATE, ContactState.BOARDING_DONE.toString()).
- add("C." + Contact.VALIDATION_COMPANY, Boolean.TRUE).
- add("C." + Contact.VALIDATION_PROGRAM + " IS NULL OR " + "C." + Contact.VALIDATION_PROGRAM + " = :booleanTrue").
- addParam("booleanTrue", Boolean.TRUE);
-
- if (boat != null) {
- query.add("C." + Contact.BOAT, boat);
- }
-
- if (fromDate != null) {
- query.add("C." + Contact.TIDE_BEGIN_DATE, Op.GE, fromDate);
- }
- return query;
- }
-
-} //ContactDAOImpl<E extends Contact>
Copied: trunk/wao-business/src/main/java/fr/ifremer/wao/entity/ContactDAOImpl.java (from rev 354, trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/ContactDAOImpl.java)
===================================================================
--- trunk/wao-business/src/main/java/fr/ifremer/wao/entity/ContactDAOImpl.java (rev 0)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/entity/ContactDAOImpl.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -0,0 +1,95 @@
+/*
+ * *##%
+ * 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.entity;
+
+import fr.ifremer.wao.bean.ContactState;
+import java.util.Date;
+import org.nuiton.topia.framework.TopiaQuery;
+import org.nuiton.topia.framework.TopiaQuery.Op;
+import org.nuiton.topia.persistence.TopiaEntity;
+
+
+/**
+ * ContactDAOImpl
+ *
+ * Created: 21 déc. 2009
+ *
+ * @param <E>
+ * @author fdesbois
+ * @version $Revision$
+ *
+ * Mise a jour: $Date$
+ * par : $Author$
+ */
+public class ContactDAOImpl<E extends Contact> extends ContactDAOAbstract<E> {
+
+ /**
+ * Create the query for the last contact of the boat and company.
+ *
+ * @param boat the boat concerned by the contact
+ * @param company the company concerned by the user who create the contact
+ * @return the TopiaQuery created
+ */
+ @Override
+ public TopiaQuery createQueryLastContactForBoat(Boat boat, Company company) {
+ TopiaQuery query = createQuery("C1").
+ add("C1." + Contact.BOAT, boat).
+ add("C1." + Contact.OBSERVER + "." + WaoUser.COMPANY + " = :company").
+ addParam("company", company);
+
+ TopiaQuery subquery = createQuery("C2").
+ setSelect("MAX(C2." + TopiaEntity.TOPIA_CREATE_DATE + ")").
+ add("C2." + Contact.BOAT + " = C1." + Contact.BOAT).
+ add("C2." + Contact.OBSERVER + "." + WaoUser.COMPANY + " = :company");
+
+ query.add("C1." + TopiaEntity.TOPIA_CREATE_DATE + " = (" + subquery.fullQuery() + ")");
+ return query;
+ }
+
+ /**
+ * Create the query for contacts linked with a boat with BoardingDone state since the fromDate.
+ * This query is used to get all boarding dones with the boat for all companies.
+ * Only the validate contacts by company will be count. The param fromDate can be null,
+ * in this case, all contacts will be given (no matter which date then started).
+ *
+ * @param boat the boat concerned by the contact
+ * @param fromDate the date to start
+ * @return the TopiaQuery created
+ */
+ @Override
+ public TopiaQuery createQueryDoneContactsFromDate(Boat boat, Date fromDate) {
+ TopiaQuery query = createQuery("C").
+ add("C." + Contact.STATE, ContactState.BOARDING_DONE.toString()).
+ add("C." + Contact.VALIDATION_COMPANY, Boolean.TRUE).
+ add("C." + Contact.VALIDATION_PROGRAM + " IS NULL OR " + "C." + Contact.VALIDATION_PROGRAM + " = :booleanTrue").
+ addParam("booleanTrue", Boolean.TRUE);
+
+ if (boat != null) {
+ query.add("C." + Contact.BOAT, boat);
+ }
+
+ if (fromDate != null) {
+ query.add("C." + Contact.TIDE_BEGIN_DATE, Op.GE, fromDate);
+ }
+ return query;
+ }
+
+} //ContactDAOImpl<E extends Contact>
Deleted: trunk/wao-business/src/main/java/fr/ifremer/wao/entity/ContactImpl.java
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/ContactImpl.java 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/entity/ContactImpl.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,79 +0,0 @@
-/*
- * *##%
- * SuiviObsmer :: 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.suiviobsmer.entity;
-
-import java.io.Serializable;
-import java.util.Date;
-import org.nuiton.util.DateUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * ContactImpl
- *
- * Created: 18 déc. 2009
- *
- * @author fdesbois
- * @version $Revision$
- *
- * Mise a jour: $Date$
- * par : $Author$
- */
-public class ContactImpl extends ContactAbstract implements Serializable, Contact {
-
- private static final Logger log = LoggerFactory.getLogger(ContactImpl.class);
-
- private static final long serialVersionUID = 1L;
-
- /**
- * Calculate the number of days between the tideBeginDate and the tideEndDate.
- * Automatically called when tideBeginDate or tideEndDate are modified.
- * The value of tideNbDays is always up to date.
- */
- @Override
- protected void calculTideNbDays() {
- Date beginDate = getTideBeginDate();
- Date endDate = getTideEndDate();
- if (beginDate != null && endDate != null) {
- int nbDays = DateUtils.getDifferenceInDays(beginDate, endDate);
- // nbDays + 1 to have the first day
- setTideNbDays(nbDays + 1);
- }
- }
-
- /**
- * Get the reference date for the contact. It depends on existence of tideBeginDate.
- *
- * @return the tideBeginDate if exists or the topiaCreateDate if not
- */
- @Override
- public Date getReferenceDate() {
- if (log.isDebugEnabled()) {
- log.debug("topia " + getTopiaCreateDate());
- }
- if (getTideBeginDate() != null) {
- return getTideBeginDate();
- }
- return getTopiaCreateDate();
- }
-
-}
Copied: trunk/wao-business/src/main/java/fr/ifremer/wao/entity/ContactImpl.java (from rev 354, trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/ContactImpl.java)
===================================================================
--- trunk/wao-business/src/main/java/fr/ifremer/wao/entity/ContactImpl.java (rev 0)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/entity/ContactImpl.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -0,0 +1,79 @@
+/*
+ * *##%
+ * 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.entity;
+
+import java.io.Serializable;
+import java.util.Date;
+import org.nuiton.util.DateUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * ContactImpl
+ *
+ * Created: 18 déc. 2009
+ *
+ * @author fdesbois
+ * @version $Revision$
+ *
+ * Mise a jour: $Date$
+ * par : $Author$
+ */
+public class ContactImpl extends ContactAbstract implements Serializable, Contact {
+
+ private static final Logger log = LoggerFactory.getLogger(ContactImpl.class);
+
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * Calculate the number of days between the tideBeginDate and the tideEndDate.
+ * Automatically called when tideBeginDate or tideEndDate are modified.
+ * The value of tideNbDays is always up to date.
+ */
+ @Override
+ protected void calculTideNbDays() {
+ Date beginDate = getTideBeginDate();
+ Date endDate = getTideEndDate();
+ if (beginDate != null && endDate != null) {
+ int nbDays = DateUtils.getDifferenceInDays(beginDate, endDate);
+ // nbDays + 1 to have the first day
+ setTideNbDays(nbDays + 1);
+ }
+ }
+
+ /**
+ * Get the reference date for the contact. It depends on existence of tideBeginDate.
+ *
+ * @return the tideBeginDate if exists or the topiaCreateDate if not
+ */
+ @Override
+ public Date getReferenceDate() {
+ if (log.isDebugEnabled()) {
+ log.debug("topia " + getTopiaCreateDate());
+ }
+ if (getTideBeginDate() != null) {
+ return getTideBeginDate();
+ }
+ return getTopiaCreateDate();
+ }
+
+}
Deleted: trunk/wao-business/src/main/java/fr/ifremer/wao/entity/FishingZoneImpl.java
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/FishingZoneImpl.java 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/entity/FishingZoneImpl.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,50 +0,0 @@
-/*
- * *##%
- * SuiviObsmer :: 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.suiviobsmer.entity;
-
-import java.io.Serializable;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * FishingZoneImpl
- *
- * Created: 1 déc. 2009
- *
- * @author fdesbois
- * @version $Revision$
- *
- * Mise a jour: $Date$
- * par : $Author$
- */
-public class FishingZoneImpl extends FishingZoneAbstract implements Serializable, FishingZone {
-
- private static final Logger log = LoggerFactory.getLogger(FishingZoneImpl.class);
-
- private static final long serialVersionUID = 1L;
-
- @Override
- public String getCode() {
- return getFacadeName() + " - " + getSectorName() + " - " + getDistrictCode();
- }
-
-}
Copied: trunk/wao-business/src/main/java/fr/ifremer/wao/entity/FishingZoneImpl.java (from rev 354, trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/FishingZoneImpl.java)
===================================================================
--- trunk/wao-business/src/main/java/fr/ifremer/wao/entity/FishingZoneImpl.java (rev 0)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/entity/FishingZoneImpl.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -0,0 +1,50 @@
+/*
+ * *##%
+ * 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.entity;
+
+import java.io.Serializable;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * FishingZoneImpl
+ *
+ * Created: 1 déc. 2009
+ *
+ * @author fdesbois
+ * @version $Revision$
+ *
+ * Mise a jour: $Date$
+ * par : $Author$
+ */
+public class FishingZoneImpl extends FishingZoneAbstract implements Serializable, FishingZone {
+
+ private static final Logger log = LoggerFactory.getLogger(FishingZoneImpl.class);
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public String getCode() {
+ return getFacadeName() + " - " + getSectorName() + " - " + getDistrictCode();
+ }
+
+}
Deleted: trunk/wao-business/src/main/java/fr/ifremer/wao/entity/ProfessionImpl.java
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/ProfessionImpl.java 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/entity/ProfessionImpl.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,61 +0,0 @@
-/*
- * *##%
- * SuiviObsmer :: 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.suiviobsmer.entity;
-
-import java.io.Serializable;
-import org.apache.commons.lang.StringUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * ProfessionImpl
- *
- * Created: 1 déc. 2009
- *
- * @author fdesbois
- * @version $Revision$
- *
- * Mise a jour: $Date$
- * par : $Author$
- */
-public class ProfessionImpl extends ProfessionAbstract implements Serializable, Profession {
-
- private static final Logger log = LoggerFactory.getLogger(ProfessionImpl.class);
-
- private static final long serialVersionUID = 1L;
-
- @Override
- public String getCode() {
- String code = getCodeDCF5();
- if (!StringUtils.isEmpty(getMeshSize())) {
- code += " " + getMeshSize();
- }
- if (!StringUtils.isEmpty(getSize())) {
- code += " " + getSize();
- }
- if (!StringUtils.isEmpty(getOther())) {
- code += " " + getOther();
- }
- return code;
- }
-
-}
Copied: trunk/wao-business/src/main/java/fr/ifremer/wao/entity/ProfessionImpl.java (from rev 354, trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/ProfessionImpl.java)
===================================================================
--- trunk/wao-business/src/main/java/fr/ifremer/wao/entity/ProfessionImpl.java (rev 0)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/entity/ProfessionImpl.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -0,0 +1,61 @@
+/*
+ * *##%
+ * 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.entity;
+
+import java.io.Serializable;
+import org.apache.commons.lang.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * ProfessionImpl
+ *
+ * Created: 1 déc. 2009
+ *
+ * @author fdesbois
+ * @version $Revision$
+ *
+ * Mise a jour: $Date$
+ * par : $Author$
+ */
+public class ProfessionImpl extends ProfessionAbstract implements Serializable, Profession {
+
+ private static final Logger log = LoggerFactory.getLogger(ProfessionImpl.class);
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public String getCode() {
+ String code = getCodeDCF5();
+ if (!StringUtils.isEmpty(getMeshSize())) {
+ code += " " + getMeshSize();
+ }
+ if (!StringUtils.isEmpty(getSize())) {
+ code += " " + getSize();
+ }
+ if (!StringUtils.isEmpty(getOther())) {
+ code += " " + getOther();
+ }
+ return code;
+ }
+
+}
Deleted: trunk/wao-business/src/main/java/fr/ifremer/wao/entity/SampleMonthImpl.java
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/SampleMonthImpl.java 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/entity/SampleMonthImpl.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,110 +0,0 @@
-/*
- * *##%
- * SuiviObsmer :: 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.suiviobsmer.entity;
-
-import fr.ifremer.suiviobsmer.SuiviObsmerContext;
-import fr.ifremer.suiviobsmer.SuiviObsmerException;
-import fr.ifremer.suiviobsmer.SuiviObsmerModelDAOHelper;
-import java.io.Serializable;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.Calendar;
-import java.util.GregorianCalendar;
-import org.nuiton.topia.TopiaContext;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * SampleMonthImpl
- *
- * Created: 2 déc. 2009
- *
- * @author fdesbois
- * @version $Revision$
- *
- * Mise a jour: $Date$
- * par : $Author$
- */
-public class SampleMonthImpl extends SampleMonthAbstract implements Serializable, SampleMonth {
-
- private static final Logger log = LoggerFactory.getLogger(SampleMonthImpl.class);
-
- private static final long serialVersionUID = 1L;
-
- /**
- * Method could be use to add some time for realTidesValue or
- * remove time with a negative nbDays.
- * If nbDays is negative and superior to the current value,
- * the real tides value will be set to 0.
- * @param nbDays to add or remove (if negative)
- * @throws SuiviObsmerException for saving problem
- */
- @Override
- public void addRealTideTime(int nbDays) throws SuiviObsmerException {
- TopiaContext transaction = null;
- try {
- transaction = SuiviObsmerContext.getTopiaRootContext().beginTransaction();
-
- SampleMonthDAO dao = SuiviObsmerModelDAOHelper.getSampleMonthDAO(transaction);
- SampleMonth month = dao.findByTopiaId(getTopiaId());
- int result = month.getRealTidesValue() + nbDays;
- if (result < 0) {
- result = 0;
- }
-
- month.setRealTidesValue(result);
- if (log.isDebugEnabled()) {
- log.debug("Change realTideTime from " + month.getRealTidesValue() + " to " + result);
- }
-
- transaction.commitTransaction();
- //transaction.closeContext();
- } catch (Exception eee) {
- SuiviObsmerContext.serviceException(transaction,
- "Impossible d'enregistrer le nombre de marées réels pour le mois de " +
- formatMonth() + " [ligne : " + this.getSampleRow().getCode() + "]", eee);
- } finally {
- SuiviObsmerContext.closeTransaction(transaction);
- }
- }
-
- @Override
- public String formatMonth() {
- DateFormat dateFormat = new SimpleDateFormat("MM/yyyy");
- return dateFormat.format(getPeriodDate());
- }
-
-
- @Override
- public boolean isCurrentMonth() {
- Calendar current = new GregorianCalendar();
- current.setTime(SuiviObsmerContext.getCurrentDate());
- Calendar calendar = new GregorianCalendar();
- calendar.setTime(getPeriodDate());
-
- int currentMonth = current.get(Calendar.MONTH);
- int month = calendar.get(Calendar.MONTH);
-
- return month == currentMonth;
- }
-
-}
Copied: trunk/wao-business/src/main/java/fr/ifremer/wao/entity/SampleMonthImpl.java (from rev 354, trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/SampleMonthImpl.java)
===================================================================
--- trunk/wao-business/src/main/java/fr/ifremer/wao/entity/SampleMonthImpl.java (rev 0)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/entity/SampleMonthImpl.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -0,0 +1,112 @@
+/*
+ * *##%
+ * 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.entity;
+
+import fr.ifremer.wao.WaoContext;
+import fr.ifremer.wao.WaoException;
+import fr.ifremer.wao.WaoModelDAOHelper;
+import java.io.Serializable;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.GregorianCalendar;
+import org.nuiton.topia.TopiaContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * SampleMonthImpl
+ *
+ * Created: 2 déc. 2009
+ *
+ * @author fdesbois
+ * @version $Revision$
+ *
+ * Mise a jour: $Date$
+ * par : $Author$
+ */
+public class SampleMonthImpl extends SampleMonthAbstract implements Serializable, SampleMonth {
+
+ private static final Logger log = LoggerFactory.getLogger(SampleMonthImpl.class);
+
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * Method could be use to add some time for realTidesValue or
+ * remove time with a negative nbDays.
+ * If nbDays is negative and superior to the current value,
+ * the real tides value will be set to 0.
+ * @param nbDays to add or remove (if negative)
+ * @throws WaoException for saving problem
+ */
+ @Override
+ public void addRealTideTime(int nbDays) throws WaoException {
+ TopiaContext transaction = null;
+ try {
+ transaction = WaoContext.getTopiaRootContext().beginTransaction();
+
+ SampleMonthDAO dao = WaoModelDAOHelper.getSampleMonthDAO(transaction);
+ SampleMonth month = dao.findByTopiaId(getTopiaId());
+ int result = month.getRealTidesValue() + nbDays;
+ if (result < 0) {
+ result = 0;
+ }
+
+ month.setRealTidesValue(result);
+ if (log.isDebugEnabled()) {
+ log.debug("Change realTideTime from " + month.getRealTidesValue() + " to " + result);
+ }
+
+ transaction.commitTransaction();
+ //transaction.closeContext();
+ } catch (Exception eee) {
+ WaoContext.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);
+ }
+ }
+
+ @Override
+ public String formatMonth() {
+ DateFormat dateFormat = new SimpleDateFormat("MM/yyyy");
+ return dateFormat.format(getPeriodDate());
+ }
+
+
+ @Override
+ public boolean isCurrentMonth() {
+ Calendar current = new GregorianCalendar();
+ current.setTime(WaoContext.getCurrentDate());
+ Calendar calendar = new GregorianCalendar();
+ calendar.setTime(getPeriodDate());
+
+ int currentMonth = current.get(Calendar.MONTH);
+ int month = calendar.get(Calendar.MONTH);
+ int currentYear = current.get(Calendar.YEAR);
+ int year = calendar.get(Calendar.YEAR);
+
+ return month == currentMonth && currentYear == year;
+ }
+
+}
Deleted: trunk/wao-business/src/main/java/fr/ifremer/wao/entity/SampleRowImpl.java
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/SampleRowImpl.java 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/entity/SampleRowImpl.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,272 +0,0 @@
-/*
- * *##%
- * SuiviObsmer :: 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.suiviobsmer.entity;
-
-import fr.ifremer.suiviobsmer.SuiviObsmerContext;
-import fr.ifremer.suiviobsmer.SuiviObsmerException;
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.GregorianCalendar;
-import java.util.Iterator;
-import java.util.List;
-import org.apache.commons.lang.BooleanUtils;
-import org.nuiton.util.DateUtils;
-import org.nuiton.util.PeriodDates;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * SampleRowImpl
- *
- * Created: 30 nov. 2009
- *
- * @author fdesbois
- * @version $Revision$
- *
- * Mise a jour: $Date$
- * par : $Author$
- */
-public class SampleRowImpl extends SampleRowAbstract implements SampleRow, Serializable {
-
- private static final Logger log = LoggerFactory.getLogger(SampleRowImpl.class);
-
- private static final long serialVersionUID = 1L;
-
- /**
- * Get a SampleMonth from a date. The month and year of the date must correspond to the SampleMonth to get.
- * @param date a Date
- * @return the SampleMonth if it exists in the SampleMonth list or null otherwise
- */
- @Override
- public SampleMonth getSampleMonth(Date date) {
- if (getSampleMonth() == null) {
- return null;
- }
-// Calendar ref = new GregorianCalendar();
-// ref.setTime(date);
- //log.info("Ref : " + date);
- for (SampleMonth curr : getSampleMonth()) {
- //log.info("Curr month : " + curr.getPeriodDate() + " : " + curr.getPeriodMonth() + " / " + curr.getPeriodYear());
-// if (ref.get(Calendar.MONTH) == (curr.getPeriodMonth()-1) && ref.get(Calendar.YEAR) == curr.getPeriodYear()) {
-// return curr;
-// }
- Date min = DateUtils.setFirstDayOfMonth(curr.getPeriodDate());
- Date max = DateUtils.setLastDayOfMonth(curr.getPeriodDate());
- if (DateUtils.between(date, min, max)) {
- return curr;
- }
- }
- return null;
- }
-
- /**
- * Return the first fishingZone of the list linked with the SampleRow.
- * @return a FishingZone or null if there is no fishingZone linked with the SampleRow
- */
-// @Override
-// public FishingZone getFirstFishingZone() {
-// if (getFishingZone().size() > 0) {
-// return getFishingZone().get(0);
-// }
-// return null;
-// }
-
- /**
- * Get the facade of the sampleRow. The row has normally only one facade in the FishingZone list.
- *
- * @return the facade name of the row
- */
- @Override
- public String getFacade() {
- if (getFishingZone().size() > 0) {
- return getFishingZone().get(0).getFacadeName();
- }
- return null;
- }
-
- /**
- * Get the sectors of the sampleRow. The sectors will be concat as a single String with "-" as separator.
- *
- * @return a String with all sectors linked to the sampleRow
- */
- @Override
- public String getSectors() {
- List<String> results = new ArrayList<String>();
- for (FishingZone zone : getFishingZone()) {
- String sector = zone.getSectorName();
- if (!results.contains(sector)) {
- results.add(sector);
- }
- }
- String result = "";
- for (String sector : results) {
- result += sector + " - ";
- }
- return result.substring(0, result.length()-3);
- }
-
- /**
- * Check if the sampleRow has an ElligibleBoat corresponding to the boat in argument.
- * The test return true only if it's a global ElligbleBoat set by an admin and not by a user (companyActive).
- * @param boat Boat to test
- * @return true if the ElligibleBoat is find, false otherwise
- */
- @Override
- public boolean hasElligibleBoat(Boat boat) {
- for (ElligibleBoat elligible : this.getElligibleBoat()) {
- String elligibleBoatTopiaId = elligible.getBoat().getTopiaId();
- if (elligibleBoatTopiaId.equals(boat.getTopiaId()) && elligible.getCompanyActive() == null) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * Check from the list of ElligibleBoat linked with the SampleRow if the boats in argument corresponding.
- * The argument means new boats to linked with SampleRow, so an ElligibleBoat not contains in this list is removed.
- *
- * @param boats a List of Boats to check with ElligibleBoats linked with the SampleRow.
- * @see fr.ifremer.suiviobsmer.impl.ServiceSamplingImpl#createUpdateSampleRow(fr.ifremer.suiviobsmer.entity.SampleRow, java.util.List)
- */
- @Override
- public void removeNoLongerElligibleBoats(List<Boat> boats) {
- Iterator<ElligibleBoat> it = getElligibleBoat().iterator();
- while (it.hasNext()) {
- ElligibleBoat elligible = it.next();
- String elligibleBoatTopiaId = elligible.getBoat().getTopiaId();
- boolean find = false;
- for (Boat boat : boats) {
- if (elligibleBoatTopiaId.equals(boat.getTopiaId())) {
- find = true;
- break;
- }
- }
- // only if no company use this elligibleBoat
- if (!find) {
- if (BooleanUtils.isNotTrue(elligible.getCompanyActive())) {
- it.remove();
- } else {
- elligible.setGlobalActive(false);
- }
- }
- }
- }
-
- /**
- * Used to get a list of boat's immatriculations linked with the sampleRow.
- *
- * @return a simple String which contains immatriculations separate by a space
- */
- @Override
- public String getMainElligibleBoatsAsString() {
- String result = "";
- for (ElligibleBoat elligible : getElligibleBoat()) {
- if (elligible.getCompanyActive() == null) {
- Boat boat = elligible.getBoat();
- result += boat.getImmatriculation() + " ";
- }
- }
- return result;
- }
-
- /**
- * Check if SampleMonth of the SampleRow has already realTidesValue set (different from 0).
- * It means the SampleRow could'nt be deleted and have some modification constraints.
- * @return true if a SampleMonth have realTidesValue, false otherwise
- */
- @Override
- public boolean hasSampleMonthRealTideTime() {
- for (SampleMonth month : getSampleMonth()) {
- if (month.getRealTidesValue() != 0) {
- return true;
- }
- }
- return false;
- }
-
- @Override
- public boolean addRealTideTime(Contact contact) throws SuiviObsmerException {
- if (contact.getTideEndDate() == null || contact.getTideBeginDate() == null) {
- return false;
- }
- //int nbDays = contact.getTideNbDays(); //getDifferenceDays(contact);
- SampleMonth month = getSampleMonth(contact.getTideBeginDate());
- if (month == null) {
- return false;
- }
- if (log.isTraceEnabled()) {
- log.trace("Add 1 tide for " + month.formatMonth() + " [" + this.getCode() + "]");
- }
- month.addRealTideTime(1);
- return true;
- }
-
- @Override
- public void removeRealTideTime(Contact contact) throws SuiviObsmerException {
- if (contact.getTideEndDate() == null || contact.getTideBeginDate() == null) {
- return;
- }
- //int nbDays = contact.getTideNbDays(); //getDifferenceDays(contact);
- SampleMonth month = getSampleMonth(contact.getTideBeginDate());
- if (log.isTraceEnabled()) {
- log.trace("Remove 1 tide for " + month.formatMonth() + " [" + this.getCode() + "]");
- }
- month.addRealTideTime(-1);
- }
-
- @Override
- public void setPeriod(PeriodDates period) {
- period.initDayOfMonthExtremities();
- setPeriodBegin(period.getFromDate());
- setPeriodEnd(period.getThruDate());
- }
-
- @Override
- public boolean isStarted() {
- Date current = SuiviObsmerContext.getCurrentDate();
- return current.after(getPeriodBegin()) || current.equals(getPeriodBegin());
- }
-
- @Override
- public boolean isFinished(int nbMonths) {
- Calendar calendar = new GregorianCalendar();
- calendar.setTime(SuiviObsmerContext.getCurrentDate());
- calendar.add(Calendar.MONTH, nbMonths);
- return calendar.getTime().after(getPeriodEnd());
- }
-
- /**
- * Check if a SampleMonth is valid for the date in argument.
- *
- * @param begin date for testing SampleMonth existence
- * @return true if a SampleMonth exist for this begin date, false otherwise
- */
- @Override
- public boolean isValid(Date begin) {
- SampleMonth month = getSampleMonth(begin);
- return month != null;
- }
-
-}
Copied: trunk/wao-business/src/main/java/fr/ifremer/wao/entity/SampleRowImpl.java (from rev 354, trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/SampleRowImpl.java)
===================================================================
--- trunk/wao-business/src/main/java/fr/ifremer/wao/entity/SampleRowImpl.java (rev 0)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/entity/SampleRowImpl.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -0,0 +1,272 @@
+/*
+ * *##%
+ * 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.entity;
+
+import fr.ifremer.wao.WaoContext;
+import fr.ifremer.wao.WaoException;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.GregorianCalendar;
+import java.util.Iterator;
+import java.util.List;
+import org.apache.commons.lang.BooleanUtils;
+import org.nuiton.util.DateUtils;
+import org.nuiton.util.PeriodDates;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * SampleRowImpl
+ *
+ * Created: 30 nov. 2009
+ *
+ * @author fdesbois
+ * @version $Revision$
+ *
+ * Mise a jour: $Date$
+ * par : $Author$
+ */
+public class SampleRowImpl extends SampleRowAbstract implements SampleRow, Serializable {
+
+ private static final Logger log = LoggerFactory.getLogger(SampleRowImpl.class);
+
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * Get a SampleMonth from a date. The month and year of the date must correspond to the SampleMonth to get.
+ * @param date a Date
+ * @return the SampleMonth if it exists in the SampleMonth list or null otherwise
+ */
+ @Override
+ public SampleMonth getSampleMonth(Date date) {
+ if (getSampleMonth() == null) {
+ return null;
+ }
+// Calendar ref = new GregorianCalendar();
+// ref.setTime(date);
+ //log.info("Ref : " + date);
+ for (SampleMonth curr : getSampleMonth()) {
+ //log.info("Curr month : " + curr.getPeriodDate() + " : " + curr.getPeriodMonth() + " / " + curr.getPeriodYear());
+// if (ref.get(Calendar.MONTH) == (curr.getPeriodMonth()-1) && ref.get(Calendar.YEAR) == curr.getPeriodYear()) {
+// return curr;
+// }
+ Date min = DateUtils.setFirstDayOfMonth(curr.getPeriodDate());
+ Date max = DateUtils.setLastDayOfMonth(curr.getPeriodDate());
+ if (DateUtils.between(date, min, max)) {
+ return curr;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Return the first fishingZone of the list linked with the SampleRow.
+ * @return a FishingZone or null if there is no fishingZone linked with the SampleRow
+ */
+// @Override
+// public FishingZone getFirstFishingZone() {
+// if (getFishingZone().size() > 0) {
+// return getFishingZone().get(0);
+// }
+// return null;
+// }
+
+ /**
+ * Get the facade of the sampleRow. The row has normally only one facade in the FishingZone list.
+ *
+ * @return the facade name of the row
+ */
+ @Override
+ public String getFacade() {
+ if (getFishingZone().size() > 0) {
+ return getFishingZone().get(0).getFacadeName();
+ }
+ return null;
+ }
+
+ /**
+ * Get the sectors of the sampleRow. The sectors will be concat as a single String with "-" as separator.
+ *
+ * @return a String with all sectors linked to the sampleRow
+ */
+ @Override
+ public String getSectors() {
+ List<String> results = new ArrayList<String>();
+ for (FishingZone zone : getFishingZone()) {
+ String sector = zone.getSectorName();
+ if (!results.contains(sector)) {
+ results.add(sector);
+ }
+ }
+ String result = "";
+ for (String sector : results) {
+ result += sector + " - ";
+ }
+ return result.substring(0, result.length()-3);
+ }
+
+ /**
+ * Check if the sampleRow has an ElligibleBoat corresponding to the boat in argument.
+ * The test return true only if it's a global ElligbleBoat set by an admin and not by a user (companyActive).
+ * @param boat Boat to test
+ * @return true if the ElligibleBoat is find, false otherwise
+ */
+ @Override
+ public boolean hasElligibleBoat(Boat boat) {
+ for (ElligibleBoat elligible : this.getElligibleBoat()) {
+ String elligibleBoatTopiaId = elligible.getBoat().getTopiaId();
+ if (elligibleBoatTopiaId.equals(boat.getTopiaId()) && elligible.getCompanyActive() == null) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Check from the list of ElligibleBoat linked with the SampleRow if the boats in argument corresponding.
+ * The argument means new boats to linked with SampleRow, so an ElligibleBoat not contains in this list is removed.
+ *
+ * @param boats a List of Boats to check with ElligibleBoats linked with the SampleRow.
+ * @see fr.ifremer.wao.impl.ServiceSamplingImpl#createUpdateSampleRow(fr.ifremer.wao.entity.SampleRow, java.util.List)
+ */
+ @Override
+ public void removeNoLongerElligibleBoats(List<Boat> boats) {
+ Iterator<ElligibleBoat> it = getElligibleBoat().iterator();
+ while (it.hasNext()) {
+ ElligibleBoat elligible = it.next();
+ String elligibleBoatTopiaId = elligible.getBoat().getTopiaId();
+ boolean find = false;
+ for (Boat boat : boats) {
+ if (elligibleBoatTopiaId.equals(boat.getTopiaId())) {
+ find = true;
+ break;
+ }
+ }
+ // only if no company use this elligibleBoat
+ if (!find) {
+ if (BooleanUtils.isNotTrue(elligible.getCompanyActive())) {
+ it.remove();
+ } else {
+ elligible.setGlobalActive(false);
+ }
+ }
+ }
+ }
+
+ /**
+ * Used to get a list of boat's immatriculations linked with the sampleRow.
+ *
+ * @return a simple String which contains immatriculations separate by a space
+ */
+ @Override
+ public String getMainElligibleBoatsAsString() {
+ String result = "";
+ for (ElligibleBoat elligible : getElligibleBoat()) {
+ if (elligible.getCompanyActive() == null) {
+ Boat boat = elligible.getBoat();
+ result += boat.getImmatriculation() + " ";
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Check if SampleMonth of the SampleRow has already realTidesValue set (different from 0).
+ * It means the SampleRow could'nt be deleted and have some modification constraints.
+ * @return true if a SampleMonth have realTidesValue, false otherwise
+ */
+ @Override
+ public boolean hasSampleMonthRealTideTime() {
+ for (SampleMonth month : getSampleMonth()) {
+ if (month.getRealTidesValue() != 0) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public boolean addRealTideTime(Contact contact) throws WaoException {
+ if (contact.getTideEndDate() == null || contact.getTideBeginDate() == null) {
+ return false;
+ }
+ //int nbDays = contact.getTideNbDays(); //getDifferenceDays(contact);
+ SampleMonth month = getSampleMonth(contact.getTideBeginDate());
+ if (month == null) {
+ return false;
+ }
+ if (log.isTraceEnabled()) {
+ log.trace("Add 1 tide for " + month.formatMonth() + " [" + this.getCode() + "]");
+ }
+ month.addRealTideTime(1);
+ return true;
+ }
+
+ @Override
+ public void removeRealTideTime(Contact contact) throws WaoException {
+ if (contact.getTideEndDate() == null || contact.getTideBeginDate() == null) {
+ return;
+ }
+ //int nbDays = contact.getTideNbDays(); //getDifferenceDays(contact);
+ SampleMonth month = getSampleMonth(contact.getTideBeginDate());
+ if (log.isTraceEnabled()) {
+ log.trace("Remove 1 tide for " + month.formatMonth() + " [" + this.getCode() + "]");
+ }
+ month.addRealTideTime(-1);
+ }
+
+ @Override
+ public void setPeriod(PeriodDates period) {
+ period.initDayOfMonthExtremities();
+ setPeriodBegin(period.getFromDate());
+ setPeriodEnd(period.getThruDate());
+ }
+
+ @Override
+ public boolean isStarted() {
+ Date current = WaoContext.getCurrentDate();
+ return current.after(getPeriodBegin()) || current.equals(getPeriodBegin());
+ }
+
+ @Override
+ public boolean isFinished(int nbMonths) {
+ Calendar calendar = new GregorianCalendar();
+ calendar.setTime(WaoContext.getCurrentDate());
+ calendar.add(Calendar.MONTH, nbMonths);
+ return calendar.getTime().after(getPeriodEnd());
+ }
+
+ /**
+ * Check if a SampleMonth is valid for the date in argument.
+ *
+ * @param begin date for testing SampleMonth existence
+ * @return true if a SampleMonth exist for this begin date, false otherwise
+ */
+ @Override
+ public boolean isValid(Date begin) {
+ SampleMonth month = getSampleMonth(begin);
+ return month != null;
+ }
+
+}
Deleted: trunk/wao-business/src/main/java/fr/ifremer/wao/entity/SampleRowLogImpl.java
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/SampleRowLogImpl.java 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/entity/SampleRowLogImpl.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,144 +0,0 @@
-/*
- * *##%
- * SuiviObsmer :: 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.suiviobsmer.entity;
-
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import org.apache.commons.lang.StringUtils;
-import org.nuiton.util.PeriodDates;
-
-/**
- * SampleRowLogImpl
- *
- * Created: 12 janv. 2010
- *
- * @author fdesbois
- * @version $Revision$
- *
- * Mise a jour: $Date$
- * par : $Author$
- */
-public class SampleRowLogImpl extends SampleRowLogAbstract implements SampleRowLog {
-
- //private static final Logger log = LoggerFactory.getLogger(SampleRowLogImpl.class);
-
- private static final long serialVersionUID = 1L;
-
- @Override
- public void addChange(String text) {
- String log = getLogText();
- if (!StringUtils.isEmpty(log)) {
- log += "\n";
- } else {
- log = "";
- }
- log += text;
- setLogText(log);
- }
-
- @Override
- public void addChangeProfession(Profession oldProfession, Profession newProfession) {
- if (oldProfession == null) {
- addChange("Le métier de la ligne est " + newProfession.getCode());
- if (newProfession.getLibelle() != null) {
- addChange("Le libelle du métier est " + newProfession.getLibelle());
- }
- if (newProfession.getSpecies() != null) {
- addChange("Les espèces cibles du métier sont " + newProfession.getSpecies());
- }
- return;
- }
-
- if (!nvl(oldProfession.getCode()).equals(nvl(newProfession.getCode()))) {
- addChange("Le métier de la ligne est passé de " + oldProfession.getCode() + " à " + newProfession.getCode());
- }
- if (newProfession.getLibelle() != null && !nvl(oldProfession.getLibelle()).equals(nvl(newProfession.getLibelle()))) {
- addChange("Le libellé du métier est passé de " + oldProfession.getLibelle() + " à " + newProfession.getLibelle());
- }
- if (newProfession.getSpecies() != null && !nvl(oldProfession.getSpecies()).equals(nvl(newProfession.getSpecies()))) {
- addChange("Les espèces cibles du métier sont passées de " + oldProfession.getSpecies() + " à " + newProfession.getSpecies());
- }
- }
-
- protected String nvl(String str) {
- return str == null ? "" : str;
- }
-
- @Override
- public void addChangeCompany(Company oldCompany, Company newCompany) {
- if (oldCompany != null) {
- String msg = "La ligne n'est plus associé à la société " + oldCompany.getName();
- if (newCompany != null && !newCompany.equals(oldCompany)) {
- addChange(msg + " mais à la société " + newCompany.getName());
- } else if (newCompany == null) {
- addChange(msg);
- }
- } else if (newCompany != null) {
- addChange("La ligne est désormais associé à la société " + newCompany.getName());
- }
- }
-
- @Override
- public void addChangeProgram(String oldProgram, String newProgram) {
- if (!StringUtils.isEmpty(oldProgram)) {
- if (!oldProgram.equals(newProgram)) {
- addChange("La ligne n'est plus associé au programme " + oldProgram + " mais au programme " + newProgram);
- }
- } else if (!StringUtils.isEmpty(newProgram)) {
- addChange("La ligne est désormais associé au programme " + newProgram);
- }
- }
-
- @Override
- public void addChangePeriod(PeriodDates oldPeriod, PeriodDates newPeriod, String pattern) {
- DateFormat dateFormat = new SimpleDateFormat(pattern);
- String newPeriodBegin = dateFormat.format(newPeriod.getFromDate());
- String newPeriodEnd = dateFormat.format(newPeriod.getThruDate());
- if (oldPeriod == null) {
- addChange("La ligne est sur la période du " + newPeriodBegin + " au " + newPeriodEnd);
- return;
- }
- // dates inside oldPeriod and newPeriod can't be null
- String oldPeriodBegin = dateFormat.format(oldPeriod.getFromDate());
- if (!oldPeriodBegin.equals(newPeriodBegin)) {
- addChange("La date de début est passé de " + oldPeriodBegin + " à " + newPeriodBegin);
- }
- String oldPeriodEnd = dateFormat.format(oldPeriod.getThruDate());
- if (!oldPeriodEnd.equals(newPeriodEnd)) {
- addChange("La date de fin est passé de " + oldPeriodEnd + " à " + newPeriodEnd);
- }
- }
-
- @Override
- public void addChangeBoats(String oldBoats, String newBoats) {
- if (oldBoats.isEmpty() && !newBoats.isEmpty()) {
- addChange("La liste des immatriculations des navires est (" + newBoats + ")");
- return;
- }
-
- if (!newBoats.isEmpty() && !oldBoats.equals(newBoats)) {
- addChange("La liste des immatriculations des navires est passé de (" + oldBoats + ") à (" + newBoats + ")");
- }
-
- }
-
-}
Copied: trunk/wao-business/src/main/java/fr/ifremer/wao/entity/SampleRowLogImpl.java (from rev 354, trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/SampleRowLogImpl.java)
===================================================================
--- trunk/wao-business/src/main/java/fr/ifremer/wao/entity/SampleRowLogImpl.java (rev 0)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/entity/SampleRowLogImpl.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -0,0 +1,144 @@
+/*
+ * *##%
+ * 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.entity;
+
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import org.apache.commons.lang.StringUtils;
+import org.nuiton.util.PeriodDates;
+
+/**
+ * SampleRowLogImpl
+ *
+ * Created: 12 janv. 2010
+ *
+ * @author fdesbois
+ * @version $Revision$
+ *
+ * Mise a jour: $Date$
+ * par : $Author$
+ */
+public class SampleRowLogImpl extends SampleRowLogAbstract implements SampleRowLog {
+
+ //private static final Logger log = LoggerFactory.getLogger(SampleRowLogImpl.class);
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void addChange(String text) {
+ String log = getLogText();
+ if (!StringUtils.isEmpty(log)) {
+ log += "\n";
+ } else {
+ log = "";
+ }
+ log += text;
+ setLogText(log);
+ }
+
+ @Override
+ public void addChangeProfession(Profession oldProfession, Profession newProfession) {
+ if (oldProfession == null) {
+ addChange("Le métier de la ligne est " + newProfession.getCode());
+ if (newProfession.getLibelle() != null) {
+ addChange("Le libelle du métier est " + newProfession.getLibelle());
+ }
+ if (newProfession.getSpecies() != null) {
+ addChange("Les espèces cibles du métier sont " + newProfession.getSpecies());
+ }
+ return;
+ }
+
+ if (!nvl(oldProfession.getCode()).equals(nvl(newProfession.getCode()))) {
+ addChange("Le métier de la ligne est passé de " + oldProfession.getCode() + " à " + newProfession.getCode());
+ }
+ if (newProfession.getLibelle() != null && !nvl(oldProfession.getLibelle()).equals(nvl(newProfession.getLibelle()))) {
+ addChange("Le libellé du métier est passé de " + oldProfession.getLibelle() + " à " + newProfession.getLibelle());
+ }
+ if (newProfession.getSpecies() != null && !nvl(oldProfession.getSpecies()).equals(nvl(newProfession.getSpecies()))) {
+ addChange("Les espèces cibles du métier sont passées de " + oldProfession.getSpecies() + " à " + newProfession.getSpecies());
+ }
+ }
+
+ protected String nvl(String str) {
+ return str == null ? "" : str;
+ }
+
+ @Override
+ public void addChangeCompany(Company oldCompany, Company newCompany) {
+ if (oldCompany != null) {
+ String msg = "La ligne n'est plus associé à la société " + oldCompany.getName();
+ if (newCompany != null && !newCompany.equals(oldCompany)) {
+ addChange(msg + " mais à la société " + newCompany.getName());
+ } else if (newCompany == null) {
+ addChange(msg);
+ }
+ } else if (newCompany != null) {
+ addChange("La ligne est désormais associé à la société " + newCompany.getName());
+ }
+ }
+
+ @Override
+ public void addChangeProgram(String oldProgram, String newProgram) {
+ if (!StringUtils.isEmpty(oldProgram)) {
+ if (!oldProgram.equals(newProgram)) {
+ addChange("La ligne n'est plus associé au programme " + oldProgram + " mais au programme " + newProgram);
+ }
+ } else if (!StringUtils.isEmpty(newProgram)) {
+ addChange("La ligne est désormais associé au programme " + newProgram);
+ }
+ }
+
+ @Override
+ public void addChangePeriod(PeriodDates oldPeriod, PeriodDates newPeriod, String pattern) {
+ DateFormat dateFormat = new SimpleDateFormat(pattern);
+ String newPeriodBegin = dateFormat.format(newPeriod.getFromDate());
+ String newPeriodEnd = dateFormat.format(newPeriod.getThruDate());
+ if (oldPeriod == null) {
+ addChange("La ligne est sur la période du " + newPeriodBegin + " au " + newPeriodEnd);
+ return;
+ }
+ // dates inside oldPeriod and newPeriod can't be null
+ String oldPeriodBegin = dateFormat.format(oldPeriod.getFromDate());
+ if (!oldPeriodBegin.equals(newPeriodBegin)) {
+ addChange("La date de début est passé de " + oldPeriodBegin + " à " + newPeriodBegin);
+ }
+ String oldPeriodEnd = dateFormat.format(oldPeriod.getThruDate());
+ if (!oldPeriodEnd.equals(newPeriodEnd)) {
+ addChange("La date de fin est passé de " + oldPeriodEnd + " à " + newPeriodEnd);
+ }
+ }
+
+ @Override
+ public void addChangeBoats(String oldBoats, String newBoats) {
+ if (oldBoats.isEmpty() && !newBoats.isEmpty()) {
+ addChange("La liste des immatriculations des navires est (" + newBoats + ")");
+ return;
+ }
+
+ if (!newBoats.isEmpty() && !oldBoats.equals(newBoats)) {
+ addChange("La liste des immatriculations des navires est passé de (" + oldBoats + ") à (" + newBoats + ")");
+ }
+
+ }
+
+}
Deleted: trunk/wao-business/src/main/java/fr/ifremer/wao/entity/WaoUserImpl.java
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/WaoUserImpl.java 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/entity/WaoUserImpl.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,79 +0,0 @@
-/*
- * *##%
- * SuiviObsmer :: 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.suiviobsmer.entity;
-
-import fr.ifremer.suiviobsmer.SuiviObsmerContext;
-import java.io.Serializable;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * UserImpl
- *
- * Created: 27 nov. 2009
- *
- * @author fdesbois
- * @version $Revision$
- *
- * Mise a jour: $Date$
- * par : $Author$
- */
-public class WaoUserImpl extends WaoUserAbstract implements Serializable, WaoUser {
-
- private static final Logger log = LoggerFactory.getLogger(WaoUserImpl.class);
-
- private static final long serialVersionUID = 1L;
-
- protected boolean passwordChanged;
-
- /**
- * Return the fullName of the user, i.e. fisrtName + lastName.
- * @return a String for the user fullName
- */
- @Override
- public String getFullName() {
- String name = getFirstName() != null ? getFirstName() : "";
- name += getLastName() != null ? " " + getLastName() : "";
- return name;
- }
-
- /**
- * Return a simplified id instead of using topiaId
- * @return a simplified id
- * @see SuiviObsmerUtils#convertId(java.lang.String)
- */
- @Override
- public String getId() {
- return SuiviObsmerContext.convertId(getTopiaId());
- }
-
- @Override
- public void setPasswordChanged(boolean changed) {
- this.passwordChanged = changed;
- }
-
- @Override
- public boolean isPasswordChanged() {
- return this.passwordChanged;
- }
-
-}
Copied: trunk/wao-business/src/main/java/fr/ifremer/wao/entity/WaoUserImpl.java (from rev 354, trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/WaoUserImpl.java)
===================================================================
--- trunk/wao-business/src/main/java/fr/ifremer/wao/entity/WaoUserImpl.java (rev 0)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/entity/WaoUserImpl.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -0,0 +1,79 @@
+/*
+ * *##%
+ * 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.entity;
+
+import fr.ifremer.wao.WaoContext;
+import java.io.Serializable;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * UserImpl
+ *
+ * Created: 27 nov. 2009
+ *
+ * @author fdesbois
+ * @version $Revision$
+ *
+ * Mise a jour: $Date$
+ * par : $Author$
+ */
+public class WaoUserImpl extends WaoUserAbstract implements Serializable, WaoUser {
+
+ private static final Logger log = LoggerFactory.getLogger(WaoUserImpl.class);
+
+ private static final long serialVersionUID = 1L;
+
+ protected boolean passwordChanged;
+
+ /**
+ * Return the fullName of the user, i.e. fisrtName + lastName.
+ * @return a String for the user fullName
+ */
+ @Override
+ public String getFullName() {
+ String name = getFirstName() != null ? getFirstName() : "";
+ name += getLastName() != null ? " " + getLastName() : "";
+ return name;
+ }
+
+ /**
+ * Return a simplified id instead of using topiaId
+ * @return a simplified id
+ * @see WaoUtils#convertId(java.lang.String)
+ */
+ @Override
+ public String getId() {
+ return WaoContext.convertId(getTopiaId());
+ }
+
+ @Override
+ public void setPasswordChanged(boolean changed) {
+ this.passwordChanged = changed;
+ }
+
+ @Override
+ public boolean isPasswordChanged() {
+ return this.passwordChanged;
+ }
+
+}
Deleted: trunk/wao-business/src/main/java/fr/ifremer/wao/io/ExportHelper.java
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/io/ExportHelper.java 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/io/ExportHelper.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,125 +0,0 @@
-
-package fr.ifremer.suiviobsmer.io;
-
-import com.csvreader.CsvWriter;
-import fr.ifremer.suiviobsmer.io.WaoCsvHeader.IOHeader;
-import java.io.IOException;
-
-/**
- * Helper for CSV Export. This class must be inherited to be used in services
- * implementations. Two methods needed :
- * <pre>
- * - {@link #record(IOHeader, String)} : record a value in the file
- * - {@link #getHeaderValue(int)} : get the string header value corresponding
- * to the index value.
- * </pre>
- * You have to used {@link WaoCsvHeader} to manage this two methods,
- * to retrieve good indexes and good values for printing data headers.
- * Steps :
- * <pre>
- * - Instanciate {@link #ExportHelper(CsvWriter, int) }
- * (with abstract method implementations if needed).
- * - Call {@link #writeHeaders() } method to prepare columns and write
- * first row in the resulting file.
- * - In the loop data, first use {@link #newRecord() } to prepare the current
- * record.
- * - Then used for each column, the {@link #record(IOHeader, String) } method.
- * - Finally call the {@link #writeRecord() } to write the record in file.
- * </pre>
- *
- * Created: 11 févr. 2010
- *
- * @param <H>
- * @author fdesbois
- * @version $Revision$
- *
- * Mise a jour: $Date$
- * par : $Author$
- */
-public abstract class ExportHelper<H extends IOHeader> {
-
- /** Writer used to record data **/
- protected CsvWriter writer;
-
- /** Current record to write **/
- protected String[] record;
-
- /** Number of columns/headers in resulting export **/
- protected int nbHeaders;
-
- /**
- * Constructor of ExportHelper. Need an existing CsvWriter ready to
- * write data in it.
- *
- * @param writer the CsvWriter used for record data
- * @param nbHeaders number of columns in the resulting file
- * @throws IOException
- */
- public ExportHelper(CsvWriter writer, int nbHeaders) throws IOException {
- this.writer = writer;
- this.nbHeaders = nbHeaders;
- }
-
- /**
- * Record a value for a header corresponding to the H generic type from
- * {@link WaoCsvReader } class.
- *
- * @param header IOHeader used to record the value (column in the file)
- * @param value the value to record
- */
- public abstract void record(H header, String value);
-
- /**
- * Return the header String value based on index. All matching integers for
- * headers are defined in {@link WaoCsvReader } class.
- *
- * @param index of the header
- * @return the String value of the header
- * @throws IOException
- */
- protected abstract String getHeaderValue(int index) throws IOException;
-
- /**
- * Write the first header line of the file. This method uses
- * {@link #getHeaderValue(int) } to retrieve the corresponding name of the
- * header depends on its index.
- *
- * @throws IOException
- */
- public void writeHeaders() throws IOException {
- for (int i = 0; i < nbHeaders; i++) {
- String header = getHeaderValue(i);
- writer.write(header);
- }
- writer.endRecord();
- }
-
- /**
- * Record a value in the current record.
- *
- * @param index of the column
- * @param value of the data to record
- */
- public void record(int index, String value) {
- if (value != null) {
- record[index] = value;
- }
- }
-
- /**
- * Prepare a new record (new file row).
- */
- public void newRecord() {
- record = new String[nbHeaders];
- }
-
- /**
- * Write the current record in the resulting file.
- *
- * @throws IOException
- */
- public void writeRecord() throws IOException {
- writer.writeRecord(record);
- writer.flush();
- }
-}
Copied: trunk/wao-business/src/main/java/fr/ifremer/wao/io/ExportHelper.java (from rev 354, trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/io/ExportHelper.java)
===================================================================
--- trunk/wao-business/src/main/java/fr/ifremer/wao/io/ExportHelper.java (rev 0)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/io/ExportHelper.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -0,0 +1,145 @@
+/*
+ * *##%
+ * 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 com.csvreader.CsvWriter;
+import fr.ifremer.wao.io.WaoCsvHeader.IOHeader;
+import java.io.IOException;
+
+/**
+ * Helper for CSV Export. This class must be inherited to be used in services
+ * implementations. Two methods needed :
+ * <pre>
+ * - {@link #record(IOHeader, String)} : record a value in the file
+ * - {@link #getHeaderValue(int)} : get the string header value corresponding
+ * to the index value.
+ * </pre>
+ * You have to used {@link WaoCsvHeader} to manage this two methods,
+ * to retrieve good indexes and good values for printing data headers.
+ * Steps :
+ * <pre>
+ * - Instanciate {@link #ExportHelper(CsvWriter, int) }
+ * (with abstract method implementations if needed).
+ * - Call {@link #writeHeaders() } method to prepare columns and write
+ * first row in the resulting file.
+ * - In the loop data, first use {@link #newRecord() } to prepare the current
+ * record.
+ * - Then used for each column, the {@link #record(IOHeader, String) } method.
+ * - Finally call the {@link #writeRecord() } to write the record in file.
+ * </pre>
+ *
+ * Created: 11 févr. 2010
+ *
+ * @param <H>
+ * @author fdesbois
+ * @version $Revision$
+ *
+ * Mise a jour: $Date$
+ * par : $Author$
+ */
+public abstract class ExportHelper<H extends IOHeader> {
+
+ /** Writer used to record data **/
+ protected CsvWriter writer;
+
+ /** Current record to write **/
+ protected String[] record;
+
+ /** Number of columns/headers in resulting export **/
+ protected int nbHeaders;
+
+ /**
+ * Constructor of ExportHelper. Need an existing CsvWriter ready to
+ * write data in it.
+ *
+ * @param writer the CsvWriter used for record data
+ * @param nbHeaders number of columns in the resulting file
+ * @throws IOException
+ */
+ public ExportHelper(CsvWriter writer, int nbHeaders) throws IOException {
+ this.writer = writer;
+ this.nbHeaders = nbHeaders;
+ }
+
+ /**
+ * Record a value for a header corresponding to the H generic type from
+ * {@link WaoCsvReader } class.
+ *
+ * @param header IOHeader used to record the value (column in the file)
+ * @param value the value to record
+ */
+ public abstract void record(H header, String value);
+
+ /**
+ * Return the header String value based on index. All matching integers for
+ * headers are defined in {@link WaoCsvReader } class.
+ *
+ * @param index of the header
+ * @return the String value of the header
+ * @throws IOException
+ */
+ protected abstract String getHeaderValue(int index) throws IOException;
+
+ /**
+ * Write the first header line of the file. This method uses
+ * {@link #getHeaderValue(int) } to retrieve the corresponding name of the
+ * header depends on its index.
+ *
+ * @throws IOException
+ */
+ public void writeHeaders() throws IOException {
+ for (int i = 0; i < nbHeaders; i++) {
+ String header = getHeaderValue(i);
+ writer.write(header);
+ }
+ writer.endRecord();
+ }
+
+ /**
+ * Record a value in the current record.
+ *
+ * @param index of the column
+ * @param value of the data to record
+ */
+ public void record(int index, String value) {
+ if (value != null) {
+ record[index] = value;
+ }
+ }
+
+ /**
+ * Prepare a new record (new file row).
+ */
+ public void newRecord() {
+ record = new String[nbHeaders];
+ }
+
+ /**
+ * Write the current record in the resulting file.
+ *
+ * @throws IOException
+ */
+ public void writeRecord() throws IOException {
+ writer.writeRecord(record);
+ writer.flush();
+ }
+}
Deleted: trunk/wao-business/src/main/java/fr/ifremer/wao/io/ImportHelper.java
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/io/ImportHelper.java 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/io/ImportHelper.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,225 +0,0 @@
-/*
- * *##%
- * SuiviObsmer :: 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.suiviobsmer.io;
-
-import fr.ifremer.suiviobsmer.*;
-import com.csvreader.CsvReader;
-import fr.ifremer.suiviobsmer.io.WaoCsvHeader.ACTIVITY_CALENDAR;
-import fr.ifremer.suiviobsmer.io.WaoCsvHeader.CONTACT;
-import fr.ifremer.suiviobsmer.io.WaoCsvHeader.DatedHeader;
-import fr.ifremer.suiviobsmer.io.WaoCsvHeader.IOHeader;
-import fr.ifremer.suiviobsmer.io.WaoCsvHeader.SAMPLING;
-import fr.ifremer.suiviobsmer.io.WaoCsvHeader.SamplingHeader;
-import java.io.IOException;
-import java.text.DateFormat;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.GregorianCalendar;
-import java.util.Locale;
-import org.apache.commons.lang.BooleanUtils;
-import org.apache.commons.lang.StringUtils;
-import org.apache.commons.lang.time.DurationFormatUtils;
-import org.nuiton.util.PeriodDates;
-import org.slf4j.Logger;
-
-/**
- * ImportHelper
- *
- * Created: 4 janv. 2010
- *
- * @author fdesbois
- * @version $Revision$
- *
- * Mise a jour: $Date$
- * par : $Author$
- */
-public class ImportHelper {
-
- protected CsvReader reader;
-
- public ImportHelper(CsvReader reader) {
- this.reader = reader;
- }
-
- public static Boolean parseContactValidation(CsvReader reader, IOHeader header) throws IOException {
- String validation = read(reader, header);
- Boolean result = null;
- if ("A".equals(validation)) {
- result = Boolean.TRUE;
- } else if ("R".equals(validation)) {
- result = Boolean.FALSE;
- }
- return result;
- }
-
- public static boolean parseContactMammals(CsvReader reader, IOHeader header) throws IOException {
- String mammals = read(reader, header);
- return "X".equals(mammals);
- }
-
- public static Date parseContactCreateDate(String code, String createDate) throws ParseException {
- Calendar time = new GregorianCalendar(Locale.FRENCH);
- if (StringUtils.isNotEmpty(code)) {
- DateFormat timeFormat = CONTACT.getTimeFormat();
- time = new GregorianCalendar(Locale.FRENCH);
- time.setTime(timeFormat.parse(code));
- } else {
- // Use current date with no time as a reference if no code is set
- time.setTime(SuiviObsmerContext.getCurrentDate());
- time.set(Calendar.HOUR_OF_DAY, 0);
- time.set(Calendar.MINUTE, 0);
- time.set(Calendar.SECOND, 0);
- time.set(Calendar.MILLISECOND, 0);
- }
-
- Calendar result = new GregorianCalendar(Locale.FRENCH);
- if (StringUtils.isNotEmpty(createDate)) {
- DateFormat dateFormat = CONTACT.getDateFormat();
- result.setTime(dateFormat.parse(createDate));
- result.set(Calendar.HOUR_OF_DAY, time.get(Calendar.HOUR_OF_DAY));
- result.set(Calendar.MINUTE, time.get(Calendar.MINUTE));
- result.set(Calendar.SECOND, time.get(Calendar.SECOND));
- result.set(Calendar.MILLISECOND, time.get(Calendar.MILLISECOND));
- } else {
- result.setTime(SuiviObsmerContext.getCurrentDate());
- }
- return result.getTime();
- }
-
- public static String readSampleRowCode(CsvReader reader) throws IOException {
- String code = read(reader, SAMPLING.PLAN_CODE);
- return SuiviObsmerContext.prepareSampleRowCode(code);
- }
-
- /**
- * Read a string value in CsvReader from {@code header} column.
- * In ActivityCalendarImport the result value can be null if the read value is "NA".
- *
- * @param reader CsvReader used to read the value
- * @param header Column header in the CsvReader
- * @return the String value read or null if set to "NA" in ActivityCalendar import.
- * @throws IOException
- */
- public static String read(CsvReader reader, IOHeader header) throws IOException {
- String result = reader.get(header.name()).trim();
- if (header instanceof ACTIVITY_CALENDAR && "NA".equals(result)) {
- return null;
- }
- return result;
- }
-
- /**
- * Read an int value in CsvReader from {@code header} column.
- *
- * @param reader CsvReader used to read the value
- * @param header Column header in the CsvReader
- * @return the int value or -1 if the value read is null
- * @throws IOException
- * @see ImportHelper#read(CsvReader, IOHeader)
- */
- public static int readInt(CsvReader reader, IOHeader header) throws IOException {
- String str = read(reader, header);
- if (StringUtils.isEmpty(str)) {
- return -1;
- }
- return Integer.parseInt(str);
- }
-
- /**
- * Read an Integer value in CsvReader from {@code header} column.
- *
- * @param reader CsvReader used to read the value
- * @param header Column header in the CsvReader
- * @return the Integer value or null if the value read is null
- * @throws IOException
- * @see ImportHelper#readInt(CsvReader, IOHeader)
- */
- public static Integer readInteger(CsvReader reader, IOHeader header) throws IOException {
- int result = readInt(reader, header);
- return result != -1 ? result : null;
- }
-
- /**
- * Read two values in CsvReader corresponding to a period from {@code headerBegin} and {@code headEnd} column.
- *
- * @param reader CsvReader used to read the value
- * @param headerBegin Column header in the CsvReader for periodBegin
- * @param headerEnd Column header in the CsvReader for periodEnd
- * @return the PeriodDates created from periodBegin and periodEnd read from Csv file
- * @throws IOException
- * @throws ParseException
- * @throws IllegalArgumentException
- * @see ImportHelper#readDate(CsvReader, IOHeader)
- */
- public static PeriodDates readPeriod(CsvReader reader, DatedHeader headerBegin, DatedHeader headerEnd)
- throws IOException, ParseException {
- Date end = readDate(reader, headerEnd);
- Date begin = readDate(reader, headerBegin);
- if (begin != null && end != null) {
- PeriodDates period = new PeriodDates(begin, end);
- period.initDayOfMonthExtremities();
- return period;
- }
- return null;
- }
-
- /**
- * Read a Date value in CsvReader from {@code header} column.
- *
- * @param reader CsvReader used to read the value
- * @param header Column header in the CsvReader
- * @return the Date value or null if the value read is null
- * @throws IOException
- * @throws ParseException
- * @see ImportHelper#read(CsvReader, IOHeader)
- */
- public static Date readDate(CsvReader reader, DatedHeader header)
- throws IOException, ParseException {
- DateFormat dateFormat = new SimpleDateFormat(header.datePattern());
- String str = read(reader, header);
- if (StringUtils.isEmpty(str)) {
- return null;
- }
- // Parsing problem with Pattern dd/MM/yyyy which is valid for dd/MM/yy date
- // The length is tested to avoid accepting wrong dates
- if (str.length() != header.datePattern().length()) {
- throw new ParseException("Date error : " + str, str.length());
- }
- return dateFormat.parse(str);
- }
-
- public static long logTimeAndMemory(Logger log, long tic1, String msg) {
- if (log.isInfoEnabled()) {
- log.info("RUNNING... Import : " + msg);
- Runtime runtime = Runtime.getRuntime();
- long mem = (runtime.totalMemory() - runtime.freeMemory()) / 1048576;
- //long memMega = mem / 1024 / 1024;
- log.info("Memory : " + mem + " Mo");
- long tic2 = System.currentTimeMillis();
- log.info("Time : " + DurationFormatUtils.formatDurationHMS(tic2 - tic1));
- }
- return System.currentTimeMillis();
- }
-
-}
Copied: trunk/wao-business/src/main/java/fr/ifremer/wao/io/ImportHelper.java (from rev 354, trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/io/ImportHelper.java)
===================================================================
--- trunk/wao-business/src/main/java/fr/ifremer/wao/io/ImportHelper.java (rev 0)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/io/ImportHelper.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -0,0 +1,225 @@
+/*
+ * *##%
+ * 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.ACTIVITY_CALENDAR;
+import fr.ifremer.wao.io.WaoCsvHeader.CONTACT;
+import fr.ifremer.wao.io.WaoCsvHeader.DatedHeader;
+import fr.ifremer.wao.io.WaoCsvHeader.IOHeader;
+import fr.ifremer.wao.io.WaoCsvHeader.SAMPLING;
+import fr.ifremer.wao.io.WaoCsvHeader.SamplingHeader;
+import java.io.IOException;
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.GregorianCalendar;
+import java.util.Locale;
+import org.apache.commons.lang.BooleanUtils;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang.time.DurationFormatUtils;
+import org.nuiton.util.PeriodDates;
+import org.slf4j.Logger;
+
+/**
+ * ImportHelper
+ *
+ * Created: 4 janv. 2010
+ *
+ * @author fdesbois
+ * @version $Revision$
+ *
+ * Mise a jour: $Date$
+ * par : $Author$
+ */
+public class ImportHelper {
+
+ protected CsvReader reader;
+
+ public ImportHelper(CsvReader reader) {
+ this.reader = reader;
+ }
+
+ public static Boolean parseContactValidation(CsvReader reader, IOHeader header) throws IOException {
+ String validation = read(reader, header);
+ Boolean result = null;
+ if ("A".equals(validation)) {
+ result = Boolean.TRUE;
+ } else if ("R".equals(validation)) {
+ result = Boolean.FALSE;
+ }
+ return result;
+ }
+
+ public static boolean parseContactMammals(CsvReader reader, IOHeader header) throws IOException {
+ String mammals = read(reader, header);
+ return "X".equals(mammals);
+ }
+
+ public static Date parseContactCreateDate(String code, String createDate) throws ParseException {
+ Calendar time = new GregorianCalendar(Locale.FRENCH);
+ if (StringUtils.isNotEmpty(code)) {
+ DateFormat timeFormat = CONTACT.getTimeFormat();
+ time = new GregorianCalendar(Locale.FRENCH);
+ 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.set(Calendar.HOUR_OF_DAY, 0);
+ time.set(Calendar.MINUTE, 0);
+ time.set(Calendar.SECOND, 0);
+ time.set(Calendar.MILLISECOND, 0);
+ }
+
+ Calendar result = new GregorianCalendar(Locale.FRENCH);
+ if (StringUtils.isNotEmpty(createDate)) {
+ DateFormat dateFormat = CONTACT.getDateFormat();
+ result.setTime(dateFormat.parse(createDate));
+ result.set(Calendar.HOUR_OF_DAY, time.get(Calendar.HOUR_OF_DAY));
+ result.set(Calendar.MINUTE, time.get(Calendar.MINUTE));
+ result.set(Calendar.SECOND, time.get(Calendar.SECOND));
+ result.set(Calendar.MILLISECOND, time.get(Calendar.MILLISECOND));
+ } else {
+ result.setTime(WaoContext.getCurrentDate());
+ }
+ return result.getTime();
+ }
+
+ public static String readSampleRowCode(CsvReader reader) throws IOException {
+ String code = read(reader, SAMPLING.PLAN_CODE);
+ return WaoContext.prepareSampleRowCode(code);
+ }
+
+ /**
+ * Read a string value in CsvReader from {@code header} column.
+ * In ActivityCalendarImport the result value can be null if the read value is "NA".
+ *
+ * @param reader CsvReader used to read the value
+ * @param header Column header in the CsvReader
+ * @return the String value read or null if set to "NA" in ActivityCalendar import.
+ * @throws IOException
+ */
+ public static String read(CsvReader reader, IOHeader header) throws IOException {
+ String result = reader.get(header.name()).trim();
+ if (header instanceof ACTIVITY_CALENDAR && "NA".equals(result)) {
+ return null;
+ }
+ return result;
+ }
+
+ /**
+ * Read an int value in CsvReader from {@code header} column.
+ *
+ * @param reader CsvReader used to read the value
+ * @param header Column header in the CsvReader
+ * @return the int value or -1 if the value read is null
+ * @throws IOException
+ * @see ImportHelper#read(CsvReader, IOHeader)
+ */
+ public static int readInt(CsvReader reader, IOHeader header) throws IOException {
+ String str = read(reader, header);
+ if (StringUtils.isEmpty(str)) {
+ return -1;
+ }
+ return Integer.parseInt(str);
+ }
+
+ /**
+ * Read an Integer value in CsvReader from {@code header} column.
+ *
+ * @param reader CsvReader used to read the value
+ * @param header Column header in the CsvReader
+ * @return the Integer value or null if the value read is null
+ * @throws IOException
+ * @see ImportHelper#readInt(CsvReader, IOHeader)
+ */
+ public static Integer readInteger(CsvReader reader, IOHeader header) throws IOException {
+ int result = readInt(reader, header);
+ return result != -1 ? result : null;
+ }
+
+ /**
+ * Read two values in CsvReader corresponding to a period from {@code headerBegin} and {@code headEnd} column.
+ *
+ * @param reader CsvReader used to read the value
+ * @param headerBegin Column header in the CsvReader for periodBegin
+ * @param headerEnd Column header in the CsvReader for periodEnd
+ * @return the PeriodDates created from periodBegin and periodEnd read from Csv file
+ * @throws IOException
+ * @throws ParseException
+ * @throws IllegalArgumentException
+ * @see ImportHelper#readDate(CsvReader, IOHeader)
+ */
+ public static PeriodDates readPeriod(CsvReader reader, DatedHeader headerBegin, DatedHeader headerEnd)
+ throws IOException, ParseException {
+ Date end = readDate(reader, headerEnd);
+ Date begin = readDate(reader, headerBegin);
+ if (begin != null && end != null) {
+ PeriodDates period = new PeriodDates(begin, end);
+ period.initDayOfMonthExtremities();
+ return period;
+ }
+ return null;
+ }
+
+ /**
+ * Read a Date value in CsvReader from {@code header} column.
+ *
+ * @param reader CsvReader used to read the value
+ * @param header Column header in the CsvReader
+ * @return the Date value or null if the value read is null
+ * @throws IOException
+ * @throws ParseException
+ * @see ImportHelper#read(CsvReader, IOHeader)
+ */
+ public static Date readDate(CsvReader reader, DatedHeader header)
+ throws IOException, ParseException {
+ DateFormat dateFormat = new SimpleDateFormat(header.datePattern());
+ String str = read(reader, header);
+ if (StringUtils.isEmpty(str)) {
+ return null;
+ }
+ // Parsing problem with Pattern dd/MM/yyyy which is valid for dd/MM/yy date
+ // The length is tested to avoid accepting wrong dates
+ if (str.length() != header.datePattern().length()) {
+ throw new ParseException("Date error : " + str, str.length());
+ }
+ return dateFormat.parse(str);
+ }
+
+ public static long logTimeAndMemory(Logger log, long tic1, String msg) {
+ if (log.isInfoEnabled()) {
+ log.info("RUNNING... Import : " + msg);
+ Runtime runtime = Runtime.getRuntime();
+ long mem = (runtime.totalMemory() - runtime.freeMemory()) / 1048576;
+ //long memMega = mem / 1024 / 1024;
+ log.info("Memory : " + mem + " Mo");
+ long tic2 = System.currentTimeMillis();
+ log.info("Time : " + DurationFormatUtils.formatDurationHMS(tic2 - tic1));
+ }
+ return System.currentTimeMillis();
+ }
+
+}
Deleted: trunk/wao-business/src/main/java/fr/ifremer/wao/io/SamplingExport.java
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/io/SamplingExport.java 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/io/SamplingExport.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,103 +0,0 @@
-
-package fr.ifremer.suiviobsmer.io;
-
-import com.csvreader.CsvWriter;
-import fr.ifremer.suiviobsmer.entity.SampleMonth;
-import fr.ifremer.suiviobsmer.entity.SampleRow;
-import fr.ifremer.suiviobsmer.entity.WaoUser;
-import fr.ifremer.suiviobsmer.io.WaoCsvHeader.SAMPLING;
-import fr.ifremer.suiviobsmer.io.WaoCsvHeader.SamplingHeader;
-import java.io.IOException;
-import java.text.ParseException;
-import java.util.Date;
-import java.util.List;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * SamplingExport
- *
- * Created: 11 févr. 2010
- *
- * @author fdesbois
- * @version $Revision$
- *
- * Mise a jour: $Date$
- * par : $Author$
- */
-public class SamplingExport extends ExportHelper<SamplingHeader> {
-
- private static final Logger log = LoggerFactory.getLogger(SamplingExport.class);
-
- protected WaoUser user;
-
- protected List<String> monthHeaders;
-
- /** Used for {@link #getHeaderValue(int)} : changed for each call to the method **/
- protected int currMonthIndex;
-
- /**
- * Constructor with {@code user} and {@code monthHeaders} needed to prepare
- * headers and record months values.
- *
- * @param writer CsvWriter used to write data in the resulting file.
- * @param user WaoUser who called the export
- * @param monthHeaders String values of months to put in header row
- * @throws IOException
- */
- public SamplingExport(CsvWriter writer, WaoUser user, List<String> monthHeaders) throws IOException {
- super(writer, SAMPLING.getTotalHeaders() + monthHeaders.size());
- this.monthHeaders = monthHeaders;
- this.user = user;
- }
-
- @Override
- protected String getHeaderValue(int index) throws IOException {
- int nbHeadersForMonths = monthHeaders.size();
- String result = "";
- if (index >= SAMPLING.getStartIndexForMonths() && currMonthIndex < nbHeadersForMonths) {
- result = monthHeaders.get(currMonthIndex);
- currMonthIndex++;
- } else {
- SamplingHeader header = WaoCsvHeader.getHeaderForSamplingCsv(index, nbHeadersForMonths);
- // for an admin, same text as in Import (enum name)
- // for a user, the text is complete
- result = user.getAdmin() ? header.name() : header.toString();
- }
- return result;
- }
-
- @Override
- public void record(SamplingHeader header, String value) {
- int index = header.forSamplingCsv();
- if (index >= SAMPLING.getStartIndexForMonths()) {
- index += monthHeaders.size();
- }
- record(index, value);
- }
-
- public void recordMonths(SampleRow row) throws ParseException {
- for (int i = 0; i < monthHeaders.size(); i++) {
- // Get date from monthHeaders list
- Date month = SAMPLING.getDateFormat().parse(monthHeaders.get(i));
- // Retrieve sampleMonth corresponding
- SampleMonth sampleMonth = row.getSampleMonth(month);
- // Add it to the file if it exists
- if (sampleMonth != null) {
- // Prepare index for record
- int index = SAMPLING.getStartIndexForMonths() + i;
- String expected = String.valueOf(sampleMonth.getExpectedTidesValue());
- String real = String.valueOf(sampleMonth.getRealTidesValue());
- // The admin as only expected value (to be the same as
- // in import)
- if (user.getAdmin()) {
- record(index, expected); //record[index] = expected;
- // The user as both expected and real values
- } else {
- record(index, expected + " (" + real + ")");
- }
- }
- }
- }
-
-}
Copied: trunk/wao-business/src/main/java/fr/ifremer/wao/io/SamplingExport.java (from rev 354, trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/io/SamplingExport.java)
===================================================================
--- trunk/wao-business/src/main/java/fr/ifremer/wao/io/SamplingExport.java (rev 0)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/io/SamplingExport.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -0,0 +1,123 @@
+/*
+ * *##%
+ * 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 com.csvreader.CsvWriter;
+import fr.ifremer.wao.entity.SampleMonth;
+import fr.ifremer.wao.entity.SampleRow;
+import fr.ifremer.wao.entity.WaoUser;
+import fr.ifremer.wao.io.WaoCsvHeader.SAMPLING;
+import fr.ifremer.wao.io.WaoCsvHeader.SamplingHeader;
+import java.io.IOException;
+import java.text.ParseException;
+import java.util.Date;
+import java.util.List;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * SamplingExport
+ *
+ * Created: 11 févr. 2010
+ *
+ * @author fdesbois
+ * @version $Revision$
+ *
+ * Mise a jour: $Date$
+ * par : $Author$
+ */
+public class SamplingExport extends ExportHelper<SamplingHeader> {
+
+ private static final Logger log = LoggerFactory.getLogger(SamplingExport.class);
+
+ protected WaoUser user;
+
+ protected List<String> monthHeaders;
+
+ /** Used for {@link #getHeaderValue(int)} : changed for each call to the method **/
+ protected int currMonthIndex;
+
+ /**
+ * Constructor with {@code user} and {@code monthHeaders} needed to prepare
+ * headers and record months values.
+ *
+ * @param writer CsvWriter used to write data in the resulting file.
+ * @param user WaoUser who called the export
+ * @param monthHeaders String values of months to put in header row
+ * @throws IOException
+ */
+ public SamplingExport(CsvWriter writer, WaoUser user, List<String> monthHeaders) throws IOException {
+ super(writer, SAMPLING.getTotalHeaders() + monthHeaders.size());
+ this.monthHeaders = monthHeaders;
+ this.user = user;
+ }
+
+ @Override
+ protected String getHeaderValue(int index) throws IOException {
+ int nbHeadersForMonths = monthHeaders.size();
+ String result = "";
+ if (index >= SAMPLING.getStartIndexForMonths() && currMonthIndex < nbHeadersForMonths) {
+ result = monthHeaders.get(currMonthIndex);
+ currMonthIndex++;
+ } else {
+ SamplingHeader header = WaoCsvHeader.getHeaderForSamplingCsv(index, nbHeadersForMonths);
+ // for an admin, same text as in Import (enum name)
+ // for a user, the text is complete
+ result = user.getAdmin() ? header.name() : header.toString();
+ }
+ return result;
+ }
+
+ @Override
+ public void record(SamplingHeader header, String value) {
+ int index = header.forSamplingCsv();
+ if (index >= SAMPLING.getStartIndexForMonths()) {
+ index += monthHeaders.size();
+ }
+ record(index, value);
+ }
+
+ public void recordMonths(SampleRow row) throws ParseException {
+ for (int i = 0; i < monthHeaders.size(); i++) {
+ // Get date from monthHeaders list
+ Date month = SAMPLING.getDateFormat().parse(monthHeaders.get(i));
+ // Retrieve sampleMonth corresponding
+ SampleMonth sampleMonth = row.getSampleMonth(month);
+ // Add it to the file if it exists
+ if (sampleMonth != null) {
+ // Prepare index for record
+ int index = SAMPLING.getStartIndexForMonths() + i;
+ String expected = String.valueOf(sampleMonth.getExpectedTidesValue());
+ String real = String.valueOf(sampleMonth.getRealTidesValue());
+ // The admin as only expected value (to be the same as
+ // in import)
+ if (user.getAdmin()) {
+ record(index, expected); //record[index] = expected;
+ // The user as both expected and real values
+ } else {
+ record(index, expected + " (" + real + ")");
+ }
+ }
+ }
+ }
+
+}
Deleted: trunk/wao-business/src/main/java/fr/ifremer/wao/io/WaoCsvHeader.java
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/io/WaoCsvHeader.java 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/io/WaoCsvHeader.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,451 +0,0 @@
-
-package fr.ifremer.suiviobsmer.io;
-
-import java.text.DateFormat;
-import java.text.NumberFormat;
-import java.text.SimpleDateFormat;
-import java.util.Locale;
-import org.apache.commons.lang.BooleanUtils;
-
-/**
- * CsvHeader
- *
- * Created: 11 févr. 2010
- *
- * @author fdesbois
- * @version $Revision$
- *
- * Mise a jour: $Date$
- * par : $Author$
- */
-public class WaoCsvHeader {
-
- public interface IOHeader {
-
- /**
- * Name of the header. This method is automatically implemented for an
- * enum.
- *
- * @return the name of the header
- */
- String name();
- }
-
- public interface DatedHeader extends IOHeader {
-
- /**
- * Pattern for Date parsing. This pattern can be null, if no format date is necessary.
- *
- * @return a String corresponding to the date pattern
- */
- String datePattern();
- }
-
- public interface ContactHeader extends IOHeader {
-
- int forContactCsv();
- }
-
- public interface SamplingHeader extends IOHeader {
-
- int forSamplingCsv();
- }
-
- /**
- * CSV headers for Boat
- */
- public enum BOAT implements ContactHeader {
- /** Boat immatriculation **/
- NAVS_COD(1, "Immatriculation", 20),
- /** Boat name **/
- CARN_NOM(2, "Nom", 21),
- /** Boat length **/
- CARN_LONGUEUR_HT(3, "Longueur (m)"),
- /** Boat build year **/
- CARN_ANNEE(4, "Année de construction"),
- /** Boat district code **/
- QUARTIER_IMMA(5, "Code quartier", 22),
- /** ShipOwner code **/
- PER_COD,
- /** ShipOwner last name **/
- PER_NOM,
- /** ShipOwner first name **/
- PER_PRENOM,
- /** Boat active **/
- NAVS_ACTIVE(0, "Actif/Inactif"),
- /** BoatInfos contactFirstName **/
- CONT_PRENOM(6, "Prénom du contact"),
- /** BoatInfos contactLastName **/
- CONT_NOM(7, "Nom du contact"),
- /** BoatInfos contactEmail **/
- CONT_EMAIL(8, "Email du contact"),
- /** BoatInfos contactPhoneNumber **/
- CONT_TEL(9, "Tél du contact"),
- /** BoatInfos dup **/
- NAVS_DUP(10, "Capacité d'accueil du navire en personnels spécialisés"),
- /** BoatInfos comment **/
- NAVS_COMMENT(11, "Commentaire");
-
- private int contactHeader;
-
- private int boatHeader;
-
- private String title;
-
- BOAT(int indexBoat, String title, int indexContact) {
- contactHeader = indexContact;
- boatHeader = indexBoat;
- this.title = title;
- }
-
- BOAT(int indexBoat, String title) {
- boatHeader = indexBoat;
- this.title = title;
- contactHeader = -1;
- }
-
- BOAT() {
- contactHeader = -1;
- boatHeader = -1;
- title = name();
- }
-
- @Override
- public int forContactCsv() {
- return contactHeader;
- }
-
- public int forBoatCsv() {
- return boatHeader;
- }
-
- @Override
- public String toString() {
- return title;
- }
-
- public static int getTotalHeaders() {
- // NAVS_COMMENT is the last column
- return NAVS_COMMENT.forBoatCsv() + 1;
- }
-
- public static String getBoatInactiveCode() {
- return "I";
- }
- }
-
- /**
- * CSV headers for SamplingPlan
- */
- public enum SAMPLING implements SamplingHeader, ContactHeader, DatedHeader {
- /** SampleRow code **/
- PLAN_CODE(0, "Code ligne du plan", 6),
- /** Company name **/
- SOCIETE_NOM(1, "Société prestataire", 5),
- /** Program code **/
- PROGRAMME_CODE(12, "Programme de rattachement", 7),
- /** Program period begin **/
- PROGRAMME_DEBUT(13, "Date de début", 8),
- /** Program period end **/
- PROGRAMME_FIN(14, "Date de fin", 9),
- /** FishingZone other infos **/
- PECHE_AUTRE(5, "Zone de pêche autres informations", 13),
- /** Profession code DCF5 **/
- METIER_CODE_DCF5(6, "Métier (Code DCF niveau 5)", 14),
- /** Profession mesh size **/
- METIER_MAILLAGE(7, "Métier maillage (mm)", 15),
- /** Profession size **/
- METIER_TAILLE(8, "Métier taille (m)", 16),
- /** Profession other infos **/
- METIER_AUTRE(9, "Métier autre information", 17),
- /** Profession libelle **/
- METIER_LIBELLE(10, "Métier libellé", 18),
- /** Profession species **/
- METIER_ESPECES(11, "Métier espèces cibles", 19),
- /** SampleRow nb observants **/
- PLAN_NB_OBSERV(16, "Nombre d'observateurs"),
- /** SampleRow average tide time **/
- PLAN_DUREE_MOY(15, "Durée moyenne d'une marée (jours)"),
- /** SampleRow comment **/
- PLAN_COMMENT(17, "Commentaire");
-
- private int contactHeader;
-
- private int samplingHeader;
-
- private String title;
-
- SAMPLING(int indexSampling, String title, int indexContact) {
- this(indexSampling, title);
- contactHeader = indexContact;
- }
-
- SAMPLING(int indexSampling, String title) {
- samplingHeader = indexSampling;
- this.title = title;
- contactHeader = -1;
- }
-
- @Override
- public int forContactCsv() {
- return contactHeader;
- }
-
- @Override
- public int forSamplingCsv() {
- return samplingHeader;
- }
-
- @Override
- public String toString() {
- return title;
- }
-
- @Override
- public String datePattern() {
- return defaultDatePattern();
- }
-
- public static String defaultDatePattern() {
- return "MM/yyyy";
- }
-
- public static DateFormat getDateFormat() {
- return new SimpleDateFormat(defaultDatePattern(), Locale.FRENCH);
- }
-
- public static NumberFormat getNumberFormat() {
- return NumberFormat.getNumberInstance(Locale.FRENCH);
- }
-
- public static int getStartIndexForMonths() {
- // PROGRAMME_FIN is the last column before months
- return PROGRAMME_FIN.forSamplingCsv() + 1;
- }
-
- public static int getTotalHeaders() {
- // PLAN_COMMENT is the last column
- return PLAN_COMMENT.forSamplingCsv() + 1;
- }
- }
-
- /**
- * CSV headers for FishingZone
- */
- public enum FISHING_ZONE implements SamplingHeader, ContactHeader {
- /** FishingZone facade **/
- PECHE_FACADE(2, "Zone de pêche façade", 10),
- /** FishingZone sector **/
- PECHE_ZONE(3, "Zone de pêche", 11),
- /** FishingZone district code **/
- PECHE_DIVISION(4, "Zone de pêche divisions", 12);
-
- private int contactHeader;
-
- private int samplingHeader;
-
- String title;
-
- FISHING_ZONE(int indexSampling, String title, int indexContact) {
- contactHeader = indexContact;
- samplingHeader = indexSampling;
- this.title = title;
- }
-
- @Override
- public int forContactCsv() {
- return contactHeader;
- }
-
- @Override
- public int forSamplingCsv() {
- return samplingHeader;
- }
-
- @Override
- public String toString() {
- return title;
- }
-
- public static String getDistrictCodeSeparator() {
- return " / ";
- }
- }
-
- /**
- * CSV headers for Contact
- */
- public enum CONTACT implements ContactHeader, DatedHeader {
- /** Contact code (create date time for existing contact) **/
- CONT_CODE(0),
- /** Contact create date **/
- CONT_CREATION(1),
- /** User id **/
- OBSERV_ID(2),
- /** User prenom **/
- OBSERV_PRENOM(3),
- /** User nom **/
- OBSERV_NOM(4),
- /** Company id **/
- //SOCIETE_ID,
- /** Contact state **/
- CONT_ETAT(23),
- /** Contact tide begin **/
- CONT_DEBUT_MAREE(24),
- /** Contact tide end **/
- CONT_FIN_MAREE(25),
- /** Contact nb observants **/
- CONT_NB_OBSERV(26),
- /** Contact mammals capture **/
- CONT_MAM_CAPT(27),
- /** Contact mammals observation **/
- CONT_MAM_OBS(28),
- /** Contact comment **/
- CONT_COMMENT(29),
- /** Contact data input **/
- CONT_ALLEGRO(30),
- /** Contact company validation **/
- CONT_SOCIETE_VALID(31),
- /** Contact program validation **/
- CONT_PROGRAM_VALID(32);
-
- private int contactHeader;
-
- CONTACT(int index) {
- this.contactHeader = index;
- }
-
- @Override
- public int forContactCsv() {
- return contactHeader;
- }
-
- @Override
- public String datePattern() {
- return defaultDatePattern();
- }
-
- private static String defaultDatePattern() {
- return "dd/MM/yyyy";
- }
-
- public static DateFormat getDateFormat() {
- return new SimpleDateFormat(defaultDatePattern(), Locale.FRENCH);
- }
-
- public static DateFormat getTimeFormat() {
- return new SimpleDateFormat("HHmmssS", Locale.FRENCH);
- }
-
- public static int getTotalHeaders() {
- // CONT_PROGRAM_VALID is the last column
- return CONT_PROGRAM_VALID.forContactCsv() + 1;
- }
-
- public static String formatValidation(Boolean validation) {
- String valid = "";
- if (validation == null) {
- valid = "N";
- } else if (BooleanUtils.isTrue(validation)) {
- valid = "A";
- } else {
- valid = "R";
- }
- return valid;
- }
-
- public static String formatMammals(boolean mammals) {
- return mammals ? "X" : "";
- }
- }
-
- public enum ACTIVITY_CALENDAR implements IOHeader {
- /** ActivityCalendar year **/
- SYNA_AN,
- /** ActivityCalendar fiability **/
- INDQ_COD,
- /** ActivityMonth month **/
- SYNA_MOI,
- /** ActivityMonth harbourCode **/
- SYNA_POR_COD,
- /** ActivityMonth nbSeaDays **/
- SYNA_NOMJDM,
- /** ActivityMonth nbFishingDays **/
- SYNA_NOMJDP,
- /** ActivityMonth nbBoardingPersons **/
- SYNA_NOMHE,
- /** ActivityMonth harbourId **/
- SYNA_TPOR_COD,
- /** ActivityMonth harbourLibelle **/
- SYNA_POR_LIB,
- /** ActivityProfession professionOrder **/
- META_ORDRE,
- /** ActivityProfession code **/
- MET_COD,
- /** ActivityProfession id **/
- MET_ID,
- /** ActivityProfession libelle **/
- MET_LIB,
- /** ActivityZone code **/
- SECT_COD,
- /** ActivityZone gradiantCode **/
- GRA_COD,
- /** ActivityZone gradiantLibelle **/
- GRA_LIB,
- /** ActivityZone zoneId **/
- TSECT_COD,
- /** ActivityZone zoneLibelle **/
- SECT_LIB;
- }
-
- public static String getHeaderForContactCsv(int index) {
- for (BOAT boatEnum : BOAT.values()) {
- if (boatEnum.forContactCsv() == index) {
- return boatEnum.name();
- }
- }
- for (SAMPLING samplingEnum : SAMPLING.values()) {
- if (samplingEnum.forContactCsv() == index) {
- return samplingEnum.name();
- }
- }
- for (FISHING_ZONE zoneEnum : FISHING_ZONE.values()) {
- if (zoneEnum.forContactCsv() == index) {
- return zoneEnum.name();
- }
- }
- for (CONTACT contactEnum : CONTACT.values()) {
- if (contactEnum.forContactCsv() == index) {
- return contactEnum.name();
- }
- }
- return "";
- }
-
- public static String getHeaderForBoatCsv(int index) {
- for (BOAT boatEnum : BOAT.values()) {
- if (boatEnum.forBoatCsv() == index) {
- return boatEnum.toString();
- }
- }
- return "";
- }
-
- public static SamplingHeader getHeaderForSamplingCsv(int index, int nbMonthHeaders) {
- if (index > SAMPLING.getStartIndexForMonths()) {
- index -= nbMonthHeaders;
- }
-
- for (SAMPLING samplingEnum : SAMPLING.values()) {
- if (samplingEnum.forSamplingCsv() == index) {
- return samplingEnum;
- }
- }
- for (FISHING_ZONE zoneEnum : FISHING_ZONE.values()) {
- if (zoneEnum.forSamplingCsv() == index) {
- return zoneEnum;
- }
- }
- return null;
- }
-}
Copied: trunk/wao-business/src/main/java/fr/ifremer/wao/io/WaoCsvHeader.java (from rev 354, trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/io/WaoCsvHeader.java)
===================================================================
--- trunk/wao-business/src/main/java/fr/ifremer/wao/io/WaoCsvHeader.java (rev 0)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/io/WaoCsvHeader.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -0,0 +1,471 @@
+/*
+ * *##%
+ * 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 java.text.DateFormat;
+import java.text.NumberFormat;
+import java.text.SimpleDateFormat;
+import java.util.Locale;
+import org.apache.commons.lang.BooleanUtils;
+
+/**
+ * CsvHeader
+ *
+ * Created: 11 févr. 2010
+ *
+ * @author fdesbois
+ * @version $Revision$
+ *
+ * Mise a jour: $Date$
+ * par : $Author$
+ */
+public class WaoCsvHeader {
+
+ public interface IOHeader {
+
+ /**
+ * Name of the header. This method is automatically implemented for an
+ * enum.
+ *
+ * @return the name of the header
+ */
+ String name();
+ }
+
+ public interface DatedHeader extends IOHeader {
+
+ /**
+ * Pattern for Date parsing. This pattern can be null, if no format date is necessary.
+ *
+ * @return a String corresponding to the date pattern
+ */
+ String datePattern();
+ }
+
+ public interface ContactHeader extends IOHeader {
+
+ int forContactCsv();
+ }
+
+ public interface SamplingHeader extends IOHeader {
+
+ int forSamplingCsv();
+ }
+
+ /**
+ * CSV headers for Boat
+ */
+ public enum BOAT implements ContactHeader {
+ /** Boat immatriculation **/
+ NAVS_COD(1, "Immatriculation", 20),
+ /** Boat name **/
+ CARN_NOM(2, "Nom", 21),
+ /** Boat length **/
+ CARN_LONGUEUR_HT(3, "Longueur (m)"),
+ /** Boat build year **/
+ CARN_ANNEE(4, "Année de construction"),
+ /** Boat district code **/
+ QUARTIER_IMMA(5, "Code quartier", 22),
+ /** ShipOwner code **/
+ PER_COD,
+ /** ShipOwner last name **/
+ PER_NOM,
+ /** ShipOwner first name **/
+ PER_PRENOM,
+ /** Boat active **/
+ NAVS_ACTIVE(0, "Actif/Inactif"),
+ /** BoatInfos contactFirstName **/
+ CONT_PRENOM(6, "Prénom du contact"),
+ /** BoatInfos contactLastName **/
+ CONT_NOM(7, "Nom du contact"),
+ /** BoatInfos contactEmail **/
+ CONT_EMAIL(8, "Email du contact"),
+ /** BoatInfos contactPhoneNumber **/
+ CONT_TEL(9, "Tél du contact"),
+ /** BoatInfos dup **/
+ NAVS_DUP(10, "Capacité d'accueil du navire en personnels spécialisés"),
+ /** BoatInfos comment **/
+ NAVS_COMMENT(11, "Commentaire");
+
+ private int contactHeader;
+
+ private int boatHeader;
+
+ private String title;
+
+ BOAT(int indexBoat, String title, int indexContact) {
+ contactHeader = indexContact;
+ boatHeader = indexBoat;
+ this.title = title;
+ }
+
+ BOAT(int indexBoat, String title) {
+ boatHeader = indexBoat;
+ this.title = title;
+ contactHeader = -1;
+ }
+
+ BOAT() {
+ contactHeader = -1;
+ boatHeader = -1;
+ title = name();
+ }
+
+ @Override
+ public int forContactCsv() {
+ return contactHeader;
+ }
+
+ public int forBoatCsv() {
+ return boatHeader;
+ }
+
+ @Override
+ public String toString() {
+ return title;
+ }
+
+ public static int getTotalHeaders() {
+ // NAVS_COMMENT is the last column
+ return NAVS_COMMENT.forBoatCsv() + 1;
+ }
+
+ public static String getBoatInactiveCode() {
+ return "I";
+ }
+ }
+
+ /**
+ * CSV headers for SamplingPlan
+ */
+ public enum SAMPLING implements SamplingHeader, ContactHeader, DatedHeader {
+ /** SampleRow code **/
+ PLAN_CODE(0, "Code ligne du plan", 6),
+ /** Company name **/
+ SOCIETE_NOM(1, "Société prestataire", 5),
+ /** Program code **/
+ PROGRAMME_CODE(12, "Programme de rattachement", 7),
+ /** Program period begin **/
+ PROGRAMME_DEBUT(13, "Date de début", 8),
+ /** Program period end **/
+ PROGRAMME_FIN(14, "Date de fin", 9),
+ /** FishingZone other infos **/
+ PECHE_AUTRE(5, "Zone de pêche autres informations", 13),
+ /** Profession code DCF5 **/
+ METIER_CODE_DCF5(6, "Métier (Code DCF niveau 5)", 14),
+ /** Profession mesh size **/
+ METIER_MAILLAGE(7, "Métier maillage (mm)", 15),
+ /** Profession size **/
+ METIER_TAILLE(8, "Métier taille (m)", 16),
+ /** Profession other infos **/
+ METIER_AUTRE(9, "Métier autre information", 17),
+ /** Profession libelle **/
+ METIER_LIBELLE(10, "Métier libellé", 18),
+ /** Profession species **/
+ METIER_ESPECES(11, "Métier espèces cibles", 19),
+ /** SampleRow nb observants **/
+ PLAN_NB_OBSERV(16, "Nombre d'observateurs"),
+ /** SampleRow average tide time **/
+ PLAN_DUREE_MOY(15, "Durée moyenne d'une marée (jours)"),
+ /** SampleRow comment **/
+ PLAN_COMMENT(17, "Commentaire");
+
+ private int contactHeader;
+
+ private int samplingHeader;
+
+ private String title;
+
+ SAMPLING(int indexSampling, String title, int indexContact) {
+ this(indexSampling, title);
+ contactHeader = indexContact;
+ }
+
+ SAMPLING(int indexSampling, String title) {
+ samplingHeader = indexSampling;
+ this.title = title;
+ contactHeader = -1;
+ }
+
+ @Override
+ public int forContactCsv() {
+ return contactHeader;
+ }
+
+ @Override
+ public int forSamplingCsv() {
+ return samplingHeader;
+ }
+
+ @Override
+ public String toString() {
+ return title;
+ }
+
+ @Override
+ public String datePattern() {
+ return defaultDatePattern();
+ }
+
+ public static String defaultDatePattern() {
+ return "MM/yyyy";
+ }
+
+ public static DateFormat getDateFormat() {
+ return new SimpleDateFormat(defaultDatePattern(), Locale.FRENCH);
+ }
+
+ public static NumberFormat getNumberFormat() {
+ return NumberFormat.getNumberInstance(Locale.FRENCH);
+ }
+
+ public static int getStartIndexForMonths() {
+ // PROGRAMME_FIN is the last column before months
+ return PROGRAMME_FIN.forSamplingCsv() + 1;
+ }
+
+ public static int getTotalHeaders() {
+ // PLAN_COMMENT is the last column
+ return PLAN_COMMENT.forSamplingCsv() + 1;
+ }
+ }
+
+ /**
+ * CSV headers for FishingZone
+ */
+ public enum FISHING_ZONE implements SamplingHeader, ContactHeader {
+ /** FishingZone facade **/
+ PECHE_FACADE(2, "Zone de pêche façade", 10),
+ /** FishingZone sector **/
+ PECHE_ZONE(3, "Zone de pêche", 11),
+ /** FishingZone district code **/
+ PECHE_DIVISION(4, "Zone de pêche divisions", 12);
+
+ private int contactHeader;
+
+ private int samplingHeader;
+
+ String title;
+
+ FISHING_ZONE(int indexSampling, String title, int indexContact) {
+ contactHeader = indexContact;
+ samplingHeader = indexSampling;
+ this.title = title;
+ }
+
+ @Override
+ public int forContactCsv() {
+ return contactHeader;
+ }
+
+ @Override
+ public int forSamplingCsv() {
+ return samplingHeader;
+ }
+
+ @Override
+ public String toString() {
+ return title;
+ }
+
+ public static String getDistrictCodeSeparator() {
+ return " / ";
+ }
+ }
+
+ /**
+ * CSV headers for Contact
+ */
+ public enum CONTACT implements ContactHeader, DatedHeader {
+ /** Contact code (create date time for existing contact) **/
+ CONT_CODE(0),
+ /** Contact create date **/
+ CONT_CREATION(1),
+ /** User id **/
+ OBSERV_ID(2),
+ /** User prenom **/
+ OBSERV_PRENOM(3),
+ /** User nom **/
+ OBSERV_NOM(4),
+ /** Company id **/
+ //SOCIETE_ID,
+ /** Contact state **/
+ CONT_ETAT(23),
+ /** Contact tide begin **/
+ CONT_DEBUT_MAREE(24),
+ /** Contact tide end **/
+ CONT_FIN_MAREE(25),
+ /** Contact nb observants **/
+ CONT_NB_OBSERV(26),
+ /** Contact mammals capture **/
+ CONT_MAM_CAPT(27),
+ /** Contact mammals observation **/
+ CONT_MAM_OBS(28),
+ /** Contact comment **/
+ CONT_COMMENT(29),
+ /** Contact data input **/
+ CONT_ALLEGRO(30),
+ /** Contact company validation **/
+ CONT_SOCIETE_VALID(31),
+ /** Contact program validation **/
+ CONT_PROGRAM_VALID(32);
+
+ private int contactHeader;
+
+ CONTACT(int index) {
+ this.contactHeader = index;
+ }
+
+ @Override
+ public int forContactCsv() {
+ return contactHeader;
+ }
+
+ @Override
+ public String datePattern() {
+ return defaultDatePattern();
+ }
+
+ private static String defaultDatePattern() {
+ return "dd/MM/yyyy";
+ }
+
+ public static DateFormat getDateFormat() {
+ return new SimpleDateFormat(defaultDatePattern(), Locale.FRENCH);
+ }
+
+ public static DateFormat getTimeFormat() {
+ return new SimpleDateFormat("HHmmssS", Locale.FRENCH);
+ }
+
+ public static int getTotalHeaders() {
+ // CONT_PROGRAM_VALID is the last column
+ return CONT_PROGRAM_VALID.forContactCsv() + 1;
+ }
+
+ public static String formatValidation(Boolean validation) {
+ String valid = "";
+ if (validation == null) {
+ valid = "N";
+ } else if (BooleanUtils.isTrue(validation)) {
+ valid = "A";
+ } else {
+ valid = "R";
+ }
+ return valid;
+ }
+
+ public static String formatMammals(boolean mammals) {
+ return mammals ? "X" : "";
+ }
+ }
+
+ public enum ACTIVITY_CALENDAR implements IOHeader {
+ /** ActivityCalendar year **/
+ SYNA_AN,
+ /** ActivityCalendar fiability **/
+ INDQ_COD,
+ /** ActivityMonth month **/
+ SYNA_MOI,
+ /** ActivityMonth harbourCode **/
+ SYNA_POR_COD,
+ /** ActivityMonth nbSeaDays **/
+ SYNA_NOMJDM,
+ /** ActivityMonth nbFishingDays **/
+ SYNA_NOMJDP,
+ /** ActivityMonth nbBoardingPersons **/
+ SYNA_NOMHE,
+ /** ActivityMonth harbourId **/
+ SYNA_TPOR_COD,
+ /** ActivityMonth harbourLibelle **/
+ SYNA_POR_LIB,
+ /** ActivityProfession professionOrder **/
+ META_ORDRE,
+ /** ActivityProfession code **/
+ MET_COD,
+ /** ActivityProfession id **/
+ MET_ID,
+ /** ActivityProfession libelle **/
+ MET_LIB,
+ /** ActivityZone code **/
+ SECT_COD,
+ /** ActivityZone gradiantCode **/
+ GRA_COD,
+ /** ActivityZone gradiantLibelle **/
+ GRA_LIB,
+ /** ActivityZone zoneId **/
+ TSECT_COD,
+ /** ActivityZone zoneLibelle **/
+ SECT_LIB;
+ }
+
+ public static String getHeaderForContactCsv(int index) {
+ for (BOAT boatEnum : BOAT.values()) {
+ if (boatEnum.forContactCsv() == index) {
+ return boatEnum.name();
+ }
+ }
+ for (SAMPLING samplingEnum : SAMPLING.values()) {
+ if (samplingEnum.forContactCsv() == index) {
+ return samplingEnum.name();
+ }
+ }
+ for (FISHING_ZONE zoneEnum : FISHING_ZONE.values()) {
+ if (zoneEnum.forContactCsv() == index) {
+ return zoneEnum.name();
+ }
+ }
+ for (CONTACT contactEnum : CONTACT.values()) {
+ if (contactEnum.forContactCsv() == index) {
+ return contactEnum.name();
+ }
+ }
+ return "";
+ }
+
+ public static String getHeaderForBoatCsv(int index) {
+ for (BOAT boatEnum : BOAT.values()) {
+ if (boatEnum.forBoatCsv() == index) {
+ return boatEnum.toString();
+ }
+ }
+ return "";
+ }
+
+ public static SamplingHeader getHeaderForSamplingCsv(int index, int nbMonthHeaders) {
+ if (index > SAMPLING.getStartIndexForMonths()) {
+ index -= nbMonthHeaders;
+ }
+
+ for (SAMPLING samplingEnum : SAMPLING.values()) {
+ if (samplingEnum.forSamplingCsv() == index) {
+ return samplingEnum;
+ }
+ }
+ for (FISHING_ZONE zoneEnum : FISHING_ZONE.values()) {
+ if (zoneEnum.forSamplingCsv() == index) {
+ return zoneEnum;
+ }
+ }
+ return null;
+ }
+}
Deleted: trunk/wao-business/src/main/java/fr/ifremer/wao/mock/ServiceNewsMock.java
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/mock/ServiceNewsMock.java 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/mock/ServiceNewsMock.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,113 +0,0 @@
-/*
- * *##%
- * SuiviObsmer :: 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.suiviobsmer.mock;
-
-import fr.ifremer.suiviobsmer.SuiviObsmerException;
-import fr.ifremer.suiviobsmer.entity.News;
-import fr.ifremer.suiviobsmer.entity.NewsImpl;
-import fr.ifremer.suiviobsmer.services.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 SuiviObsmerException {
- 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 SuiviObsmerException {
- throw new UnsupportedOperationException("Not supported yet.");
- }
-
-}
Copied: trunk/wao-business/src/main/java/fr/ifremer/wao/mock/ServiceNewsMock.java (from rev 354, trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/mock/ServiceNewsMock.java)
===================================================================
--- trunk/wao-business/src/main/java/fr/ifremer/wao/mock/ServiceNewsMock.java (rev 0)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/mock/ServiceNewsMock.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -0,0 +1,113 @@
+/*
+ * *##%
+ * 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.");
+ }
+
+}
Deleted: trunk/wao-business/src/main/java/fr/ifremer/wao/service/ActivityCalendarImport.java
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services/ActivityCalendarImport.java 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/service/ActivityCalendarImport.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,384 +0,0 @@
-/*
- * *##%
- * SuiviObsmer :: 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.suiviobsmer.services;
-
-import fr.ifremer.suiviobsmer.*;
-import com.csvreader.CsvReader;
-import fr.ifremer.suiviobsmer.entity.ActivityCalendar;
-import fr.ifremer.suiviobsmer.entity.ActivityCalendarDAO;
-import fr.ifremer.suiviobsmer.entity.ActivityMonth;
-import fr.ifremer.suiviobsmer.entity.ActivityMonthDAO;
-import fr.ifremer.suiviobsmer.entity.ActivityProfession;
-import fr.ifremer.suiviobsmer.entity.ActivityProfessionDAO;
-import fr.ifremer.suiviobsmer.entity.ActivityZone;
-import fr.ifremer.suiviobsmer.entity.ActivityZoneDAO;
-import fr.ifremer.suiviobsmer.entity.Boat;
-import fr.ifremer.suiviobsmer.entity.BoatDAO;
-import fr.ifremer.suiviobsmer.io.ImportHelper;
-import fr.ifremer.suiviobsmer.io.WaoCsvHeader.ACTIVITY_CALENDAR;
-import fr.ifremer.suiviobsmer.io.WaoCsvHeader.BOAT;
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileWriter;
-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;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Locale;
-import java.util.Map;
-import org.apache.commons.io.IOUtils;
-import org.apache.commons.lang.time.DurationFormatUtils;
-import org.nuiton.topia.TopiaContext;
-import org.nuiton.topia.TopiaException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * ActivityCalendarImport
- *
- * Created: 11 déc. 2009
- *
- * @author fdesbois
- * @version $Revision$
- *
- * Mise a jour: $Date$
- * par : $Author$
- */
-public class ActivityCalendarImport implements Runnable {
-
- private InputStream input;
-
- private Writer writer;
-
- private static final Logger log = LoggerFactory.getLogger(ActivityCalendarImport.class);
-
- private static final boolean DISABLED = false;
-
- public class ActivityCalendarKey {
-
- private Boat boat;
- private String boatId;
- private int year;
-
- public ActivityCalendarKey(Boat boat, int year) {
- boatId = boat.getTopiaId();
- this.year = year;
- this.boat = boat;
- }
-
- public String boatId() {
- return boatId;
- }
-
- public Boat boat() {
- return boat;
- }
-
- public int year() {
- return year;
- }
-
- @Override
- public boolean equals(Object key) {
- if (!ActivityCalendarKey.class.isAssignableFrom(key.getClass())) {
- throw new ClassCastException("Unable to cast object " + key.getClass() + " to " + this.getClass().getName());
- }
- ActivityCalendarKey calendarKey = (ActivityCalendarKey)key;
- return year == calendarKey.year() && boatId.equals(calendarKey.boatId());
- }
-
- @Override
- public int hashCode() {
- int hash = 7;
- hash = 61 * hash + (this.boatId != null ? this.boatId.hashCode() : 0);
- hash = 61 * hash + this.year;
- return hash;
- }
- }
-
- public ActivityCalendarImport(InputStream input) throws IOException {
- super();
- this.input = input;
- String filename = SuiviObsmerContext.getProperty(
- SuiviObsmerContext.PROP_FILENAME_LOG_ACTIVITY_IMPORT);
- File file = new File(filename);
- file.getParentFile().mkdirs();
- if (file.exists()) {
- file.delete();
- file.createNewFile();
- }
- writer = new BufferedWriter(new FileWriter(filename));
- }
-
- @Override
- public void run() {
- TopiaContext transaction = null;
- SuiviObsmerContext.setActivityCalendarImport(true);
- int currRow = 1;
- try {
- transaction = SuiviObsmerContext.getTopiaRootContext().beginTransaction();
-
- CsvReader reader = new CsvReader(input, Charset.forName("UTF-8"));
-
- long startTime = System.currentTimeMillis();
-
- reader.readHeaders();
-
- int result = 0;
-
- long firstTic = startTime;
-
- long tic1, tic2;
-
- Map<ActivityCalendarKey, ActivityCalendar> availableCalendars = new HashMap<ActivityCalendarKey, ActivityCalendar>();
-
- BoatDAO boatDAO = SuiviObsmerModelDAOHelper.getBoatDAO(transaction);
- ActivityCalendarDAO calendarDAO = SuiviObsmerModelDAOHelper.getActivityCalendarDAO(transaction);
- ActivityMonthDAO monthDAO = SuiviObsmerModelDAOHelper.getActivityMonthDAO(transaction);
- ActivityProfessionDAO professionDAO = SuiviObsmerModelDAOHelper.getActivityProfessionDAO(transaction);
- ActivityZoneDAO zoneDAO = SuiviObsmerModelDAOHelper.getActivityZoneDAO(transaction);
-
- while(reader.readRecord()) {
- currRow++;
-
- int boatImmatriculation = Integer.parseInt(reader.get(BOAT.NAVS_COD.name()).trim());
-
- Boat boat = boatDAO.findByImmatriculation(boatImmatriculation);
-
-
- if (boat != null) {
-
-// int year = Integer.parseInt(reader.get("SYNA_AN").trim());
- int year = ImportHelper.readInt(reader, ACTIVITY_CALENDAR.SYNA_AN);
- if (year == -1) {
- error("Ligne non sauvegardé car l'année (SYNA_AN) n'est pas renseigné", currRow);
- continue;
- }
-
- ActivityCalendarKey key = new ActivityCalendarKey(boat, year);
- ActivityCalendar calendar = availableCalendars.get(key);
-
- // If not available select it from Database
- if (calendar == null) {
-
- calendar = calendarDAO.findByProperties(
- ActivityCalendar.BOAT, boat,
- ActivityCalendar.YEAR, year);
-
- // Create it if not exist in Database
- if (calendar == null) {
- //int fiability = Integer.parseInt(reader.get("INDQ_COD").trim());
- // fiability can be -1 if NA is set in CSV file
- int fiability = ImportHelper.readInt(reader, ACTIVITY_CALENDAR.INDQ_COD);
-
- calendar = calendarDAO.create(
- ActivityCalendar.BOAT, key.boat(),
- ActivityCalendar.YEAR, key.year(),
- ActivityCalendar.FIABILITY, fiability);
-
- calendar.setActivityMonth(new ArrayList<ActivityMonth>());
- }
- availableCalendars.put(key, calendar);
- }
-
- //int monthNum = Integer.parseInt(reader.get("SYNA_MOI").trim());
- int monthNum = ImportHelper.readInt(reader, ACTIVITY_CALENDAR.SYNA_MOI);
- if (monthNum == -1) {
- error("Ligne non sauvegardé car le mois (SYNA_MOI) n'est pas renseigné", currRow);
- continue;
- }
-
- //String harbourCode = reader.get("SYNA_POR_COD").trim();
- String professionCode = ImportHelper.read(reader, ACTIVITY_CALENDAR.MET_COD);
- boolean active = professionCode != null && !professionCode.equals("INA");
-
- ActivityMonth month = calendar.getActivityMonth(monthNum);
-
- if (month == null) {
- month = monthDAO.create(
- ActivityMonth.ACTIVITY_CALENDAR, calendar,
- ActivityMonth.MONTH, monthNum);
-
- month.setActivityProfession(new ArrayList<ActivityProfession>());
-
- calendar.addActivityMonth(month);
- }
-
- month.setActive(active);
-
- if (active) {
-
- Integer nbSeaDays = ImportHelper.readInteger(reader, ACTIVITY_CALENDAR.SYNA_NOMJDM);
- Integer nbFishingDays = ImportHelper.readInteger(reader, ACTIVITY_CALENDAR.SYNA_NOMJDP);
- Integer nbBoardingPersons = ImportHelper.readInteger(reader, ACTIVITY_CALENDAR.SYNA_NOMHE);
-
- int harbourId = ImportHelper.readInt(reader, ACTIVITY_CALENDAR.SYNA_TPOR_COD);
- String harbourCode = ImportHelper.read(reader, ACTIVITY_CALENDAR.SYNA_POR_COD);
- String harbourLibelle = ImportHelper.read(reader, ACTIVITY_CALENDAR.SYNA_POR_LIB);
-
- month.setHarbourId(harbourId);
- month.setHarbourCode(harbourCode);
- month.setHarbourLibelle(harbourLibelle);
- month.setNbBoardingPersons(nbBoardingPersons);
- month.setNbFishingDays(nbFishingDays);
- month.setNbSeaDays(nbSeaDays);
-
- // Can be equals to -1 if set to NA in Csv File (not a problem for ordering Profession)
- int professionOrder = ImportHelper.readInt(reader, ACTIVITY_CALENDAR.META_ORDRE);
- int professionId = ImportHelper.readInt(reader, ACTIVITY_CALENDAR.MET_ID);
- String professionLibelle = ImportHelper.read(reader, ACTIVITY_CALENDAR.MET_LIB);
-
- ActivityProfession profession = month.getActivityProfession(professionOrder);
-
- if (profession == null) {
-
- profession = professionDAO.create(
- ActivityProfession.ACTIVITY_MONTH, month,
- ActivityProfession.PROFESSION_ORDER, professionOrder);
-
- profession.setActivityZone(new ArrayList<ActivityZone>());
-
- month.addActivityProfession(profession);
- }
-
- profession.setId(professionId);
- profession.setCode(professionCode);
- profession.setLibelle(professionLibelle);
-
- String zoneCode = ImportHelper.read(reader, ACTIVITY_CALENDAR.SECT_COD);
- int gradiantCode = ImportHelper.readInt(reader, ACTIVITY_CALENDAR.GRA_COD);
- String gradiantLibelle = ImportHelper.read(reader, ACTIVITY_CALENDAR.GRA_LIB);
- int zoneId = ImportHelper.readInt(reader, ACTIVITY_CALENDAR.TSECT_COD);
- String zoneLibelle = ImportHelper.read(reader, ACTIVITY_CALENDAR.SECT_LIB);
-
- ActivityZone zone = profession.getActivityZone(zoneCode);
-
- if (zone == null) {
- zone = zoneDAO.create(
- ActivityZone.ZONE_CODE, zoneCode,
- ActivityZone.ACTIVITY_PROFESSION, profession);
-
- profession.addActivityZone(zone);
- }
-
- zone.setZoneId(zoneId);
- zone.setZoneLibelle(zoneLibelle);
- zone.setGradiantCode(gradiantCode);
- zone.setGradiantLibelle(gradiantLibelle);
- }
- result++;
- } else {
- warn("Navire inexistant dans le référentiel : " + boatImmatriculation, currRow);
- }
-
- if (result % 1000 == 0) {
- tic1 = System.currentTimeMillis();
-
- transaction.commitTransaction();
- availableCalendars.clear();
- // Force garbage collector
- System.gc();
-
- tic2 = System.currentTimeMillis();
- if (log.isDebugEnabled()) {
- log.debug("commit : " + (tic2 - tic1));
- }
- firstTic = ImportHelper.logTimeAndMemory(log, firstTic, "calendrier d'activité ligne " + currRow);
- }
- }
-
- // For the last rows
- transaction.commitTransaction();
-
- long stopTime = System.currentTimeMillis();
-
- String execTime = DurationFormatUtils.formatDurationHMS(stopTime - startTime);
-
- info("Nombre de ligne ajouté : " + result, -1);
- info("Temps d'exécution : " + execTime, -1);
-
- //transaction.closeContext();
- } catch (Exception eee) {
- if (log.isErrorEnabled()) {
- log.error("Problème lors de l'import du calendrier d'activité", eee);
- }
- exception(eee, currRow);
- try {
- transaction.rollbackTransaction();
- } catch (TopiaException te) {
- exception(te, currRow);
- }
- } finally {
- IOUtils.closeQuietly(writer);
- SuiviObsmerContext.setActivityCalendarImport(false);
- try {
- transaction.closeContext();
- } catch (TopiaException te) {
- exception(te, currRow);
- }
- }
- }
-
- protected void warn(String message, int numRow) throws IOException {
- writeLog("[WARN] " + message, numRow);
- }
-
- protected void error(String message, int numRow) throws IOException {
- writeLog("[ERROR] " + message, numRow);
- }
-
- protected void exception(Throwable eee, int numRow) {
- try {
- error("exception " + eee.getClass().getSimpleName() + " : " + eee.getMessage(), numRow);
- } catch (IOException ex) {
- if (log.isErrorEnabled()) {
- log.error("IO error", ex);
- }
- }
- }
-
- protected void info(String message, int numRow) throws IOException {
- writeLog("[INFO] " + message, numRow);
- }
-
- protected void writeLog(String message, int numRow) throws IOException {
- if (DISABLED) {
- return;
- }
- Date date = new Date();
- DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss", Locale.FRENCH);
- String dateString = dateFormat.format(date);
- String ligne = numRow != -1 ? "Ligne (" + numRow + ") : " : "";
- String msg = "[" + dateString + "] " + ligne + message;
- writer.write(msg + "\n");
- writer.flush();
- if (log.isTraceEnabled()) {
- log.trace("write log activityCalendar : " + msg);
- }
- }
-
-}
Copied: trunk/wao-business/src/main/java/fr/ifremer/wao/service/ActivityCalendarImport.java (from rev 354, trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services/ActivityCalendarImport.java)
===================================================================
--- trunk/wao-business/src/main/java/fr/ifremer/wao/service/ActivityCalendarImport.java (rev 0)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/service/ActivityCalendarImport.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -0,0 +1,384 @@
+/*
+ * *##%
+ * 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.service;
+
+import fr.ifremer.wao.*;
+import com.csvreader.CsvReader;
+import fr.ifremer.wao.entity.ActivityCalendar;
+import fr.ifremer.wao.entity.ActivityCalendarDAO;
+import fr.ifremer.wao.entity.ActivityMonth;
+import fr.ifremer.wao.entity.ActivityMonthDAO;
+import fr.ifremer.wao.entity.ActivityProfession;
+import fr.ifremer.wao.entity.ActivityProfessionDAO;
+import fr.ifremer.wao.entity.ActivityZone;
+import fr.ifremer.wao.entity.ActivityZoneDAO;
+import fr.ifremer.wao.entity.Boat;
+import fr.ifremer.wao.entity.BoatDAO;
+import fr.ifremer.wao.io.ImportHelper;
+import fr.ifremer.wao.io.WaoCsvHeader.ACTIVITY_CALENDAR;
+import fr.ifremer.wao.io.WaoCsvHeader.BOAT;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+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;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Locale;
+import java.util.Map;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.lang.time.DurationFormatUtils;
+import org.nuiton.topia.TopiaContext;
+import org.nuiton.topia.TopiaException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * ActivityCalendarImport
+ *
+ * Created: 11 déc. 2009
+ *
+ * @author fdesbois
+ * @version $Revision$
+ *
+ * Mise a jour: $Date$
+ * par : $Author$
+ */
+public class ActivityCalendarImport implements Runnable {
+
+ private InputStream input;
+
+ private Writer writer;
+
+ private static final Logger log = LoggerFactory.getLogger(ActivityCalendarImport.class);
+
+ private static final boolean DISABLED = false;
+
+ public class ActivityCalendarKey {
+
+ private Boat boat;
+ private String boatId;
+ private int year;
+
+ public ActivityCalendarKey(Boat boat, int year) {
+ boatId = boat.getTopiaId();
+ this.year = year;
+ this.boat = boat;
+ }
+
+ public String boatId() {
+ return boatId;
+ }
+
+ public Boat boat() {
+ return boat;
+ }
+
+ public int year() {
+ return year;
+ }
+
+ @Override
+ public boolean equals(Object key) {
+ if (!ActivityCalendarKey.class.isAssignableFrom(key.getClass())) {
+ throw new ClassCastException("Unable to cast object " + key.getClass() + " to " + this.getClass().getName());
+ }
+ ActivityCalendarKey calendarKey = (ActivityCalendarKey)key;
+ return year == calendarKey.year() && boatId.equals(calendarKey.boatId());
+ }
+
+ @Override
+ public int hashCode() {
+ int hash = 7;
+ hash = 61 * hash + (this.boatId != null ? this.boatId.hashCode() : 0);
+ hash = 61 * hash + this.year;
+ return hash;
+ }
+ }
+
+ public ActivityCalendarImport(InputStream input) throws IOException {
+ super();
+ this.input = input;
+ String filename = WaoContext.getProperty(
+ WaoContext.PROP_FILENAME_LOG_ACTIVITY_IMPORT);
+ File file = new File(filename);
+ file.getParentFile().mkdirs();
+ if (file.exists()) {
+ file.delete();
+ file.createNewFile();
+ }
+ writer = new BufferedWriter(new FileWriter(filename));
+ }
+
+ @Override
+ public void run() {
+ TopiaContext transaction = null;
+ WaoContext.setActivityCalendarImport(true);
+ int currRow = 1;
+ try {
+ transaction = WaoContext.getTopiaRootContext().beginTransaction();
+
+ CsvReader reader = new CsvReader(input, Charset.forName("UTF-8"));
+
+ long startTime = System.currentTimeMillis();
+
+ reader.readHeaders();
+
+ int result = 0;
+
+ long firstTic = startTime;
+
+ long tic1, tic2;
+
+ 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);
+
+ while(reader.readRecord()) {
+ currRow++;
+
+ int boatImmatriculation = Integer.parseInt(reader.get(BOAT.NAVS_COD.name()).trim());
+
+ Boat boat = boatDAO.findByImmatriculation(boatImmatriculation);
+
+
+ if (boat != null) {
+
+// int year = Integer.parseInt(reader.get("SYNA_AN").trim());
+ int year = ImportHelper.readInt(reader, ACTIVITY_CALENDAR.SYNA_AN);
+ if (year == -1) {
+ error("Ligne non sauvegardé car l'année (SYNA_AN) n'est pas renseigné", currRow);
+ continue;
+ }
+
+ ActivityCalendarKey key = new ActivityCalendarKey(boat, year);
+ ActivityCalendar calendar = availableCalendars.get(key);
+
+ // If not available select it from Database
+ if (calendar == null) {
+
+ calendar = calendarDAO.findByProperties(
+ ActivityCalendar.BOAT, boat,
+ ActivityCalendar.YEAR, year);
+
+ // Create it if not exist in Database
+ if (calendar == null) {
+ //int fiability = Integer.parseInt(reader.get("INDQ_COD").trim());
+ // fiability can be -1 if NA is set in CSV file
+ int fiability = ImportHelper.readInt(reader, ACTIVITY_CALENDAR.INDQ_COD);
+
+ calendar = calendarDAO.create(
+ ActivityCalendar.BOAT, key.boat(),
+ ActivityCalendar.YEAR, key.year(),
+ ActivityCalendar.FIABILITY, fiability);
+
+ calendar.setActivityMonth(new ArrayList<ActivityMonth>());
+ }
+ availableCalendars.put(key, calendar);
+ }
+
+ //int monthNum = Integer.parseInt(reader.get("SYNA_MOI").trim());
+ int monthNum = ImportHelper.readInt(reader, ACTIVITY_CALENDAR.SYNA_MOI);
+ if (monthNum == -1) {
+ error("Ligne non sauvegardé car le mois (SYNA_MOI) n'est pas renseigné", currRow);
+ continue;
+ }
+
+ //String harbourCode = reader.get("SYNA_POR_COD").trim();
+ String professionCode = ImportHelper.read(reader, ACTIVITY_CALENDAR.MET_COD);
+ boolean active = professionCode != null && !professionCode.equals("INA");
+
+ ActivityMonth month = calendar.getActivityMonth(monthNum);
+
+ if (month == null) {
+ month = monthDAO.create(
+ ActivityMonth.ACTIVITY_CALENDAR, calendar,
+ ActivityMonth.MONTH, monthNum);
+
+ month.setActivityProfession(new ArrayList<ActivityProfession>());
+
+ calendar.addActivityMonth(month);
+ }
+
+ month.setActive(active);
+
+ if (active) {
+
+ Integer nbSeaDays = ImportHelper.readInteger(reader, ACTIVITY_CALENDAR.SYNA_NOMJDM);
+ Integer nbFishingDays = ImportHelper.readInteger(reader, ACTIVITY_CALENDAR.SYNA_NOMJDP);
+ Integer nbBoardingPersons = ImportHelper.readInteger(reader, ACTIVITY_CALENDAR.SYNA_NOMHE);
+
+ int harbourId = ImportHelper.readInt(reader, ACTIVITY_CALENDAR.SYNA_TPOR_COD);
+ String harbourCode = ImportHelper.read(reader, ACTIVITY_CALENDAR.SYNA_POR_COD);
+ String harbourLibelle = ImportHelper.read(reader, ACTIVITY_CALENDAR.SYNA_POR_LIB);
+
+ month.setHarbourId(harbourId);
+ month.setHarbourCode(harbourCode);
+ month.setHarbourLibelle(harbourLibelle);
+ month.setNbBoardingPersons(nbBoardingPersons);
+ month.setNbFishingDays(nbFishingDays);
+ month.setNbSeaDays(nbSeaDays);
+
+ // Can be equals to -1 if set to NA in Csv File (not a problem for ordering Profession)
+ int professionOrder = ImportHelper.readInt(reader, ACTIVITY_CALENDAR.META_ORDRE);
+ int professionId = ImportHelper.readInt(reader, ACTIVITY_CALENDAR.MET_ID);
+ String professionLibelle = ImportHelper.read(reader, ACTIVITY_CALENDAR.MET_LIB);
+
+ ActivityProfession profession = month.getActivityProfession(professionOrder);
+
+ if (profession == null) {
+
+ profession = professionDAO.create(
+ ActivityProfession.ACTIVITY_MONTH, month,
+ ActivityProfession.PROFESSION_ORDER, professionOrder);
+
+ profession.setActivityZone(new ArrayList<ActivityZone>());
+
+ month.addActivityProfession(profession);
+ }
+
+ profession.setId(professionId);
+ profession.setCode(professionCode);
+ profession.setLibelle(professionLibelle);
+
+ String zoneCode = ImportHelper.read(reader, ACTIVITY_CALENDAR.SECT_COD);
+ int gradiantCode = ImportHelper.readInt(reader, ACTIVITY_CALENDAR.GRA_COD);
+ String gradiantLibelle = ImportHelper.read(reader, ACTIVITY_CALENDAR.GRA_LIB);
+ int zoneId = ImportHelper.readInt(reader, ACTIVITY_CALENDAR.TSECT_COD);
+ String zoneLibelle = ImportHelper.read(reader, ACTIVITY_CALENDAR.SECT_LIB);
+
+ ActivityZone zone = profession.getActivityZone(zoneCode);
+
+ if (zone == null) {
+ zone = zoneDAO.create(
+ ActivityZone.ZONE_CODE, zoneCode,
+ ActivityZone.ACTIVITY_PROFESSION, profession);
+
+ profession.addActivityZone(zone);
+ }
+
+ zone.setZoneId(zoneId);
+ zone.setZoneLibelle(zoneLibelle);
+ zone.setGradiantCode(gradiantCode);
+ zone.setGradiantLibelle(gradiantLibelle);
+ }
+ result++;
+ } else {
+ warn("Navire inexistant dans le référentiel : " + boatImmatriculation, currRow);
+ }
+
+ if (result % 1000 == 0) {
+ tic1 = System.currentTimeMillis();
+
+ transaction.commitTransaction();
+ availableCalendars.clear();
+ // Force garbage collector
+ System.gc();
+
+ tic2 = System.currentTimeMillis();
+ if (log.isDebugEnabled()) {
+ log.debug("commit : " + (tic2 - tic1));
+ }
+ firstTic = ImportHelper.logTimeAndMemory(log, firstTic, "calendrier d'activité ligne " + currRow);
+ }
+ }
+
+ // For the last rows
+ transaction.commitTransaction();
+
+ long stopTime = System.currentTimeMillis();
+
+ String execTime = DurationFormatUtils.formatDurationHMS(stopTime - startTime);
+
+ info("Nombre de ligne ajouté : " + result, -1);
+ info("Temps d'exécution : " + execTime, -1);
+
+ //transaction.closeContext();
+ } catch (Exception eee) {
+ if (log.isErrorEnabled()) {
+ log.error("Problème lors de l'import du calendrier d'activité", eee);
+ }
+ exception(eee, currRow);
+ try {
+ transaction.rollbackTransaction();
+ } catch (TopiaException te) {
+ exception(te, currRow);
+ }
+ } finally {
+ IOUtils.closeQuietly(writer);
+ WaoContext.setActivityCalendarImport(false);
+ try {
+ transaction.closeContext();
+ } catch (TopiaException te) {
+ exception(te, currRow);
+ }
+ }
+ }
+
+ protected void warn(String message, int numRow) throws IOException {
+ writeLog("[WARN] " + message, numRow);
+ }
+
+ protected void error(String message, int numRow) throws IOException {
+ writeLog("[ERROR] " + message, numRow);
+ }
+
+ protected void exception(Throwable eee, int numRow) {
+ try {
+ error("exception " + eee.getClass().getSimpleName() + " : " + eee.getMessage(), numRow);
+ } catch (IOException ex) {
+ if (log.isErrorEnabled()) {
+ log.error("IO error", ex);
+ }
+ }
+ }
+
+ protected void info(String message, int numRow) throws IOException {
+ writeLog("[INFO] " + message, numRow);
+ }
+
+ protected void writeLog(String message, int numRow) throws IOException {
+ if (DISABLED) {
+ return;
+ }
+ Date date = new Date();
+ DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss", Locale.FRENCH);
+ String dateString = dateFormat.format(date);
+ String ligne = numRow != -1 ? "Ligne (" + numRow + ") : " : "";
+ String msg = "[" + dateString + "] " + ligne + message;
+ writer.write(msg + "\n");
+ writer.flush();
+ if (log.isTraceEnabled()) {
+ log.trace("write log activityCalendar : " + msg);
+ }
+ }
+
+}
Deleted: trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceBoatImpl.java
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services/ServiceBoatImpl.java 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceBoatImpl.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,656 +0,0 @@
-/*
- * *##%
- * SuiviObsmer :: 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.suiviobsmer.services;
-
-import com.csvreader.CsvReader;
-import com.csvreader.CsvWriter;
-import fr.ifremer.suiviobsmer.SuiviObsmerBusinessException;
-import fr.ifremer.suiviobsmer.SuiviObsmerBusinessException.Type;
-import fr.ifremer.suiviobsmer.SuiviObsmerContext;
-import fr.ifremer.suiviobsmer.SuiviObsmerException;
-import fr.ifremer.suiviobsmer.SuiviObsmerModelDAOHelper;
-import org.nuiton.topia.TopiaException;
-import org.nuiton.topia.framework.TopiaQuery;
-import org.nuiton.topia.framework.TopiaQuery.Op;
-import fr.ifremer.suiviobsmer.bean.BoatFilter;
-import fr.ifremer.suiviobsmer.bean.CompanyBoatInfos;
-import fr.ifremer.suiviobsmer.bean.CompanyBoatInfosImpl;
-import fr.ifremer.suiviobsmer.entity.*;
-import fr.ifremer.suiviobsmer.io.ImportHelper;
-import fr.ifremer.suiviobsmer.io.ExportHelper;
-import fr.ifremer.suiviobsmer.io.WaoCsvHeader;
-import fr.ifremer.suiviobsmer.io.WaoCsvHeader.BOAT;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.nio.charset.Charset;
-import java.util.ArrayList;
-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;
-
-/**
- * ServiceBoatImpl
- *
- * Created: 24 nov. 2009
- *
- * @author fdesbois
- * @version $Revision$
- *
- * Mise a jour: $Date$
- * par : $Author$
- */
-public class ServiceBoatImpl implements ServiceBoat {
-
- private static final Logger log = LoggerFactory.getLogger(ServiceBoatImpl.class);
-
- protected TopiaContext rootContext;
-
- public ServiceBoatImpl() throws SuiviObsmerException {
- rootContext = SuiviObsmerContext.getTopiaRootContext();
- }
-
- @Override
- public Map<Integer, Boat> getBoatsByFilter(BoatFilter filter) throws SuiviObsmerException {
- TopiaContext transaction = null;
- Map<Integer, Boat> results = new HashMap<Integer, Boat>();
- try {
- transaction = rootContext.beginTransaction();
-
- BoatDAO dao = SuiviObsmerModelDAOHelper.getBoatDAO(transaction);
- TopiaQuery query = dao.createQuery("B");
-
- query = createQueryForBoatFilter(query, filter);
-
-// if (StringUtils.isNotEmpty(filter.getOrderBy())) {
-// query.addOrder("B." + filter.getOrderBy());
-// }
-
- query.addLoad(Boat.ACTIVITY_CALENDAR);
-
- if (log.isDebugEnabled()) {
- log.debug("Query : " + query);
- }
-
- results = dao.findAllMappedByQuery(query, Boat.IMMATRICULATION, Integer.class);
-
- } catch (Exception eee) {
- SuiviObsmerContext.serviceException(transaction, "Impossible de filtrer la liste des navires", eee);
- } finally {
- SuiviObsmerContext.closeTransaction(transaction);
- }
- return results;
- }
-
- @Override
- public int getNbBoatsByFilter(BoatFilter filter) throws SuiviObsmerException {
- TopiaContext transaction = null;
- int result = 0;
- try {
- transaction = rootContext.beginTransaction();
-
- BoatDAO dao = SuiviObsmerModelDAOHelper.getBoatDAO(transaction);
- TopiaQuery query = dao.createQuery("B");
-
- query = createQueryForBoatFilter(query, filter);
-
- result = query.executeCount();
-
- } catch (Exception eee) {
- SuiviObsmerContext.serviceException(transaction, "Impossible de filtrer la liste des navires", eee);
- } finally {
- SuiviObsmerContext.closeTransaction(transaction);
- }
- return result;
- }
-
- protected TopiaQuery createQueryForBoatFilter(TopiaQuery query, BoatFilter filter) throws TopiaException {
- String main = query.getMainAlias();
- query = filter.prepareQueryForBoat(query, main).addDistinct();
-
- // Sampling filter
- if (filter.isSamplingFiltered()) {
- // Add join for ElligibleBoat
- //String elligibleBoatClassName = ElligibleBoat.class.getName();
- query.addFrom(ElligibleBoat.class, "E").add("E." + ElligibleBoat.BOAT + " = " + main);
- query = filter.prepareQueryForSampling(query, "E." + ElligibleBoat.SAMPLE_ROW);
-
- // Company
- if (filter.getCompany() != null) {
- //query.add("E." + ElligibleBoat.SAMPLE_ROW + "." + SampleRow.COMPANY, filter.getCompany());
- // Test only valid ElligibleBoat for that company
- query.add("E." + ElligibleBoat.COMPANY_ACTIVE + " = :booleanTrue " +
- "OR (E." + ElligibleBoat.COMPANY_ACTIVE + " IS NULL AND E." + ElligibleBoat.GLOBAL_ACTIVE + " = :booleanTrue)");
- query.addParam("booleanTrue", Boolean.TRUE);
- }
- }
-
- if (StringUtils.isNotEmpty(filter.getOrderBy())) {
- query.addOrder(main + "." + filter.getOrderBy());
- }
-
- return query;
- }
-
- /**
- * Get boat infos and elligible boats for a company and a boat. This method
- * is useful to get sampleRows elligibles for the boat. Only sampleRows not
- * closed linked with the company argument will be returned. The result give
- * a Map with sampleRowCode in key and ElligibleBoat in value.
- * The ElligibleBoat entity contains the SampleRow and attributes useful
- * to know if the link is active or specific for the company.
- *
- * @param boatImmatriculation immatriculation of the boat
- * @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.
- */
- @Override
- public CompanyBoatInfos getCompanyBoatInfos(int boatImmatriculation, Company company)
- throws SuiviObsmerException {
-
- 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 {
- transaction = rootContext.beginTransaction();
-
- BoatDAO dao = SuiviObsmerModelDAOHelper.getBoatDAO(transaction);
-
- Boat boat = dao.findByImmatriculation(boatImmatriculation);
-
- BoatInfosDAO boatInfosDAO = SuiviObsmerModelDAOHelper.getBoatInfosDAO(transaction);
- BoatInfos boatInfos = boatInfosDAO.findByProperties(
- BoatInfos.BOAT, boat, BoatInfos.COMPANY, company);
- if (boatInfos == null) {
- boatInfos = new BoatInfosImpl();
- boatInfos.setBoat(boat);
- boatInfos.setCompany(company);
- } else {
- // load data
- boatInfos.getBoat();
- }
- // load data
- boatInfos.getBoat().sizeActivityCalendar();
-
- result.setBoatInfos(boatInfos);
-
- for (ElligibleBoat elligible : boat.getElligibleBoat()) {
- SampleRow sampleRow = elligible.getSampleRow();
-
- // SampleRow non closed only
- //if (!sampleRow.isFinished()) {
-
- String companyId = sampleRow.getCompany() != null ?
- sampleRow.getCompany().getTopiaId() : "";
-
- if (companyId.equals(company.getTopiaId())) {
- elligibleBoats.put(sampleRow.getCode(), elligible);
- }
- //}
- }
-
- // Last contact
- ContactDAO contactDAO = SuiviObsmerModelDAOHelper.getContactDAO(transaction);
- TopiaQuery query = contactDAO.createQueryLastContactForBoat(boat, company).
- addLoad(Contact.SAMPLE_ROW, Contact.OBSERVER);
-
- Contact contact = contactDAO.findByQuery(query);
-
- if (contact != null) {
- result.setLastContact(contact);
- }
-
-// transaction.closeContext();
- } catch (Exception eee) {
- SuiviObsmerContext.serviceException(transaction,
- "Impossible de récupérer les informations du navire " +
- "immatriculé '" + boatImmatriculation + "'" +
- " pour la société '" + company.getName() + "'", eee);
- } finally {
- SuiviObsmerContext.closeTransaction(transaction);
- }
- return result;
- }
-
- @Override
- public void createUpdateCompanyBoatInfos(CompanyBoatInfos companyBoatInfos)
- throws SuiviObsmerException {
- TopiaContext transaction = null;
- try {
- transaction = rootContext.beginTransaction();
-
- BoatInfosDAO dao = SuiviObsmerModelDAOHelper.getBoatInfosDAO(transaction);
-
- BoatInfos boatInfos = companyBoatInfos.getBoatInfos();
- SuiviObsmerContext.prepareTopiaId(BoatInfos.class, boatInfos);
- dao.update(boatInfos);
-
- ElligibleBoatDAO elligibleDAO = SuiviObsmerModelDAOHelper.getElligibleBoatDAO(transaction);
-
- for (ElligibleBoat elligible : companyBoatInfos.getElligibleBoatsValues()) {
- SuiviObsmerContext.prepareTopiaId(ElligibleBoat.class, elligible);
- elligibleDAO.update(elligible);
- }
-
- // Delete ElligibleBoats for the company
- for (ElligibleBoat elligible : companyBoatInfos.getDeletedElligibleBoats()) {
- elligibleDAO.delete(elligible);
- }
-
- transaction.commitTransaction();
- //transaction.closeContext();
- } catch (Exception eee) {
- Boat boat = companyBoatInfos.getBoatInfos().getBoat();
- Company company = companyBoatInfos.getCompany();
- SuiviObsmerContext.serviceException(transaction,
- "Impossible de créer ou modifier les informations liés au navire " +
- boat.getImmatriculation() + " pour la société " + company.getName(), eee);
- } finally {
- SuiviObsmerContext.closeTransaction(transaction);
- }
- }
-
- @Override
- public List<Boat> getBoatsByImmatriculations(String immatriculations) throws SuiviObsmerException {
- List<Boat> boats = new ArrayList<Boat>();
- TopiaContext transaction = null;
- if (StringUtils.isEmpty(immatriculations)) {
- return boats;
- }
- try {
- transaction = rootContext.beginTransaction();
-
- BoatDAO dao = SuiviObsmerModelDAOHelper.getBoatDAO(transaction);
-
- Pattern pattern = Pattern.compile("\\d{6}");
- Matcher matcher = pattern.matcher(immatriculations);
- while(matcher.find()) {
- String res = matcher.group();
- int immatriculation = Integer.parseInt(res);
- Boat boat = dao.findByImmatriculation(immatriculation);
- if (boat == null) {
- throw new SuiviObsmerBusinessException(Type.NOT_EXISTS, ServiceBoat.class,
- "Immatriculation " + immatriculation + " incorrect, ne référence aucun navire");
- }
- boats.add(boat);
- }
-
- //transaction.closeContext();
- } catch (Exception eee) {
- SuiviObsmerContext.serviceException(transaction,
- "La chaîne d'immatriculations est incorrect ! Chaque immatriculation doit posséder 6 chiffres", eee);
- } finally {
- SuiviObsmerContext.closeTransaction(transaction);
- }
- return boats;
- }
-
- @Override
- public Boat getBoat(String boatId) throws SuiviObsmerException {
- TopiaContext transaction = null;
- Boat result = null;
- try {
- transaction = rootContext.beginTransaction();
-
- BoatDAO dao = SuiviObsmerModelDAOHelper.getBoatDAO(transaction);
-
- result = dao.findByTopiaId(boatId);
-
- //transaction.closeContext();
- } catch (Exception eee) {
- SuiviObsmerContext.serviceException(transaction, "Impossible de charger le navire", eee);
- } finally {
- SuiviObsmerContext.closeTransaction(transaction);
- }
- return result;
- }
-
- @Override
- public List<String> getBoatNamesStartWith(String input) throws SuiviObsmerException {
- TopiaContext transaction = null;
- List<String> results = new ArrayList<String>();
- try {
- transaction = rootContext.beginTransaction();
-
- input = StringUtils.upperCase(input);
-
- BoatDAO dao = SuiviObsmerModelDAOHelper.getBoatDAO(transaction);
-
- results = (List<String>)dao.createQuery().addDistinct().setSelect(Boat.NAME).add(Boat.NAME, Op.LIKE, input + "%").execute();
-
- //transaction.closeContext();
- } catch (Exception eee) {
- SuiviObsmerContext.serviceException(transaction,
- "Impossible de récupérer les navires avec un nom commencant par '" + input + "'", eee);
- } finally {
- SuiviObsmerContext.closeTransaction(transaction);
- }
- return results;
- }
-
- /**
- * Import boats from a CSV file. Warning, must be UTF-8 encoding.
- * Use of CsvReader to manage InputStream and create or update boats.
- * Header file must be : NAVS_COD,CARN_NOM,CARN_LONGUEUR_HT,CARN_ANNEE,
- * QUARTIER_IMMA,PER_COD, PER_NOM,PER_PRENOM.
- * Existing boats (with same immatriculation) are updated.
- *
- * @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 SuiviObsmerException
- * @see com.csvreader.CsvReader
- */
- @Override
- public int[] importBoatCsv(InputStream input) throws SuiviObsmerException {
- TopiaContext transaction = null;
- int[] result = new int[]{0,0};
- try {
- transaction = rootContext.beginTransaction();
-
- CsvReader reader = new CsvReader(input, Charset.forName("UTF-8"));
- reader.readHeaders();
-
- long startTime = System.currentTimeMillis();
- long tic;
-
- BoatDAO boatDAO = SuiviObsmerModelDAOHelper.getBoatDAO(transaction);
- ShipOwnerDAO shipOwnerDAO = SuiviObsmerModelDAOHelper.getShipOwnerDAO(transaction);
-
- Map<String, ShipOwner> availableShipOwners = new HashMap<String, ShipOwner>();
-
- tic = System.currentTimeMillis();
- while(reader.readRecord()) {
- result[0]++;
-
-// if (log.isTraceEnabled()) {
-// log.trace(" " + Arrays.asList(reader.getValues()));
-// }
-
-
- 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();
- String activeStr = ImportHelper.read(reader, BOAT.NAVS_ACTIVE);
- boolean active = !activeStr.equals(BOAT.getBoatInactiveCode());
-
- if (log.isDebugEnabled()) {
- log.debug("Active : " + active + " (" + activeStr + ")");
- }
-
- // Find existing boat with immatriculation
- Boat boat = boatDAO.findByImmatriculation(immatriculation);
-
- if (boat == null) {
- boat = boatDAO.create(Boat.IMMATRICULATION, immatriculation);
- result[1]++;
- }
- boat.setName(boatName);
- boat.setDistrictCode(districtCode);
- boat.setBuildYear(buildYear);
- boat.setBoatLength(boatLength);
- 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);
- }
-
- availableShipOwners.put(shipOwnerCode, shipOwner);
- }
- shipOwner.setFirstName(shipOwnerFirstName);
- 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]);
- }
- }
-
- // 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) {
- SuiviObsmerContext.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 {
- SuiviObsmerContext.closeTransaction(transaction);
- }
- return result;
- }
-
- @Override
- public InputStream exportBoatCsv(BoatFilter filter) throws SuiviObsmerException {
- TopiaContext transaction = null;
- InputStream result = null;
- CsvWriter writer = null;
- try {
- transaction = rootContext.beginTransaction();
-
- File file = File.createTempFile("wao-boats-", ".csv");
- file.deleteOnExit();
-
- FileOutputStream output = new FileOutputStream(file);
- writer = new CsvWriter(output, ',', Charset.forName("UTF-8"));
-
- ExportHelper<BOAT> export = new ExportHelper<BOAT>(writer, BOAT.getTotalHeaders()) {
- @Override
- public String getHeaderValue(int index) throws IOException {
- return WaoCsvHeader.getHeaderForBoatCsv(index);
- }
-
- @Override
- public void record(BOAT header, String value) {
- record(header.forBoatCsv(), value);
- }
- };
-
- export.writeHeaders();
-
- // Get boats from database filterd by filter in argument
- BoatDAO dao = SuiviObsmerModelDAOHelper.getBoatDAO(transaction);
- TopiaQuery query = dao.createQuery("B");
- query = createQueryForBoatFilter(query, filter);
-
- // Reset limit : no pagination needed for results
- query.resetLimit();
-
- if (log.isDebugEnabled()) {
- log.debug("Exec query : " + query);
- }
- List<Boat> boats = dao.findAllByQuery(query);
-
- for (Boat boat : boats) {
- export.newRecord();
-
- if (log.isTraceEnabled()) {
- log.trace("add boat : " + boat.getName() + " (" + 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.QUARTIER_IMMA, boat.getDistrictCode());
- export.record(BOAT.NAVS_ACTIVE, (!boat.getActive() ? BOAT.getBoatInactiveCode() : ""));
-
-
- if (filter.getCompany() != null) {
- 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.writeRecord();
- }
- result = new FileInputStream(file);
-
- //transaction.closeContext();
- } catch (Exception eee) {
- SuiviObsmerContext.serviceException(transaction,
- "Impossible d'exporter les navires sélectionnés", eee);
- } finally {
- if (writer != null) {
- writer.close();
- }
- SuiviObsmerContext.closeTransaction(transaction);
- }
- return result;
- }
-
- @Override
- public void importActivityCalendarCsv(InputStream input) throws SuiviObsmerException {
- if (!SuiviObsmerContext.isActivityCalendarImportRun()) {
- try {
- ActivityCalendarImport calendarImport = new ActivityCalendarImport(input);
- new Thread(calendarImport).start();
- } catch (IOException eee) {
- SuiviObsmerContext.serviceException(null,
- "Problème d'import du fichier CSV des calendriers d'activité", eee);
- }
- }
- }
-
- @Override
- public ActivityCalendar getLastActivityCalendar(WaoUser user, Boat boat) throws SuiviObsmerException {
- TopiaContext transaction = null;
- ActivityCalendar result = null;
- try {
- transaction = rootContext.beginTransaction();
-
- ActivityCalendarDAO dao = SuiviObsmerModelDAOHelper.getActivityCalendarDAO(transaction);
-
- TopiaQuery query = dao.createQuery("A").
- add("A." + ActivityCalendar.BOAT, boat);
-
- TopiaQuery subquery = dao.createQuery("B").
- setSelect("MAX(B." + ActivityCalendar.YEAR + ")").
- add("B." + ActivityCalendar.BOAT + " = A." + ActivityCalendar.BOAT).
- addGroup("B." + ActivityCalendar.BOAT);
-
- query.add("A." + ActivityCalendar.YEAR + " = (" + subquery.fullQuery() + ")");
-
- query.addLoad(ActivityCalendar.BOAT);
- result = dao.findByQuery(query);
-
- // load other complex data from collections
- List<ActivityMonth> months = result.getActivityMonth();
- for (ActivityMonth month : months) {
- List<ActivityProfession> professions = month.getActivityProfession();
- for (ActivityProfession profession : professions) {
- List<ActivityZone> zones = profession.getActivityZone();
- zones.size();
- }
- }
-
- // Log ActivityCalendar access only for non admin user
- if (!user.getAdmin()) {
- Company company = user.getCompany();
- SuiviObsmerContext.addActivityCalendarAccessLog(
- "Calendrier " + result.getYear() + " du navire " +
- boat.getName() + " (" + boat.getImmatriculation() + ") vu " +
- "par " + user.getFullName() + " de la société " +
- company.getName());
- }
-
- //transaction.closeContext();
- } catch (Exception eee) {
- SuiviObsmerContext.serviceException(transaction,
- "Impossible de charger le dernier calendrier d'activité du navire " +
- boat.getName() + " (" + boat.getImmatriculation() + ")", eee);
- } finally {
- SuiviObsmerContext.closeTransaction(transaction);
- }
- return result;
- }
-
- @Override
- public InputStream getActivityCalendarLogFile() throws FileNotFoundException {
- String filename = SuiviObsmerContext.getProperty(
- SuiviObsmerContext.PROP_FILENAME_LOG_ACTIVITY_IMPORT);
- File file = new File(filename);
- return new FileInputStream(file);
- }
-
- @Override
- public InputStream getActivityCalendarLogAccessFile() throws FileNotFoundException {
- String filename = SuiviObsmerContext.getProperty(
- SuiviObsmerContext.PROP_FILENAME_LOG_ACTIVITY_ACCESS);
- File file = new File(filename);
- return new FileInputStream(file);
- }
-}
Copied: trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceBoatImpl.java (from rev 354, trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services/ServiceBoatImpl.java)
===================================================================
--- trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceBoatImpl.java (rev 0)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceBoatImpl.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -0,0 +1,656 @@
+/*
+ * *##%
+ * 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.service;
+
+import com.csvreader.CsvReader;
+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 org.nuiton.topia.TopiaException;
+import org.nuiton.topia.framework.TopiaQuery;
+import org.nuiton.topia.framework.TopiaQuery.Op;
+import fr.ifremer.wao.bean.BoatFilter;
+import fr.ifremer.wao.bean.CompanyBoatInfos;
+import fr.ifremer.wao.bean.CompanyBoatInfosImpl;
+import fr.ifremer.wao.entity.*;
+import fr.ifremer.wao.io.ImportHelper;
+import fr.ifremer.wao.io.ExportHelper;
+import fr.ifremer.wao.io.WaoCsvHeader;
+import fr.ifremer.wao.io.WaoCsvHeader.BOAT;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.charset.Charset;
+import java.util.ArrayList;
+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;
+
+/**
+ * ServiceBoatImpl
+ *
+ * Created: 24 nov. 2009
+ *
+ * @author fdesbois
+ * @version $Revision$
+ *
+ * Mise a jour: $Date$
+ * par : $Author$
+ */
+public class ServiceBoatImpl implements ServiceBoat {
+
+ private static final Logger log = LoggerFactory.getLogger(ServiceBoatImpl.class);
+
+ protected TopiaContext rootContext;
+
+ 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 {
+ transaction = rootContext.beginTransaction();
+
+ BoatDAO dao = WaoModelDAOHelper.getBoatDAO(transaction);
+ TopiaQuery query = dao.createQuery("B");
+
+ query = createQueryForBoatFilter(query, filter);
+
+// if (StringUtils.isNotEmpty(filter.getOrderBy())) {
+// query.addOrder("B." + filter.getOrderBy());
+// }
+
+ query.addLoad(Boat.ACTIVITY_CALENDAR);
+
+ if (log.isDebugEnabled()) {
+ log.debug("Query : " + query);
+ }
+
+ results = dao.findAllMappedByQuery(query, Boat.IMMATRICULATION, Integer.class);
+
+ } catch (Exception eee) {
+ WaoContext.serviceException(transaction, "Impossible de filtrer la liste des navires", eee);
+ } finally {
+ WaoContext.closeTransaction(transaction);
+ }
+ return results;
+ }
+
+ @Override
+ public int getNbBoatsByFilter(BoatFilter filter) throws WaoException {
+ TopiaContext transaction = null;
+ int result = 0;
+ try {
+ transaction = rootContext.beginTransaction();
+
+ BoatDAO dao = WaoModelDAOHelper.getBoatDAO(transaction);
+ TopiaQuery query = dao.createQuery("B");
+
+ query = createQueryForBoatFilter(query, filter);
+
+ result = query.executeCount();
+
+ } catch (Exception eee) {
+ WaoContext.serviceException(transaction, "Impossible de filtrer la liste des navires", eee);
+ } finally {
+ WaoContext.closeTransaction(transaction);
+ }
+ return result;
+ }
+
+ protected TopiaQuery createQueryForBoatFilter(TopiaQuery query, BoatFilter filter) throws TopiaException {
+ String main = query.getMainAlias();
+ query = filter.prepareQueryForBoat(query, main).addDistinct();
+
+ // Sampling filter
+ if (filter.isSamplingFiltered()) {
+ // Add join for ElligibleBoat
+ //String elligibleBoatClassName = ElligibleBoat.class.getName();
+ query.addFrom(ElligibleBoat.class, "E").add("E." + ElligibleBoat.BOAT + " = " + main);
+ query = filter.prepareQueryForSampling(query, "E." + ElligibleBoat.SAMPLE_ROW);
+
+ // Company
+ if (filter.getCompany() != null) {
+ //query.add("E." + ElligibleBoat.SAMPLE_ROW + "." + SampleRow.COMPANY, filter.getCompany());
+ // Test only valid ElligibleBoat for that company
+ query.add("E." + ElligibleBoat.COMPANY_ACTIVE + " = :booleanTrue " +
+ "OR (E." + ElligibleBoat.COMPANY_ACTIVE + " IS NULL AND E." + ElligibleBoat.GLOBAL_ACTIVE + " = :booleanTrue)");
+ query.addParam("booleanTrue", Boolean.TRUE);
+ }
+ }
+
+ if (StringUtils.isNotEmpty(filter.getOrderBy())) {
+ query.addOrder(main + "." + filter.getOrderBy());
+ }
+
+ return query;
+ }
+
+ /**
+ * Get boat infos and elligible boats for a company and a boat. This method
+ * is useful to get sampleRows elligibles for the boat. Only sampleRows not
+ * closed linked with the company argument will be returned. The result give
+ * a Map with sampleRowCode in key and ElligibleBoat in value.
+ * The ElligibleBoat entity contains the SampleRow and attributes useful
+ * to know if the link is active or specific for the company.
+ *
+ * @param boatImmatriculation immatriculation of the boat
+ * @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.
+ */
+ @Override
+ public CompanyBoatInfos getCompanyBoatInfos(int boatImmatriculation, Company company)
+ throws WaoException {
+
+ 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 {
+ transaction = rootContext.beginTransaction();
+
+ BoatDAO dao = WaoModelDAOHelper.getBoatDAO(transaction);
+
+ Boat boat = dao.findByImmatriculation(boatImmatriculation);
+
+ BoatInfosDAO boatInfosDAO = WaoModelDAOHelper.getBoatInfosDAO(transaction);
+ BoatInfos boatInfos = boatInfosDAO.findByProperties(
+ BoatInfos.BOAT, boat, BoatInfos.COMPANY, company);
+ if (boatInfos == null) {
+ boatInfos = new BoatInfosImpl();
+ boatInfos.setBoat(boat);
+ boatInfos.setCompany(company);
+ } else {
+ // load data
+ boatInfos.getBoat();
+ }
+ // load data
+ boatInfos.getBoat().sizeActivityCalendar();
+
+ result.setBoatInfos(boatInfos);
+
+ for (ElligibleBoat elligible : boat.getElligibleBoat()) {
+ SampleRow sampleRow = elligible.getSampleRow();
+
+ // SampleRow non closed only
+ //if (!sampleRow.isFinished()) {
+
+ String companyId = sampleRow.getCompany() != null ?
+ sampleRow.getCompany().getTopiaId() : "";
+
+ if (companyId.equals(company.getTopiaId())) {
+ elligibleBoats.put(sampleRow.getCode(), elligible);
+ }
+ //}
+ }
+
+ // Last contact
+ ContactDAO contactDAO = WaoModelDAOHelper.getContactDAO(transaction);
+ TopiaQuery query = contactDAO.createQueryLastContactForBoat(boat, company).
+ addLoad(Contact.SAMPLE_ROW, Contact.OBSERVER);
+
+ Contact contact = contactDAO.findByQuery(query);
+
+ if (contact != null) {
+ result.setLastContact(contact);
+ }
+
+// 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);
+ }
+ return result;
+ }
+
+ @Override
+ public void createUpdateCompanyBoatInfos(CompanyBoatInfos companyBoatInfos)
+ throws WaoException {
+ TopiaContext transaction = null;
+ try {
+ transaction = rootContext.beginTransaction();
+
+ BoatInfosDAO dao = WaoModelDAOHelper.getBoatInfosDAO(transaction);
+
+ BoatInfos boatInfos = companyBoatInfos.getBoatInfos();
+ WaoContext.prepareTopiaId(BoatInfos.class, boatInfos);
+ dao.update(boatInfos);
+
+ ElligibleBoatDAO elligibleDAO = WaoModelDAOHelper.getElligibleBoatDAO(transaction);
+
+ for (ElligibleBoat elligible : companyBoatInfos.getElligibleBoatsValues()) {
+ WaoContext.prepareTopiaId(ElligibleBoat.class, elligible);
+ elligibleDAO.update(elligible);
+ }
+
+ // Delete ElligibleBoats for the company
+ for (ElligibleBoat elligible : companyBoatInfos.getDeletedElligibleBoats()) {
+ elligibleDAO.delete(elligible);
+ }
+
+ transaction.commitTransaction();
+ //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);
+ }
+ }
+
+ @Override
+ public List<Boat> getBoatsByImmatriculations(String immatriculations) throws WaoException {
+ List<Boat> boats = new ArrayList<Boat>();
+ TopiaContext transaction = null;
+ if (StringUtils.isEmpty(immatriculations)) {
+ return boats;
+ }
+ try {
+ transaction = rootContext.beginTransaction();
+
+ BoatDAO dao = WaoModelDAOHelper.getBoatDAO(transaction);
+
+ Pattern pattern = Pattern.compile("\\d{6}");
+ Matcher matcher = pattern.matcher(immatriculations);
+ while(matcher.find()) {
+ String res = matcher.group();
+ 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");
+ }
+ boats.add(boat);
+ }
+
+ //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);
+ }
+ return boats;
+ }
+
+ @Override
+ public Boat getBoat(String boatId) throws WaoException {
+ TopiaContext transaction = null;
+ Boat result = null;
+ try {
+ transaction = rootContext.beginTransaction();
+
+ BoatDAO dao = WaoModelDAOHelper.getBoatDAO(transaction);
+
+ result = dao.findByTopiaId(boatId);
+
+ //transaction.closeContext();
+ } catch (Exception eee) {
+ WaoContext.serviceException(transaction, "Impossible de charger le navire", eee);
+ } finally {
+ WaoContext.closeTransaction(transaction);
+ }
+ return result;
+ }
+
+ @Override
+ public List<String> getBoatNamesStartWith(String input) throws WaoException {
+ TopiaContext transaction = null;
+ List<String> results = new ArrayList<String>();
+ try {
+ transaction = rootContext.beginTransaction();
+
+ input = StringUtils.upperCase(input);
+
+ BoatDAO dao = WaoModelDAOHelper.getBoatDAO(transaction);
+
+ results = (List<String>)dao.createQuery().addDistinct().setSelect(Boat.NAME).add(Boat.NAME, Op.LIKE, input + "%").execute();
+
+ //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;
+ }
+
+ /**
+ * Import boats from a CSV file. Warning, must be UTF-8 encoding.
+ * Use of CsvReader to manage InputStream and create or update boats.
+ * Header file must be : NAVS_COD,CARN_NOM,CARN_LONGUEUR_HT,CARN_ANNEE,
+ * QUARTIER_IMMA,PER_COD, PER_NOM,PER_PRENOM.
+ * Existing boats (with same immatriculation) are updated.
+ *
+ * @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
+ * @see com.csvreader.CsvReader
+ */
+ @Override
+ public int[] importBoatCsv(InputStream input) throws WaoException {
+ TopiaContext transaction = null;
+ int[] result = new int[]{0,0};
+ try {
+ transaction = rootContext.beginTransaction();
+
+ CsvReader reader = new CsvReader(input, Charset.forName("UTF-8"));
+ reader.readHeaders();
+
+ long startTime = System.currentTimeMillis();
+ long tic;
+
+ BoatDAO boatDAO = WaoModelDAOHelper.getBoatDAO(transaction);
+ ShipOwnerDAO shipOwnerDAO = WaoModelDAOHelper.getShipOwnerDAO(transaction);
+
+ Map<String, ShipOwner> availableShipOwners = new HashMap<String, ShipOwner>();
+
+ tic = System.currentTimeMillis();
+ while(reader.readRecord()) {
+ result[0]++;
+
+// if (log.isTraceEnabled()) {
+// log.trace(" " + Arrays.asList(reader.getValues()));
+// }
+
+
+ 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();
+ String activeStr = ImportHelper.read(reader, BOAT.NAVS_ACTIVE);
+ boolean active = !activeStr.equals(BOAT.getBoatInactiveCode());
+
+ if (log.isTraceEnabled()) {
+ log.trace("Active : " + active + " (" + activeStr + ")");
+ }
+
+ // Find existing boat with immatriculation
+ Boat boat = boatDAO.findByImmatriculation(immatriculation);
+
+ if (boat == null) {
+ boat = boatDAO.create(Boat.IMMATRICULATION, immatriculation);
+ result[1]++;
+ }
+ boat.setName(boatName);
+ boat.setDistrictCode(districtCode);
+ boat.setBuildYear(buildYear);
+ boat.setBoatLength(boatLength);
+ 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);
+ }
+
+ availableShipOwners.put(shipOwnerCode, shipOwner);
+ }
+ shipOwner.setFirstName(shipOwnerFirstName);
+ 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]);
+ }
+ }
+
+ // 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);
+ }
+ return result;
+ }
+
+ @Override
+ public InputStream exportBoatCsv(BoatFilter filter) throws WaoException {
+ TopiaContext transaction = null;
+ InputStream result = null;
+ CsvWriter writer = null;
+ try {
+ transaction = rootContext.beginTransaction();
+
+ File file = File.createTempFile("wao-boats-", ".csv");
+ file.deleteOnExit();
+
+ FileOutputStream output = new FileOutputStream(file);
+ writer = new CsvWriter(output, ',', Charset.forName("UTF-8"));
+
+ ExportHelper<BOAT> export = new ExportHelper<BOAT>(writer, BOAT.getTotalHeaders()) {
+ @Override
+ public String getHeaderValue(int index) throws IOException {
+ return WaoCsvHeader.getHeaderForBoatCsv(index);
+ }
+
+ @Override
+ public void record(BOAT header, String value) {
+ record(header.forBoatCsv(), value);
+ }
+ };
+
+ export.writeHeaders();
+
+ // Get boats from database filterd by filter in argument
+ BoatDAO dao = WaoModelDAOHelper.getBoatDAO(transaction);
+ TopiaQuery query = dao.createQuery("B");
+ query = createQueryForBoatFilter(query, filter);
+
+ // Reset limit : no pagination needed for results
+ query.resetLimit();
+
+ if (log.isDebugEnabled()) {
+ log.debug("Exec query : " + query);
+ }
+ List<Boat> boats = dao.findAllByQuery(query);
+
+ for (Boat boat : boats) {
+ export.newRecord();
+
+ if (log.isTraceEnabled()) {
+ log.trace("add boat : " + boat.getName() + " (" + 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.QUARTIER_IMMA, boat.getDistrictCode());
+ export.record(BOAT.NAVS_ACTIVE, (!boat.getActive() ? BOAT.getBoatInactiveCode() : ""));
+
+
+ if (filter.getCompany() != null) {
+ 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.writeRecord();
+ }
+ result = new FileInputStream(file);
+
+ //transaction.closeContext();
+ } catch (Exception eee) {
+ WaoContext.serviceException(transaction,
+ "Impossible d'exporter les navires sélectionnés", eee);
+ } finally {
+ if (writer != null) {
+ writer.close();
+ }
+ WaoContext.closeTransaction(transaction);
+ }
+ return result;
+ }
+
+ @Override
+ public void importActivityCalendarCsv(InputStream input) throws WaoException {
+ if (!WaoContext.isActivityCalendarImportRun()) {
+ try {
+ ActivityCalendarImport calendarImport = new ActivityCalendarImport(input);
+ new Thread(calendarImport).start();
+ } catch (IOException eee) {
+ WaoContext.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;
+ ActivityCalendar result = null;
+ try {
+ transaction = rootContext.beginTransaction();
+
+ ActivityCalendarDAO dao = WaoModelDAOHelper.getActivityCalendarDAO(transaction);
+
+ TopiaQuery query = dao.createQuery("A").
+ add("A." + ActivityCalendar.BOAT, boat);
+
+ TopiaQuery subquery = dao.createQuery("B").
+ setSelect("MAX(B." + ActivityCalendar.YEAR + ")").
+ add("B." + ActivityCalendar.BOAT + " = A." + ActivityCalendar.BOAT).
+ addGroup("B." + ActivityCalendar.BOAT);
+
+ query.add("A." + ActivityCalendar.YEAR + " = (" + subquery.fullQuery() + ")");
+
+ query.addLoad(ActivityCalendar.BOAT);
+ result = dao.findByQuery(query);
+
+ // load other complex data from collections
+ List<ActivityMonth> months = result.getActivityMonth();
+ for (ActivityMonth month : months) {
+ List<ActivityProfession> professions = month.getActivityProfession();
+ for (ActivityProfession profession : professions) {
+ List<ActivityZone> zones = profession.getActivityZone();
+ zones.size();
+ }
+ }
+
+ // Log ActivityCalendar access only for non admin user
+ if (!user.getAdmin()) {
+ Company company = user.getCompany();
+ WaoContext.addActivityCalendarAccessLog(
+ "Calendrier " + result.getYear() + " du navire " +
+ boat.getName() + " (" + boat.getImmatriculation() + ") vu " +
+ "par " + user.getFullName() + " de la société " +
+ company.getName());
+ }
+
+ //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);
+ }
+ return result;
+ }
+
+ @Override
+ public InputStream getActivityCalendarLogFile() throws FileNotFoundException {
+ String filename = WaoContext.getProperty(
+ WaoContext.PROP_FILENAME_LOG_ACTIVITY_IMPORT);
+ 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);
+ File file = new File(filename);
+ return new FileInputStream(file);
+ }
+}
Deleted: trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceContactImpl.java
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services/ServiceContactImpl.java 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceContactImpl.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,536 +0,0 @@
-/*
- * *##%
- * SuiviObsmer :: 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.suiviobsmer.services;
-
-import com.csvreader.CsvReader;
-import com.csvreader.CsvWriter;
-import fr.ifremer.suiviobsmer.io.ImportHelper;
-import fr.ifremer.suiviobsmer.io.ImportHelper.*;
-import fr.ifremer.suiviobsmer.SuiviObsmerBusinessException;
-import fr.ifremer.suiviobsmer.SuiviObsmerBusinessException.Type;
-import fr.ifremer.suiviobsmer.SuiviObsmerException;
-import fr.ifremer.suiviobsmer.SuiviObsmerModelDAOHelper;
-import fr.ifremer.suiviobsmer.SuiviObsmerContext;
-import fr.ifremer.suiviobsmer.bean.ContactState;
-import java.io.IOException;
-import java.io.InputStream;
-import org.nuiton.topia.framework.TopiaQuery;
-import fr.ifremer.suiviobsmer.bean.ContactFilter;
-import fr.ifremer.suiviobsmer.bean.ImportResults;
-import fr.ifremer.suiviobsmer.bean.ImportResultsImpl;
-import fr.ifremer.suiviobsmer.entity.Boat;
-import fr.ifremer.suiviobsmer.entity.BoatDAO;
-import fr.ifremer.suiviobsmer.entity.Company;
-import fr.ifremer.suiviobsmer.entity.CompanyDAO;
-import fr.ifremer.suiviobsmer.entity.Contact;
-import fr.ifremer.suiviobsmer.entity.ContactDAO;
-import fr.ifremer.suiviobsmer.entity.ContactImpl;
-import fr.ifremer.suiviobsmer.entity.ElligibleBoat;
-import fr.ifremer.suiviobsmer.entity.ElligibleBoatDAO;
-import fr.ifremer.suiviobsmer.entity.FishingZone;
-import fr.ifremer.suiviobsmer.entity.Profession;
-import fr.ifremer.suiviobsmer.entity.SampleRow;
-import fr.ifremer.suiviobsmer.entity.SampleRowDAO;
-import fr.ifremer.suiviobsmer.entity.WaoUser;
-import fr.ifremer.suiviobsmer.entity.WaoUserDAO;
-import fr.ifremer.suiviobsmer.io.ExportHelper;
-import fr.ifremer.suiviobsmer.io.WaoCsvHeader;
-import fr.ifremer.suiviobsmer.io.WaoCsvHeader.BOAT;
-import fr.ifremer.suiviobsmer.io.WaoCsvHeader.CONTACT;
-import fr.ifremer.suiviobsmer.io.WaoCsvHeader.ContactHeader;
-import fr.ifremer.suiviobsmer.io.WaoCsvHeader.FISHING_ZONE;
-import fr.ifremer.suiviobsmer.io.WaoCsvHeader.SAMPLING;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.nio.charset.Charset;
-import java.text.DateFormat;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.Arrays;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import org.apache.commons.lang.BooleanUtils;
-import org.apache.commons.lang.StringUtils;
-import org.nuiton.topia.TopiaContext;
-import org.nuiton.topia.persistence.TopiaEntity;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * ServiceContactImpl
- *
- * Created: 3 déc. 2009
- *
- * @author fdesbois
- * @version $Revision$
- *
- * Mise a jour: $Date$
- * par : $Author$
- */
-public class ServiceContactImpl implements ServiceContact {
-
- private static final Logger log = LoggerFactory.getLogger(ServiceContactImpl.class);
-
- protected TopiaContext rootContext;
-
- public ServiceContactImpl() throws SuiviObsmerException {
- rootContext = SuiviObsmerContext.getTopiaRootContext();
- }
-
- @Override
- public Map<String, Contact> getContacts(ContactFilter filter) throws SuiviObsmerException {
- Map<String, Contact> results = new HashMap<String, Contact>();
- TopiaContext transaction = null;
- try {
- transaction = rootContext.beginTransaction();
-
- ContactDAO dao = SuiviObsmerModelDAOHelper.getContactDAO(transaction);
-
- TopiaQuery query = dao.createQuery("C").addDistinct();
-
- query = filter.prepareQueryForContact(query);
-
- query.addOrderDesc("C." + TopiaEntity.TOPIA_CREATE_DATE).addLoad(Contact.OBSERVER + "." + WaoUser.COMPANY);
-
- if (log.isDebugEnabled()) {
- log.debug("Query : " + query);
- }
-
- results = dao.findAllMappedByQuery(query);
-
- //transaction.closeContext();
- } catch (Exception eee) {
- SuiviObsmerContext.serviceException(transaction,
- "Impossible de filtrer la liste des contacts", eee);
- } finally {
- SuiviObsmerContext.closeTransaction(transaction);
- }
- return results;
- }
-
- @Override
- public int getNbContacts(ContactFilter filter) throws SuiviObsmerException {
- TopiaContext transaction = null;
- int result = 0;
- try {
- transaction = rootContext.beginTransaction();
-
- ContactDAO dao = SuiviObsmerModelDAOHelper.getContactDAO(transaction);
- TopiaQuery query = dao.createQuery("C");
- query = filter.prepareQueryForContact(query);
-
- result = query.executeCount();
-
- //transaction.closeContext();
- } catch (Exception eee) {
- SuiviObsmerContext.serviceException(transaction,
- "Impossible de compter le nombre de contacts filtrés", eee);
- } finally {
- SuiviObsmerContext.closeTransaction(transaction);
- }
- return result;
- }
-
- @Override
- public Contact getNewContact(WaoUser user, SampleRow row, Boat boat) {
- Contact result = new ContactImpl();
- result.setObserver(user);
- result.setSampleRow(row);
- result.setBoat(boat);
- result.setState(ContactState.CONTACT_START.toString());
- return result;
- }
-
- @Override
- public void saveContact(Contact contact, boolean delete) throws SuiviObsmerException {
- TopiaContext transaction = null;
- try {
- transaction = rootContext.beginTransaction();
-
- ContactDAO dao = SuiviObsmerModelDAOHelper.getContactDAO(transaction);
-
- if (log.isDebugEnabled()) {
- log.debug("Create date : " + contact.getTopiaCreateDate());
- }
-
- SuiviObsmerContext.prepareTopiaId(Contact.class, contact);
- if (delete) {
- dao.delete(contact);
- } else {
- dao.update(contact);
- }
-
- transaction.commitTransaction();
- //transaction.closeContext();
- } catch (Exception eee) {
- SuiviObsmerContext.serviceException(transaction,
- "Impossible de sauvegarder le contact", eee);
- } finally {
- SuiviObsmerContext.closeTransaction(transaction);
- }
- }
-
- @Override
- public InputStream exportContactCsv(ContactFilter filter)
- throws SuiviObsmerException {
- TopiaContext transaction = null;
- InputStream result = null;
- CsvWriter writer = null;
- try {
- transaction = rootContext.beginTransaction();
-
- File file = File.createTempFile("wao-contacts-", ".csv");
- file.deleteOnExit();
-
- if (log.isDebugEnabled()) {
- log.debug("Export contacts into : " + file.getAbsolutePath());
- }
-
- FileOutputStream output = new FileOutputStream(file);
- writer = new CsvWriter(output, ',', Charset.forName("UTF-8"));
-
- ExportHelper<ContactHeader> export = new ExportHelper<ContactHeader>(writer, CONTACT.getTotalHeaders()) {
-
- @Override
- public void record(ContactHeader header, String value) {
- record(header.forContactCsv(), value);
- }
-
- @Override
- protected String getHeaderValue(int index) throws IOException {
- if (log.isDebugEnabled()) {
- log.debug("record header : " + index + " = " + WaoCsvHeader.getHeaderForContactCsv(index));
- }
- return WaoCsvHeader.getHeaderForContactCsv(index);
- }
- };
-
- export.writeHeaders();
-
- DateFormat dateFormat = CONTACT.getDateFormat();
-
- // Get contacts from database
- ContactDAO dao = SuiviObsmerModelDAOHelper.getContactDAO(transaction);
- TopiaQuery query = dao.createQuery("C");
- query.addOrderDesc("C." + TopiaEntity.TOPIA_CREATE_DATE);
-
- // No page limit in this case
- query = filter.prepareQueryForContact(query).resetLimit();
-
- if (log.isDebugEnabled()) {
- log.debug("Exec query : " + query);
- }
-
- List<Contact> contacts = dao.findAllByQuery(query);
-
- DateFormat timeFormat = CONTACT.getTimeFormat();
-
- for (Contact contact : contacts) {
- export.newRecord();
-
- // Contact part
- export.record(CONTACT.CONT_CODE, timeFormat.format(contact.getTopiaCreateDate()));
- export.record(CONTACT.CONT_CREATION, dateFormat.format(contact.getTopiaCreateDate()));
- export.record(CONTACT.CONT_ETAT, contact.getState());
- if (contact.getTideBeginDate() != null) {
- export.record(CONTACT.CONT_DEBUT_MAREE, dateFormat.format(contact.getTideBeginDate()));
- }
- if (contact.getTideEndDate() != null) {
- export.record(CONTACT.CONT_FIN_MAREE, dateFormat.format(contact.getTideEndDate()));
- }
- export.record(CONTACT.CONT_NB_OBSERV, String.valueOf(contact.getNbObservants()));
- export.record(CONTACT.CONT_MAM_CAPT, CONTACT.formatMammals(contact.getMammalsCapture()));
- export.record(CONTACT.CONT_MAM_OBS, CONTACT.formatMammals(contact.getMammalsObservation()));
- export.record(CONTACT.CONT_COMMENT, contact.getComment());
- if (contact.getDataInputDate() != null) {
- export.record(CONTACT.CONT_ALLEGRO, dateFormat.format(contact.getDataInputDate()));
- }
- export.record(CONTACT.CONT_SOCIETE_VALID, CONTACT.formatValidation(contact.getValidationCompany()));
- export.record(CONTACT.CONT_PROGRAM_VALID, CONTACT.formatValidation(contact.getValidationProgram()));
-
- // Observer part
- WaoUser observer = contact.getObserver();
- Company company = observer.getCompany();
- export.record(CONTACT.OBSERV_ID, observer.getLogin());
- export.record(CONTACT.OBSERV_PRENOM, observer.getFirstName());
- export.record(CONTACT.OBSERV_NOM, observer.getLastName());
- export.record(SAMPLING.SOCIETE_NOM, company.getName());
-
- // SampleRow part
- SampleRow row = contact.getSampleRow();
- export.record(SAMPLING.PLAN_CODE, row.getCode());
- export.record(SAMPLING.PROGRAMME_CODE, row.getProgramName());
- export.record(SAMPLING.PROGRAMME_DEBUT, dateFormat.format(row.getPeriodBegin()));
- export.record(SAMPLING.PROGRAMME_FIN, dateFormat.format(row.getPeriodEnd()));
- export.record(SAMPLING.PECHE_AUTRE, row.getFishingZonesInfos());
-
- // FishingZone part
- String divisions = "";
- String separator = " - ";
- for (FishingZone zone : row.getFishingZone()) {
- divisions += separator + zone.getDistrictCode();
- }
- export.record(FISHING_ZONE.PECHE_DIVISION, divisions.substring(separator.length()));
- export.record(FISHING_ZONE.PECHE_FACADE, row.getFacade());
- export.record(FISHING_ZONE.PECHE_ZONE, row.getSectors());
-
- // Profession part
- Profession profession = row.getProfession();
- export.record(SAMPLING.METIER_CODE_DCF5, profession.getCodeDCF5());
- export.record(SAMPLING.METIER_MAILLAGE, profession.getMeshSize());
- export.record(SAMPLING.METIER_TAILLE, profession.getSize());
- export.record(SAMPLING.METIER_AUTRE, profession.getOther());
- export.record(SAMPLING.METIER_LIBELLE, profession.getLibelle());
- export.record(SAMPLING.METIER_ESPECES, profession.getSpecies());
-
- // Boat part
- Boat boat = contact.getBoat();
- export.record(BOAT.NAVS_COD, String.valueOf(boat.getImmatriculation()));
- export.record(BOAT.CARN_NOM, boat.getName());
- export.record(BOAT.QUARTIER_IMMA, boat.getDistrictCode());
-
- export.writeRecord();
- }
- result = new FileInputStream(file);
-
- //transaction.closeContext();
- } catch (Exception eee) {
- SuiviObsmerContext.serviceException(transaction,
- "Impossible d'exporter les contacts", eee);
- } finally {
- if (writer != null) {
- writer.close();
- }
- SuiviObsmerContext.closeTransaction(transaction);
- }
- return result;
- }
-
- @Override
- public ImportResults importContactCsv(WaoUser user, InputStream input) throws SuiviObsmerException {
- TopiaContext transaction = null;
- ImportResults result = new ImportResultsImpl();
- int currRow = 1;
- CsvReader reader = null;
- try {
- transaction = rootContext.beginTransaction();
-
- reader = new CsvReader(input, Charset.forName("UTF-8"));
- reader.readHeaders();
-
- ContactDAO dao = SuiviObsmerModelDAOHelper.getContactDAO(transaction);
- WaoUserDAO userDAO = SuiviObsmerModelDAOHelper.getWaoUserDAO(transaction);
- CompanyDAO companyDAO = SuiviObsmerModelDAOHelper.getCompanyDAO(transaction);
- SampleRowDAO rowDAO = SuiviObsmerModelDAOHelper.getSampleRowDAO(transaction);
- BoatDAO boatDAO = SuiviObsmerModelDAOHelper.getBoatDAO(transaction);
-
- long tic;
- tic = System.currentTimeMillis();
- while(reader.readRecord()) {
- currRow++;
-
- String observerId = ImportHelper.read(reader, CONTACT.OBSERV_ID);
- String state = ImportHelper.read(reader, CONTACT.CONT_ETAT);
-
- ContactState contactState = ContactState.createContactStateEnum(state);
-
- if (contactState == null) {
- throw new SuiviObsmerBusinessException(Type.IMPORT_ERROR, this.getClass(),
- "Erreur ligne " + currRow + " : " +
- "Etat du contact invalide '" + state + "', valeurs possibles : " +
- ContactState.availableStates());
- }
-
- WaoUser observer = userDAO.findByLogin(observerId);
- if (observer != null) {
- Company company = user.getCompany();
- // For an admin, get the company from database
- if (user.getAdmin()) {
- // FIXME-FD20100104 findContains not optimized in TopiaDAOImpl
- company = companyDAO.findContainsWaoUser(observer);
- // For a user, check if the observer as the same company as the current user
- } else if (!observer.getCompany().equals(company)) {
- throw new SuiviObsmerBusinessException(Type.IMPORT_ERROR, this.getClass(),
- "Erreur ligne " + currRow + " : " +
- "L'observateur avec pour login '" + observerId + "' n'appartient pas à votre société !");
- }
-
- if (company != null) {
- String rowCode = ImportHelper.readSampleRowCode(reader);
-
- SampleRow row = rowDAO.findByProperties(SampleRow.CODE, rowCode, SampleRow.COMPANY, company);
-
- if (row != null) {
- int boatImmatriculation = ImportHelper.readInt(reader, BOAT.NAVS_COD);
-
- Boat boat = boatDAO.findByImmatriculation(boatImmatriculation);
-
- if (boat != null) {
-
- ElligibleBoatDAO elligibleDAO = SuiviObsmerModelDAOHelper.getElligibleBoatDAO(transaction);
- ElligibleBoat elligible = elligibleDAO.findByProperties(
- ElligibleBoat.BOAT, boat, ElligibleBoat.SAMPLE_ROW, row);
-
- if (elligible == null) {
- // Create new elligible boat not active in a global way
- elligible = elligibleDAO.create(
- ElligibleBoat.BOAT, boat, ElligibleBoat.SAMPLE_ROW, row);
- if (log.isTraceEnabled()) {
- log.trace("Create elligibleBoat for : " + boat.getImmatriculation() + " - " + row.getCode());
- }
- }
- elligible.setCompanyActive(Boolean.TRUE);
-
- Contact contact = null;
-
- String createDateString = ImportHelper.read(reader, CONTACT.CONT_CREATION);
- String contactCode = ImportHelper.read(reader, CONTACT.CONT_CODE);
- Date createDate = ImportHelper.parseContactCreateDate(contactCode, createDateString);
-
- if (log.isDebugEnabled()) {
- log.debug("Ligne " + currRow + " : Create date : " + createDate);
- }
-
- if (/*!StringUtils.isEmpty(contactCode) && */StringUtils.isNotEmpty(createDateString)) {
- // Get entity from database
- TopiaQuery query = dao.createQuery().
- add(TopiaEntity.TOPIA_CREATE_DATE, createDate).
- add(Contact.OBSERVER + "." + WaoUser.COMPANY, company).
- add(Contact.BOAT, boat).
- add(Contact.SAMPLE_ROW, row);
- contact = dao.findByQuery(query);
- }
-
- if (contact != null && contact.getValidationCompany() != null) {
- result.addError(currRow, "Le contact est déjà validé dans l'application et ne peut pas être importé");
- result.incNbRefused();
- continue;
- }
-
- // new contact to import
- boolean newContact = false;
- if (contact == null) {
- contact = dao.create(
- TopiaEntity.TOPIA_CREATE_DATE, createDate,
- Contact.SAMPLE_ROW, row,
- Contact.BOAT, boat);
- newContact = true;
- }
-
- Date tideBegin = ImportHelper.readDate(reader, CONTACT.CONT_DEBUT_MAREE);
- Date tideEnd = ImportHelper.readDate(reader, CONTACT.CONT_FIN_MAREE);
- Date dataInput = ImportHelper.readDate(reader, CONTACT.CONT_ALLEGRO);
- int nbObservants = ImportHelper.readInt(reader, CONTACT.CONT_NB_OBSERV);
- if (nbObservants == -1) {
- nbObservants = 0;
- }
- boolean mammalsCapture =
- ImportHelper.parseContactMammals(reader, CONTACT.CONT_MAM_CAPT);
- boolean mammalsObsv =
- ImportHelper.parseContactMammals(reader, CONTACT.CONT_MAM_OBS);
-
- contact.setObserver(observer);
- contact.setState(state);
- contact.setTideBeginDate(tideBegin);
- contact.setTideEndDate(tideEnd);
- contact.setNbObservants(nbObservants);
- contact.setMammalsCapture(mammalsCapture);
- contact.setMammalsObservation(mammalsObsv);
- contact.setDataInputDate(dataInput);
-
- // Import validations only for superadmin and a new contact : useful for archives
- if (newContact && user.getAdmin() && user.getLogin().equals("admin")) {
- if (log.isDebugEnabled()) {
- log.debug("SuperAdmin import :: validations");
- }
- Boolean companyValidation = ImportHelper.parseContactValidation(reader, CONTACT.CONT_SOCIETE_VALID);
- Boolean programValidation = ImportHelper.parseContactValidation(reader, CONTACT.CONT_PROGRAM_VALID);
- contact.setValidationCompany(companyValidation);
- contact.setValidationProgram(programValidation);
-
- // Add realTideTime for this contact if validations are ok and state is BOARDING_DONE
- if (BooleanUtils.isTrue(companyValidation) && BooleanUtils.isNotFalse(programValidation) &&
- contact.getState().equals(ContactState.BOARDING_DONE.toString())) {
- boolean ok = contact.getSampleRow().addRealTideTime(contact);
- if (!ok) {
- DateFormat dateFormat1 = new SimpleDateFormat("MM/yyyy");
- result.addError(currRow, "Impossible de mettre à jour le nombre de marée réels, vérifiez le mois " +
- "de " + dateFormat1.format(contact.getTideBeginDate()) + " pour la ligne du plan " + row.getCode());
- result.incNbRefused();
- continue;
- }
- }
- }
-
- result.incNbImported();
-
- } else {
- result.addError(currRow, "Navire inexistant avec l'immatriculation : " + boatImmatriculation);
- result.incNbRefused();
- }
- } else {
- result.addError(currRow, "Ligne d'échantillon inexistante ou incompatible avec la société " +
- "pour le code : " + rowCode);
- result.incNbRefused();
- }
- } else {
- result.addError(currRow, "Cet utilisateur n'est lié à aucune société : " + user.getFullName());
- result.incNbRefused();
- }
- } else {
- result.addError(currRow, "Utilisateur inexistant avec l'identifiant : " + observerId);
- result.incNbRefused();
- }
-
- if (result.getNbRowsImported() % 1000 == 0) {
- transaction.commitTransaction();
- tic = ImportHelper.logTimeAndMemory(log, tic, "contacts ligne " + currRow);
- }
- }
-
- transaction.commitTransaction();
-
- //transaction.closeContext();
- } catch (ParseException eee) {
- SuiviObsmerContext.serviceException(transaction,
- "Erreur ligne " + currRow + " : " +
- "Le format des dates est incorrect, il doit être de la forme : JJ/MM/AAAA", eee);
- } catch (Exception eee) {
- if (log.isDebugEnabled()) {
- try {
- log.debug("Ligne : " + currRow + " :: " + Arrays.toString(reader.getValues()));
- } catch (IOException ex) {
- log.error("Reader error", ex);
- }
- }
- SuiviObsmerContext.serviceException(transaction,
- "Impossible d'importer les contacts", eee);
- } finally {
- SuiviObsmerContext.closeTransaction(transaction);
- }
- return result;
- }
-
-}
Copied: trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceContactImpl.java (from rev 354, trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services/ServiceContactImpl.java)
===================================================================
--- trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceContactImpl.java (rev 0)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceContactImpl.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -0,0 +1,536 @@
+/*
+ * *##%
+ * 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.service;
+
+import com.csvreader.CsvReader;
+import com.csvreader.CsvWriter;
+import fr.ifremer.wao.io.ImportHelper;
+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.bean.ContactState;
+import java.io.IOException;
+import java.io.InputStream;
+import org.nuiton.topia.framework.TopiaQuery;
+import fr.ifremer.wao.bean.ContactFilter;
+import fr.ifremer.wao.bean.ImportResults;
+import fr.ifremer.wao.bean.ImportResultsImpl;
+import fr.ifremer.wao.entity.Boat;
+import fr.ifremer.wao.entity.BoatDAO;
+import fr.ifremer.wao.entity.Company;
+import fr.ifremer.wao.entity.CompanyDAO;
+import fr.ifremer.wao.entity.Contact;
+import fr.ifremer.wao.entity.ContactDAO;
+import fr.ifremer.wao.entity.ContactImpl;
+import fr.ifremer.wao.entity.ElligibleBoat;
+import fr.ifremer.wao.entity.ElligibleBoatDAO;
+import fr.ifremer.wao.entity.FishingZone;
+import fr.ifremer.wao.entity.Profession;
+import fr.ifremer.wao.entity.SampleRow;
+import fr.ifremer.wao.entity.SampleRowDAO;
+import fr.ifremer.wao.entity.WaoUser;
+import fr.ifremer.wao.entity.WaoUserDAO;
+import fr.ifremer.wao.io.ExportHelper;
+import fr.ifremer.wao.io.WaoCsvHeader;
+import fr.ifremer.wao.io.WaoCsvHeader.BOAT;
+import fr.ifremer.wao.io.WaoCsvHeader.CONTACT;
+import fr.ifremer.wao.io.WaoCsvHeader.ContactHeader;
+import fr.ifremer.wao.io.WaoCsvHeader.FISHING_ZONE;
+import fr.ifremer.wao.io.WaoCsvHeader.SAMPLING;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.nio.charset.Charset;
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import org.apache.commons.lang.BooleanUtils;
+import org.apache.commons.lang.StringUtils;
+import org.nuiton.topia.TopiaContext;
+import org.nuiton.topia.persistence.TopiaEntity;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * ServiceContactImpl
+ *
+ * Created: 3 déc. 2009
+ *
+ * @author fdesbois
+ * @version $Revision$
+ *
+ * Mise a jour: $Date$
+ * par : $Author$
+ */
+public class ServiceContactImpl implements ServiceContact {
+
+ private static final Logger log = LoggerFactory.getLogger(ServiceContactImpl.class);
+
+ protected TopiaContext rootContext;
+
+ public ServiceContactImpl() throws WaoException {
+ rootContext = WaoContext.getTopiaRootContext();
+ }
+
+ @Override
+ public Map<String, Contact> getContacts(ContactFilter filter) throws WaoException {
+ Map<String, Contact> results = new HashMap<String, Contact>();
+ TopiaContext transaction = null;
+ try {
+ transaction = rootContext.beginTransaction();
+
+ ContactDAO dao = WaoModelDAOHelper.getContactDAO(transaction);
+
+ TopiaQuery query = dao.createQuery("C").addDistinct();
+
+ query = filter.prepareQueryForContact(query);
+
+ query.addOrderDesc("C." + TopiaEntity.TOPIA_CREATE_DATE).addLoad(Contact.OBSERVER + "." + WaoUser.COMPANY);
+
+ if (log.isDebugEnabled()) {
+ log.debug("Query : " + query);
+ }
+
+ results = dao.findAllMappedByQuery(query);
+
+ //transaction.closeContext();
+ } catch (Exception eee) {
+ WaoContext.serviceException(transaction,
+ "Impossible de filtrer la liste des contacts", eee);
+ } finally {
+ WaoContext.closeTransaction(transaction);
+ }
+ return results;
+ }
+
+ @Override
+ public int getNbContacts(ContactFilter filter) throws WaoException {
+ TopiaContext transaction = null;
+ int result = 0;
+ try {
+ transaction = rootContext.beginTransaction();
+
+ ContactDAO dao = WaoModelDAOHelper.getContactDAO(transaction);
+ TopiaQuery query = dao.createQuery("C");
+ query = filter.prepareQueryForContact(query);
+
+ result = query.executeCount();
+
+ //transaction.closeContext();
+ } catch (Exception eee) {
+ WaoContext.serviceException(transaction,
+ "Impossible de compter le nombre de contacts filtrés", eee);
+ } finally {
+ WaoContext.closeTransaction(transaction);
+ }
+ return result;
+ }
+
+ @Override
+ public Contact getNewContact(WaoUser user, SampleRow row, Boat boat) {
+ Contact result = new ContactImpl();
+ result.setObserver(user);
+ result.setSampleRow(row);
+ result.setBoat(boat);
+ result.setState(ContactState.CONTACT_START.toString());
+ return result;
+ }
+
+ @Override
+ public void saveContact(Contact contact, boolean delete) throws WaoException {
+ TopiaContext transaction = null;
+ try {
+ transaction = rootContext.beginTransaction();
+
+ ContactDAO dao = WaoModelDAOHelper.getContactDAO(transaction);
+
+ if (log.isDebugEnabled()) {
+ log.debug("Create date : " + contact.getTopiaCreateDate());
+ }
+
+ WaoContext.prepareTopiaId(Contact.class, contact);
+ if (delete) {
+ dao.delete(contact);
+ } else {
+ dao.update(contact);
+ }
+
+ transaction.commitTransaction();
+ //transaction.closeContext();
+ } catch (Exception eee) {
+ WaoContext.serviceException(transaction,
+ "Impossible de sauvegarder le contact", eee);
+ } finally {
+ WaoContext.closeTransaction(transaction);
+ }
+ }
+
+ @Override
+ public InputStream exportContactCsv(ContactFilter filter)
+ throws WaoException {
+ TopiaContext transaction = null;
+ InputStream result = null;
+ CsvWriter writer = null;
+ try {
+ transaction = rootContext.beginTransaction();
+
+ File file = File.createTempFile("wao-contacts-", ".csv");
+ file.deleteOnExit();
+
+ if (log.isDebugEnabled()) {
+ log.debug("Export contacts into : " + file.getAbsolutePath());
+ }
+
+ FileOutputStream output = new FileOutputStream(file);
+ writer = new CsvWriter(output, ',', Charset.forName("UTF-8"));
+
+ ExportHelper<ContactHeader> export = new ExportHelper<ContactHeader>(writer, CONTACT.getTotalHeaders()) {
+
+ @Override
+ public void record(ContactHeader header, String value) {
+ record(header.forContactCsv(), value);
+ }
+
+ @Override
+ protected String getHeaderValue(int index) throws IOException {
+ if (log.isDebugEnabled()) {
+ log.debug("record header : " + index + " = " + WaoCsvHeader.getHeaderForContactCsv(index));
+ }
+ return WaoCsvHeader.getHeaderForContactCsv(index);
+ }
+ };
+
+ export.writeHeaders();
+
+ DateFormat dateFormat = CONTACT.getDateFormat();
+
+ // Get contacts from database
+ ContactDAO dao = WaoModelDAOHelper.getContactDAO(transaction);
+ TopiaQuery query = dao.createQuery("C");
+ query.addOrderDesc("C." + TopiaEntity.TOPIA_CREATE_DATE);
+
+ // No page limit in this case
+ query = filter.prepareQueryForContact(query).resetLimit();
+
+ if (log.isDebugEnabled()) {
+ log.debug("Exec query : " + query);
+ }
+
+ List<Contact> contacts = dao.findAllByQuery(query);
+
+ DateFormat timeFormat = CONTACT.getTimeFormat();
+
+ for (Contact contact : contacts) {
+ export.newRecord();
+
+ // Contact part
+ export.record(CONTACT.CONT_CODE, timeFormat.format(contact.getTopiaCreateDate()));
+ export.record(CONTACT.CONT_CREATION, dateFormat.format(contact.getTopiaCreateDate()));
+ export.record(CONTACT.CONT_ETAT, contact.getState());
+ if (contact.getTideBeginDate() != null) {
+ export.record(CONTACT.CONT_DEBUT_MAREE, dateFormat.format(contact.getTideBeginDate()));
+ }
+ if (contact.getTideEndDate() != null) {
+ export.record(CONTACT.CONT_FIN_MAREE, dateFormat.format(contact.getTideEndDate()));
+ }
+ export.record(CONTACT.CONT_NB_OBSERV, String.valueOf(contact.getNbObservants()));
+ export.record(CONTACT.CONT_MAM_CAPT, CONTACT.formatMammals(contact.getMammalsCapture()));
+ export.record(CONTACT.CONT_MAM_OBS, CONTACT.formatMammals(contact.getMammalsObservation()));
+ export.record(CONTACT.CONT_COMMENT, contact.getComment());
+ if (contact.getDataInputDate() != null) {
+ export.record(CONTACT.CONT_ALLEGRO, dateFormat.format(contact.getDataInputDate()));
+ }
+ export.record(CONTACT.CONT_SOCIETE_VALID, CONTACT.formatValidation(contact.getValidationCompany()));
+ export.record(CONTACT.CONT_PROGRAM_VALID, CONTACT.formatValidation(contact.getValidationProgram()));
+
+ // Observer part
+ WaoUser observer = contact.getObserver();
+ Company company = observer.getCompany();
+ export.record(CONTACT.OBSERV_ID, observer.getLogin());
+ export.record(CONTACT.OBSERV_PRENOM, observer.getFirstName());
+ export.record(CONTACT.OBSERV_NOM, observer.getLastName());
+ export.record(SAMPLING.SOCIETE_NOM, company.getName());
+
+ // SampleRow part
+ SampleRow row = contact.getSampleRow();
+ export.record(SAMPLING.PLAN_CODE, row.getCode());
+ export.record(SAMPLING.PROGRAMME_CODE, row.getProgramName());
+ export.record(SAMPLING.PROGRAMME_DEBUT, dateFormat.format(row.getPeriodBegin()));
+ export.record(SAMPLING.PROGRAMME_FIN, dateFormat.format(row.getPeriodEnd()));
+ export.record(SAMPLING.PECHE_AUTRE, row.getFishingZonesInfos());
+
+ // FishingZone part
+ String divisions = "";
+ String separator = " - ";
+ for (FishingZone zone : row.getFishingZone()) {
+ divisions += separator + zone.getDistrictCode();
+ }
+ export.record(FISHING_ZONE.PECHE_DIVISION, divisions.substring(separator.length()));
+ export.record(FISHING_ZONE.PECHE_FACADE, row.getFacade());
+ export.record(FISHING_ZONE.PECHE_ZONE, row.getSectors());
+
+ // Profession part
+ Profession profession = row.getProfession();
+ export.record(SAMPLING.METIER_CODE_DCF5, profession.getCodeDCF5());
+ export.record(SAMPLING.METIER_MAILLAGE, profession.getMeshSize());
+ export.record(SAMPLING.METIER_TAILLE, profession.getSize());
+ export.record(SAMPLING.METIER_AUTRE, profession.getOther());
+ export.record(SAMPLING.METIER_LIBELLE, profession.getLibelle());
+ export.record(SAMPLING.METIER_ESPECES, profession.getSpecies());
+
+ // Boat part
+ Boat boat = contact.getBoat();
+ export.record(BOAT.NAVS_COD, String.valueOf(boat.getImmatriculation()));
+ export.record(BOAT.CARN_NOM, boat.getName());
+ export.record(BOAT.QUARTIER_IMMA, boat.getDistrictCode());
+
+ export.writeRecord();
+ }
+ result = new FileInputStream(file);
+
+ //transaction.closeContext();
+ } catch (Exception eee) {
+ WaoContext.serviceException(transaction,
+ "Impossible d'exporter les contacts", eee);
+ } finally {
+ if (writer != null) {
+ writer.close();
+ }
+ WaoContext.closeTransaction(transaction);
+ }
+ return result;
+ }
+
+ @Override
+ public ImportResults importContactCsv(WaoUser user, InputStream input) throws WaoException {
+ TopiaContext transaction = null;
+ ImportResults result = new ImportResultsImpl();
+ int currRow = 1;
+ CsvReader reader = null;
+ try {
+ transaction = rootContext.beginTransaction();
+
+ reader = new CsvReader(input, Charset.forName("UTF-8"));
+ 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);
+
+ long tic;
+ tic = System.currentTimeMillis();
+ while(reader.readRecord()) {
+ currRow++;
+
+ String observerId = ImportHelper.read(reader, CONTACT.OBSERV_ID);
+ String state = ImportHelper.read(reader, CONTACT.CONT_ETAT);
+
+ ContactState contactState = ContactState.createContactStateEnum(state);
+
+ if (contactState == null) {
+ throw new WaoBusinessException(Type.IMPORT_ERROR, this.getClass(),
+ "Erreur ligne " + currRow + " : " +
+ "Etat du contact invalide '" + state + "', valeurs possibles : " +
+ ContactState.availableStates());
+ }
+
+ WaoUser observer = userDAO.findByLogin(observerId);
+ if (observer != null) {
+ Company company = user.getCompany();
+ // For an admin, get the company from database
+ if (user.getAdmin()) {
+ // FIXME-FD20100104 findContains not optimized in TopiaDAOImpl
+ company = companyDAO.findContainsWaoUser(observer);
+ // For a user, check if the observer as the same company as the current user
+ } else if (!observer.getCompany().equals(company)) {
+ throw new WaoBusinessException(Type.IMPORT_ERROR, this.getClass(),
+ "Erreur ligne " + currRow + " : " +
+ "L'observateur avec pour login '" + observerId + "' n'appartient pas à votre société !");
+ }
+
+ if (company != null) {
+ String rowCode = ImportHelper.readSampleRowCode(reader);
+
+ SampleRow row = rowDAO.findByProperties(SampleRow.CODE, rowCode, SampleRow.COMPANY, company);
+
+ if (row != null) {
+ int boatImmatriculation = ImportHelper.readInt(reader, BOAT.NAVS_COD);
+
+ Boat boat = boatDAO.findByImmatriculation(boatImmatriculation);
+
+ if (boat != null) {
+
+ ElligibleBoatDAO elligibleDAO = WaoModelDAOHelper.getElligibleBoatDAO(transaction);
+ ElligibleBoat elligible = elligibleDAO.findByProperties(
+ ElligibleBoat.BOAT, boat, ElligibleBoat.SAMPLE_ROW, row);
+
+ if (elligible == null) {
+ // Create new elligible boat not active in a global way
+ elligible = elligibleDAO.create(
+ ElligibleBoat.BOAT, boat, ElligibleBoat.SAMPLE_ROW, row);
+ if (log.isTraceEnabled()) {
+ log.trace("Create elligibleBoat for : " + boat.getImmatriculation() + " - " + row.getCode());
+ }
+ }
+ elligible.setCompanyActive(Boolean.TRUE);
+
+ Contact contact = null;
+
+ String createDateString = ImportHelper.read(reader, CONTACT.CONT_CREATION);
+ String contactCode = ImportHelper.read(reader, CONTACT.CONT_CODE);
+ Date createDate = ImportHelper.parseContactCreateDate(contactCode, createDateString);
+
+ if (log.isDebugEnabled()) {
+ log.debug("Ligne " + currRow + " : Create date : " + createDate);
+ }
+
+ if (/*!StringUtils.isEmpty(contactCode) && */StringUtils.isNotEmpty(createDateString)) {
+ // Get entity from database
+ TopiaQuery query = dao.createQuery().
+ add(TopiaEntity.TOPIA_CREATE_DATE, createDate).
+ add(Contact.OBSERVER + "." + WaoUser.COMPANY, company).
+ add(Contact.BOAT, boat).
+ add(Contact.SAMPLE_ROW, row);
+ contact = dao.findByQuery(query);
+ }
+
+ if (contact != null && contact.getValidationCompany() != null) {
+ result.addError(currRow, "Le contact est déjà validé dans l'application et ne peut pas être importé");
+ result.incNbRefused();
+ continue;
+ }
+
+ // new contact to import
+ boolean newContact = false;
+ if (contact == null) {
+ contact = dao.create(
+ TopiaEntity.TOPIA_CREATE_DATE, createDate,
+ Contact.SAMPLE_ROW, row,
+ Contact.BOAT, boat);
+ newContact = true;
+ }
+
+ Date tideBegin = ImportHelper.readDate(reader, CONTACT.CONT_DEBUT_MAREE);
+ Date tideEnd = ImportHelper.readDate(reader, CONTACT.CONT_FIN_MAREE);
+ Date dataInput = ImportHelper.readDate(reader, CONTACT.CONT_ALLEGRO);
+ int nbObservants = ImportHelper.readInt(reader, CONTACT.CONT_NB_OBSERV);
+ if (nbObservants == -1) {
+ nbObservants = 0;
+ }
+ boolean mammalsCapture =
+ ImportHelper.parseContactMammals(reader, CONTACT.CONT_MAM_CAPT);
+ boolean mammalsObsv =
+ ImportHelper.parseContactMammals(reader, CONTACT.CONT_MAM_OBS);
+
+ contact.setObserver(observer);
+ contact.setState(state);
+ contact.setTideBeginDate(tideBegin);
+ contact.setTideEndDate(tideEnd);
+ contact.setNbObservants(nbObservants);
+ contact.setMammalsCapture(mammalsCapture);
+ contact.setMammalsObservation(mammalsObsv);
+ contact.setDataInputDate(dataInput);
+
+ // Import validations only for superadmin and a new contact : useful for archives
+ if (newContact && user.getAdmin() && user.getLogin().equals("admin")) {
+ if (log.isDebugEnabled()) {
+ log.debug("SuperAdmin import :: validations");
+ }
+ Boolean companyValidation = ImportHelper.parseContactValidation(reader, CONTACT.CONT_SOCIETE_VALID);
+ Boolean programValidation = ImportHelper.parseContactValidation(reader, CONTACT.CONT_PROGRAM_VALID);
+ contact.setValidationCompany(companyValidation);
+ contact.setValidationProgram(programValidation);
+
+ // Add realTideTime for this contact if validations are ok and state is BOARDING_DONE
+ if (BooleanUtils.isTrue(companyValidation) && BooleanUtils.isNotFalse(programValidation) &&
+ contact.getState().equals(ContactState.BOARDING_DONE.toString())) {
+ boolean ok = contact.getSampleRow().addRealTideTime(contact);
+ if (!ok) {
+ DateFormat dateFormat1 = new SimpleDateFormat("MM/yyyy");
+ result.addError(currRow, "Impossible de mettre à jour le nombre de marée réels, vérifiez le mois " +
+ "de " + dateFormat1.format(contact.getTideBeginDate()) + " pour la ligne du plan " + row.getCode());
+ result.incNbRefused();
+ continue;
+ }
+ }
+ }
+
+ result.incNbImported();
+
+ } else {
+ result.addError(currRow, "Navire inexistant avec l'immatriculation : " + boatImmatriculation);
+ result.incNbRefused();
+ }
+ } else {
+ result.addError(currRow, "Ligne d'échantillon inexistante ou incompatible avec la société " +
+ "pour le code : " + rowCode);
+ result.incNbRefused();
+ }
+ } else {
+ result.addError(currRow, "Cet utilisateur n'est lié à aucune société : " + user.getFullName());
+ result.incNbRefused();
+ }
+ } else {
+ result.addError(currRow, "Utilisateur inexistant avec l'identifiant : " + observerId);
+ result.incNbRefused();
+ }
+
+ if (result.getNbRowsImported() % 1000 == 0) {
+ transaction.commitTransaction();
+ tic = ImportHelper.logTimeAndMemory(log, tic, "contacts ligne " + currRow);
+ }
+ }
+
+ transaction.commitTransaction();
+
+ //transaction.closeContext();
+ } catch (ParseException eee) {
+ WaoContext.serviceException(transaction,
+ "Erreur ligne " + currRow + " : " +
+ "Le format des dates est incorrect, il doit être de la forme : JJ/MM/AAAA", eee);
+ } catch (Exception eee) {
+ if (log.isDebugEnabled()) {
+ try {
+ log.debug("Ligne : " + currRow + " :: " + Arrays.toString(reader.getValues()));
+ } catch (IOException ex) {
+ log.error("Reader error", ex);
+ }
+ }
+ WaoContext.serviceException(transaction,
+ "Impossible d'importer les contacts", eee);
+ } finally {
+ WaoContext.closeTransaction(transaction);
+ }
+ return result;
+ }
+
+}
Deleted: trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceNewsImpl.java
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services/ServiceNewsImpl.java 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceNewsImpl.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,104 +0,0 @@
-/*
- * *##%
- * SuiviObsmer :: 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.suiviobsmer.services;
-
-import fr.ifremer.suiviobsmer.SuiviObsmerContext;
-import fr.ifremer.suiviobsmer.SuiviObsmerException;
-import fr.ifremer.suiviobsmer.SuiviObsmerModelDAOHelper;
-import fr.ifremer.suiviobsmer.entity.News;
-import fr.ifremer.suiviobsmer.entity.NewsDAO;
-import fr.ifremer.suiviobsmer.services.ServiceNews;
-import java.util.ArrayList;
-import java.util.List;
-import org.nuiton.topia.TopiaContext;
-import org.nuiton.topia.persistence.TopiaEntity;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * ServiceNews
- *
- * Created: 17 janv. 2010
- *
- * @author fdesbois
- * @version $Revision$
- *
- * Mise a jour: $Date$
- * par : $Author$
- */
-public class ServiceNewsImpl implements ServiceNews {
-
- private static final Logger log = LoggerFactory.getLogger(ServiceNewsImpl.class);
-
- protected TopiaContext rootContext;
-
- public ServiceNewsImpl() throws SuiviObsmerException {
- rootContext = SuiviObsmerContext.getTopiaRootContext();
- }
-
- @Override
- public List<News> getNews() throws SuiviObsmerException {
- TopiaContext transaction = null;
- List<News> results = new ArrayList<News>();
- try {
- transaction = rootContext.beginTransaction();
-
- NewsDAO dao = SuiviObsmerModelDAOHelper.getNewsDAO(transaction);
-
- results = dao.findAllWithOrder(TopiaEntity.TOPIA_CREATE_DATE + " DESC");
-
- //transaction.closeContext();
- } catch (Exception eee) {
- SuiviObsmerContext.serviceException(transaction,
- "Impossible de récupérer l'ensemble des news", eee);
- } finally {
- SuiviObsmerContext.closeTransaction(transaction);
- }
- return results;
- }
-
- @Override
- public void saveNews(News news, boolean delete) throws SuiviObsmerException {
- TopiaContext transaction = null;
- try {
- transaction = rootContext.beginTransaction();
-
- NewsDAO dao = SuiviObsmerModelDAOHelper.getNewsDAO(transaction);
-
- if (delete) {
- dao.delete(news);
- } else {
- SuiviObsmerContext.prepareTopiaId(News.class, news);
- dao.update(news);
- }
-
- transaction.commitTransaction();
- //transaction.closeContext();
- } catch (Exception eee) {
- SuiviObsmerContext.serviceException(transaction,
- "Impossible de récupérer l'ensemble des news", eee);
- } finally {
- SuiviObsmerContext.closeTransaction(transaction);
- }
- }
-
-}
Copied: trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceNewsImpl.java (from rev 354, trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services/ServiceNewsImpl.java)
===================================================================
--- trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceNewsImpl.java (rev 0)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceNewsImpl.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -0,0 +1,104 @@
+/*
+ * *##%
+ * 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.service;
+
+import fr.ifremer.wao.WaoContext;
+import fr.ifremer.wao.WaoException;
+import fr.ifremer.wao.WaoModelDAOHelper;
+import fr.ifremer.wao.entity.News;
+import fr.ifremer.wao.entity.NewsDAO;
+import fr.ifremer.wao.service.ServiceNews;
+import java.util.ArrayList;
+import java.util.List;
+import org.nuiton.topia.TopiaContext;
+import org.nuiton.topia.persistence.TopiaEntity;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * ServiceNews
+ *
+ * Created: 17 janv. 2010
+ *
+ * @author fdesbois
+ * @version $Revision$
+ *
+ * Mise a jour: $Date$
+ * par : $Author$
+ */
+public class ServiceNewsImpl implements ServiceNews {
+
+ private static final Logger log = LoggerFactory.getLogger(ServiceNewsImpl.class);
+
+ protected TopiaContext rootContext;
+
+ public ServiceNewsImpl() throws WaoException {
+ rootContext = WaoContext.getTopiaRootContext();
+ }
+
+ @Override
+ public List<News> getNews() throws WaoException {
+ TopiaContext transaction = null;
+ List<News> results = new ArrayList<News>();
+ try {
+ transaction = rootContext.beginTransaction();
+
+ NewsDAO dao = WaoModelDAOHelper.getNewsDAO(transaction);
+
+ results = dao.findAllWithOrder(TopiaEntity.TOPIA_CREATE_DATE + " DESC");
+
+ //transaction.closeContext();
+ } catch (Exception eee) {
+ WaoContext.serviceException(transaction,
+ "Impossible de récupérer l'ensemble des news", eee);
+ } finally {
+ WaoContext.closeTransaction(transaction);
+ }
+ return results;
+ }
+
+ @Override
+ public void saveNews(News news, boolean delete) throws WaoException {
+ TopiaContext transaction = null;
+ try {
+ transaction = rootContext.beginTransaction();
+
+ NewsDAO dao = WaoModelDAOHelper.getNewsDAO(transaction);
+
+ if (delete) {
+ dao.delete(news);
+ } else {
+ WaoContext.prepareTopiaId(News.class, news);
+ dao.update(news);
+ }
+
+ transaction.commitTransaction();
+ //transaction.closeContext();
+ } catch (Exception eee) {
+ WaoContext.serviceException(transaction,
+ "Impossible de récupérer l'ensemble des news", eee);
+ } finally {
+ WaoContext.closeTransaction(transaction);
+ }
+ }
+
+}
Deleted: trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceReferentialImpl.java
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services/ServiceReferentialImpl.java 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceReferentialImpl.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,222 +0,0 @@
-/*
- * *##%
- * SuiviObsmer :: 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.suiviobsmer.services;
-
-import com.csvreader.CsvReader;
-import fr.ifremer.suiviobsmer.SuiviObsmerException;
-import fr.ifremer.suiviobsmer.SuiviObsmerModelDAOHelper;
-import fr.ifremer.suiviobsmer.SuiviObsmerContext;
-import fr.ifremer.suiviobsmer.bean.SamplingFilter;
-import fr.ifremer.suiviobsmer.entity.FishingZone;
-import fr.ifremer.suiviobsmer.entity.FishingZoneDAO;
-import fr.ifremer.suiviobsmer.entity.Profession;
-import fr.ifremer.suiviobsmer.entity.ProfessionDAO;
-import fr.ifremer.suiviobsmer.entity.SampleRow;
-import fr.ifremer.suiviobsmer.io.ImportHelper;
-import fr.ifremer.suiviobsmer.io.WaoCsvHeader.FISHING_ZONE;
-import java.io.InputStream;
-import java.nio.charset.Charset;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import org.apache.commons.lang.StringUtils;
-import org.nuiton.topia.TopiaContext;
-import org.nuiton.topia.TopiaException;
-import org.nuiton.topia.framework.TopiaQuery;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * ServiceReferentialImpl
- *
- * Created: 30 nov. 2009
- *
- * @author fdesbois
- * @version $Revision$
- *
- * Mise a jour: $Date$
- * par : $Author$
- */
-public class ServiceReferentialImpl implements ServiceReferential {
-
- private static final Logger log = LoggerFactory.getLogger(ServiceReferentialImpl.class);
-
- protected TopiaContext rootContext;
-
- public ServiceReferentialImpl() throws SuiviObsmerException {
- rootContext = SuiviObsmerContext.getTopiaRootContext();
- }
-
- @Override
- public List<String> getFacades(SamplingFilter filter) throws SuiviObsmerException {
- TopiaContext transaction = null;
- List<String> results = new ArrayList<String>();
- try {
- transaction = rootContext.beginTransaction();
-
- FishingZoneDAO dao = SuiviObsmerModelDAOHelper.getFishingZoneDAO(transaction);
- TopiaQuery query = dao.createQuery("F");
-
- query = prepareQueryForFishingZoneFilter(query, filter);
-
- results = (List<String>)query.setSelect("DISTINCT F." + FishingZone.FACADE_NAME).execute();
-
- //transaction.closeContext();
- } catch (Exception eee) {
- SuiviObsmerContext.serviceException(transaction, "Impossible de charger la liste des facades", eee);
- } finally {
- SuiviObsmerContext.closeTransaction(transaction);
- }
- return results;
- }
-
- @Override
- public List<String> getSectors(SamplingFilter filter) throws SuiviObsmerException {
- TopiaContext transaction = null;
- List<String> results = new ArrayList<String>();
- try {
- transaction = rootContext.beginTransaction();
-
- FishingZoneDAO dao = SuiviObsmerModelDAOHelper.getFishingZoneDAO(transaction);
- TopiaQuery query = dao.createQuery("F");
-
- query = prepareQueryForFishingZoneFilter(query, filter);
-
- if (StringUtils.isNotEmpty(filter.getFacadeName())) {
- query.add("F." + FishingZone.FACADE_NAME, filter.getFacadeName());
- }
-
- results = (List<String>)query.setSelect("DISTINCT F." + FishingZone.SECTOR_NAME).execute();
-
- //transaction.closeContext();
- } catch (Exception eee) {
- SuiviObsmerContext.serviceException(transaction, "Impossible de charger la liste des secteurs de pêche", eee);
- } finally {
- SuiviObsmerContext.closeTransaction(transaction);
- }
- return results;
- }
-
- protected TopiaQuery prepareQueryForFishingZoneFilter(TopiaQuery query, SamplingFilter filter) throws TopiaException {
- if (filter.getCompany() != null || StringUtils.isNotEmpty(filter.getProgramName())) {
- query.addFrom(SampleRow.class.getName() + " S").
- add("S IN elements(F." + FishingZone.SAMPLE_ROW + ")");
- }
-
- if (filter.getCompany() != null) {
- query.add("S." + SampleRow.COMPANY, filter.getCompany());
- }
-
- if (filter.getProgramName() != null) {
- query.add("S." + SampleRow.PROGRAM_NAME, filter.getProgramName());
- }
-
- return query;
- }
-
- @Override
- public List<Profession> getProfessions() throws SuiviObsmerException {
- TopiaContext transaction = null;
- List<Profession> results = new ArrayList<Profession>();
- try {
- transaction = rootContext.beginTransaction();
-
- ProfessionDAO dao = SuiviObsmerModelDAOHelper.getProfessionDAO(transaction);
-
- results = dao.findAll();
-
- //transaction.closeContext();
- } catch (Exception eee) {
- SuiviObsmerContext.serviceException(transaction,
- "Impossible de charger la liste des métiers", eee);
- } finally {
- SuiviObsmerContext.closeTransaction(transaction);
- }
- return results;
- }
-
- @Override
- public List<FishingZone> getFishingZones() throws SuiviObsmerException {
- TopiaContext transaction = null;
- List<FishingZone> results = new ArrayList<FishingZone>();
- try {
- transaction = rootContext.beginTransaction();
-
- FishingZoneDAO dao = SuiviObsmerModelDAOHelper.getFishingZoneDAO(transaction);
-
- results = dao.findAll();
-
- //transaction.closeContext();
- } catch (Exception eee) {
- SuiviObsmerContext.serviceException(transaction,
- "Impossible de charger la liste des zones de pêche", eee);
- } finally {
- SuiviObsmerContext.closeTransaction(transaction);
- }
- return results;
- }
-
- @Override
- public int importFishingZoneCsv(InputStream input) throws SuiviObsmerException {
- TopiaContext transaction = null;
- int result = 0;
- try {
- transaction = rootContext.beginTransaction();
-
- CsvReader reader = new CsvReader(input, Charset.forName("UTF-8"));
- reader.readHeaders();
-
- FishingZoneDAO dao = SuiviObsmerModelDAOHelper.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);
-
- FishingZone zone = dao.findByDistrictCode(districtCode);
-
- if (zone == null) {
- zone = dao.create(FishingZone.DISTRICT_CODE, districtCode);
- }
- zone.setFacadeName(facadeName);
- zone.setSectorName(sectorName);
- result++;
- }
-
- transaction.commitTransaction();
- //transaction.closeContext();
- } catch (Exception eee) {
- SuiviObsmerContext.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 {
- SuiviObsmerContext.closeTransaction(transaction);
- }
- return result;
- }
-
-}
Copied: trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceReferentialImpl.java (from rev 354, trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services/ServiceReferentialImpl.java)
===================================================================
--- trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceReferentialImpl.java (rev 0)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceReferentialImpl.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -0,0 +1,222 @@
+/*
+ * *##%
+ * 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.service;
+
+import com.csvreader.CsvReader;
+import fr.ifremer.wao.WaoException;
+import fr.ifremer.wao.WaoModelDAOHelper;
+import fr.ifremer.wao.WaoContext;
+import fr.ifremer.wao.bean.SamplingFilter;
+import fr.ifremer.wao.entity.FishingZone;
+import fr.ifremer.wao.entity.FishingZoneDAO;
+import fr.ifremer.wao.entity.Profession;
+import fr.ifremer.wao.entity.ProfessionDAO;
+import fr.ifremer.wao.entity.SampleRow;
+import fr.ifremer.wao.io.ImportHelper;
+import fr.ifremer.wao.io.WaoCsvHeader.FISHING_ZONE;
+import java.io.InputStream;
+import java.nio.charset.Charset;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import org.apache.commons.lang.StringUtils;
+import org.nuiton.topia.TopiaContext;
+import org.nuiton.topia.TopiaException;
+import org.nuiton.topia.framework.TopiaQuery;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * ServiceReferentialImpl
+ *
+ * Created: 30 nov. 2009
+ *
+ * @author fdesbois
+ * @version $Revision$
+ *
+ * Mise a jour: $Date$
+ * par : $Author$
+ */
+public class ServiceReferentialImpl implements ServiceReferential {
+
+ private static final Logger log = LoggerFactory.getLogger(ServiceReferentialImpl.class);
+
+ protected TopiaContext rootContext;
+
+ 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 {
+ transaction = rootContext.beginTransaction();
+
+ FishingZoneDAO dao = WaoModelDAOHelper.getFishingZoneDAO(transaction);
+ TopiaQuery query = dao.createQuery("F");
+
+ query = prepareQueryForFishingZoneFilter(query, filter);
+
+ results = (List<String>)query.setSelect("DISTINCT F." + FishingZone.FACADE_NAME).execute();
+
+ //transaction.closeContext();
+ } catch (Exception eee) {
+ WaoContext.serviceException(transaction, "Impossible de charger la liste des facades", eee);
+ } finally {
+ WaoContext.closeTransaction(transaction);
+ }
+ return results;
+ }
+
+ @Override
+ public List<String> getSectors(SamplingFilter filter) throws WaoException {
+ TopiaContext transaction = null;
+ List<String> results = new ArrayList<String>();
+ try {
+ transaction = rootContext.beginTransaction();
+
+ FishingZoneDAO dao = WaoModelDAOHelper.getFishingZoneDAO(transaction);
+ TopiaQuery query = dao.createQuery("F");
+
+ query = prepareQueryForFishingZoneFilter(query, filter);
+
+ if (StringUtils.isNotEmpty(filter.getFacadeName())) {
+ query.add("F." + FishingZone.FACADE_NAME, filter.getFacadeName());
+ }
+
+ results = (List<String>)query.setSelect("DISTINCT F." + FishingZone.SECTOR_NAME).execute();
+
+ //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;
+ }
+
+ protected TopiaQuery prepareQueryForFishingZoneFilter(TopiaQuery query, SamplingFilter filter) throws TopiaException {
+ if (filter.getCompany() != null || StringUtils.isNotEmpty(filter.getProgramName())) {
+ query.addFrom(SampleRow.class.getName() + " S").
+ add("S IN elements(F." + FishingZone.SAMPLE_ROW + ")");
+ }
+
+ if (filter.getCompany() != null) {
+ query.add("S." + SampleRow.COMPANY, filter.getCompany());
+ }
+
+ if (filter.getProgramName() != null) {
+ query.add("S." + SampleRow.PROGRAM_NAME, filter.getProgramName());
+ }
+
+ return query;
+ }
+
+ @Override
+ public List<Profession> getProfessions() throws WaoException {
+ TopiaContext transaction = null;
+ List<Profession> results = new ArrayList<Profession>();
+ try {
+ transaction = rootContext.beginTransaction();
+
+ ProfessionDAO dao = WaoModelDAOHelper.getProfessionDAO(transaction);
+
+ results = dao.findAll();
+
+ //transaction.closeContext();
+ } catch (Exception eee) {
+ WaoContext.serviceException(transaction,
+ "Impossible de charger la liste des métiers", eee);
+ } finally {
+ WaoContext.closeTransaction(transaction);
+ }
+ return results;
+ }
+
+ @Override
+ public List<FishingZone> getFishingZones() throws WaoException {
+ TopiaContext transaction = null;
+ List<FishingZone> results = new ArrayList<FishingZone>();
+ try {
+ transaction = rootContext.beginTransaction();
+
+ FishingZoneDAO dao = WaoModelDAOHelper.getFishingZoneDAO(transaction);
+
+ results = dao.findAll();
+
+ //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;
+ }
+
+ @Override
+ public int importFishingZoneCsv(InputStream input) throws WaoException {
+ TopiaContext transaction = null;
+ int result = 0;
+ try {
+ transaction = rootContext.beginTransaction();
+
+ CsvReader reader = new CsvReader(input, Charset.forName("UTF-8"));
+ reader.readHeaders();
+
+ FishingZoneDAO dao = WaoModelDAOHelper.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);
+
+ FishingZone zone = dao.findByDistrictCode(districtCode);
+
+ if (zone == null) {
+ zone = dao.create(FishingZone.DISTRICT_CODE, districtCode);
+ }
+ zone.setFacadeName(facadeName);
+ zone.setSectorName(sectorName);
+ result++;
+ }
+
+ 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);
+ }
+ return result;
+ }
+
+}
Deleted: trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceSamplingImpl.java
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services/ServiceSamplingImpl.java 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceSamplingImpl.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,917 +0,0 @@
-/*
- * *##%
- * SuiviObsmer :: 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.suiviobsmer.services;
-
-import com.csvreader.CsvReader;
-import com.csvreader.CsvWriter;
-import fr.ifremer.suiviobsmer.io.ImportHelper;
-import fr.ifremer.suiviobsmer.SuiviObsmerBusinessException;
-import fr.ifremer.suiviobsmer.SuiviObsmerBusinessException.Type;
-import fr.ifremer.suiviobsmer.SuiviObsmerException;
-import fr.ifremer.suiviobsmer.SuiviObsmerModelDAOHelper;
-import fr.ifremer.suiviobsmer.SuiviObsmerContext;
-import fr.ifremer.suiviobsmer.bean.FacadeRow;
-import fr.ifremer.suiviobsmer.bean.FacadeRowImpl;
-import fr.ifremer.suiviobsmer.bean.ImportResults;
-import fr.ifremer.suiviobsmer.bean.ImportResultsImpl;
-import fr.ifremer.suiviobsmer.bean.SamplingFilter;
-import fr.ifremer.suiviobsmer.entity.*;
-import fr.ifremer.suiviobsmer.io.WaoCsvHeader.FISHING_ZONE;
-import fr.ifremer.suiviobsmer.io.WaoCsvHeader.SAMPLING;
-import fr.ifremer.suiviobsmer.io.WaoCsvHeader.SamplingHeader;
-import fr.ifremer.suiviobsmer.io.ExportHelper;
-import fr.ifremer.suiviobsmer.io.ExportHelper;
-import fr.ifremer.suiviobsmer.io.SamplingExport;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.nio.charset.Charset;
-import java.text.DateFormat;
-import java.text.NumberFormat;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.GregorianCalendar;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import org.apache.commons.lang.StringUtils;
-import org.nuiton.topia.TopiaContext;
-import org.nuiton.topia.TopiaException;
-import org.nuiton.topia.framework.TopiaQuery;
-import org.nuiton.topia.framework.TopiaQuery.Op;
-import org.nuiton.topia.persistence.util.EntityLoador;
-import org.nuiton.util.DateUtils;
-import org.nuiton.util.PeriodDates;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * ServiceSamplingImpl
- *
- * Created: 30 nov. 2009
- *
- * @author fdesbois
- * @version $Revision$
- *
- * Mise a jour: $Date$
- * par : $Author$
- */
-public class ServiceSamplingImpl implements ServiceSampling {
-
- private static final Logger log = LoggerFactory.getLogger(ServiceSamplingImpl.class);
-
- protected TopiaContext rootContext;
-
- public ServiceSamplingImpl() throws SuiviObsmerException {
- rootContext = SuiviObsmerContext.getTopiaRootContext();
- }
-
- @Override
- public void createUpdateSampleRow(SampleRow row, List<Boat> boats, SampleRowLog rowLog) throws SuiviObsmerException {
- TopiaContext transaction = null;
- try {
- transaction = rootContext.beginTransaction();
-
- SampleRowLogDAO logDAO = SuiviObsmerModelDAOHelper.getSampleRowLogDAO(transaction);
- SuiviObsmerContext.prepareTopiaId(SampleRowLog.class, rowLog);
- logDAO.update(rowLog);
-
- boolean newRow = SuiviObsmerContext.prepareTopiaId(SampleRow.class, row);
-
- if (log.isDebugEnabled()) {
- log.debug("new sampleRow : " + newRow);
- log.debug("samplRow topiaId : " + row.getTopiaId());
- }
-
- String pattern = DateUtils.MONTH_PATTERN;
- DateFormat dateFormat = new SimpleDateFormat(pattern);
-
- SampleRow oldRow = null;
- Profession oldProfession = null;
- Company oldCompany = null;
- Map<String, SampleMonth> oldMonths = new HashMap<String, SampleMonth>();
- List<FishingZone> oldZones = new ArrayList<FishingZone>();
- // UPDATE
- if (!newRow) {
- // Prepare data for logging or deleting oldMonths
- TopiaContext transaction2 = rootContext.beginTransaction();
- SampleRowDAO oldDAO = SuiviObsmerModelDAOHelper.getSampleRowDAO(transaction2);
- oldRow = oldDAO.findByTopiaId(row.getTopiaId());
- oldCompany = oldRow.getCompany();
- oldProfession = oldRow.getProfession();
- for (SampleMonth month : oldRow.getSampleMonth()) {
- oldMonths.put(month.getTopiaId(), month);
- }
- oldZones = oldRow.getFishingZone();
- transaction2.closeContext();
-
- // NbObservants
- if (oldRow.getNbObservants() != row.getNbObservants()) {
- rowLog.addChange("Le nombre d'observateurs est passé de " + oldRow.getNbObservants() + " à " + row.getNbObservants());
- }
- // AverageTideTime
- if (oldRow.getAverageTideTime() != row.getAverageTideTime()) {
- rowLog.addChange("La durée moyenne d'une marée est passé de " + oldRow.getAverageTideTime() + " jours à " + row.getAverageTideTime());
- }
- } else {
- rowLog.addChange("Le nombre d'observateurs est " + row.getNbObservants());
- rowLog.addChange("La durée moyenne d'une marée est " + row.getAverageTideTime());
- }
- // ChangeLog Company
- rowLog.addChangeCompany(oldCompany, row.getCompany());
- // ChangeLog Program
- String oldProgram = oldRow != null ? oldRow.getProgramName() : null;
- rowLog.addChangeProgram(oldProgram, row.getProgramName());
- // ChangeLog Period
- PeriodDates oldPeriod = null;
- if (oldRow != null) {
- oldPeriod = new PeriodDates(oldRow.getPeriodBegin(), oldRow.getPeriodEnd());
- }
- PeriodDates newPeriod = new PeriodDates(row.getPeriodBegin(), row.getPeriodEnd());
- rowLog.addChangePeriod(oldPeriod, newPeriod, pattern);
-
- // Save Profession
- ProfessionDAO professionDAO = SuiviObsmerModelDAOHelper.getProfessionDAO(transaction);
- SuiviObsmerContext.prepareTopiaId(Profession.class, row.getProfession());
- rowLog.addChangeProfession(oldProfession, row.getProfession());
- professionDAO.update(row.getProfession());
-
- // Save sampleMonth
- SampleMonthDAO monthDAO = SuiviObsmerModelDAOHelper.getSampleMonthDAO(transaction);
-
- // Delete oldMonths
- List<SampleMonth> newMonths = row.getSampleMonth();
- for (SampleMonth oldMonth : oldMonths.values()) {
- if (!newMonths.contains(oldMonth)) {
- String date = dateFormat.format(oldMonth.getPeriodDate());
- // Delete old month : add to log
- monthDAO.delete(oldMonth);
- rowLog.addChange("Le mois " + date + " a été supprimé, " +
- "l'ancienne valeur d'effort était " + oldMonth.getExpectedTidesValue());
- }
- }
- // Create or update months
- for (SampleMonth month : newMonths) {
- boolean monthCreated = SuiviObsmerContext.prepareTopiaId(SampleMonth.class, month);
- String date = dateFormat.format(month.getPeriodDate());
- if (monthCreated) {
- // log create month
- rowLog.addChange("Le mois " + date + " a été créé avec un nombre de marées de " + month.getExpectedTidesValue());
- } else {
- SampleMonth oldMonth = oldMonths.get(month.getTopiaId());
- if (oldMonth.getExpectedTidesValue() != month.getExpectedTidesValue()) {
- // log change month value
- rowLog.addChange("Le nombre de marées du mois " + date + " est passé de " +
- oldMonth.getExpectedTidesValue() + " à " + month.getExpectedTidesValue());
- }
- }
- monthDAO.update(month);
- }
-
- // Remove no longer elligibleBoats
- row.removeNoLongerElligibleBoats(boats);
- // Save new elligibleBoats
- ElligibleBoatDAO dao = SuiviObsmerModelDAOHelper.getElligibleBoatDAO(transaction);
- for (Boat boat : boats) {
- if (!row.hasElligibleBoat(boat)) {
- ElligibleBoat elligibleBoat = dao.create();
- elligibleBoat.setSampleRow(row);
- elligibleBoat.setGlobalActive(true);
- elligibleBoat.setBoat(boat);
- row.addElligibleBoat(elligibleBoat);
- }
- }
-
- // ChangeLog boats
- String oldBoats = oldRow != null ? oldRow.getMainElligibleBoatsAsString() : "";
- rowLog.addChangeBoats(oldBoats, row.getMainElligibleBoatsAsString());
-
-
- // Remove no longer linked FishingZone
- List<FishingZone> newZones = row.getFishingZone();
- for (FishingZone oldZone : oldZones) {
- if (!newZones.contains(oldZone)) {
- updateFishingZones(transaction, oldZone.getTopiaId(), row, true);
- rowLog.addChange("La zone de pêche " + oldZone.getCode() + " a été dissociée de la ligne");
- }
- }
- // Add new linked FishingZone
- // ConcurrentModificationException ????
- for (FishingZone zone : new ArrayList<FishingZone>(newZones)) {
- if (!oldZones.contains(zone)) {
- 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 = SuiviObsmerModelDAOHelper.getSampleRowDAO(transaction);
- if (log.isDebugEnabled()) {
- log.debug("update row : " + row);
- }
- row.addSampleRowLog(rowLog);
- rowDAO.update(row);
-
- if (log.isDebugEnabled()) {
- log.debug("Change log : " + rowLog.getLogText());
- log.debug("commit transaction !");
- }
- transaction.commitTransaction();
- //transaction.closeContext();
- } catch (Exception eee) {
- SuiviObsmerContext.serviceException(transaction,
- "Impossible de sauvegarder la ligne d'échantillon", eee);
- } finally {
- SuiviObsmerContext.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 = SuiviObsmerModelDAOHelper.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 SuiviObsmerException {
-// TopiaContext transaction = null;
-// List<SampleRowLog> results = new ArrayList<SampleRowLog>();
-// try {
-// transaction = rootContext.beginTransaction();
-//
-// SampleRowLogDAO dao = SuiviObsmerModelDAOHelper.getSampleRowLogDAO(transaction);
-// results = dao.createQuery().add(SampleRowLog.SAMPLE_ROW, sampleRow).addOrderDesc(TopiaEntity.TOPIA_CREATE_DATE).executeToEntityList();
-//
-// transaction.closeContext();
-// } catch (Exception eee) {
-// SuiviObsmerContext.serviceException(transaction,
-// "Impossible de récupérer l'historique de la ligne d'échantillonnage", eee);
-// }
-// return results;
-// }
-
- @Override
- public FacadeRow getSampleRowsOrderedByFishingZone(PeriodDates period, Company company) throws SuiviObsmerException {
- TopiaContext transaction = null;
- FacadeRow result = new FacadeRowImpl();
- try {
- if (period.getFromDate() == null || period.getThruDate() == null) {
- throw new IllegalArgumentException("PeriodBegin date and/or PeriodEnd date can't be null !");
- }
- transaction = rootContext.beginTransaction();
-
- SampleRowDAO dao = SuiviObsmerModelDAOHelper.getSampleRowDAO(transaction);
-
- TopiaQuery query = dao.createQuery("S").addDistinct().
- addFrom(FishingZone.class.getName() + " F").
- add("S IN elements(F." + FishingZone.SAMPLE_ROW + ")");
-
- if (company != null) {
- query.add("S." + SampleRow.COMPANY, company);
- }
-
- // Prepare period dates
- period.initDayOfMonthExtremities();
- query.add("S." + SampleRow.PERIOD_BEGIN, Op.LT, period.getThruDate()).
- add("S." + SampleRow.PERIOD_END, Op.GT, period.getFromDate());
-
- // Order By facade, sector, districtCode, sampleRowCode
- String zoneOrder = "F." + FishingZone.FACADE_NAME + " , F." + FishingZone.SECTOR_NAME + ", F." + FishingZone.DISTRICT_CODE;
- query.addOrder(zoneOrder).addOrder("S." + SampleRow.CODE).addSelect(zoneOrder);
- // Load data
- //query.addLoad(SampleRow.PROFESSION, SampleRow.COMPANY);
-
- if (log.isDebugEnabled()) {
- log.debug("Query : " + query);
- }
-
- List<SampleRow> results = dao.findAllByQuery(query);
-
- for (SampleRow row : results) {
- // use FacadeRow to complete ordering using maps
- result.addRow(row);
- }
-
- //transaction.closeContext();
- } catch (Exception eee) {
- SuiviObsmerContext.serviceException(transaction,
- "Impossible de récupérer la liste des lignes du plan d'échantillonnage", eee);
- } finally {
- SuiviObsmerContext.closeTransaction(transaction);
- }
- return result;
- }
-
- @Override
- public List<String> getPrograms(Company company) throws SuiviObsmerException {
- TopiaContext transaction = null;
- List<String> results = new ArrayList<String>();
- try {
- transaction = rootContext.beginTransaction();
-
- SampleRowDAO dao = SuiviObsmerModelDAOHelper.getSampleRowDAO(transaction);
- TopiaQuery query = dao.createQuery();
-
- if (company != null) {
- query.add(SampleRow.COMPANY, company);
- }
-
- results = (List<String>)query.setSelect("DISTINCT " + SampleRow.PROGRAM_NAME).execute();
-
- //transaction.closeContext();
- } catch (Exception eee) {
- SuiviObsmerContext.serviceException(transaction,
- "Impossible de charger la liste des programmes", eee);
- } finally {
- SuiviObsmerContext.closeTransaction(transaction);
- }
- return results;
- }
-
- @Override
- public List<SampleRow> getSampleRowsByFilter(SamplingFilter filter) throws SuiviObsmerException {
- TopiaContext transaction = null;
- List<SampleRow> results = new ArrayList<SampleRow>();
- try {
- transaction = rootContext.beginTransaction();
-
- SampleRowDAO dao = SuiviObsmerModelDAOHelper.getSampleRowDAO(transaction);
-
- TopiaQuery query = dao.createQuery("S").addDistinct().addOrder("S." + SampleRow.CODE);
-
- query = filter.prepareQueryForSampling(query, "S");
-
- if (log.isDebugEnabled()) {
- log.debug("Query : " + query);
- }
-
-// if (finished) {
-// // Only rows which are not finished will be kept
-// Date current = SuiviObsmerContext.getCurrentDate();
-// query.add(SampleRow.PERIOD_END, Op.GE, current);
-// }
-
-// if (filter.getCompany() != null) {
-// query.add("S." + SampleRow.COMPANY, filter.getCompany());
-// }
-
- results = dao.findAllByQuery(query);
-
- //transaction.closeContext();
- } catch (Exception eee) {
- SuiviObsmerContext.serviceException(transaction,
- "Impossible de récupérer la liste des lignes du plan d'échantillonnage", eee);
- } finally {
- SuiviObsmerContext.closeTransaction(transaction);
- }
- return results;
- }
-
- @Override
- public SampleRow getSampleRow(String sampleRowId) throws SuiviObsmerException {
- TopiaContext transaction = null;
- SampleRow result = null;
- try {
- transaction = rootContext.beginTransaction();
-
- SampleRowDAO dao = SuiviObsmerModelDAOHelper.getSampleRowDAO(transaction);
-
- result = dao.findByTopiaId(sampleRowId);
-
- //transaction.closeContext();
- } catch (Exception eee) {
- SuiviObsmerContext.serviceException(transaction,
- "Impossible de charger la ligne d'échantillon ayant pour identifiant : " + sampleRowId,
- eee);
- } finally {
- SuiviObsmerContext.closeTransaction(transaction);
- }
- return result;
- }
-
- @Override
- public void deleteSampleRow(SampleRow sampleRow) throws SuiviObsmerException {
- TopiaContext transaction = null;
- try {
- transaction = rootContext.beginTransaction();
-
- SampleRowDAO dao = SuiviObsmerModelDAOHelper.getSampleRowDAO(transaction);
-
- SampleRow row = dao.findByTopiaId(sampleRow.getTopiaId());
-
- dao.delete(row);
-
- transaction.commitTransaction();
- //transaction.closeContext();
- } catch (Exception eee) {
- SuiviObsmerContext.serviceException(transaction,
- "Impossible de supprimer la ligne d'échantillon : " + sampleRow.getCode(),
- eee);
- } finally {
- SuiviObsmerContext.closeTransaction(transaction);
- }
- }
-
- @Override
- public String getNewSampleRowCode(Date beginDate) throws SuiviObsmerException {
- TopiaContext transaction = null;
- String result = null;
- if (beginDate == null) {
- return result;
- }
- try {
- transaction = rootContext.beginTransaction();
-
- Calendar begin = new GregorianCalendar();
- begin.setTime(beginDate);
- int year = begin.get(Calendar.YEAR);
-
- SampleRowDAO dao = SuiviObsmerModelDAOHelper.getSampleRowDAO(transaction);
- TopiaQuery query = dao.createQuery().add(SampleRow.CODE, Op.LIKE, year + "_%");
-
- String maxCode = query.executeToString("MAX(" + SampleRow.CODE + ")");
-
- if (log.isDebugEnabled()) {
- log.debug("Max code found : " + maxCode);
- }
-
- int num = 1;
- if (!StringUtils.isEmpty(maxCode)) {
- String[] part = maxCode.split("_");
- num = Integer.parseInt(part[1]) + 1;
- }
- String str = StringUtils.leftPad("" + num, 4, "0");
- result = year + "_" + str;
-
- //transaction.closeContext();
- } catch (Exception eee) {
- SuiviObsmerContext.serviceException(transaction,
- "Impossible de récupérer un nouveau code pour une ligne d'échantillonnage",
- eee);
- } finally {
- SuiviObsmerContext.closeTransaction(transaction);
- }
- return result;
- }
-
- @Override
- public SampleRow getNewSampleRow() {
- SampleRow row = new SampleRowImpl();
- row.setProfession(new ProfessionImpl());
- row.setFishingZone(new ArrayList<FishingZone>());
- //row.setProgram(new ProgramImpl());
- row.setElligibleBoat(new ArrayList<ElligibleBoat>());
- row.setSampleMonth(new ArrayList<SampleMonth>());
- return row;
- }
-
- @Override
- public SampleMonth getNewSampleMonth(Date period, SampleRow row) {
- SampleMonth month = new SampleMonthImpl();
- month.setSampleRow(row);
- month.setPeriodDate(period);
- return month;
- }
-
- /**
- * Create a new profession from an existing one. Copy all attributes values from
- * the profession in argument to a new profession not created yet in database.
- *
- * @param profession the profession source
- * @return a new Profession
- */
- @Override
- public Profession getNewProfession(Profession profession) {
- Profession newProfession = new ProfessionImpl();
- EntityLoador<Profession> loador = EntityLoador.newEntityLoador(Profession.class,
- Profession.CODE_DCF5, Profession.LIBELLE, Profession.MESH_SIZE, Profession.OTHER, Profession.SIZE, Profession.SPECIES);
- loador.load(profession, newProfession, false);
- return newProfession;
- }
-
- @Override
- public InputStream exportSamplingPlanCsv(WaoUser user, PeriodDates period) throws SuiviObsmerException {
- TopiaContext transaction = null;
- InputStream result = null;
- CsvWriter writer = null;
- try {
- transaction = rootContext.beginTransaction();
-
- File file = File.createTempFile("wao-samplingPlan-", ".csv");
- file.deleteOnExit();
-
- FileOutputStream output = new FileOutputStream(file);
- writer = new CsvWriter(output, ',', Charset.forName("UTF-8"));
-
- // Get min and max dates to have the biggest period
-// Date min = (Date)query.executeToObject("MIN(S." + SampleRow.PERIOD_BEGIN + ")");
-// Date max = (Date)query.executeToObject("MAX(S." + SampleRow.PERIOD_END + ")");
-
-// PeriodDates periodMax = new PeriodDates(min, max);
- period.setPattern(SAMPLING.defaultDatePattern());
- List<String> monthHeaders = period.getFormatedMonths();
-
- SamplingExport export = new SamplingExport(writer, user, monthHeaders);
-
- export.writeHeaders();
-
- // Get sampleRows from database filtered by company if needed
- // (only for user) and period
- SampleRowDAO dao = SuiviObsmerModelDAOHelper.getSampleRowDAO(transaction);
- TopiaQuery query = dao.createQuery("S");
-
- if (!user.getAdmin()) {
- query.add("S." + SampleRow.COMPANY, user.getCompany());
- }
-
- // Prepare period dates
- period.initDayOfMonthExtremities();
- query.add("S." + SampleRow.PERIOD_BEGIN, Op.LT, period.getThruDate()).
- add("S." + SampleRow.PERIOD_END, Op.GT, period.getFromDate());
-
- query.addOrder("S." + SampleRow.CODE);
-
- List<SampleRow> rows = dao.findAllByQuery(query);
-
- DateFormat dateFormat = SAMPLING.getDateFormat();
- NumberFormat numberFormat = SAMPLING.getNumberFormat();
-
- for (SampleRow row : rows) {
- export.newRecord();
-
- if (log.isDebugEnabled()) {
- log.debug("add sampleRow : " + row.getCode());
- }
-
- export.record(SAMPLING.PLAN_CODE, row.getCode());
- Company company = row.getCompany();
- if (company != null) {
- export.record(SAMPLING.SOCIETE_NOM, company.getName());
- }
-
- // Profession can't be null
- Profession profession = row.getProfession();
- export.record(SAMPLING.METIER_CODE_DCF5, profession.getCodeDCF5());
- export.record(SAMPLING.METIER_MAILLAGE, profession.getMeshSize());
- export.record(SAMPLING.METIER_TAILLE, profession.getSize());
- export.record(SAMPLING.METIER_AUTRE, profession.getOther());
- export.record(SAMPLING.METIER_LIBELLE, profession.getLibelle());
- export.record(SAMPLING.METIER_ESPECES, profession.getSpecies());
-
- export.record(SAMPLING.PROGRAMME_CODE, row.getProgramName());
- export.record(SAMPLING.PROGRAMME_DEBUT, dateFormat.format(row.getPeriodBegin()));
- export.record(SAMPLING.PROGRAMME_FIN, dateFormat.format(row.getPeriodEnd()));
-
- export.record(FISHING_ZONE.PECHE_FACADE, row.getFacade());
- export.record(FISHING_ZONE.PECHE_ZONE, row.getSectors());
- export.record(SAMPLING.PECHE_AUTRE, row.getFishingZonesInfos());
-
- String divisions = "";
- String separator = FISHING_ZONE.getDistrictCodeSeparator();
- for (FishingZone zone : row.getFishingZone()) {
- divisions += separator + zone.getDistrictCode();
- }
-
- // There is at least one district in row, so no problem with substring
- export.record(FISHING_ZONE.PECHE_DIVISION, divisions.substring(separator.length()));
-
- export.record(SAMPLING.PLAN_NB_OBSERV, numberFormat.format(row.getNbObservants()));
- export.record(SAMPLING.PLAN_DUREE_MOY, numberFormat.format(row.getAverageTideTime()));
- export.record(SAMPLING.PLAN_COMMENT, String.valueOf(row.getComment()));
-
- export.recordMonths(row);
-
-// for (int i = 0; i < monthHeaders.size(); i++) {
-// // Get date from monthHeaders list
-// Date month = dateFormat.parse(monthHeaders.get(i));
-// // Retrieve sampleMonth corresponding
-// SampleMonth sampleMonth = row.getSampleMonth(month);
-// // Add it to the file if it exists
-// if (sampleMonth != null) {
-// // Prepare index for record
-// int index = SAMPLING.getStartIndexForMonths() + i;
-// String expected = String.valueOf(sampleMonth.getExpectedTidesValue());
-// String real = String.valueOf(sampleMonth.getRealTidesValue());
-// // The admin as only expected value (to be the same as
-// // in import)
-// if (user.getAdmin()) {
-// export.record(index, expected); //record[index] = expected;
-// // The user as both expected and real values
-// } else {
-// export.record(index, expected + " (" + real + ")");
-// }
-// }
-// }
-
- export.writeRecord();
- }
-
- result = new FileInputStream(file);
-
- } catch (Exception eee) {
- DateFormat dateFormat = SAMPLING.getDateFormat();
- SuiviObsmerContext.serviceException(transaction,
- "Impossible d'exporter le plan d'échantillonnage sur la période du " +
- dateFormat.format(period.getFromDate()) + " au " +
- dateFormat.format(period.getThruDate()), eee);
- } finally {
- if (writer != null) {
- writer.close();
- }
- SuiviObsmerContext.closeTransaction(transaction);
- }
- return result;
- }
-
- @Override
- public ImportResults importSamplingPlanCsv(InputStream input) throws SuiviObsmerException {
- TopiaContext transaction = null;
- ImportResults result = new ImportResultsImpl();
- //int[] result = new int[3];
- int currRow = 0;
- SampleRow row = null;
- try {
- transaction = rootContext.beginTransaction();
-
- CsvReader reader = new CsvReader(input, Charset.forName("UTF-8"));
- reader.readHeaders();
-
- SampleRowDAO dao = SuiviObsmerModelDAOHelper.getSampleRowDAO(transaction);
-
- //int nbImported = 0;
- //int nbRefused = 0;
-
- while(reader.readRecord()) {
-
- currRow++;
-
- if (log.isTraceEnabled()) {
- log.trace(" " + Arrays.asList(reader.getValues()));
- }
-
- String code = ImportHelper.readSampleRowCode(reader); //reader.get(SAMPLING.PLAN_CODE.name()).trim();
-
- if (StringUtils.isEmpty(code)) {
- continue;
- }
-
- String districts = reader.get(FISHING_ZONE.PECHE_DIVISION.name());
-
- row = dao.findByCode(code);
- // Refuse existing SampleRow
- if (row != null) {
- result.addError(currRow, "[CODE = " + code + "] refusé : Code déjà existant");
- result.incNbRefused();
- // Refuse Fishing zones empty
- } else if (StringUtils.isEmpty(districts)) {
- result.addError(currRow, "[CODE = " + code + "] refusé : Zone de pêche non renseigné");
- result.incNbRefused(); //nbRefused++;
- } else {
- row = dao.create(SampleRow.CODE, code);
-
- String companyName = ImportHelper.read(reader, SAMPLING.SOCIETE_NOM);
-
- // Create link with company if set in file
- if (!StringUtils.isEmpty(companyName)) {
- CompanyDAO companyDAO = SuiviObsmerModelDAOHelper.getCompanyDAO(transaction);
- Company company = companyDAO.findByName(companyName);
- if (company == null) {
- throw new SuiviObsmerBusinessException(Type.IMPORT_ERROR, this.getClass(),
- "Erreur à la ligne " + currRow + " [CODE = " + code + "] : " +
- "La société portant le nom '" + companyName + "' n'existe pas dans l'application");
- }
- row.setCompany(company);
- }
-
- // Import profession. Creation if not exist
- Profession profession = importProfession(transaction, reader);
- row.setProfession(profession);
-
- // Import zones and set them to the row
- // throw SuiviObsmerException if FishingZone doesn't exist
- importFishingZones(transaction, districts, currRow, row);
-
- updateRow(transaction, row, reader);
- result.incNbImported(); //nbImported++;
- }
- // Commit row by row
- transaction.commitTransaction();
- }
-
- //transaction.closeContext();
-
- } catch (NumberFormatException eee) {
- SuiviObsmerContext.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) {
- SuiviObsmerContext.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) {
- SuiviObsmerContext.serviceException(transaction,
- "Erreur à la ligne " + currRow + " [CODE = " + row.getCode() + "]",
- eee);
- } finally {
- SuiviObsmerContext.closeTransaction(transaction);
- }
- return result;
- }
-
- /**
- * Import a profession from CSV File from importSamplingPlanCsv method.
- * This profession is imported for a new SampleRow line.
- * Key value for the profession : codeDCF5, meshSize, size, other.
- * If profession already exists, update libelle and species.
- * @param transaction Topia transaction for using ProfessionDAO
- * @param reader CsvReader for getting Profession parameters
- * @return an existing Profession or a new one
- * @throws IOException for reader errors
- * @throws TopiaException for dao errors
- */
- protected Profession importProfession(TopiaContext transaction, CsvReader reader)
- throws IOException, TopiaException {
-
- String codeDCF5 = reader.get(SAMPLING.METIER_CODE_DCF5.name()).trim();
- String maillage = reader.get(SAMPLING.METIER_MAILLAGE.name()).trim();
- String taille = reader.get(SAMPLING.METIER_TAILLE.name()).trim();
- String autre = reader.get(SAMPLING.METIER_AUTRE.name()).trim();
- String libelle = reader.get(SAMPLING.METIER_LIBELLE.name()).trim();
- String especes = reader.get(SAMPLING.METIER_ESPECES.name()).trim();
-
- ProfessionDAO dao = SuiviObsmerModelDAOHelper.getProfessionDAO(transaction);
- Map<String, Object> existParams = new HashMap<String, Object>();
- existParams.put(Profession.CODE_DCF5, codeDCF5);
- existParams.put(Profession.MESH_SIZE, maillage);
- existParams.put(Profession.SIZE, taille);
- existParams.put(Profession.OTHER, autre);
-
- Profession profession = dao.findByProperties(existParams);
-
- if (profession == null) {
- profession = dao.create(existParams);
- }
-
- profession.setLibelle(libelle);
- profession.setSpecies(especes);
-
- return profession;
- }
-
- /**
- * Import a fishingZone from CSV File from importSamplingPlanCsv method.
- * These fishingZones are imported for a new SampleRow line.
- * Key value for the fishingZone : districtCode.
- * The districts argument contains multiple districtCode separating with " - ".
- * The fishingZone must be exist in database.
- * @param transaction Topia transaction for using FishingZoneDAO
- * @param districts String which contains several fishingZone districtCodes
- * @param currRow Row number in the line for the SampleRow
- * @param row SampleRow linked with districts (from Csv file)
- * @throws TopiaException for dao errors
- * @throws SuiviObsmerException if a FishingZone doesn't exist.
- */
- protected void importFishingZones(TopiaContext transaction, String districts, int currRow, SampleRow row)
- throws TopiaException, SuiviObsmerException {
-
- FishingZoneDAO dao = SuiviObsmerModelDAOHelper.getFishingZoneDAO(transaction);
-
- List<String> districtList = new ArrayList<String>(Arrays.asList(districts.split(FISHING_ZONE.getDistrictCodeSeparator())));
-
- if (log.isDebugEnabled()) {
- log.debug("FishingZone districts : " + districts);
- log.debug("FishingZone nb zones : " + districtList.size());
- }
- for (String districtCode : districtList) {
- FishingZone zone = dao.findByDistrictCode(districtCode.trim());
- if (zone == null) {
- throw new SuiviObsmerBusinessException(Type.IMPORT_ERROR, this.getClass(),
- "Erreur à la ligne " + currRow + " [CODE = " + row.getCode() + "] : " +
- "Cette ligne est lié à une zone inexistante : " + districtCode);
- }
- row.addFishingZone(zone);
- }
- }
-
- /**
- * Update a SampleRow from CSV File from importSamplingPlanCsv method.
- * Program must be set to get beginDate and endDate for getting correct months.
- * SampleMonth will be created corresponding to program period.
- * Careful : fixed columns set to 16 and months columns start to 13.
- * Updatable fields : fishingZoneInfos, nbObservants, averageTideTime, sampleMonths.
- * @param transaction Topia transaction for using FishingZoneDAO
- * @param sampleRow
- * @param reader CsvReader to get values for updatable fields
- * @throws IOException for CsvReader errors
- * @throws TopiaException for SampleMonthDAO errors
- * @throws ParseException for format errors
- * @see #getMonthAndYear(java.lang.String)
- */
- protected void updateRow(TopiaContext transaction, SampleRow sampleRow, CsvReader reader)
- throws IOException, TopiaException, ParseException {
-
- String fishingZoneInfos = ImportHelper.read(reader, SAMPLING.PECHE_AUTRE);
- int nbObservants = ImportHelper.readInt(reader, SAMPLING.PLAN_NB_OBSERV);
- String averageStr = ImportHelper.read(reader, SAMPLING.PLAN_DUREE_MOY);
- averageStr = averageStr.replaceAll(",", ".");
- double averageTideTime = Double.parseDouble(averageStr);
- String programName = ImportHelper.read(reader, SAMPLING.PROGRAMME_CODE);
- String comment = ImportHelper.read(reader, SAMPLING.PLAN_COMMENT);
- PeriodDates period = ImportHelper.readPeriod(reader, SAMPLING.PROGRAMME_DEBUT, SAMPLING.PROGRAMME_FIN);
-
- sampleRow.setFishingZonesInfos(fishingZoneInfos);
- sampleRow.setNbObservants(nbObservants);
- sampleRow.setAverageTideTime(averageTideTime);
- sampleRow.setProgramName(programName);
- sampleRow.setPeriodBegin(period.getFromDate());
- sampleRow.setPeriodEnd(period.getThruDate());
- sampleRow.setComment(comment);
-
- // 16 fixed columns : 13 before months and 3 after
- final int nbFixedColumns = 16;
- // Months begin at 14th column
- final int firstMonthColumnId = 13;
- int nbTotalColumns = reader.getColumnCount();
- // Note : nbTotalColumns must be > nbFixedColumns
- int lastMonthColumnId = firstMonthColumnId + nbTotalColumns - nbFixedColumns;
-
- DateFormat dateFormat = SAMPLING.getDateFormat();
-
- for (int i = firstMonthColumnId; i < lastMonthColumnId; i++) {
-
- Date monthDate = dateFormat.parse(reader.getHeader(i));
- Integer monthValue = StringUtils.isEmpty(reader.get(i)) ? null : Integer.parseInt(reader.get(i));
-
- if (monthValue != null && DateUtils.between(monthDate, sampleRow.getPeriodBegin(), sampleRow.getPeriodEnd())) {
- SampleMonthDAO dao = SuiviObsmerModelDAOHelper.getSampleMonthDAO(transaction);
-
- SampleMonth month = sampleRow.getSampleMonth(monthDate);
-
- if (month == null) {
- month = dao.create(
- SampleMonth.SAMPLE_ROW, sampleRow,
- SampleMonth.PERIOD_DATE, monthDate);
- sampleRow.addSampleMonth(month);
- }
- month.setExpectedTidesValue(monthValue);
- }
-// else if (monthValue != null) {
-// // exception, outOfBounds month
-// if (log.isErrorEnabled()) {
-// log.error("Month out of bounds : value=" + monthValue + " _ monthDate=" + monthDate +
-// " _ periode=" + sampleRow.getPeriodBegin() + " au " + sampleRow.getPeriodEnd());
-// }
-// }
- }
- }
-
-// protected static final int TAB_MONTH = 0;
-// protected static final int TAB_YEAR = 1;
-
-// @Deprecated
-// protected int[] getMonthAndYear(String str) throws ParseException {
-// DateFormat dateFormat = new SimpleDateFormat("MM/yyyy");
-// int[] result = new int[2];
-//
-// Date date = dateFormat.parse(str);
-// Calendar calendar = new GregorianCalendar();
-// calendar.setTime(date);
-//
-// result[TAB_MONTH] = calendar.get(Calendar.MONTH) + 1;
-// result[TAB_YEAR] = calendar.get(Calendar.YEAR);
-// return result;
-// }
-
-}
Copied: trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceSamplingImpl.java (from rev 354, trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services/ServiceSamplingImpl.java)
===================================================================
--- trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceSamplingImpl.java (rev 0)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceSamplingImpl.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -0,0 +1,893 @@
+/*
+ * *##%
+ * 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.service;
+
+import com.csvreader.CsvReader;
+import com.csvreader.CsvWriter;
+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.bean.FacadeRow;
+import fr.ifremer.wao.bean.FacadeRowImpl;
+import fr.ifremer.wao.bean.ImportResults;
+import fr.ifremer.wao.bean.ImportResultsImpl;
+import fr.ifremer.wao.bean.SamplingFilter;
+import fr.ifremer.wao.entity.*;
+import fr.ifremer.wao.io.WaoCsvHeader.FISHING_ZONE;
+import fr.ifremer.wao.io.WaoCsvHeader.SAMPLING;
+import fr.ifremer.wao.io.WaoCsvHeader.SamplingHeader;
+import fr.ifremer.wao.io.ExportHelper;
+import fr.ifremer.wao.io.ExportHelper;
+import fr.ifremer.wao.io.SamplingExport;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.charset.Charset;
+import java.text.DateFormat;
+import java.text.NumberFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.GregorianCalendar;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import org.apache.commons.lang.StringUtils;
+import org.nuiton.topia.TopiaContext;
+import org.nuiton.topia.TopiaException;
+import org.nuiton.topia.framework.TopiaQuery;
+import org.nuiton.topia.framework.TopiaQuery.Op;
+import org.nuiton.topia.persistence.util.EntityLoador;
+import org.nuiton.util.DateUtils;
+import org.nuiton.util.PeriodDates;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * ServiceSamplingImpl
+ *
+ * Created: 30 nov. 2009
+ *
+ * @author fdesbois
+ * @version $Revision$
+ *
+ * Mise a jour: $Date$
+ * par : $Author$
+ */
+public class ServiceSamplingImpl implements ServiceSampling {
+
+ private static final Logger log = LoggerFactory.getLogger(ServiceSamplingImpl.class);
+
+ protected TopiaContext rootContext;
+
+ public ServiceSamplingImpl() throws WaoException {
+ rootContext = WaoContext.getTopiaRootContext();
+ }
+
+ @Override
+ public void createUpdateSampleRow(SampleRow row, List<Boat> boats, SampleRowLog rowLog) throws WaoException {
+ TopiaContext transaction = null;
+ try {
+ transaction = rootContext.beginTransaction();
+
+ SampleRowLogDAO logDAO = WaoModelDAOHelper.getSampleRowLogDAO(transaction);
+ WaoContext.prepareTopiaId(SampleRowLog.class, rowLog);
+ logDAO.update(rowLog);
+
+ boolean newRow = WaoContext.prepareTopiaId(SampleRow.class, row);
+
+ if (log.isDebugEnabled()) {
+ log.debug("new sampleRow : " + newRow);
+ log.debug("samplRow topiaId : " + row.getTopiaId());
+ }
+
+ String pattern = DateUtils.MONTH_PATTERN;
+ DateFormat dateFormat = new SimpleDateFormat(pattern);
+
+ SampleRow oldRow = null;
+ Profession oldProfession = null;
+ Company oldCompany = null;
+ Map<String, SampleMonth> oldMonths = new HashMap<String, SampleMonth>();
+ List<FishingZone> oldZones = new ArrayList<FishingZone>();
+ // UPDATE
+ if (!newRow) {
+ // Prepare data for logging or deleting oldMonths
+ TopiaContext transaction2 = rootContext.beginTransaction();
+ SampleRowDAO oldDAO = WaoModelDAOHelper.getSampleRowDAO(transaction2);
+ oldRow = oldDAO.findByTopiaId(row.getTopiaId());
+ oldCompany = oldRow.getCompany();
+ oldProfession = oldRow.getProfession();
+ for (SampleMonth month : oldRow.getSampleMonth()) {
+ oldMonths.put(month.getTopiaId(), month);
+ }
+ oldZones = oldRow.getFishingZone();
+ transaction2.closeContext();
+
+ // NbObservants
+ if (oldRow.getNbObservants() != row.getNbObservants()) {
+ rowLog.addChange("Le nombre d'observateurs est passé de " + oldRow.getNbObservants() + " à " + row.getNbObservants());
+ }
+ // AverageTideTime
+ if (oldRow.getAverageTideTime() != row.getAverageTideTime()) {
+ rowLog.addChange("La durée moyenne d'une marée est passé de " + oldRow.getAverageTideTime() + " jours à " + row.getAverageTideTime());
+ }
+ } else {
+ rowLog.addChange("Le nombre d'observateurs est " + row.getNbObservants());
+ rowLog.addChange("La durée moyenne d'une marée est " + row.getAverageTideTime());
+ }
+ // ChangeLog Company
+ rowLog.addChangeCompany(oldCompany, row.getCompany());
+ // ChangeLog Program
+ String oldProgram = oldRow != null ? oldRow.getProgramName() : null;
+ rowLog.addChangeProgram(oldProgram, row.getProgramName());
+ // ChangeLog Period
+ PeriodDates oldPeriod = null;
+ if (oldRow != null) {
+ oldPeriod = new PeriodDates(oldRow.getPeriodBegin(), oldRow.getPeriodEnd());
+ }
+ PeriodDates newPeriod = new PeriodDates(row.getPeriodBegin(), row.getPeriodEnd());
+ rowLog.addChangePeriod(oldPeriod, newPeriod, pattern);
+
+ // Save Profession
+ ProfessionDAO professionDAO = WaoModelDAOHelper.getProfessionDAO(transaction);
+ WaoContext.prepareTopiaId(Profession.class, row.getProfession());
+ rowLog.addChangeProfession(oldProfession, row.getProfession());
+ professionDAO.update(row.getProfession());
+
+ // Save sampleMonth
+ SampleMonthDAO monthDAO = WaoModelDAOHelper.getSampleMonthDAO(transaction);
+
+ // Delete oldMonths
+ List<SampleMonth> newMonths = row.getSampleMonth();
+ for (SampleMonth oldMonth : oldMonths.values()) {
+ if (!newMonths.contains(oldMonth)) {
+ String date = dateFormat.format(oldMonth.getPeriodDate());
+ // Delete old month : add to log
+ monthDAO.delete(oldMonth);
+ rowLog.addChange("Le mois " + date + " a été supprimé, " +
+ "l'ancienne valeur d'effort était " + oldMonth.getExpectedTidesValue());
+ }
+ }
+ // Create or update months
+ for (SampleMonth month : newMonths) {
+ boolean monthCreated = WaoContext.prepareTopiaId(SampleMonth.class, month);
+ String date = dateFormat.format(month.getPeriodDate());
+ if (monthCreated) {
+ // log create month
+ rowLog.addChange("Le mois " + date + " a été créé avec un nombre de marées de " + month.getExpectedTidesValue());
+ } else {
+ SampleMonth oldMonth = oldMonths.get(month.getTopiaId());
+ if (oldMonth.getExpectedTidesValue() != month.getExpectedTidesValue()) {
+ // log change month value
+ rowLog.addChange("Le nombre de marées du mois " + date + " est passé de " +
+ oldMonth.getExpectedTidesValue() + " à " + month.getExpectedTidesValue());
+ }
+ }
+ monthDAO.update(month);
+ }
+
+ // Remove no longer elligibleBoats
+ row.removeNoLongerElligibleBoats(boats);
+ // Save new elligibleBoats
+ ElligibleBoatDAO dao = WaoModelDAOHelper.getElligibleBoatDAO(transaction);
+ for (Boat boat : boats) {
+ if (!row.hasElligibleBoat(boat)) {
+ ElligibleBoat elligibleBoat = dao.create();
+ elligibleBoat.setSampleRow(row);
+ elligibleBoat.setGlobalActive(true);
+ elligibleBoat.setBoat(boat);
+ row.addElligibleBoat(elligibleBoat);
+ }
+ }
+
+ // ChangeLog boats
+ String oldBoats = oldRow != null ? oldRow.getMainElligibleBoatsAsString() : "";
+ rowLog.addChangeBoats(oldBoats, row.getMainElligibleBoatsAsString());
+
+
+ // Remove no longer linked FishingZone
+ List<FishingZone> newZones = row.getFishingZone();
+ for (FishingZone oldZone : oldZones) {
+ if (!newZones.contains(oldZone)) {
+ updateFishingZones(transaction, oldZone.getTopiaId(), row, true);
+ rowLog.addChange("La zone de pêche " + oldZone.getCode() + " a été dissociée de la ligne");
+ }
+ }
+ // Add new linked FishingZone
+ // ConcurrentModificationException ????
+ for (FishingZone zone : new ArrayList<FishingZone>(newZones)) {
+ if (!oldZones.contains(zone)) {
+ 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);
+ if (log.isDebugEnabled()) {
+ log.debug("update row : " + row);
+ }
+ row.addSampleRowLog(rowLog);
+ rowDAO.update(row);
+
+ if (log.isDebugEnabled()) {
+ log.debug("Change log : " + rowLog.getLogText());
+ log.debug("commit transaction !");
+ }
+ transaction.commitTransaction();
+ //transaction.closeContext();
+ } catch (Exception eee) {
+ WaoContext.serviceException(transaction,
+ "Impossible de sauvegarder la ligne d'échantillon", eee);
+ } finally {
+ WaoContext.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);
+ }
+
+// @Override
+// public List<SampleRowLog> getSampleRowLogs(SampleRow sampleRow) throws WaoException {
+// TopiaContext transaction = null;
+// List<SampleRowLog> results = new ArrayList<SampleRowLog>();
+// try {
+// transaction = rootContext.beginTransaction();
+//
+// SampleRowLogDAO dao = WaoModelDAOHelper.getSampleRowLogDAO(transaction);
+// results = dao.createQuery().add(SampleRowLog.SAMPLE_ROW, sampleRow).addOrderDesc(TopiaEntity.TOPIA_CREATE_DATE).executeToEntityList();
+//
+// transaction.closeContext();
+// } catch (Exception eee) {
+// WaoContext.serviceException(transaction,
+// "Impossible de récupérer l'historique de la ligne d'échantillonnage", eee);
+// }
+// return results;
+// }
+
+ @Override
+ public FacadeRow getSampleRowsOrderedByFishingZone(PeriodDates period, Company company) throws WaoException {
+ TopiaContext transaction = null;
+ FacadeRow result = new FacadeRowImpl();
+ try {
+ if (period.getFromDate() == null || period.getThruDate() == null) {
+ throw new IllegalArgumentException("PeriodBegin date and/or PeriodEnd date can't be null !");
+ }
+ transaction = rootContext.beginTransaction();
+
+ SampleRowDAO dao = WaoModelDAOHelper.getSampleRowDAO(transaction);
+
+ TopiaQuery query = dao.createQuery("S").addDistinct().
+ addFrom(FishingZone.class.getName() + " F").
+ add("S IN elements(F." + FishingZone.SAMPLE_ROW + ")");
+
+ if (company != null) {
+ query.add("S." + SampleRow.COMPANY, company);
+ }
+
+ // Prepare period dates
+ period.initDayOfMonthExtremities();
+ query.add("S." + SampleRow.PERIOD_BEGIN, Op.LT, period.getThruDate()).
+ add("S." + SampleRow.PERIOD_END, Op.GT, period.getFromDate());
+
+ // Order By facade, sector, districtCode, sampleRowCode
+ String zoneOrder = "F." + FishingZone.FACADE_NAME + " , F." + FishingZone.SECTOR_NAME + ", F." + FishingZone.DISTRICT_CODE;
+ query.addOrder(zoneOrder).addOrder("S." + SampleRow.CODE).addSelect(zoneOrder);
+ // Load data
+ //query.addLoad(SampleRow.PROFESSION, SampleRow.COMPANY);
+
+ if (log.isDebugEnabled()) {
+ log.debug("Query : " + query);
+ }
+
+ List<SampleRow> results = dao.findAllByQuery(query);
+
+ for (SampleRow row : results) {
+ // use FacadeRow to complete ordering using maps
+ result.addRow(row);
+ }
+
+ //transaction.closeContext();
+ } catch (Exception eee) {
+ WaoContext.serviceException(transaction,
+ "Impossible de récupérer la liste des lignes du plan d'échantillonnage", eee);
+ } finally {
+ WaoContext.closeTransaction(transaction);
+ }
+ return result;
+ }
+
+ @Override
+ public List<String> getPrograms(Company company) throws WaoException {
+ TopiaContext transaction = null;
+ List<String> results = new ArrayList<String>();
+ try {
+ transaction = rootContext.beginTransaction();
+
+ SampleRowDAO dao = WaoModelDAOHelper.getSampleRowDAO(transaction);
+ TopiaQuery query = dao.createQuery();
+
+ if (company != null) {
+ query.add(SampleRow.COMPANY, company);
+ }
+
+ results = (List<String>)query.setSelect("DISTINCT " + SampleRow.PROGRAM_NAME).execute();
+
+ //transaction.closeContext();
+ } catch (Exception eee) {
+ WaoContext.serviceException(transaction,
+ "Impossible de charger la liste des programmes", eee);
+ } finally {
+ WaoContext.closeTransaction(transaction);
+ }
+ return results;
+ }
+
+ @Override
+ public List<SampleRow> getSampleRowsByFilter(SamplingFilter filter) throws WaoException {
+ TopiaContext transaction = null;
+ List<SampleRow> results = new ArrayList<SampleRow>();
+ try {
+ transaction = rootContext.beginTransaction();
+
+ SampleRowDAO dao = WaoModelDAOHelper.getSampleRowDAO(transaction);
+
+ TopiaQuery query = dao.createQuery("S").addDistinct().addOrder("S." + SampleRow.CODE);
+
+ query = filter.prepareQueryForSampling(query, "S");
+
+ if (log.isDebugEnabled()) {
+ log.debug("Query : " + query);
+ }
+
+// if (finished) {
+// // Only rows which are not finished will be kept
+// Date current = WaoContext.getCurrentDate();
+// query.add(SampleRow.PERIOD_END, Op.GE, current);
+// }
+
+// if (filter.getCompany() != null) {
+// query.add("S." + SampleRow.COMPANY, filter.getCompany());
+// }
+
+ results = dao.findAllByQuery(query);
+
+ //transaction.closeContext();
+ } catch (Exception eee) {
+ WaoContext.serviceException(transaction,
+ "Impossible de récupérer la liste des lignes du plan d'échantillonnage", eee);
+ } finally {
+ WaoContext.closeTransaction(transaction);
+ }
+ return results;
+ }
+
+ @Override
+ public SampleRow getSampleRow(String sampleRowId) throws WaoException {
+ TopiaContext transaction = null;
+ SampleRow result = null;
+ try {
+ transaction = rootContext.beginTransaction();
+
+ SampleRowDAO dao = WaoModelDAOHelper.getSampleRowDAO(transaction);
+
+ result = dao.findByTopiaId(sampleRowId);
+
+ //transaction.closeContext();
+ } catch (Exception eee) {
+ WaoContext.serviceException(transaction,
+ "Impossible de charger la ligne d'échantillon ayant pour identifiant : " + sampleRowId,
+ eee);
+ } finally {
+ WaoContext.closeTransaction(transaction);
+ }
+ return result;
+ }
+
+ @Override
+ public void deleteSampleRow(SampleRow sampleRow) throws WaoException {
+ TopiaContext transaction = null;
+ try {
+ transaction = rootContext.beginTransaction();
+
+ SampleRowDAO dao = WaoModelDAOHelper.getSampleRowDAO(transaction);
+
+ SampleRow row = dao.findByTopiaId(sampleRow.getTopiaId());
+
+ dao.delete(row);
+
+ transaction.commitTransaction();
+ //transaction.closeContext();
+ } catch (Exception eee) {
+ WaoContext.serviceException(transaction,
+ "Impossible de supprimer la ligne d'échantillon : " + sampleRow.getCode(),
+ eee);
+ } finally {
+ WaoContext.closeTransaction(transaction);
+ }
+ }
+
+ @Override
+ public String getNewSampleRowCode(Date beginDate) throws WaoException {
+ TopiaContext transaction = null;
+ String result = null;
+ if (beginDate == null) {
+ return result;
+ }
+ try {
+ transaction = rootContext.beginTransaction();
+
+ Calendar begin = new GregorianCalendar();
+ begin.setTime(beginDate);
+ int year = begin.get(Calendar.YEAR);
+
+ SampleRowDAO dao = WaoModelDAOHelper.getSampleRowDAO(transaction);
+ TopiaQuery query = dao.createQuery().add(SampleRow.CODE, Op.LIKE, year + "_%");
+
+ String maxCode = query.executeToString("MAX(" + SampleRow.CODE + ")");
+
+ if (log.isDebugEnabled()) {
+ log.debug("Max code found : " + maxCode);
+ }
+
+ int num = 1;
+ if (!StringUtils.isEmpty(maxCode)) {
+ String[] part = maxCode.split("_");
+ num = Integer.parseInt(part[1]) + 1;
+ }
+ String str = StringUtils.leftPad("" + num, 4, "0");
+ result = year + "_" + str;
+
+ //transaction.closeContext();
+ } catch (Exception eee) {
+ WaoContext.serviceException(transaction,
+ "Impossible de récupérer un nouveau code pour une ligne d'échantillonnage",
+ eee);
+ } finally {
+ WaoContext.closeTransaction(transaction);
+ }
+ return result;
+ }
+
+ @Override
+ public SampleRow getNewSampleRow() {
+ SampleRow row = new SampleRowImpl();
+ row.setProfession(new ProfessionImpl());
+ row.setFishingZone(new ArrayList<FishingZone>());
+ //row.setProgram(new ProgramImpl());
+ row.setElligibleBoat(new ArrayList<ElligibleBoat>());
+ row.setSampleMonth(new ArrayList<SampleMonth>());
+ return row;
+ }
+
+ @Override
+ public SampleMonth getNewSampleMonth(Date period, SampleRow row) {
+ SampleMonth month = new SampleMonthImpl();
+ month.setSampleRow(row);
+ month.setPeriodDate(period);
+ return month;
+ }
+
+ /**
+ * Create a new profession from an existing one. Copy all attributes values from
+ * the profession in argument to a new profession not created yet in database.
+ *
+ * @param profession the profession source
+ * @return a new Profession
+ */
+ @Override
+ public Profession getNewProfession(Profession profession) {
+ Profession newProfession = new ProfessionImpl();
+ EntityLoador<Profession> loador = EntityLoador.newEntityLoador(Profession.class,
+ Profession.CODE_DCF5, Profession.LIBELLE, Profession.MESH_SIZE, Profession.OTHER, Profession.SIZE, Profession.SPECIES);
+ loador.load(profession, newProfession, false);
+ return newProfession;
+ }
+
+ @Override
+ public InputStream exportSamplingPlanCsv(WaoUser user, PeriodDates period) throws WaoException {
+ TopiaContext transaction = null;
+ InputStream result = null;
+ CsvWriter writer = null;
+ try {
+ transaction = rootContext.beginTransaction();
+
+ File file = File.createTempFile("wao-samplingPlan-", ".csv");
+ file.deleteOnExit();
+
+ FileOutputStream output = new FileOutputStream(file);
+ writer = new CsvWriter(output, ',', Charset.forName("UTF-8"));
+
+ // Get min and max dates to have the biggest period
+// Date min = (Date)query.executeToObject("MIN(S." + SampleRow.PERIOD_BEGIN + ")");
+// Date max = (Date)query.executeToObject("MAX(S." + SampleRow.PERIOD_END + ")");
+
+// PeriodDates periodMax = new PeriodDates(min, max);
+ period.setPattern(SAMPLING.defaultDatePattern());
+ List<String> monthHeaders = period.getFormatedMonths();
+
+ SamplingExport export = new SamplingExport(writer, user, monthHeaders);
+
+ export.writeHeaders();
+
+ // Get sampleRows from database filtered by company if needed
+ // (only for user) and period
+ SampleRowDAO dao = WaoModelDAOHelper.getSampleRowDAO(transaction);
+ TopiaQuery query = dao.createQuery("S");
+
+ if (!user.getAdmin()) {
+ query.add("S." + SampleRow.COMPANY, user.getCompany());
+ }
+
+ // Prepare period dates
+ period.initDayOfMonthExtremities();
+ query.add("S." + SampleRow.PERIOD_BEGIN, Op.LT, period.getThruDate()).
+ add("S." + SampleRow.PERIOD_END, Op.GT, period.getFromDate());
+
+ query.addOrder("S." + SampleRow.CODE);
+
+ List<SampleRow> rows = dao.findAllByQuery(query);
+
+ DateFormat dateFormat = SAMPLING.getDateFormat();
+ NumberFormat numberFormat = SAMPLING.getNumberFormat();
+
+ for (SampleRow row : rows) {
+ export.newRecord();
+
+ if (log.isDebugEnabled()) {
+ log.debug("add sampleRow : " + row.getCode());
+ }
+
+ export.record(SAMPLING.PLAN_CODE, row.getCode());
+ Company company = row.getCompany();
+ if (company != null) {
+ export.record(SAMPLING.SOCIETE_NOM, company.getName());
+ }
+
+ // Profession can't be null
+ Profession profession = row.getProfession();
+ export.record(SAMPLING.METIER_CODE_DCF5, profession.getCodeDCF5());
+ export.record(SAMPLING.METIER_MAILLAGE, profession.getMeshSize());
+ export.record(SAMPLING.METIER_TAILLE, profession.getSize());
+ export.record(SAMPLING.METIER_AUTRE, profession.getOther());
+ export.record(SAMPLING.METIER_LIBELLE, profession.getLibelle());
+ export.record(SAMPLING.METIER_ESPECES, profession.getSpecies());
+
+ export.record(SAMPLING.PROGRAMME_CODE, row.getProgramName());
+ export.record(SAMPLING.PROGRAMME_DEBUT, dateFormat.format(row.getPeriodBegin()));
+ export.record(SAMPLING.PROGRAMME_FIN, dateFormat.format(row.getPeriodEnd()));
+
+ export.record(FISHING_ZONE.PECHE_FACADE, row.getFacade());
+ export.record(FISHING_ZONE.PECHE_ZONE, row.getSectors());
+ export.record(SAMPLING.PECHE_AUTRE, row.getFishingZonesInfos());
+
+ String divisions = "";
+ String separator = FISHING_ZONE.getDistrictCodeSeparator();
+ for (FishingZone zone : row.getFishingZone()) {
+ divisions += separator + zone.getDistrictCode();
+ }
+
+ // There is at least one district in row, so no problem with substring
+ export.record(FISHING_ZONE.PECHE_DIVISION, divisions.substring(separator.length()));
+
+ export.record(SAMPLING.PLAN_NB_OBSERV, numberFormat.format(row.getNbObservants()));
+ export.record(SAMPLING.PLAN_DUREE_MOY, numberFormat.format(row.getAverageTideTime()));
+ export.record(SAMPLING.PLAN_COMMENT, String.valueOf(row.getComment()));
+
+ export.recordMonths(row);
+
+// for (int i = 0; i < monthHeaders.size(); i++) {
+// // Get date from monthHeaders list
+// Date month = dateFormat.parse(monthHeaders.get(i));
+// // Retrieve sampleMonth corresponding
+// SampleMonth sampleMonth = row.getSampleMonth(month);
+// // Add it to the file if it exists
+// if (sampleMonth != null) {
+// // Prepare index for record
+// int index = SAMPLING.getStartIndexForMonths() + i;
+// String expected = String.valueOf(sampleMonth.getExpectedTidesValue());
+// String real = String.valueOf(sampleMonth.getRealTidesValue());
+// // The admin as only expected value (to be the same as
+// // in import)
+// if (user.getAdmin()) {
+// export.record(index, expected); //record[index] = expected;
+// // The user as both expected and real values
+// } else {
+// export.record(index, expected + " (" + real + ")");
+// }
+// }
+// }
+
+ export.writeRecord();
+ }
+
+ result = new FileInputStream(file);
+
+ } catch (Exception eee) {
+ DateFormat dateFormat = SAMPLING.getDateFormat();
+ WaoContext.serviceException(transaction,
+ "Impossible d'exporter le plan d'échantillonnage sur la période du " +
+ dateFormat.format(period.getFromDate()) + " au " +
+ dateFormat.format(period.getThruDate()), eee);
+ } finally {
+ if (writer != null) {
+ writer.close();
+ }
+ WaoContext.closeTransaction(transaction);
+ }
+ return result;
+ }
+
+ @Override
+ public ImportResults importSamplingPlanCsv(InputStream input) throws WaoException {
+ TopiaContext transaction = null;
+ ImportResults result = new ImportResultsImpl();
+ //int[] result = new int[3];
+ int currRow = 0;
+ SampleRow row = null;
+ try {
+ transaction = rootContext.beginTransaction();
+
+ CsvReader reader = new CsvReader(input, Charset.forName("UTF-8"));
+ reader.readHeaders();
+
+ SampleRowDAO dao = WaoModelDAOHelper.getSampleRowDAO(transaction);
+
+ //int nbImported = 0;
+ //int nbRefused = 0;
+
+ while(reader.readRecord()) {
+
+ currRow++;
+
+ if (log.isTraceEnabled()) {
+ log.trace(" " + Arrays.asList(reader.getValues()));
+ }
+
+ String code = ImportHelper.readSampleRowCode(reader); //reader.get(SAMPLING.PLAN_CODE.name()).trim();
+
+ if (StringUtils.isEmpty(code)) {
+ continue;
+ }
+
+ String districts = reader.get(FISHING_ZONE.PECHE_DIVISION.name());
+
+ row = dao.findByCode(code);
+ // Refuse existing SampleRow
+ if (row != null) {
+ result.addError(currRow, "[CODE = " + code + "] refusé : Code déjà existant");
+ result.incNbRefused();
+ // Refuse Fishing zones empty
+ } else if (StringUtils.isEmpty(districts)) {
+ result.addError(currRow, "[CODE = " + code + "] refusé : Zone de pêche non renseigné");
+ result.incNbRefused(); //nbRefused++;
+ } else {
+ row = dao.create(SampleRow.CODE, code);
+
+ String companyName = ImportHelper.read(reader, SAMPLING.SOCIETE_NOM);
+
+ // Create link with company if set in file
+ if (!StringUtils.isEmpty(companyName)) {
+ CompanyDAO companyDAO = WaoModelDAOHelper.getCompanyDAO(transaction);
+ Company company = companyDAO.findByName(companyName);
+ if (company == null) {
+ throw new WaoBusinessException(Type.IMPORT_ERROR, this.getClass(),
+ "Erreur à la ligne " + currRow + " [CODE = " + code + "] : " +
+ "La société portant le nom '" + companyName + "' n'existe pas dans l'application");
+ }
+ row.setCompany(company);
+ }
+
+ // Import profession. Creation if not exist
+ Profession profession = importProfession(transaction, reader);
+ row.setProfession(profession);
+
+ // Import zones and set them to the row
+ // throw WaoException if FishingZone doesn't exist
+ importFishingZones(transaction, districts, currRow, row);
+
+ updateRow(transaction, row, reader);
+ result.incNbImported(); //nbImported++;
+ }
+ // Commit row by row
+ transaction.commitTransaction();
+ }
+
+ //transaction.closeContext();
+
+ } catch (NumberFormatException eee) {
+ WaoContext.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,
+ "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,
+ "Erreur à la ligne " + currRow + " [CODE = " + row.getCode() + "]",
+ eee);
+ } finally {
+ WaoContext.closeTransaction(transaction);
+ }
+ return result;
+ }
+
+ /**
+ * Import a profession from CSV File from importSamplingPlanCsv method.
+ * This profession is imported for a new SampleRow line.
+ * Key value for the profession : codeDCF5, meshSize, size, other.
+ * If profession already exists, update libelle and species.
+ * @param transaction Topia transaction for using ProfessionDAO
+ * @param reader CsvReader for getting Profession parameters
+ * @return an existing Profession or a new one
+ * @throws IOException for reader errors
+ * @throws TopiaException for dao errors
+ */
+ protected Profession importProfession(TopiaContext transaction, CsvReader reader)
+ throws IOException, TopiaException {
+
+ String codeDCF5 = reader.get(SAMPLING.METIER_CODE_DCF5.name()).trim();
+ String maillage = reader.get(SAMPLING.METIER_MAILLAGE.name()).trim();
+ String taille = reader.get(SAMPLING.METIER_TAILLE.name()).trim();
+ String autre = reader.get(SAMPLING.METIER_AUTRE.name()).trim();
+ String libelle = reader.get(SAMPLING.METIER_LIBELLE.name()).trim();
+ String especes = reader.get(SAMPLING.METIER_ESPECES.name()).trim();
+
+ ProfessionDAO dao = WaoModelDAOHelper.getProfessionDAO(transaction);
+ Map<String, Object> existParams = new HashMap<String, Object>();
+ existParams.put(Profession.CODE_DCF5, codeDCF5);
+ existParams.put(Profession.MESH_SIZE, maillage);
+ existParams.put(Profession.SIZE, taille);
+ existParams.put(Profession.OTHER, autre);
+
+ Profession profession = dao.findByProperties(existParams);
+
+ if (profession == null) {
+ profession = dao.create(existParams);
+ }
+
+ profession.setLibelle(libelle);
+ profession.setSpecies(especes);
+
+ return profession;
+ }
+
+ /**
+ * Import a fishingZone from CSV File from importSamplingPlanCsv method.
+ * These fishingZones are imported for a new SampleRow line.
+ * Key value for the fishingZone : districtCode.
+ * The districts argument contains multiple districtCode separating with " - ".
+ * The fishingZone must be exist in database.
+ * @param transaction Topia transaction for using FishingZoneDAO
+ * @param districts String which contains several fishingZone districtCodes
+ * @param currRow Row number in the line for the SampleRow
+ * @param row SampleRow linked with districts (from Csv file)
+ * @throws TopiaException for dao errors
+ * @throws WaoException if a FishingZone doesn't exist.
+ */
+ protected void importFishingZones(TopiaContext transaction, String districts, int currRow, SampleRow row)
+ throws TopiaException, WaoException {
+
+ FishingZoneDAO dao = WaoModelDAOHelper.getFishingZoneDAO(transaction);
+
+ List<String> districtList = new ArrayList<String>(Arrays.asList(districts.split(FISHING_ZONE.getDistrictCodeSeparator())));
+
+ if (log.isTraceEnabled()) {
+ log.trace("FishingZone districts : " + districts);
+ log.trace("FishingZone nb zones : " + districtList.size());
+ }
+ for (String districtCode : districtList) {
+ FishingZone zone = dao.findByDistrictCode(districtCode.trim());
+ if (zone == null) {
+ throw new WaoBusinessException(Type.IMPORT_ERROR, this.getClass(),
+ "Erreur à la ligne " + currRow + " [CODE = " + row.getCode() + "] : " +
+ "Cette ligne est lié à une zone inexistante : " + districtCode);
+ }
+ row.addFishingZone(zone);
+ }
+ }
+
+ /**
+ * Update a SampleRow from CSV File from importSamplingPlanCsv method.
+ * Program must be set to get beginDate and endDate for getting correct months.
+ * SampleMonth will be created corresponding to program period.
+ * Careful : fixed columns set to 16 and months columns start to 13.
+ * Updatable fields : fishingZoneInfos, nbObservants, averageTideTime, sampleMonths.
+ * @param transaction Topia transaction for using FishingZoneDAO
+ * @param sampleRow
+ * @param reader CsvReader to get values for updatable fields
+ * @throws IOException for CsvReader errors
+ * @throws TopiaException for SampleMonthDAO errors
+ * @throws ParseException for format errors
+ * @see #getMonthAndYear(java.lang.String)
+ */
+ protected void updateRow(TopiaContext transaction, SampleRow sampleRow, CsvReader reader)
+ throws IOException, TopiaException, ParseException {
+
+ String fishingZoneInfos = ImportHelper.read(reader, SAMPLING.PECHE_AUTRE);
+ int nbObservants = ImportHelper.readInt(reader, SAMPLING.PLAN_NB_OBSERV);
+ String averageStr = ImportHelper.read(reader, SAMPLING.PLAN_DUREE_MOY);
+ averageStr = averageStr.replaceAll(",", ".");
+ double averageTideTime = Double.parseDouble(averageStr);
+ String programName = ImportHelper.read(reader, SAMPLING.PROGRAMME_CODE);
+ String comment = ImportHelper.read(reader, SAMPLING.PLAN_COMMENT);
+ PeriodDates period = ImportHelper.readPeriod(reader, SAMPLING.PROGRAMME_DEBUT, SAMPLING.PROGRAMME_FIN);
+
+ sampleRow.setFishingZonesInfos(fishingZoneInfos);
+ sampleRow.setNbObservants(nbObservants);
+ sampleRow.setAverageTideTime(averageTideTime);
+ sampleRow.setProgramName(programName);
+ sampleRow.setPeriodBegin(period.getFromDate());
+ sampleRow.setPeriodEnd(period.getThruDate());
+ sampleRow.setComment(comment);
+
+ // 16 fixed columns : 13 before months and 3 after
+ final int nbFixedColumns = 16;
+ // Months begin at 14th column
+ final int firstMonthColumnId = 13;
+ int nbTotalColumns = reader.getColumnCount();
+ // Note : nbTotalColumns must be > nbFixedColumns
+ int lastMonthColumnId = firstMonthColumnId + nbTotalColumns - nbFixedColumns;
+
+ DateFormat dateFormat = SAMPLING.getDateFormat();
+
+ for (int i = firstMonthColumnId; i < lastMonthColumnId; i++) {
+
+ Date monthDate = dateFormat.parse(reader.getHeader(i));
+ Integer monthValue = StringUtils.isEmpty(reader.get(i)) ? null : Integer.parseInt(reader.get(i));
+
+ if (monthValue != null && DateUtils.between(monthDate, sampleRow.getPeriodBegin(), sampleRow.getPeriodEnd())) {
+ SampleMonthDAO dao = WaoModelDAOHelper.getSampleMonthDAO(transaction);
+
+ SampleMonth month = sampleRow.getSampleMonth(monthDate);
+
+ if (month == null) {
+ month = dao.create(
+ SampleMonth.SAMPLE_ROW, sampleRow,
+ SampleMonth.PERIOD_DATE, monthDate);
+ sampleRow.addSampleMonth(month);
+ }
+ month.setExpectedTidesValue(monthValue);
+ }
+ }
+ }
+
+}
Deleted: trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceSynthesisImpl.java
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services/ServiceSynthesisImpl.java 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceSynthesisImpl.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,493 +0,0 @@
-/*
- * *##%
- * SuiviObsmer :: 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.suiviobsmer.services;
-
-import fr.ifremer.suiviobsmer.SuiviObsmerContext;
-import fr.ifremer.suiviobsmer.SuiviObsmerException;
-import fr.ifremer.suiviobsmer.SuiviObsmerModelDAOHelper;
-import fr.ifremer.suiviobsmer.bean.BoardingResult;
-import fr.ifremer.suiviobsmer.bean.BoardingResultImpl;
-import fr.ifremer.suiviobsmer.bean.ContactStateStatistics;
-import fr.ifremer.suiviobsmer.bean.ContactStateStatisticsImpl;
-import fr.ifremer.suiviobsmer.bean.SamplingFilter;
-import fr.ifremer.suiviobsmer.entity.Boat;
-import fr.ifremer.suiviobsmer.entity.Company;
-import fr.ifremer.suiviobsmer.entity.Contact;
-import fr.ifremer.suiviobsmer.entity.ContactDAO;
-import fr.ifremer.suiviobsmer.entity.SampleMonth;
-import fr.ifremer.suiviobsmer.entity.SampleMonthDAO;
-import fr.ifremer.suiviobsmer.entity.SampleRow;
-import fr.ifremer.suiviobsmer.entity.WaoUser;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.SortedMap;
-import java.util.TreeMap;
-import org.nuiton.topia.TopiaContext;
-import org.nuiton.topia.framework.TopiaContextImplementor;
-import org.nuiton.topia.framework.TopiaQuery;
-import org.nuiton.topia.framework.TopiaQuery.Op;
-import org.nuiton.topia.persistence.TopiaEntity;
-import org.nuiton.util.PeriodDates;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * ServiceSynthesisImpl
- *
- * Created: 7 janv. 2010
- *
- * @author fdesbois
- * @version $Revision$
- *
- * Mise a jour: $Date$
- * par : $Author$
- */
-public class ServiceSynthesisImpl implements ServiceSynthesis {
-
- private static final Logger log = LoggerFactory.getLogger(ServiceSynthesisImpl.class);
-
- protected TopiaContext rootContext;
-
- public ServiceSynthesisImpl() throws SuiviObsmerException {
- rootContext = SuiviObsmerContext.getTopiaRootContext();
- }
-
- @Override
- public List<SortedMap<Date, Integer>> getDataSampling(SamplingFilter filter) throws SuiviObsmerException {
- TopiaContext transaction = null;
- List<SortedMap<Date, Integer>> results = new ArrayList<SortedMap<Date, Integer>>();
- try {
- transaction = rootContext.beginTransaction();
-
- PeriodDates period = filter.getPeriod();
- if (period == null || period.getFromDate() == null || period.getThruDate() == null) {
- return results;
- }
-
- // Expected
- SortedMap<Date, Integer> serie1 = new TreeMap<Date,Integer>();
- // Real
- SortedMap<Date, Integer> serie2 = new TreeMap<Date,Integer>();
- results.add(serie1);
- results.add(serie2);
-
- // Prepare results
- for (Date month : period.getMonths()) {
- serie1.put(month, 0);
- serie2.put(month, 0);
- }
-
- SampleMonthDAO dao = SuiviObsmerModelDAOHelper.getSampleMonthDAO(transaction);
- String periodDate = "M." + SampleMonth.PERIOD_DATE;
- TopiaQuery query = dao.createQuery("M").
- setSelect(periodDate).
- addSelect("SUM(M." + SampleMonth.REAL_TIDES_VALUE + ")").
- addSelect("SUM(M." + SampleMonth.EXPECTED_TIDES_VALUE + ")").
- add(periodDate + " BETWEEN :fromDate AND :thruDate").
- addParam("fromDate", period.getFromDate()).addParam("thruDate", period.getThruDate()).
- addGroup(periodDate).addOrder(periodDate);
-
- query = filter.prepareQueryForSampling(query, "M." + SampleMonth.SAMPLE_ROW);
-
- if (log.isTraceEnabled()) {
- log.trace("Exec query : " + query);
- }
-
- List<Object[]> res = (List<Object[]>)query.execute();
-
- for (Object[] tab : res) {
- Date date = (Date)tab[0];
- int sumReal = ((Long)tab[1]).intValue();
- int sumExpected = ((Long)tab[2]).intValue();
- serie1.put(date, sumExpected);
- serie2.put(date, sumReal);
- if (log.isTraceEnabled()) {
- DateFormat dateFormat = new SimpleDateFormat(period.getPattern());
- log.trace("Res : " + dateFormat.format(date) + " : " + sumReal + " / " + sumExpected);
- }
- }
-
- //transaction.closeContext();
- } catch (Exception eee) {
- SuiviObsmerContext.serviceException(transaction,
- "Impossible de récupérer les données pour le graphique dynamique des efforts de marées", eee);
- } finally {
- SuiviObsmerContext.closeTransaction(transaction);
- }
- return results;
- }
-
- /**
- * We need to select the boats and for each one, the number of boardings
- * done. The number of boardings is calculated with the number of contacts
- * finished linked with each boat. The {@code fromDate} is used to filter
- * results since this date. For observer view, only results for his
- * company is needed.
- *
- * @param company the company used to filter results
- * @param fromDate the since date used to filter contact results
- * @return a BoardingResult which contains the number of boats for boardings
- * from 1 to {@link MAX_BOARDINGS}, the boat with the max boarding and its
- * value.
- * @throws SuiviObsmerException
- */
- @Override
- public BoardingResult getBoardingBoats(Company company, Date fromDate)
- throws SuiviObsmerException {
- TopiaContext transaction = null;
- Map<String, Integer> map = new LinkedHashMap<String, Integer>();
- BoardingResult result = new BoardingResultImpl();
- result.setData(map);
- try {
- transaction = rootContext.beginTransaction();
-
- // Initialiaze max boardings and its max key value
- final int maxBoardings = 12;
- final String maxBoardingsKey = maxBoardings + " +";
-
- // Prepare map which contains for each entry the number of boardings
- // for the key and the number of boats for the value.
- for (int i = 1; i < maxBoardings; i++) {
- map.put(String.valueOf(i), 0);
- }
- map.put(maxBoardingsKey, 0);
-
- ContactDAO dao =
- SuiviObsmerModelDAOHelper.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
- TopiaQuery query =
- dao.createQueryDoneContactsFromDate(null, fromDate);
-
- String contact = query.getMainAlias();
- String sampleRow = contact + "." + Contact.SAMPLE_ROW;
-
- // Only for sampleRows with averageTideTime less or equals to 2 days
- query.add(sampleRow + "." + SampleRow.AVERAGE_TIDE_TIME, Op.LE, 2.);
-
- // Add filter on sampleRow company if needed
- if (company != null) {
- query.add(sampleRow + "." + SampleRow.COMPANY, company);
- }
-
- // Prepare aliases for mapping results in select part
- String countAlias = "nbBoardings";
- String boatAlias = "boat";
- // Use a map for each result with boat and its number of boardings
- // Order by number of boardings to easily find the max value (the
- // first result)
- query.setSelect("new map(" + contact + "." + Contact.BOAT + " as " +
- boatAlias + ", COUNT(*) as " + countAlias + ")").
- addGroup(contact + "." + Contact.BOAT).
- addOrderDesc("COUNT(*)");
-
- if (log.isTraceEnabled()) {
- log.trace("Exec query : " + query);
- }
-
- List<Map<String, Object>> nbBoardingsByBoat = query.execute();
-
- if (!nbBoardingsByBoat.isEmpty()) {
- for (Map<String, Object> row : nbBoardingsByBoat) {
- Long count = (Long)row.get(countAlias);
- int intValue = count.intValue();
- String value = count.toString();
- if (intValue >= maxBoardings) {
- value = maxBoardingsKey;
- }
- // Increment the number of boats for the current number of
- // boardings
- Integer nbBoats = map.get(value);
- map.put(value, nbBoats + 1);
- }
-
- // Set the max boat and its number of boardings value
- Map<String, Object> max = nbBoardingsByBoat.get(0);
- result.setMaxBoardingBoat((Boat)max.get(boatAlias));
- Long maxValue = (Long)max.get(countAlias);
- result.setMaxBoardingValue(maxValue.intValue());
- }
-
- //transaction.closeContext();
- } catch (Exception eee) {
- SuiviObsmerContext.serviceException(transaction,
- "Impossible de récupérer les données pour le graphique " +
- "dynamique des efforts de marées", eee);
- } finally {
- SuiviObsmerContext.closeTransaction(transaction);
- }
- return result;
- }
-
- @Override
- public Map<String, Double> getNonComplianceBoardingIndicator(Company company) throws SuiviObsmerException {
- TopiaContext transaction = null;
- // Carefull with results, the company may not be present in the map :
- // only if there is no unfinished sampleRow or no contact done
- Map<String, Double> results = new HashMap<String, Double>();
- try {
- transaction = rootContext.beginTransaction();
-
- ContactDAO dao = SuiviObsmerModelDAOHelper.getContactDAO(transaction);
-
- // Only for done contacts with no constraint
- TopiaQuery query =
- dao.createQueryDoneContactsFromDate(null, null);
-
- String contact = query.getMainAlias();
- String sampleRow = contact + "." + Contact.SAMPLE_ROW;
- String companyProp = sampleRow + "." + SampleRow.COMPANY;
- String companyName = companyProp + "." + Company.NAME;
-
- // Only for unfinished sampleRows
- Date current = SuiviObsmerContext.getCurrentDate();
- query.add(sampleRow + "." + SampleRow.PERIOD_END, Op.GE, current);
-
- if (company != null) {
- query.add(companyProp, company);
- }
-
- // Prepare results
- query.setSelect(companyName, "COUNT(*)").addGroup(companyName);
-
- if (log.isDebugEnabled()) {
- log.debug("Exec query for total : " + query);
- }
-
- List<Object[]> totalResults = query.execute();
-
- // Use the same query and add the constraint of non compliance
- //i.e. nbObservantsReal (contact) < nbObservantsExpected (sampleRow)
- query.add(contact + "." + Contact.NB_OBSERVANTS + " < " +
- sampleRow + "." + SampleRow.NB_OBSERVANTS);
-
- if (log.isDebugEnabled()) {
- log.debug("Exec query for result : " + query);
- }
-
- List<Object[]> diffResults = query.execute();
-
- // Use the map to set the number of non compliance results
- for (Object[] row : diffResults) {
- String rowCompanyName = (String)row[0];
- Long rowCount = (Long)row[1];
- if (log.isDebugEnabled()) {
- log.debug("result row : " + rowCompanyName + " = " + rowCount);
- }
- results.put(rowCompanyName, rowCount.doubleValue());
- }
-
- // Get the previous value from the map and make the division to have
- // the result percent of non compliance. Put 0 in the map if no
- // previous result is set
- for (Object[] row : totalResults) {
- String rowCompanyName = (String)row[0];
- Long rowCount = (Long)row[1];
- if (log.isDebugEnabled()) {
- log.debug("total row : " + rowCompanyName + " = " + rowCount);
- }
- Double value = results.get(rowCompanyName);
- if (value == null) {
- results.put(rowCompanyName, 0.);
- } else {
- results.put(rowCompanyName, value / rowCount);
- }
- }
-
- //transaction.closeContext();
- } catch (Exception eee) {
- String msgEnd = "";
- if (company != null) {
- msgEnd = " pour la société " + company.getName();
- }
- SuiviObsmerContext.serviceException(transaction,
- "Impossible de récupérer l'indicateur de non respect du " +
- "nombre d'observateurs embarqués" + msgEnd, eee);
- } finally {
- SuiviObsmerContext.closeTransaction(transaction);
- }
- return results;
- }
-
- @Override
- public Collection<ContactStateStatistics> getContactStateStatistics(Company company, PeriodDates period) throws SuiviObsmerException {
- TopiaContext transaction = null;
- Map<String, ContactStateStatistics> results = new HashMap<String, ContactStateStatistics>();
- try {
- transaction = rootContext.beginTransaction();
-
- ContactDAO dao = SuiviObsmerModelDAOHelper.getContactDAO(transaction);
-
- // Only for contacts not refused by the program
- String contact = "C";
- String validationProgram = contact + "." + Contact.VALIDATION_PROGRAM;
- TopiaQuery query = dao.createQuery(contact).
- add(validationProgram + " IS NULL " +
- "OR " + validationProgram + " = :booleanTrue").
- addParam("booleanTrue", Boolean.TRUE);
-
- String companyProp = contact + "." + Contact.OBSERVER + "." + WaoUser.COMPANY;
-
- if (company != null) {
- query.add(companyProp, company);
- }
-
- if (period != null) {
- // Contacts include in the period
- String tideBeginDate = contact + "." + Contact.TIDE_BEGIN_DATE;
- String createDate = contact + "." + TopiaEntity.TOPIA_CREATE_DATE;
- query.add("(" + tideBeginDate + " IS NOT NULL " +
- "AND " + tideBeginDate + " BETWEEN :fromDate AND :thruDate)" +
- " OR (" + tideBeginDate + " IS NULL " +
- "AND " + createDate + " BETWEEN :fromDate AND :thruDate)");
-
- query.addParam("fromDate", period.getFromDate()).
- addParam("thruDate", period.getThruDate());
- }
-
- String state = contact + "." + Contact.STATE;
- String companyName = companyProp + "." + Company.NAME;
- query.addGroup(companyName, state).
- addOrder(companyName).
- setSelect(companyName, state, "COUNT(*)");
-
- if (log.isDebugEnabled()) {
- log.debug("Exec query : " + query);
- }
-
- List<Object[]> res = query.execute();
-
- for (Object[] row : res) {
- String rowCompanyName = (String)row[0];
- String rowState = (String)row[1];
- Long rowCount = (Long)row[2];
- if (log.isDebugEnabled()) {
- log.debug("res : " + rowCompanyName + " _ " + rowState + " _ " + rowCount);
- }
- ContactStateStatistics stats = results.get(rowCompanyName);
- if (stats == null) {
- stats = new ContactStateStatisticsImpl();
- stats.setCompanyName(rowCompanyName);
- results.put(rowCompanyName, stats);
- }
- stats.addResult(rowState, rowCount.intValue());
- }
-
- //transaction.closeContext();
- } catch (Exception eee) {
- String msgEnd = "";
- if (company != null) {
- msgEnd = " pour la société " + company.getName();
- }
- SuiviObsmerContext.serviceException(transaction,
- "Impossible de récupérer les statistiques sur les états des " +
- "contacts " + msgEnd, eee);
- } finally {
- SuiviObsmerContext.closeTransaction(transaction);
- }
- return results.values();
- }
-
- @Override
- public Map<String, Double> getContactDataInputDateReactivity(Company company, PeriodDates period) throws SuiviObsmerException {
- TopiaContext transaction = null;
- // Carefull with results, the company may not be present in the map :
- // only if there is no unfinished sampleRow or no contact done
- Map<String, Double> results = new HashMap<String, Double>();
- try {
- transaction = rootContext.beginTransaction();
-
- ContactDAO dao = SuiviObsmerModelDAOHelper.getContactDAO(transaction);
-
- String contact = "C";
- TopiaQuery query = dao.createQuery(contact);
-
- String companyKey = contact + "." + Contact.OBSERVER + "." + WaoUser.COMPANY;
- String companyName = companyKey + "." + Company.NAME;
-
- if (company != null) {
- query.add(companyKey, company);
- }
-
- String tideBegin = contact + "." + Contact.TIDE_BEGIN_DATE;
- period.initDayOfMonthExtremities();
- query.add(tideBegin + " BETWEEN :fromDate AND :thruDate").
- addParam("fromDate", period.getFromDate()).
- addParam("thruDate", period.getThruDate());
-
- String dataInput = contact + "." + Contact.DATA_INPUT_DATE;
- query.addNotNull(dataInput);
-
- // FIXME-FD20100212 Hack for H2 which not managed day for date diff
- TopiaContextImplementor context = (TopiaContextImplementor)transaction;
- String dialect = context.getHibernateConfiguration().getProperty("hibernate.dialect");
-
- String avg = "AVG(day(" + dataInput + " - " + tideBegin + "))";
- if (dialect.contains("H2Dialect")) {
- avg = "AVG(" + dataInput + " - " + tideBegin + ")";
- }
-
- query.setSelect(companyName, avg).addGroup(companyName);
-
- if (log.isTraceEnabled()) {
- log.trace("Exec query : " + query);
- }
-
- List<Object[]> res = query.execute();
-
- for (Object[] row : res) {
- String rowCompanyName = (String)row[0];
- Double rowAverage = (Double)row[1];
- if (log.isTraceEnabled()) {
- log.trace("Company : " + rowCompanyName);
- log.trace("Res : " + rowAverage.doubleValue());
- }
- if (rowAverage < 0) {
- rowAverage = 0.;
- }
- results.put(rowCompanyName, rowAverage);
- }
-
-
- } catch (Exception eee) {
- String msgEnd = "";
- if (company != null) {
- msgEnd = " pour la société " + company.getName();
- }
- SuiviObsmerContext.serviceException(transaction,
- "Impossible de récupérer l'indicateur de réactivité sur " +
- "les dates de saisies dans Allegro" + msgEnd, eee);
- } finally {
- SuiviObsmerContext.closeTransaction(transaction);
- }
- return results;
- }
-
-}
Copied: trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceSynthesisImpl.java (from rev 354, trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services/ServiceSynthesisImpl.java)
===================================================================
--- trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceSynthesisImpl.java (rev 0)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceSynthesisImpl.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -0,0 +1,533 @@
+/*
+ * *##%
+ * 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.service;
+
+import fr.ifremer.wao.WaoContext;
+import fr.ifremer.wao.WaoException;
+import fr.ifremer.wao.WaoModelDAOHelper;
+import fr.ifremer.wao.bean.ContactAverageReactivityImpl;
+import fr.ifremer.wao.bean.ContactAverageReactivity;
+import fr.ifremer.wao.bean.BoardingResult;
+import fr.ifremer.wao.bean.BoardingResultImpl;
+import fr.ifremer.wao.bean.ContactStateStatistics;
+import fr.ifremer.wao.bean.ContactStateStatisticsImpl;
+import fr.ifremer.wao.bean.SamplingFilter;
+import fr.ifremer.wao.entity.Boat;
+import fr.ifremer.wao.entity.Company;
+import fr.ifremer.wao.entity.Contact;
+import fr.ifremer.wao.entity.ContactDAO;
+import fr.ifremer.wao.entity.SampleMonth;
+import fr.ifremer.wao.entity.SampleMonthDAO;
+import fr.ifremer.wao.entity.SampleRow;
+import fr.ifremer.wao.entity.WaoUser;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.SortedMap;
+import java.util.TreeMap;
+import org.nuiton.topia.TopiaContext;
+import org.nuiton.topia.framework.TopiaQuery;
+import org.nuiton.topia.framework.TopiaQuery.Op;
+import org.nuiton.topia.persistence.TopiaEntity;
+import org.nuiton.util.DateUtils;
+import org.nuiton.util.PeriodDates;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * ServiceSynthesisImpl
+ *
+ * Created: 7 janv. 2010
+ *
+ * @author fdesbois
+ * @version $Revision$
+ *
+ * Mise a jour: $Date$
+ * par : $Author$
+ */
+public class ServiceSynthesisImpl implements ServiceSynthesis {
+
+ private static final Logger log = LoggerFactory.getLogger(ServiceSynthesisImpl.class);
+
+ protected TopiaContext rootContext;
+
+ public ServiceSynthesisImpl() throws WaoException {
+ rootContext = WaoContext.getTopiaRootContext();
+ }
+
+ @Override
+ public List<SortedMap<Date, Integer>> getDataSampling(SamplingFilter filter) throws WaoException {
+ TopiaContext transaction = null;
+ List<SortedMap<Date, Integer>> results = new ArrayList<SortedMap<Date, Integer>>();
+ try {
+ transaction = rootContext.beginTransaction();
+
+ PeriodDates period = filter.getPeriod();
+ if (period == null || period.getFromDate() == null || period.getThruDate() == null) {
+ return results;
+ }
+ period.initDayOfMonthExtremities();
+
+ // Expected
+ SortedMap<Date, Integer> serie1 = new TreeMap<Date,Integer>();
+ // Real
+ SortedMap<Date, Integer> serie2 = new TreeMap<Date,Integer>();
+ results.add(serie1);
+ results.add(serie2);
+
+ // Prepare results
+ for (Date month : period.getMonths()) {
+ serie1.put(month, 0);
+ serie2.put(month, 0);
+ }
+
+ SampleMonthDAO dao = WaoModelDAOHelper.getSampleMonthDAO(transaction);
+ String periodDate = "M." + SampleMonth.PERIOD_DATE;
+ TopiaQuery query = dao.createQuery("M").
+ setSelect(periodDate).
+ addSelect("SUM(M." + SampleMonth.REAL_TIDES_VALUE + ")").
+ addSelect("SUM(M." + SampleMonth.EXPECTED_TIDES_VALUE + ")").
+ add(periodDate + " BETWEEN :fromDate AND :thruDate").
+ addParam("fromDate", period.getFromDate()).addParam("thruDate", period.getThruDate()).
+ addGroup(periodDate).addOrder(periodDate);
+
+ query = filter.prepareQueryForSampling(query, "M." + SampleMonth.SAMPLE_ROW);
+
+ if (log.isTraceEnabled()) {
+ log.trace("Exec query : " + query);
+ }
+
+ List<Object[]> res = (List<Object[]>)query.execute();
+
+ for (Object[] tab : res) {
+ Date date = (Date)tab[0];
+ int sumReal = ((Long)tab[1]).intValue();
+ int sumExpected = ((Long)tab[2]).intValue();
+ serie1.put(date, sumExpected);
+ serie2.put(date, sumReal);
+ if (log.isTraceEnabled()) {
+ DateFormat dateFormat = new SimpleDateFormat(period.getPattern());
+ log.trace("Res : " + dateFormat.format(date) + " : " + sumReal + " / " + sumExpected);
+ }
+ }
+
+ //transaction.closeContext();
+ } catch (Exception eee) {
+ WaoContext.serviceException(transaction,
+ "Impossible de récupérer les données pour le graphique dynamique des efforts de marées", eee);
+ } finally {
+ WaoContext.closeTransaction(transaction);
+ }
+ return results;
+ }
+
+ /**
+ * We need to select the boats and for each one, the number of boardings
+ * done. The number of boardings is calculated with the number of contacts
+ * finished linked with each boat. The {@code fromDate} is used to filter
+ * results since this date. For observer view, only results for his
+ * company is needed.
+ *
+ * @param company the company used to filter results
+ * @param fromDate the since date used to filter contact results
+ * @return a BoardingResult which contains the number of boats for boardings
+ * from 1 to {@link MAX_BOARDINGS}, the boat with the max boarding and its
+ * value.
+ * @throws WaoException
+ */
+ @Override
+ public BoardingResult getBoardingBoats(Company company, Date fromDate)
+ throws WaoException {
+ TopiaContext transaction = null;
+ Map<String, Integer> map = new LinkedHashMap<String, Integer>();
+ BoardingResult result = new BoardingResultImpl();
+ result.setData(map);
+ try {
+ transaction = rootContext.beginTransaction();
+
+ // Initialiaze max boardings and its max key value
+ final int maxBoardings = 12;
+ final String maxBoardingsKey = maxBoardings + " +";
+
+ // Prepare map which contains for each entry the number of boardings
+ // for the key and the number of boats for the value.
+ for (int i = 1; i < maxBoardings; i++) {
+ map.put(String.valueOf(i), 0);
+ }
+ map.put(maxBoardingsKey, 0);
+
+ ContactDAO dao =
+ WaoModelDAOHelper.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
+ TopiaQuery query =
+ dao.createQueryDoneContactsFromDate(null, fromDate);
+
+ String contact = query.getMainAlias();
+ String sampleRow = contact + "." + Contact.SAMPLE_ROW;
+
+ // Only for sampleRows with averageTideTime less or equals to 2 days
+ query.add(sampleRow + "." + SampleRow.AVERAGE_TIDE_TIME, Op.LE, 2.);
+
+ // Add filter on sampleRow company if needed
+ if (company != null) {
+ query.add(sampleRow + "." + SampleRow.COMPANY, company);
+ }
+
+ // Prepare aliases for mapping results in select part
+ String countAlias = "nbBoardings";
+ String boatAlias = "boat";
+ // Use a map for each result with boat and its number of boardings
+ // Order by number of boardings to easily find the max value (the
+ // first result)
+ query.setSelect("new map(" + contact + "." + Contact.BOAT + " as " +
+ boatAlias + ", COUNT(*) as " + countAlias + ")").
+ addGroup(contact + "." + Contact.BOAT).
+ addOrderDesc("COUNT(*)");
+
+ if (log.isTraceEnabled()) {
+ log.trace("Exec query : " + query);
+ }
+
+ List<Map<String, Object>> nbBoardingsByBoat = query.execute();
+
+ if (!nbBoardingsByBoat.isEmpty()) {
+ for (Map<String, Object> row : nbBoardingsByBoat) {
+ Long count = (Long)row.get(countAlias);
+ int intValue = count.intValue();
+ String value = count.toString();
+ if (intValue >= maxBoardings) {
+ value = maxBoardingsKey;
+ }
+ // Increment the number of boats for the current number of
+ // boardings
+ Integer nbBoats = map.get(value);
+ map.put(value, nbBoats + 1);
+ }
+
+ // Set the max boat and its number of boardings value
+ Map<String, Object> max = nbBoardingsByBoat.get(0);
+ result.setMaxBoardingBoat((Boat)max.get(boatAlias));
+ Long maxValue = (Long)max.get(countAlias);
+ result.setMaxBoardingValue(maxValue.intValue());
+ }
+
+ //transaction.closeContext();
+ } catch (Exception eee) {
+ WaoContext.serviceException(transaction,
+ "Impossible de récupérer les données pour le graphique " +
+ "dynamique des efforts de marées", eee);
+ } finally {
+ WaoContext.closeTransaction(transaction);
+ }
+ return result;
+ }
+
+ @Override
+ public Map<String, Double> getNonComplianceBoardingIndicator(Company company) throws WaoException {
+ TopiaContext transaction = null;
+ // Carefull with results, the company may not be present in the map :
+ // only if there is no unfinished sampleRow or no contact done
+ Map<String, Double> results = new HashMap<String, Double>();
+ try {
+ transaction = rootContext.beginTransaction();
+
+ ContactDAO dao = WaoModelDAOHelper.getContactDAO(transaction);
+
+ // Only for done contacts with no constraint
+ TopiaQuery query =
+ dao.createQueryDoneContactsFromDate(null, null);
+
+ String contact = query.getMainAlias();
+ String sampleRow = contact + "." + Contact.SAMPLE_ROW;
+ String companyProp = sampleRow + "." + SampleRow.COMPANY;
+ String companyName = companyProp + "." + Company.NAME;
+
+ // Only for unfinished sampleRows
+ Date current = WaoContext.getCurrentDate();
+ query.add(sampleRow + "." + SampleRow.PERIOD_END, Op.GE, current);
+
+ if (company != null) {
+ query.add(companyProp, company);
+ }
+
+ // Prepare results
+ query.setSelect(companyName, "COUNT(*)").addGroup(companyName);
+
+ if (log.isDebugEnabled()) {
+ log.debug("Exec query for total : " + query);
+ }
+
+ List<Object[]> totalResults = query.execute();
+
+ // Use the same query and add the constraint of non compliance
+ //i.e. nbObservantsReal (contact) < nbObservantsExpected (sampleRow)
+ query.add(contact + "." + Contact.NB_OBSERVANTS + " < " +
+ sampleRow + "." + SampleRow.NB_OBSERVANTS);
+
+ if (log.isDebugEnabled()) {
+ log.debug("Exec query for result : " + query);
+ }
+
+ List<Object[]> diffResults = query.execute();
+
+ // Use the map to set the number of non compliance results
+ for (Object[] row : diffResults) {
+ String rowCompanyName = (String)row[0];
+ Long rowCount = (Long)row[1];
+ if (log.isDebugEnabled()) {
+ log.debug("result row : " + rowCompanyName + " = " + rowCount);
+ }
+ results.put(rowCompanyName, rowCount.doubleValue());
+ }
+
+ // Get the previous value from the map and make the division to have
+ // the result percent of non compliance. Put 0 in the map if no
+ // previous result is set
+ for (Object[] row : totalResults) {
+ String rowCompanyName = (String)row[0];
+ Long rowCount = (Long)row[1];
+ if (log.isDebugEnabled()) {
+ log.debug("total row : " + rowCompanyName + " = " + rowCount);
+ }
+ Double value = results.get(rowCompanyName);
+ if (value == null) {
+ results.put(rowCompanyName, 0.);
+ } else {
+ results.put(rowCompanyName, value / rowCount);
+ }
+ }
+
+ //transaction.closeContext();
+ } catch (Exception eee) {
+ String msgEnd = "";
+ if (company != null) {
+ msgEnd = " pour la société " + company.getName();
+ }
+ WaoContext.serviceException(transaction,
+ "Impossible de récupérer l'indicateur de non respect du " +
+ "nombre d'observateurs embarqués" + msgEnd, eee);
+ } finally {
+ WaoContext.closeTransaction(transaction);
+ }
+ return results;
+ }
+
+ @Override
+ public Collection<ContactStateStatistics> getContactStateStatistics(Company company, PeriodDates period) throws WaoException {
+ TopiaContext transaction = null;
+ Map<String, ContactStateStatistics> results = new HashMap<String, ContactStateStatistics>();
+ try {
+ transaction = rootContext.beginTransaction();
+
+ ContactDAO dao = WaoModelDAOHelper.getContactDAO(transaction);
+
+ // Only for contacts not refused by the program
+ String contact = "C";
+ String validationProgram = contact + "." + Contact.VALIDATION_PROGRAM;
+ TopiaQuery query = dao.createQuery(contact).
+ add(validationProgram + " IS NULL " +
+ "OR " + validationProgram + " = :booleanTrue").
+ addParam("booleanTrue", Boolean.TRUE);
+
+ String companyProp = contact + "." + Contact.OBSERVER + "." + WaoUser.COMPANY;
+
+ if (company != null) {
+ query.add(companyProp, company);
+ }
+
+ if (period != null) {
+ // Contacts include in the period
+ String tideBeginDate = contact + "." + Contact.TIDE_BEGIN_DATE;
+ String createDate = contact + "." + TopiaEntity.TOPIA_CREATE_DATE;
+ query.add("(" + tideBeginDate + " IS NOT NULL " +
+ "AND " + tideBeginDate + " BETWEEN :fromDate AND :thruDate)" +
+ " OR (" + tideBeginDate + " IS NULL " +
+ "AND " + createDate + " BETWEEN :fromDate AND :thruDate)");
+
+ period.initDayOfMonthExtremities();
+ query.addParam("fromDate", period.getFromDate()).
+ addParam("thruDate", period.getThruDate());
+ }
+
+ String state = contact + "." + Contact.STATE;
+ String companyName = companyProp + "." + Company.NAME;
+ query.addGroup(companyName, state).
+ addOrder(companyName).
+ setSelect(companyName, state, "COUNT(*)");
+
+ if (log.isDebugEnabled()) {
+ log.debug("Exec query : " + query);
+ }
+
+ List<Object[]> res = query.execute();
+
+ for (Object[] row : res) {
+ String rowCompanyName = (String)row[0];
+ String rowState = (String)row[1];
+ Long rowCount = (Long)row[2];
+ if (log.isDebugEnabled()) {
+ log.debug("res : " + rowCompanyName + " _ " + rowState + " _ " + rowCount);
+ }
+ ContactStateStatistics stats = results.get(rowCompanyName);
+ if (stats == null) {
+ stats = new ContactStateStatisticsImpl();
+ stats.setCompanyName(rowCompanyName);
+ results.put(rowCompanyName, stats);
+ }
+ stats.addResult(rowState, rowCount.intValue());
+ }
+
+ //transaction.closeContext();
+ } catch (Exception eee) {
+ String msgEnd = "";
+ if (company != null) {
+ msgEnd = " pour la société " + company.getName();
+ }
+ WaoContext.serviceException(transaction,
+ "Impossible de récupérer les statistiques sur les états des " +
+ "contacts " + msgEnd, eee);
+ } finally {
+ WaoContext.closeTransaction(transaction);
+ }
+ return results.values();
+ }
+
+ @Override
+ public Collection<ContactAverageReactivity> getContactDataInputDateReactivity(Company company, PeriodDates period) throws WaoException {
+ TopiaContext transaction = null;
+ // Carefull with results, the company may not be present in the map :
+ // only if there is no unfinished sampleRow or no contact done
+
+ Map<String, ContactAverageReactivity> results = new HashMap<String, ContactAverageReactivity>();
+ try {
+ transaction = rootContext.beginTransaction();
+
+ ContactDAO dao = WaoModelDAOHelper.getContactDAO(transaction);
+
+// String contact = "C";
+// TopiaQuery query = dao.createQuery(contact);
+
+ TopiaQuery query = dao.createQueryDoneContactsFromDate(null, period.getFromDate());
+
+ String contact = query.getMainAlias();
+ String companyKey = contact + "." + Contact.OBSERVER + "." + WaoUser.COMPANY;
+ String companyName = companyKey + "." + Company.NAME;
+
+ if (company != null) {
+ query.add(companyKey, company);
+ }
+
+ String tideBegin = contact + "." + Contact.TIDE_BEGIN_DATE;
+ //period.initDayOfMonthExtremities();
+
+ if (period.getThruDate() != null) {
+ query.add(tideBegin, Op.LE, period.getThruDate());
+ }
+
+ String dataInput = contact + "." + Contact.DATA_INPUT_DATE;
+ //query.addNotNull(dataInput);
+
+ // FIXME-FD20100212 Hack for H2 which not managed day for date diff
+// TopiaContextImplementor context = (TopiaContextImplementor)transaction;
+// String dialect = context.getHibernateConfiguration().getProperty("hibernate.dialect");
+
+// String avg = "AVG(day(" + dataInput + " - " + tideBegin + "))";
+// if (dialect.contains("H2Dialect")) {
+// avg = "AVG(" + dataInput + " - " + tideBegin + ")";
+// }
+
+ //query.setSelect(companyName, avg).addGroup(companyName);
+ query.setSelect(companyName, dataInput, tideBegin);
+
+ if (log.isDebugEnabled()) {
+ log.debug("Exec query : " + query);
+ }
+
+ List<Object[]> res = query.execute();
+
+ for (Object[] row : res) {
+ String rowCompanyName = (String)row[0];
+ Date rowDataInputDate = (Date)row[1];
+ Date rowTideBeginDate = (Date)row[2];
+
+ int nbDays = DateUtils.getDifferenceInDays(rowTideBeginDate, rowDataInputDate);
+
+ if (log.isDebugEnabled()) {
+ log.debug("Company : " + rowCompanyName);
+ log.debug("tideBegin : " + rowTideBeginDate);
+ log.debug("dataInput : " + rowDataInputDate);
+ log.debug("nbDays : " + nbDays);
+ }
+
+ ContactAverageReactivity avg = results.get(rowCompanyName);
+ if (avg == null) {
+ avg = new ContactAverageReactivityImpl();
+ avg.setCompanyName(rowCompanyName);
+ results.put(rowCompanyName, avg);
+ }
+
+ avg.addValue(nbDays);
+
+
+
+// String rowCompanyName = (String)row[0];
+// Object rowAverage = row[1];
+// if (log.isDebugEnabled()) {
+// log.debug("Company : " + rowCompanyName);
+// log.debug("Res : " + rowAverage.getClass().getName());
+// log.debug("Res : " + rowAverage);
+// log.debug("tideBegin : " + (Date)row[3]);
+// log.debug("dataInput : " + (Date)row[2]);
+// }
+//// Double d = new Double((double)rowAverage.intValue());
+//// if (rowAverage < 0) {
+//// rowAverage = 0.;
+//// }
+// results.put(rowCompanyName, 0.);
+ }
+
+
+
+
+ } catch (Exception eee) {
+ String msgEnd = "";
+ if (company != null) {
+ msgEnd = " pour la société " + company.getName();
+ }
+ WaoContext.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);
+ }
+ return results.values();
+ }
+
+}
Deleted: trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceUserImpl.java
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services/ServiceUserImpl.java 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceUserImpl.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,342 +0,0 @@
-/*
- * *##%
- * SuiviObsmer :: 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.suiviobsmer.services;
-
-import fr.ifremer.suiviobsmer.SuiviObsmerBusinessException;
-import fr.ifremer.suiviobsmer.SuiviObsmerBusinessException.Type;
-import fr.ifremer.suiviobsmer.SuiviObsmerException;
-import fr.ifremer.suiviobsmer.SuiviObsmerModelDAOHelper;
-import fr.ifremer.suiviobsmer.SuiviObsmerContext;
-import fr.ifremer.suiviobsmer.entity.Company;
-import fr.ifremer.suiviobsmer.entity.CompanyDAO;
-import fr.ifremer.suiviobsmer.entity.Contact;
-import fr.ifremer.suiviobsmer.entity.ContactDAO;
-import fr.ifremer.suiviobsmer.entity.SampleRowLog;
-import fr.ifremer.suiviobsmer.entity.SampleRowLogDAO;
-import fr.ifremer.suiviobsmer.entity.WaoUser;
-import fr.ifremer.suiviobsmer.entity.WaoUserDAO;
-import java.util.ArrayList;
-import java.util.List;
-import org.nuiton.topia.TopiaContext;
-import org.nuiton.topia.framework.TopiaQuery;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * ServiceUserImpl
- *
- * Created: 27 nov. 2009
- *
- * @author fdesbois
- * @version $Revision$
- *
- * Mise a jour: $Date$
- * par : $Author$
- */
-public class ServiceUserImpl implements ServiceUser {
-
- private static final Logger log = LoggerFactory.getLogger(ServiceUserImpl.class);
-
- protected TopiaContext rootContext;
-
- public ServiceUserImpl() throws SuiviObsmerException {
- rootContext = SuiviObsmerContext.getTopiaRootContext();
- }
-
- @Override
- public WaoUser connect(String login, String password) throws SuiviObsmerException {
- TopiaContext transaction = null;
- WaoUser user = null;
- try {
- transaction = rootContext.beginTransaction();
-
- WaoUserDAO dao = SuiviObsmerModelDAOHelper.getWaoUserDAO(transaction);
-
- String passwordEncoded = SuiviObsmerContext.encodeString(password);
- user = dao.findByProperties(WaoUser.LOGIN, login, WaoUser.PASSWORD, passwordEncoded);
-
- if (user != null && user.getActive()) {
- // load company entity
- user.getCompany();
- } else if (user != null && !user.getActive()) {
- throw new SuiviObsmerBusinessException(Type.ILLEGAL_CONNECTION, this.getClass(),
- "Vous n'avez plus les droits nécessaires pour vous connecter. Veuillez contacter un administrateur.");
- } else {
- throw new SuiviObsmerBusinessException(Type.BAD_CONNECTION, this.getClass(),
- "Identifiant ou mot de passe incorrects, veuillez réessayer.");
- }
-
- //transaction.closeContext();
- } catch (Exception eee) {
- SuiviObsmerContext.serviceException(transaction, "Une erreur est survenue lors de la demande de connexion", eee);
- } finally {
- SuiviObsmerContext.closeTransaction(transaction);
- }
- return user;
- }
-
- @Override
- public void forgetPassword(String login) throws SuiviObsmerException {
- TopiaContext transaction = null;
- try {
- if (!login.contains("@")) {
- throw new SuiviObsmerBusinessException(Type.SYNTAX, this.getClass(), "Votre identifiant n'est pas un email valide, " +
- "veuillez contacter un administrateur pour qu'il puisse changer votre mot de passe.");
- }
-
- transaction = rootContext.beginTransaction();
-
- WaoUserDAO dao = SuiviObsmerModelDAOHelper.getWaoUserDAO(transaction);
-
- WaoUser user = dao.findByLogin(login);
- if (user == null) {
- throw new SuiviObsmerBusinessException(Type.NOT_EXISTS, this.getClass(),
- "L'email '" + login + "' n'est pas référencé dans l'application.");
- }
-
- String password = SuiviObsmerContext.createRandomString(8);
- String passwordEncoded = SuiviObsmerContext.encodeString(password);
- user.setPassword(passwordEncoded);
-
- String subject = "[WAO] Mot de passe oublié";
- String msg = "Bonjour,\n\n" +
- "\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://" + SuiviObsmerContext.getProperty(SuiviObsmerContext.PROP_SERVER) + "\n\n" +
- "Cordialement,\n\n" +
- "L'Equipe WAO";
-
- SuiviObsmerContext.sendEmail(user.getLogin(), subject, msg);
- if (log.isDebugEnabled()) {
- log.debug("send email to : " + user.getLogin());
- }
-
- transaction.commitTransaction();
- //transaction.closeContext();
- } catch (Exception eee) {
- SuiviObsmerContext.serviceException(transaction, "Impossible de créer ou de mettre à jour l'utilisateur", eee);
- } finally {
- SuiviObsmerContext.closeTransaction(transaction);
- }
- }
-
- @Override
- public void createUpdateUser(WaoUser user, boolean generatePassword) throws SuiviObsmerException {
- TopiaContext transaction = null;
- try {
- if (user == null) {
- throw new IllegalArgumentException("user parameter can't be null");
- }
-
- transaction = rootContext.beginTransaction();
-
- WaoUserDAO dao = SuiviObsmerModelDAOHelper.getWaoUserDAO(transaction);
-
- boolean newUser = SuiviObsmerContext.prepareTopiaId(WaoUser.class, user);
-
- // Check for a new user if login already exists
- if (newUser) {
- WaoUser existUser = dao.findByLogin(user.getLogin());
- if (existUser != null) {
- throw new SuiviObsmerBusinessException(Type.ALREADY_EXISTS, this.getClass(),
- "Un utilisateur existe déjà avec ce login " + user.getLogin());
- }
- }
-
- String password = user.getPassword();
-
- if (generatePassword) {
- password = SuiviObsmerContext.createRandomString(8);
- user.setPasswordChanged(true);
-// if (log.isDebugEnabled()) {
-// log.debug("show generated password : " + password);
-// }
- }
- // For a password set manually by user or generated
- if (user.isPasswordChanged()) {
- String passwordEncoded = SuiviObsmerContext.encodeString(password);
- user.setPassword(passwordEncoded);
- }
-
- dao.update(user);
-
- // FIXME-JC20100122 Use REGEX instead of @ to test if the login is
- // a valid email
- if (user.getLogin().contains("@") && user.isPasswordChanged()) {
- String subject = "[WAO] ";
- String msg = "Bonjour,\n\n";
- if (newUser) {
- subject += "Création de votre compte";
- msg += "\tVous avez été inscris sur le site WAO : Web Applicatif Obsmer. Vos identifiants de connexion sont :\n" +
- "\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://" + SuiviObsmerContext.getProperty(SuiviObsmerContext.PROP_SERVER) + "\n\n";
- } else {
- subject += "Modification de votre compte";
- if (generatePassword) {
- msg += "\tVotre mot de passe de connexion à l'application WAO a été modifié : " + password + "\n\n";
- } else {
- msg += "\tVotre changement de mot de passe à bien été enregistré.\n" +
- "Pour des raisons de sécurité, le nouveau mot de passe n'est pas précisé dans ce message.\n" +
- "Vous pouvez faire une nouvelle demande de mot de passe en cas de perte sur la page de connexion ou en " +
- "répondant à ce message.\n\n";
- }
- }
- msg += "Cordialement,\n\n" +
- "L'Equipe WAO";
-
- SuiviObsmerContext.sendEmail(user.getLogin(), subject, msg);
-// if (log.isDebugEnabled()) {
-// log.debug("send email to : " + user.getLogin());
-// }
- }
-
- transaction.commitTransaction();
- //transaction.closeContext();
- } catch (Exception eee) {
- SuiviObsmerContext.serviceException(transaction, "Impossible de créer ou de mettre à jour l'utilisateur", eee);
- } finally {
- SuiviObsmerContext.closeTransaction(transaction);
- }
- }
-
- @Override
- public void deleteUser(WaoUser user) throws SuiviObsmerException {
- TopiaContext transaction = null;
- try {
- transaction = rootContext.beginTransaction();
-
- String userType = user.getAdmin() ? "administrateur" : "observateur";
- String msgBegin = "L'" + userType + " '" + user.getLogin() + "' ne peut pas être supprimé";
- String msgEnd = "Vous pouvez cependant le désactiver pour qu'il ne puisse plus se connecter.";
-
- if (user.getAdmin()) {
- SampleRowLogDAO logDAO = SuiviObsmerModelDAOHelper.getSampleRowLogDAO(transaction);
- List<SampleRowLog> results = logDAO.findAllByAdmin(user);
-
- if (!results.isEmpty()) {
- throw new SuiviObsmerBusinessException(Type.ALREADY_EXISTS, this.getClass(),
- msgBegin + " car il a participé à la modification du plan d'échantillonnage. " + msgEnd);
- }
- } else {
-
- ContactDAO contactDAO = SuiviObsmerModelDAOHelper.getContactDAO(transaction);
- List<Contact> results = contactDAO.findAllByObserver(user);
-
- if (!results.isEmpty()) {
- throw new SuiviObsmerBusinessException(Type.ALREADY_EXISTS, this.getClass(),
- msgBegin + " car il est lié à plusieurs contacts existants. " + msgEnd);
- }
- }
-
-
- WaoUserDAO dao = SuiviObsmerModelDAOHelper.getWaoUserDAO(transaction);
-
- dao.delete(user);
-
- transaction.commitTransaction();
- //transaction.closeContext();
- } catch (Exception eee) {
- SuiviObsmerContext.serviceException(transaction, "Impossible de créer ou de mettre à jour l'utilisateur", eee);
- } finally {
- SuiviObsmerContext.closeTransaction(transaction);
- }
- }
-
- @Override
- public void createUpdateCompany(Company company) throws SuiviObsmerException {
- TopiaContext transaction = null;
- try {
- if (company == null) {
- throw new IllegalArgumentException("company parameter can't be null");
- }
-
- transaction = rootContext.beginTransaction();
-
- CompanyDAO dao = SuiviObsmerModelDAOHelper.getCompanyDAO(transaction);
-
- SuiviObsmerContext.prepareTopiaId(Company.class, company);
- dao.update(company);
-
- transaction.commitTransaction();
- //transaction.closeContext();
- } catch (Exception eee) {
- SuiviObsmerContext.serviceException(transaction, "Impossible de créer ou de mettre à jour la société", eee);
- } finally {
- SuiviObsmerContext.closeTransaction(transaction);
- }
- }
-
- @Override
- public List<Company> getCompanies(boolean activeOnly) throws SuiviObsmerException {
- TopiaContext transaction = null;
- List<Company> results = new ArrayList<Company>();
- try {
- transaction = rootContext.beginTransaction();
-
- CompanyDAO dao = SuiviObsmerModelDAOHelper.getCompanyDAO(transaction);
-
- if (activeOnly) {
- results = dao.findAllByActive(activeOnly);
- } else {
- results = dao.findAll();
- }
-
- //transaction.closeContext();
- } catch (Exception eee) {
- SuiviObsmerContext.serviceException(transaction, "Impossible de récupérer la liste des sociétés", eee);
- } finally {
- SuiviObsmerContext.closeTransaction(transaction);
- }
- return results;
- }
-
- @Override
- public List<WaoUser> getObservers(boolean activeOnly) throws SuiviObsmerException {
- TopiaContext transaction = null;
- List<WaoUser> results = new ArrayList<WaoUser>();
- try {
- transaction = rootContext.beginTransaction();
-
- WaoUserDAO dao = SuiviObsmerModelDAOHelper.getWaoUserDAO(transaction);
- TopiaQuery query = dao.createQuery().add(WaoUser.ADMIN, Boolean.FALSE);
-
- if (activeOnly) {
- query.add(WaoUser.ACTIVE, Boolean.TRUE);
- }
-
- results = dao.findAllByQuery(query);
-
- //transaction.closeContext();
- } catch (Exception eee) {
- SuiviObsmerContext.serviceException(transaction, "Impossible de récupérer la liste des observateurs", eee);
- } finally {
- SuiviObsmerContext.closeTransaction(transaction);
- }
- return results;
- }
-
-
-
-}
Copied: trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceUserImpl.java (from rev 354, trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services/ServiceUserImpl.java)
===================================================================
--- trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceUserImpl.java (rev 0)
+++ trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceUserImpl.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -0,0 +1,342 @@
+/*
+ * *##%
+ * 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.service;
+
+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.entity.Company;
+import fr.ifremer.wao.entity.CompanyDAO;
+import fr.ifremer.wao.entity.Contact;
+import fr.ifremer.wao.entity.ContactDAO;
+import fr.ifremer.wao.entity.SampleRowLog;
+import fr.ifremer.wao.entity.SampleRowLogDAO;
+import fr.ifremer.wao.entity.WaoUser;
+import fr.ifremer.wao.entity.WaoUserDAO;
+import java.util.ArrayList;
+import java.util.List;
+import org.nuiton.topia.TopiaContext;
+import org.nuiton.topia.framework.TopiaQuery;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * ServiceUserImpl
+ *
+ * Created: 27 nov. 2009
+ *
+ * @author fdesbois
+ * @version $Revision$
+ *
+ * Mise a jour: $Date$
+ * par : $Author$
+ */
+public class ServiceUserImpl implements ServiceUser {
+
+ private static final Logger log = LoggerFactory.getLogger(ServiceUserImpl.class);
+
+ protected TopiaContext rootContext;
+
+ public ServiceUserImpl() throws WaoException {
+ rootContext = WaoContext.getTopiaRootContext();
+ }
+
+ @Override
+ public WaoUser connect(String login, String password) throws WaoException {
+ TopiaContext transaction = null;
+ WaoUser user = null;
+ try {
+ transaction = rootContext.beginTransaction();
+
+ WaoUserDAO dao = WaoModelDAOHelper.getWaoUserDAO(transaction);
+
+ String passwordEncoded = WaoContext.encodeString(password);
+ user = dao.findByProperties(WaoUser.LOGIN, login, WaoUser.PASSWORD, passwordEncoded);
+
+ if (user != null && user.getActive()) {
+ // load company entity
+ user.getCompany();
+ } else if (user != null && !user.getActive()) {
+ throw new WaoBusinessException(Type.ILLEGAL_CONNECTION, this.getClass(),
+ "Vous n'avez plus les droits nécessaires pour vous connecter. Veuillez contacter un administrateur.");
+ } else {
+ throw new WaoBusinessException(Type.BAD_CONNECTION, this.getClass(),
+ "Identifiant ou mot de passe incorrects, veuillez réessayer.");
+ }
+
+ //transaction.closeContext();
+ } catch (Exception eee) {
+ WaoContext.serviceException(transaction, "Une erreur est survenue lors de la demande de connexion", eee);
+ } finally {
+ WaoContext.closeTransaction(transaction);
+ }
+ return user;
+ }
+
+ @Override
+ public void forgetPassword(String login) throws WaoException {
+ TopiaContext transaction = null;
+ try {
+ if (!login.contains("@")) {
+ throw new WaoBusinessException(Type.SYNTAX, this.getClass(), "Votre identifiant n'est pas un email valide, " +
+ "veuillez contacter un administrateur pour qu'il puisse changer votre mot de passe.");
+ }
+
+ transaction = rootContext.beginTransaction();
+
+ WaoUserDAO dao = WaoModelDAOHelper.getWaoUserDAO(transaction);
+
+ WaoUser user = dao.findByLogin(login);
+ if (user == null) {
+ throw new WaoBusinessException(Type.NOT_EXISTS, this.getClass(),
+ "L'email '" + login + "' n'est pas référencé dans l'application.");
+ }
+
+ String password = WaoContext.createRandomString(8);
+ String passwordEncoded = WaoContext.encodeString(password);
+ user.setPassword(passwordEncoded);
+
+ String subject = "[WAO] Mot de passe oublié";
+ String msg = "Bonjour,\n\n" +
+ "\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" +
+ "Cordialement,\n\n" +
+ "L'Equipe WAO";
+
+ WaoContext.sendEmail(user.getLogin(), subject, msg);
+ if (log.isDebugEnabled()) {
+ log.debug("send email to : " + user.getLogin());
+ }
+
+ transaction.commitTransaction();
+ //transaction.closeContext();
+ } catch (Exception eee) {
+ WaoContext.serviceException(transaction, "Impossible de créer ou de mettre à jour l'utilisateur", eee);
+ } finally {
+ WaoContext.closeTransaction(transaction);
+ }
+ }
+
+ @Override
+ public void createUpdateUser(WaoUser user, boolean generatePassword) throws WaoException {
+ TopiaContext transaction = null;
+ try {
+ if (user == null) {
+ throw new IllegalArgumentException("user parameter can't be null");
+ }
+
+ transaction = rootContext.beginTransaction();
+
+ WaoUserDAO dao = WaoModelDAOHelper.getWaoUserDAO(transaction);
+
+ boolean newUser = WaoContext.prepareTopiaId(WaoUser.class, user);
+
+ // Check for a new user if login already exists
+ if (newUser) {
+ WaoUser existUser = dao.findByLogin(user.getLogin());
+ if (existUser != null) {
+ throw new WaoBusinessException(Type.ALREADY_EXISTS, this.getClass(),
+ "Un utilisateur existe déjà avec ce login " + user.getLogin());
+ }
+ }
+
+ String password = user.getPassword();
+
+ if (generatePassword) {
+ password = WaoContext.createRandomString(8);
+ user.setPasswordChanged(true);
+// if (log.isDebugEnabled()) {
+// log.debug("show generated password : " + password);
+// }
+ }
+ // For a password set manually by user or generated
+ if (user.isPasswordChanged()) {
+ String passwordEncoded = WaoContext.encodeString(password);
+ user.setPassword(passwordEncoded);
+ }
+
+ dao.update(user);
+
+ // FIXME-JC20100122 Use REGEX instead of @ to test if the login is
+ // a valid email
+ if (user.getLogin().contains("@") && user.isPasswordChanged()) {
+ String subject = "[WAO] ";
+ String msg = "Bonjour,\n\n";
+ if (newUser) {
+ subject += "Création de votre compte";
+ msg += "\tVous avez été inscris sur le site WAO : Web Applicatif Obsmer. Vos identifiants de connexion sont :\n" +
+ "\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";
+ } else {
+ subject += "Modification de votre compte";
+ if (generatePassword) {
+ msg += "\tVotre mot de passe de connexion à l'application WAO a été modifié : " + password + "\n\n";
+ } else {
+ msg += "\tVotre changement de mot de passe à bien été enregistré.\n" +
+ "Pour des raisons de sécurité, le nouveau mot de passe n'est pas précisé dans ce message.\n" +
+ "Vous pouvez faire une nouvelle demande de mot de passe en cas de perte sur la page de connexion ou en " +
+ "répondant à ce message.\n\n";
+ }
+ }
+ msg += "Cordialement,\n\n" +
+ "L'Equipe WAO";
+
+ WaoContext.sendEmail(user.getLogin(), subject, msg);
+// if (log.isDebugEnabled()) {
+// log.debug("send email to : " + user.getLogin());
+// }
+ }
+
+ transaction.commitTransaction();
+ //transaction.closeContext();
+ } catch (Exception eee) {
+ WaoContext.serviceException(transaction, "Impossible de créer ou de mettre à jour l'utilisateur", eee);
+ } finally {
+ WaoContext.closeTransaction(transaction);
+ }
+ }
+
+ @Override
+ public void deleteUser(WaoUser user) throws WaoException {
+ TopiaContext transaction = null;
+ try {
+ transaction = rootContext.beginTransaction();
+
+ String userType = user.getAdmin() ? "administrateur" : "observateur";
+ String msgBegin = "L'" + userType + " '" + user.getLogin() + "' ne peut pas être supprimé";
+ String msgEnd = "Vous pouvez cependant le désactiver pour qu'il ne puisse plus se connecter.";
+
+ if (user.getAdmin()) {
+ SampleRowLogDAO logDAO = WaoModelDAOHelper.getSampleRowLogDAO(transaction);
+ List<SampleRowLog> results = logDAO.findAllByAdmin(user);
+
+ if (!results.isEmpty()) {
+ throw new WaoBusinessException(Type.ALREADY_EXISTS, this.getClass(),
+ msgBegin + " car il a participé à la modification du plan d'échantillonnage. " + msgEnd);
+ }
+ } else {
+
+ ContactDAO contactDAO = WaoModelDAOHelper.getContactDAO(transaction);
+ List<Contact> results = contactDAO.findAllByObserver(user);
+
+ if (!results.isEmpty()) {
+ throw new WaoBusinessException(Type.ALREADY_EXISTS, this.getClass(),
+ msgBegin + " car il est lié à plusieurs contacts existants. " + msgEnd);
+ }
+ }
+
+
+ WaoUserDAO dao = WaoModelDAOHelper.getWaoUserDAO(transaction);
+
+ dao.delete(user);
+
+ transaction.commitTransaction();
+ //transaction.closeContext();
+ } catch (Exception eee) {
+ WaoContext.serviceException(transaction, "Impossible de créer ou de mettre à jour l'utilisateur", eee);
+ } finally {
+ WaoContext.closeTransaction(transaction);
+ }
+ }
+
+ @Override
+ public void createUpdateCompany(Company company) throws WaoException {
+ TopiaContext transaction = null;
+ try {
+ if (company == null) {
+ throw new IllegalArgumentException("company parameter can't be null");
+ }
+
+ transaction = rootContext.beginTransaction();
+
+ CompanyDAO dao = WaoModelDAOHelper.getCompanyDAO(transaction);
+
+ WaoContext.prepareTopiaId(Company.class, company);
+ dao.update(company);
+
+ transaction.commitTransaction();
+ //transaction.closeContext();
+ } catch (Exception eee) {
+ WaoContext.serviceException(transaction, "Impossible de créer ou de mettre à jour la société", eee);
+ } finally {
+ WaoContext.closeTransaction(transaction);
+ }
+ }
+
+ @Override
+ public List<Company> getCompanies(boolean activeOnly) throws WaoException {
+ TopiaContext transaction = null;
+ List<Company> results = new ArrayList<Company>();
+ try {
+ transaction = rootContext.beginTransaction();
+
+ CompanyDAO dao = WaoModelDAOHelper.getCompanyDAO(transaction);
+
+ if (activeOnly) {
+ results = dao.findAllByActive(activeOnly);
+ } else {
+ results = dao.findAll();
+ }
+
+ //transaction.closeContext();
+ } catch (Exception eee) {
+ WaoContext.serviceException(transaction, "Impossible de récupérer la liste des sociétés", eee);
+ } finally {
+ WaoContext.closeTransaction(transaction);
+ }
+ return results;
+ }
+
+ @Override
+ public List<WaoUser> getObservers(boolean activeOnly) throws WaoException {
+ TopiaContext transaction = null;
+ List<WaoUser> results = new ArrayList<WaoUser>();
+ try {
+ transaction = rootContext.beginTransaction();
+
+ WaoUserDAO dao = WaoModelDAOHelper.getWaoUserDAO(transaction);
+ TopiaQuery query = dao.createQuery().add(WaoUser.ADMIN, Boolean.FALSE);
+
+ if (activeOnly) {
+ query.add(WaoUser.ACTIVE, Boolean.TRUE);
+ }
+
+ results = dao.findAllByQuery(query);
+
+ //transaction.closeContext();
+ } catch (Exception eee) {
+ WaoContext.serviceException(transaction, "Impossible de récupérer la liste des observateurs", eee);
+ } finally {
+ WaoContext.closeTransaction(transaction);
+ }
+ return results;
+ }
+
+
+
+}
Modified: trunk/wao-business/src/main/resources/oldmappings/SuiviObsmerModel/0/fr/ifremer/suiviobsmer/entity/ActivityCalendarImpl.hbm.xml
===================================================================
--- trunk/suiviobsmer-business/src/main/resources/oldmappings/SuiviObsmerModel/0/fr/ifremer/suiviobsmer/entity/ActivityCalendarImpl.hbm.xml 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-business/src/main/resources/oldmappings/SuiviObsmerModel/0/fr/ifremer/suiviobsmer/entity/ActivityCalendarImpl.hbm.xml 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,7 +1,7 @@
<?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 auto-import="true" default-access="field" package="fr.ifremer.suiviobsmer.entity">
- <class abstract="false" name="fr.ifremer.suiviobsmer.entity.ActivityCalendarImpl" node="fr.ifremer.suiviobsmer.entity.ActivityCalendarImpl" proxy="fr.ifremer.suiviobsmer.entity.ActivityCalendar" table="activityCalendar">
+<hibernate-mapping auto-import="true" default-access="field" package="fr.ifremer.wao.entity">
+ <class abstract="false" name="fr.ifremer.wao.entity.ActivityCalendarImpl" node="fr.ifremer.wao.entity.ActivityCalendarImpl" proxy="fr.ifremer.wao.entity.ActivityCalendar" table="activityCalendar">
<id length="255" name="topiaId" node="@topiaId" type="string"/>
<version name="topiaVersion" node="@topiaVersion" type="long"/>
<property name="topiaCreateDate" node="@topiaCreateDate" type="timestamp"/>
@@ -9,8 +9,8 @@
<property access="field" column="fiability" name="fiability" node="fiability" type="int"/>
<bag cascade="all,delete-orphan" embed-xml="false" inverse="true" lazy="true" name="activityMonth" node="activityMonth" order-by="month">
<key column="activityCalendar"/>
- <one-to-many class="fr.ifremer.suiviobsmer.entity.ActivityMonthImpl" embed-xml="false" node="topiaId"/>
+ <one-to-many class="fr.ifremer.wao.entity.ActivityMonthImpl" embed-xml="false" node="topiaId"/>
</bag>
- <many-to-one class="fr.ifremer.suiviobsmer.entity.BoatImpl" column="boat" embed-xml="false" name="boat" node="boat/@topiaId"/>
+ <many-to-one class="fr.ifremer.wao.entity.BoatImpl" column="boat" embed-xml="false" name="boat" node="boat/@topiaId"/>
</class>
</hibernate-mapping>
Modified: trunk/wao-business/src/main/resources/oldmappings/SuiviObsmerModel/0/fr/ifremer/suiviobsmer/entity/ActivityMonthImpl.hbm.xml
===================================================================
--- trunk/suiviobsmer-business/src/main/resources/oldmappings/SuiviObsmerModel/0/fr/ifremer/suiviobsmer/entity/ActivityMonthImpl.hbm.xml 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-business/src/main/resources/oldmappings/SuiviObsmerModel/0/fr/ifremer/suiviobsmer/entity/ActivityMonthImpl.hbm.xml 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,7 +1,7 @@
<?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 auto-import="true" default-access="field" package="fr.ifremer.suiviobsmer.entity">
- <class abstract="false" name="fr.ifremer.suiviobsmer.entity.ActivityMonthImpl" node="fr.ifremer.suiviobsmer.entity.ActivityMonthImpl" proxy="fr.ifremer.suiviobsmer.entity.ActivityMonth" table="activityMonth">
+<hibernate-mapping auto-import="true" default-access="field" package="fr.ifremer.wao.entity">
+ <class abstract="false" name="fr.ifremer.wao.entity.ActivityMonthImpl" node="fr.ifremer.wao.entity.ActivityMonthImpl" proxy="fr.ifremer.wao.entity.ActivityMonth" table="activityMonth">
<id length="255" name="topiaId" node="@topiaId" type="string"/>
<version name="topiaVersion" node="@topiaVersion" type="long"/>
<property name="topiaCreateDate" node="@topiaCreateDate" type="timestamp"/>
@@ -15,8 +15,8 @@
<property access="field" column="harbourId" name="harbourId" node="harbourId" type="int"/>
<bag cascade="all,delete-orphan" embed-xml="false" inverse="true" lazy="true" name="activityProfession" node="activityProfession" order-by="professionOrder">
<key column="activityMonth"/>
- <one-to-many class="fr.ifremer.suiviobsmer.entity.ActivityProfessionImpl" embed-xml="false" node="topiaId"/>
+ <one-to-many class="fr.ifremer.wao.entity.ActivityProfessionImpl" embed-xml="false" node="topiaId"/>
</bag>
- <many-to-one class="fr.ifremer.suiviobsmer.entity.ActivityCalendarImpl" column="activityCalendar" embed-xml="false" name="activityCalendar" node="activityCalendar/@topiaId"/>
+ <many-to-one class="fr.ifremer.wao.entity.ActivityCalendarImpl" column="activityCalendar" embed-xml="false" name="activityCalendar" node="activityCalendar/@topiaId"/>
</class>
</hibernate-mapping>
Modified: trunk/wao-business/src/main/resources/oldmappings/SuiviObsmerModel/0/fr/ifremer/suiviobsmer/entity/ActivityProfessionImpl.hbm.xml
===================================================================
--- trunk/suiviobsmer-business/src/main/resources/oldmappings/SuiviObsmerModel/0/fr/ifremer/suiviobsmer/entity/ActivityProfessionImpl.hbm.xml 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-business/src/main/resources/oldmappings/SuiviObsmerModel/0/fr/ifremer/suiviobsmer/entity/ActivityProfessionImpl.hbm.xml 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,7 +1,7 @@
<?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 auto-import="true" default-access="field" package="fr.ifremer.suiviobsmer.entity">
- <class abstract="false" name="fr.ifremer.suiviobsmer.entity.ActivityProfessionImpl" node="fr.ifremer.suiviobsmer.entity.ActivityProfessionImpl" proxy="fr.ifremer.suiviobsmer.entity.ActivityProfession" table="activityProfession">
+<hibernate-mapping auto-import="true" default-access="field" package="fr.ifremer.wao.entity">
+ <class abstract="false" name="fr.ifremer.wao.entity.ActivityProfessionImpl" node="fr.ifremer.wao.entity.ActivityProfessionImpl" proxy="fr.ifremer.wao.entity.ActivityProfession" table="activityProfession">
<id length="255" name="topiaId" node="@topiaId" type="string"/>
<version name="topiaVersion" node="@topiaVersion" type="long"/>
<property name="topiaCreateDate" node="@topiaCreateDate" type="timestamp"/>
@@ -9,10 +9,10 @@
<property access="field" column="libelle" name="libelle" node="libelle" type="text"/>
<property access="field" column="id" name="id" node="id" type="int"/>
<property access="field" column="professionOrder" name="professionOrder" node="professionOrder" type="int"/>
- <many-to-one class="fr.ifremer.suiviobsmer.entity.ActivityMonthImpl" column="activityMonth" embed-xml="false" name="activityMonth" node="activityMonth/@topiaId"/>
+ <many-to-one class="fr.ifremer.wao.entity.ActivityMonthImpl" column="activityMonth" embed-xml="false" name="activityMonth" node="activityMonth/@topiaId"/>
<bag cascade="all,delete-orphan" embed-xml="false" inverse="true" lazy="true" name="activityZone" node="activityZone" order-by="zoneId">
<key column="activityProfession"/>
- <one-to-many class="fr.ifremer.suiviobsmer.entity.ActivityZoneImpl" embed-xml="false" node="topiaId"/>
+ <one-to-many class="fr.ifremer.wao.entity.ActivityZoneImpl" embed-xml="false" node="topiaId"/>
</bag>
</class>
</hibernate-mapping>
Modified: trunk/wao-business/src/main/resources/oldmappings/SuiviObsmerModel/0/fr/ifremer/suiviobsmer/entity/ActivityZoneImpl.hbm.xml
===================================================================
--- trunk/suiviobsmer-business/src/main/resources/oldmappings/SuiviObsmerModel/0/fr/ifremer/suiviobsmer/entity/ActivityZoneImpl.hbm.xml 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-business/src/main/resources/oldmappings/SuiviObsmerModel/0/fr/ifremer/suiviobsmer/entity/ActivityZoneImpl.hbm.xml 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,7 +1,7 @@
<?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 auto-import="true" default-access="field" package="fr.ifremer.suiviobsmer.entity">
- <class abstract="false" name="fr.ifremer.suiviobsmer.entity.ActivityZoneImpl" node="fr.ifremer.suiviobsmer.entity.ActivityZoneImpl" proxy="fr.ifremer.suiviobsmer.entity.ActivityZone" table="activityZone">
+<hibernate-mapping auto-import="true" default-access="field" package="fr.ifremer.wao.entity">
+ <class abstract="false" name="fr.ifremer.wao.entity.ActivityZoneImpl" node="fr.ifremer.wao.entity.ActivityZoneImpl" proxy="fr.ifremer.wao.entity.ActivityZone" table="activityZone">
<id length="255" name="topiaId" node="@topiaId" type="string"/>
<version name="topiaVersion" node="@topiaVersion" type="long"/>
<property name="topiaCreateDate" node="@topiaCreateDate" type="timestamp"/>
@@ -10,6 +10,6 @@
<property access="field" column="zoneId" name="zoneId" node="zoneId" type="int"/>
<property access="field" column="gradiantCode" name="gradiantCode" node="gradiantCode" type="int"/>
<property access="field" column="gradiantLibelle" name="gradiantLibelle" node="gradiantLibelle" type="text"/>
- <many-to-one class="fr.ifremer.suiviobsmer.entity.ActivityProfessionImpl" column="activityProfession" embed-xml="false" name="activityProfession" node="activityProfession/@topiaId"/>
+ <many-to-one class="fr.ifremer.wao.entity.ActivityProfessionImpl" column="activityProfession" embed-xml="false" name="activityProfession" node="activityProfession/@topiaId"/>
</class>
</hibernate-mapping>
Modified: trunk/wao-business/src/main/resources/oldmappings/SuiviObsmerModel/0/fr/ifremer/suiviobsmer/entity/BoatImpl.hbm.xml
===================================================================
--- trunk/suiviobsmer-business/src/main/resources/oldmappings/SuiviObsmerModel/0/fr/ifremer/suiviobsmer/entity/BoatImpl.hbm.xml 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-business/src/main/resources/oldmappings/SuiviObsmerModel/0/fr/ifremer/suiviobsmer/entity/BoatImpl.hbm.xml 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,7 +1,7 @@
<?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 auto-import="true" default-access="field" package="fr.ifremer.suiviobsmer.entity">
- <class abstract="false" name="fr.ifremer.suiviobsmer.entity.BoatImpl" node="fr.ifremer.suiviobsmer.entity.BoatImpl" proxy="fr.ifremer.suiviobsmer.entity.Boat" table="boat">
+<hibernate-mapping auto-import="true" default-access="field" package="fr.ifremer.wao.entity">
+ <class abstract="false" name="fr.ifremer.wao.entity.BoatImpl" node="fr.ifremer.wao.entity.BoatImpl" proxy="fr.ifremer.wao.entity.Boat" table="boat">
<id length="255" name="topiaId" node="@topiaId" type="string"/>
<version name="topiaVersion" node="@topiaVersion" type="long"/>
<property name="topiaCreateDate" node="@topiaCreateDate" type="timestamp"/>
@@ -11,18 +11,18 @@
<property access="field" column="boatLength" name="boatLength" node="boatLength" type="int"/>
<property access="field" column="buildYear" name="buildYear" node="buildYear" type="int"/>
<property access="field" column="active" name="active" node="active" type="boolean"/>
- <many-to-one class="fr.ifremer.suiviobsmer.entity.ShipOwnerImpl" column="shipOwner" embed-xml="false" lazy="false" name="shipOwner" node="shipOwner/@topiaId"/>
+ <many-to-one class="fr.ifremer.wao.entity.ShipOwnerImpl" column="shipOwner" embed-xml="false" lazy="false" name="shipOwner" node="shipOwner/@topiaId"/>
<bag cascade="all,delete-orphan" embed-xml="false" inverse="true" lazy="true" name="companyBoatInfos" node="companyBoatInfos">
<key column="boat"/>
- <one-to-many class="fr.ifremer.suiviobsmer.entity.BoatInfosImpl" embed-xml="false" node="topiaId"/>
+ <one-to-many class="fr.ifremer.wao.entity.BoatInfosImpl" embed-xml="false" node="topiaId"/>
</bag>
<bag cascade="all,delete-orphan" embed-xml="false" inverse="true" lazy="true" name="activityCalendar" node="activityCalendar">
<key column="boat"/>
- <one-to-many class="fr.ifremer.suiviobsmer.entity.ActivityCalendarImpl" embed-xml="false" node="topiaId"/>
+ <one-to-many class="fr.ifremer.wao.entity.ActivityCalendarImpl" embed-xml="false" node="topiaId"/>
</bag>
<bag embed-xml="false" inverse="true" lazy="true" name="elligibleBoat" node="elligibleBoat" order-by="companyActive">
<key column="boat"/>
- <one-to-many class="fr.ifremer.suiviobsmer.entity.ElligibleBoatImpl" embed-xml="false" node="topiaId"/>
+ <one-to-many class="fr.ifremer.wao.entity.ElligibleBoatImpl" embed-xml="false" node="topiaId"/>
</bag>
</class>
</hibernate-mapping>
Modified: trunk/wao-business/src/main/resources/oldmappings/SuiviObsmerModel/0/fr/ifremer/suiviobsmer/entity/BoatInfosImpl.hbm.xml
===================================================================
--- trunk/suiviobsmer-business/src/main/resources/oldmappings/SuiviObsmerModel/0/fr/ifremer/suiviobsmer/entity/BoatInfosImpl.hbm.xml 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-business/src/main/resources/oldmappings/SuiviObsmerModel/0/fr/ifremer/suiviobsmer/entity/BoatInfosImpl.hbm.xml 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,7 +1,7 @@
<?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 auto-import="true" default-access="field" package="fr.ifremer.suiviobsmer.entity">
- <class abstract="false" name="fr.ifremer.suiviobsmer.entity.BoatInfosImpl" node="fr.ifremer.suiviobsmer.entity.BoatInfosImpl" proxy="fr.ifremer.suiviobsmer.entity.BoatInfos" table="boatInfos">
+<hibernate-mapping auto-import="true" default-access="field" package="fr.ifremer.wao.entity">
+ <class abstract="false" name="fr.ifremer.wao.entity.BoatInfosImpl" node="fr.ifremer.wao.entity.BoatInfosImpl" proxy="fr.ifremer.wao.entity.BoatInfos" table="boatInfos">
<id length="255" name="topiaId" node="@topiaId" type="string"/>
<version name="topiaVersion" node="@topiaVersion" type="long"/>
<property name="topiaCreateDate" node="@topiaCreateDate" type="timestamp"/>
@@ -11,7 +11,7 @@
<property access="field" column="contactPhoneNumber" name="contactPhoneNumber" node="contactPhoneNumber" type="text"/>
<property access="field" column="dup" name="dup" node="dup" type="java.lang.Integer"/>
<property access="field" column="comment" name="comment" node="comment" type="text"/>
- <many-to-one class="fr.ifremer.suiviobsmer.entity.CompanyImpl" column="company" embed-xml="false" name="company" node="company/@topiaId"/>
- <many-to-one class="fr.ifremer.suiviobsmer.entity.BoatImpl" column="boat" embed-xml="false" name="boat" node="boat/@topiaId"/>
+ <many-to-one class="fr.ifremer.wao.entity.CompanyImpl" column="company" embed-xml="false" name="company" node="company/@topiaId"/>
+ <many-to-one class="fr.ifremer.wao.entity.BoatImpl" column="boat" embed-xml="false" name="boat" node="boat/@topiaId"/>
</class>
</hibernate-mapping>
Modified: trunk/wao-business/src/main/resources/oldmappings/SuiviObsmerModel/0/fr/ifremer/suiviobsmer/entity/CompanyImpl.hbm.xml
===================================================================
--- trunk/suiviobsmer-business/src/main/resources/oldmappings/SuiviObsmerModel/0/fr/ifremer/suiviobsmer/entity/CompanyImpl.hbm.xml 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-business/src/main/resources/oldmappings/SuiviObsmerModel/0/fr/ifremer/suiviobsmer/entity/CompanyImpl.hbm.xml 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,7 +1,7 @@
<?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 auto-import="true" default-access="field" package="fr.ifremer.suiviobsmer.entity">
- <class abstract="false" name="fr.ifremer.suiviobsmer.entity.CompanyImpl" node="fr.ifremer.suiviobsmer.entity.CompanyImpl" proxy="fr.ifremer.suiviobsmer.entity.Company" table="company">
+<hibernate-mapping auto-import="true" default-access="field" package="fr.ifremer.wao.entity">
+ <class abstract="false" name="fr.ifremer.wao.entity.CompanyImpl" node="fr.ifremer.wao.entity.CompanyImpl" proxy="fr.ifremer.wao.entity.Company" table="company">
<id length="255" name="topiaId" node="@topiaId" type="string"/>
<version name="topiaVersion" node="@topiaVersion" type="long"/>
<property name="topiaCreateDate" node="@topiaCreateDate" type="timestamp"/>
@@ -15,11 +15,11 @@
<property access="field" column="postalCode" name="postalCode" node="postalCode" type="int"/>
<bag cascade="all,delete-orphan" embed-xml="false" inverse="true" lazy="false" name="waoUser" node="waoUser">
<key column="company"/>
- <one-to-many class="fr.ifremer.suiviobsmer.entity.WaoUserImpl" embed-xml="false" node="topiaId"/>
+ <one-to-many class="fr.ifremer.wao.entity.WaoUserImpl" embed-xml="false" node="topiaId"/>
</bag>
<bag cascade="all,delete-orphan" embed-xml="false" inverse="true" lazy="true" name="boatBoatInfos" node="boatBoatInfos">
<key column="company"/>
- <one-to-many class="fr.ifremer.suiviobsmer.entity.BoatInfosImpl" embed-xml="false" node="topiaId"/>
+ <one-to-many class="fr.ifremer.wao.entity.BoatInfosImpl" embed-xml="false" node="topiaId"/>
</bag>
</class>
</hibernate-mapping>
Modified: trunk/wao-business/src/main/resources/oldmappings/SuiviObsmerModel/0/fr/ifremer/suiviobsmer/entity/ContactImpl.hbm.xml
===================================================================
--- trunk/suiviobsmer-business/src/main/resources/oldmappings/SuiviObsmerModel/0/fr/ifremer/suiviobsmer/entity/ContactImpl.hbm.xml 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-business/src/main/resources/oldmappings/SuiviObsmerModel/0/fr/ifremer/suiviobsmer/entity/ContactImpl.hbm.xml 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,7 +1,7 @@
<?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 auto-import="true" default-access="field" package="fr.ifremer.suiviobsmer.entity">
- <class abstract="false" name="fr.ifremer.suiviobsmer.entity.ContactImpl" node="fr.ifremer.suiviobsmer.entity.ContactImpl" proxy="fr.ifremer.suiviobsmer.entity.Contact" table="contact">
+<hibernate-mapping auto-import="true" default-access="field" package="fr.ifremer.wao.entity">
+ <class abstract="false" name="fr.ifremer.wao.entity.ContactImpl" node="fr.ifremer.wao.entity.ContactImpl" proxy="fr.ifremer.wao.entity.Contact" table="contact">
<id length="255" name="topiaId" node="@topiaId" type="string"/>
<version name="topiaVersion" node="@topiaVersion" type="long"/>
<property name="topiaCreateDate" node="@topiaCreateDate" type="timestamp"/>
@@ -16,8 +16,8 @@
<property access="field" column="comment" name="comment" node="comment" type="text"/>
<property access="field" column="state" name="state" node="state" type="text"/>
<property access="field" column="tideNbDays" name="tideNbDays" node="tideNbDays" type="int"/>
- <many-to-one class="fr.ifremer.suiviobsmer.entity.WaoUserImpl" column="observer" embed-xml="false" name="observer" node="observer/@topiaId"/>
- <many-to-one class="fr.ifremer.suiviobsmer.entity.SampleRowImpl" column="sampleRow" embed-xml="false" lazy="false" name="sampleRow" node="sampleRow/@topiaId"/>
- <many-to-one class="fr.ifremer.suiviobsmer.entity.BoatImpl" column="boat" embed-xml="false" lazy="false" name="boat" node="boat/@topiaId"/>
+ <many-to-one class="fr.ifremer.wao.entity.WaoUserImpl" column="observer" embed-xml="false" name="observer" node="observer/@topiaId"/>
+ <many-to-one class="fr.ifremer.wao.entity.SampleRowImpl" column="sampleRow" embed-xml="false" lazy="false" name="sampleRow" node="sampleRow/@topiaId"/>
+ <many-to-one class="fr.ifremer.wao.entity.BoatImpl" column="boat" embed-xml="false" lazy="false" name="boat" node="boat/@topiaId"/>
</class>
</hibernate-mapping>
Modified: trunk/wao-business/src/main/resources/oldmappings/SuiviObsmerModel/0/fr/ifremer/suiviobsmer/entity/ElligibleBoatImpl.hbm.xml
===================================================================
--- trunk/suiviobsmer-business/src/main/resources/oldmappings/SuiviObsmerModel/0/fr/ifremer/suiviobsmer/entity/ElligibleBoatImpl.hbm.xml 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-business/src/main/resources/oldmappings/SuiviObsmerModel/0/fr/ifremer/suiviobsmer/entity/ElligibleBoatImpl.hbm.xml 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,13 +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 auto-import="true" default-access="field" package="fr.ifremer.suiviobsmer.entity">
- <class abstract="false" name="fr.ifremer.suiviobsmer.entity.ElligibleBoatImpl" node="fr.ifremer.suiviobsmer.entity.ElligibleBoatImpl" proxy="fr.ifremer.suiviobsmer.entity.ElligibleBoat" table="elligibleBoat">
+<hibernate-mapping auto-import="true" default-access="field" package="fr.ifremer.wao.entity">
+ <class abstract="false" name="fr.ifremer.wao.entity.ElligibleBoatImpl" node="fr.ifremer.wao.entity.ElligibleBoatImpl" proxy="fr.ifremer.wao.entity.ElligibleBoat" table="elligibleBoat">
<id length="255" name="topiaId" node="@topiaId" type="string"/>
<version name="topiaVersion" node="@topiaVersion" type="long"/>
<property name="topiaCreateDate" node="@topiaCreateDate" type="timestamp"/>
<property access="field" column="globalActive" name="globalActive" node="globalActive" type="boolean"/>
<property access="field" column="companyActive" name="companyActive" node="companyActive" type="java.lang.Boolean"/>
- <many-to-one class="fr.ifremer.suiviobsmer.entity.BoatImpl" column="boat" embed-xml="false" lazy="false" name="boat" node="boat/@topiaId"/>
- <many-to-one class="fr.ifremer.suiviobsmer.entity.SampleRowImpl" column="sampleRow" embed-xml="false" name="sampleRow" node="sampleRow/@topiaId"/>
+ <many-to-one class="fr.ifremer.wao.entity.BoatImpl" column="boat" embed-xml="false" lazy="false" name="boat" node="boat/@topiaId"/>
+ <many-to-one class="fr.ifremer.wao.entity.SampleRowImpl" column="sampleRow" embed-xml="false" name="sampleRow" node="sampleRow/@topiaId"/>
</class>
</hibernate-mapping>
Modified: trunk/wao-business/src/main/resources/oldmappings/SuiviObsmerModel/0/fr/ifremer/suiviobsmer/entity/FishingZoneImpl.hbm.xml
===================================================================
--- trunk/suiviobsmer-business/src/main/resources/oldmappings/SuiviObsmerModel/0/fr/ifremer/suiviobsmer/entity/FishingZoneImpl.hbm.xml 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-business/src/main/resources/oldmappings/SuiviObsmerModel/0/fr/ifremer/suiviobsmer/entity/FishingZoneImpl.hbm.xml 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,7 +1,7 @@
<?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 auto-import="true" default-access="field" package="fr.ifremer.suiviobsmer.entity">
- <class abstract="false" name="fr.ifremer.suiviobsmer.entity.FishingZoneImpl" node="fr.ifremer.suiviobsmer.entity.FishingZoneImpl" proxy="fr.ifremer.suiviobsmer.entity.FishingZone" table="fishingZone">
+<hibernate-mapping auto-import="true" default-access="field" package="fr.ifremer.wao.entity">
+ <class abstract="false" name="fr.ifremer.wao.entity.FishingZoneImpl" node="fr.ifremer.wao.entity.FishingZoneImpl" proxy="fr.ifremer.wao.entity.FishingZone" table="fishingZone">
<id length="255" name="topiaId" node="@topiaId" type="string"/>
<version name="topiaVersion" node="@topiaVersion" type="long"/>
<property name="topiaCreateDate" node="@topiaCreateDate" type="timestamp"/>
@@ -10,7 +10,7 @@
<property access="field" column="districtCode" name="districtCode" node="districtCode" type="text"/>
<bag embed-xml="true" lazy="true" name="sampleRow" node="sampleRow" table="fishingzone_samplerow">
<key column="fishingZone"/>
- <many-to-many class="fr.ifremer.suiviobsmer.entity.SampleRowImpl" column="sampleRow" node="topiaId" order-by="code"/>
+ <many-to-many class="fr.ifremer.wao.entity.SampleRowImpl" column="sampleRow" node="topiaId" order-by="code"/>
</bag>
</class>
</hibernate-mapping>
Modified: trunk/wao-business/src/main/resources/oldmappings/SuiviObsmerModel/0/fr/ifremer/suiviobsmer/entity/NewsImpl.hbm.xml
===================================================================
--- trunk/suiviobsmer-business/src/main/resources/oldmappings/SuiviObsmerModel/0/fr/ifremer/suiviobsmer/entity/NewsImpl.hbm.xml 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-business/src/main/resources/oldmappings/SuiviObsmerModel/0/fr/ifremer/suiviobsmer/entity/NewsImpl.hbm.xml 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,7 +1,7 @@
<?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 auto-import="true" default-access="field" package="fr.ifremer.suiviobsmer.entity">
- <class abstract="false" name="fr.ifremer.suiviobsmer.entity.NewsImpl" node="fr.ifremer.suiviobsmer.entity.NewsImpl" proxy="fr.ifremer.suiviobsmer.entity.News" table="news">
+<hibernate-mapping auto-import="true" default-access="field" package="fr.ifremer.wao.entity">
+ <class abstract="false" name="fr.ifremer.wao.entity.NewsImpl" node="fr.ifremer.wao.entity.NewsImpl" proxy="fr.ifremer.wao.entity.News" table="news">
<id length="255" name="topiaId" node="@topiaId" type="string"/>
<version name="topiaVersion" node="@topiaVersion" type="long"/>
<property name="topiaCreateDate" node="@topiaCreateDate" type="timestamp"/>
Modified: trunk/wao-business/src/main/resources/oldmappings/SuiviObsmerModel/0/fr/ifremer/suiviobsmer/entity/ProfessionImpl.hbm.xml
===================================================================
--- trunk/suiviobsmer-business/src/main/resources/oldmappings/SuiviObsmerModel/0/fr/ifremer/suiviobsmer/entity/ProfessionImpl.hbm.xml 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-business/src/main/resources/oldmappings/SuiviObsmerModel/0/fr/ifremer/suiviobsmer/entity/ProfessionImpl.hbm.xml 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,7 +1,7 @@
<?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 auto-import="true" default-access="field" package="fr.ifremer.suiviobsmer.entity">
- <class abstract="false" name="fr.ifremer.suiviobsmer.entity.ProfessionImpl" node="fr.ifremer.suiviobsmer.entity.ProfessionImpl" proxy="fr.ifremer.suiviobsmer.entity.Profession" table="profession">
+<hibernate-mapping auto-import="true" default-access="field" package="fr.ifremer.wao.entity">
+ <class abstract="false" name="fr.ifremer.wao.entity.ProfessionImpl" node="fr.ifremer.wao.entity.ProfessionImpl" proxy="fr.ifremer.wao.entity.Profession" table="profession">
<id length="255" name="topiaId" node="@topiaId" type="string"/>
<version name="topiaVersion" node="@topiaVersion" type="long"/>
<property name="topiaCreateDate" node="@topiaCreateDate" type="timestamp"/>
Modified: trunk/wao-business/src/main/resources/oldmappings/SuiviObsmerModel/0/fr/ifremer/suiviobsmer/entity/SampleMonthImpl.hbm.xml
===================================================================
--- trunk/suiviobsmer-business/src/main/resources/oldmappings/SuiviObsmerModel/0/fr/ifremer/suiviobsmer/entity/SampleMonthImpl.hbm.xml 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-business/src/main/resources/oldmappings/SuiviObsmerModel/0/fr/ifremer/suiviobsmer/entity/SampleMonthImpl.hbm.xml 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,13 +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 auto-import="true" default-access="field" package="fr.ifremer.suiviobsmer.entity">
- <class abstract="false" name="fr.ifremer.suiviobsmer.entity.SampleMonthImpl" node="fr.ifremer.suiviobsmer.entity.SampleMonthImpl" proxy="fr.ifremer.suiviobsmer.entity.SampleMonth" table="sampleMonth">
+<hibernate-mapping auto-import="true" default-access="field" package="fr.ifremer.wao.entity">
+ <class abstract="false" name="fr.ifremer.wao.entity.SampleMonthImpl" node="fr.ifremer.wao.entity.SampleMonthImpl" proxy="fr.ifremer.wao.entity.SampleMonth" table="sampleMonth">
<id length="255" name="topiaId" node="@topiaId" type="string"/>
<version name="topiaVersion" node="@topiaVersion" type="long"/>
<property name="topiaCreateDate" node="@topiaCreateDate" type="timestamp"/>
<property access="field" column="realTidesValue" name="realTidesValue" node="realTidesValue" type="int"/>
<property access="field" column="expectedTidesValue" name="expectedTidesValue" node="expectedTidesValue" type="int"/>
<property access="field" column="periodDate" name="periodDate" node="periodDate" type="java.util.Date"/>
- <many-to-one class="fr.ifremer.suiviobsmer.entity.SampleRowImpl" column="sampleRow" embed-xml="false" name="sampleRow" node="sampleRow/@topiaId"/>
+ <many-to-one class="fr.ifremer.wao.entity.SampleRowImpl" column="sampleRow" embed-xml="false" name="sampleRow" node="sampleRow/@topiaId"/>
</class>
</hibernate-mapping>
Modified: trunk/wao-business/src/main/resources/oldmappings/SuiviObsmerModel/0/fr/ifremer/suiviobsmer/entity/SampleRowImpl.hbm.xml
===================================================================
--- trunk/suiviobsmer-business/src/main/resources/oldmappings/SuiviObsmerModel/0/fr/ifremer/suiviobsmer/entity/SampleRowImpl.hbm.xml 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-business/src/main/resources/oldmappings/SuiviObsmerModel/0/fr/ifremer/suiviobsmer/entity/SampleRowImpl.hbm.xml 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,7 +1,7 @@
<?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 auto-import="true" default-access="field" package="fr.ifremer.suiviobsmer.entity">
- <class abstract="false" name="fr.ifremer.suiviobsmer.entity.SampleRowImpl" node="fr.ifremer.suiviobsmer.entity.SampleRowImpl" proxy="fr.ifremer.suiviobsmer.entity.SampleRow" table="sampleRow">
+<hibernate-mapping auto-import="true" default-access="field" package="fr.ifremer.wao.entity">
+ <class abstract="false" name="fr.ifremer.wao.entity.SampleRowImpl" node="fr.ifremer.wao.entity.SampleRowImpl" proxy="fr.ifremer.wao.entity.SampleRow" table="sampleRow">
<id length="255" name="topiaId" node="@topiaId" type="string"/>
<version name="topiaVersion" node="@topiaVersion" type="long"/>
<property name="topiaCreateDate" node="@topiaCreateDate" type="timestamp"/>
@@ -13,27 +13,27 @@
<property access="field" column="programName" name="programName" node="programName" type="text"/>
<property access="field" column="periodBegin" name="periodBegin" node="periodBegin" type="java.util.Date"/>
<property access="field" column="periodEnd" name="periodEnd" node="periodEnd" type="java.util.Date"/>
- <many-to-one class="fr.ifremer.suiviobsmer.entity.ProfessionImpl" column="profession" embed-xml="false" lazy="false" name="profession" node="profession/@topiaId"/>
+ <many-to-one class="fr.ifremer.wao.entity.ProfessionImpl" column="profession" embed-xml="false" lazy="false" name="profession" node="profession/@topiaId"/>
<bag cascade="all,delete-orphan" embed-xml="false" inverse="true" lazy="false" name="sampleMonth" node="sampleMonth" order-by="periodDate">
<key column="sampleRow"/>
- <one-to-many class="fr.ifremer.suiviobsmer.entity.SampleMonthImpl" embed-xml="false" node="topiaId"/>
+ <one-to-many class="fr.ifremer.wao.entity.SampleMonthImpl" embed-xml="false" node="topiaId"/>
</bag>
- <many-to-one class="fr.ifremer.suiviobsmer.entity.CompanyImpl" column="company" embed-xml="false" lazy="false" name="company" node="company/@topiaId"/>
+ <many-to-one class="fr.ifremer.wao.entity.CompanyImpl" column="company" embed-xml="false" lazy="false" name="company" node="company/@topiaId"/>
<bag cascade="all,delete-orphan" embed-xml="false" inverse="true" lazy="false" name="sampleRowLog" node="sampleRowLog" order-by="topiaCreateDate desc">
<key column="sampleRow"/>
- <one-to-many class="fr.ifremer.suiviobsmer.entity.SampleRowLogImpl" embed-xml="false" node="topiaId"/>
+ <one-to-many class="fr.ifremer.wao.entity.SampleRowLogImpl" embed-xml="false" node="topiaId"/>
</bag>
<bag cascade="all,delete-orphan" embed-xml="false" inverse="true" lazy="false" name="elligibleBoat" node="elligibleBoat" order-by="companyActive">
<key column="sampleRow"/>
- <one-to-many class="fr.ifremer.suiviobsmer.entity.ElligibleBoatImpl" embed-xml="false" node="topiaId"/>
+ <one-to-many class="fr.ifremer.wao.entity.ElligibleBoatImpl" embed-xml="false" node="topiaId"/>
</bag>
<bag embed-xml="true" inverse="true" lazy="false" name="fishingZone" node="fishingZone" table="fishingzone_samplerow">
<key column="sampleRow"/>
- <many-to-many class="fr.ifremer.suiviobsmer.entity.FishingZoneImpl" column="fishingZone" node="topiaId" order-by="facadeName,sectorName,districtCode"/>
+ <many-to-many class="fr.ifremer.wao.entity.FishingZoneImpl" column="fishingZone" node="topiaId" order-by="facadeName,sectorName,districtCode"/>
</bag>
<bag embed-xml="false" inverse="true" lazy="true" name="contact" node="contact">
<key column="sampleRow"/>
- <one-to-many class="fr.ifremer.suiviobsmer.entity.ContactImpl" embed-xml="false" node="topiaId"/>
+ <one-to-many class="fr.ifremer.wao.entity.ContactImpl" embed-xml="false" node="topiaId"/>
</bag>
</class>
</hibernate-mapping>
Modified: trunk/wao-business/src/main/resources/oldmappings/SuiviObsmerModel/0/fr/ifremer/suiviobsmer/entity/SampleRowLogImpl.hbm.xml
===================================================================
--- trunk/suiviobsmer-business/src/main/resources/oldmappings/SuiviObsmerModel/0/fr/ifremer/suiviobsmer/entity/SampleRowLogImpl.hbm.xml 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-business/src/main/resources/oldmappings/SuiviObsmerModel/0/fr/ifremer/suiviobsmer/entity/SampleRowLogImpl.hbm.xml 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,13 +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 auto-import="true" default-access="field" package="fr.ifremer.suiviobsmer.entity">
- <class abstract="false" name="fr.ifremer.suiviobsmer.entity.SampleRowLogImpl" node="fr.ifremer.suiviobsmer.entity.SampleRowLogImpl" proxy="fr.ifremer.suiviobsmer.entity.SampleRowLog" table="sampleRowLog">
+<hibernate-mapping auto-import="true" default-access="field" package="fr.ifremer.wao.entity">
+ <class abstract="false" name="fr.ifremer.wao.entity.SampleRowLogImpl" node="fr.ifremer.wao.entity.SampleRowLogImpl" proxy="fr.ifremer.wao.entity.SampleRowLog" table="sampleRowLog">
<id length="255" name="topiaId" node="@topiaId" type="string"/>
<version name="topiaVersion" node="@topiaVersion" type="long"/>
<property name="topiaCreateDate" node="@topiaCreateDate" type="timestamp"/>
<property access="field" column="logText" name="logText" node="logText" type="text"/>
<property access="field" column="comment" name="comment" node="comment" type="text"/>
- <many-to-one class="fr.ifremer.suiviobsmer.entity.SampleRowImpl" column="sampleRow" embed-xml="false" name="sampleRow" node="sampleRow/@topiaId"/>
- <many-to-one class="fr.ifremer.suiviobsmer.entity.WaoUserImpl" column="admin" embed-xml="false" lazy="false" name="admin" node="admin/@topiaId"/>
+ <many-to-one class="fr.ifremer.wao.entity.SampleRowImpl" column="sampleRow" embed-xml="false" name="sampleRow" node="sampleRow/@topiaId"/>
+ <many-to-one class="fr.ifremer.wao.entity.WaoUserImpl" column="admin" embed-xml="false" lazy="false" name="admin" node="admin/@topiaId"/>
</class>
</hibernate-mapping>
Modified: trunk/wao-business/src/main/resources/oldmappings/SuiviObsmerModel/0/fr/ifremer/suiviobsmer/entity/ShipOwnerImpl.hbm.xml
===================================================================
--- trunk/suiviobsmer-business/src/main/resources/oldmappings/SuiviObsmerModel/0/fr/ifremer/suiviobsmer/entity/ShipOwnerImpl.hbm.xml 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-business/src/main/resources/oldmappings/SuiviObsmerModel/0/fr/ifremer/suiviobsmer/entity/ShipOwnerImpl.hbm.xml 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,7 +1,7 @@
<?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 auto-import="true" default-access="field" package="fr.ifremer.suiviobsmer.entity">
- <class abstract="false" name="fr.ifremer.suiviobsmer.entity.ShipOwnerImpl" node="fr.ifremer.suiviobsmer.entity.ShipOwnerImpl" proxy="fr.ifremer.suiviobsmer.entity.ShipOwner" table="shipOwner">
+<hibernate-mapping auto-import="true" default-access="field" package="fr.ifremer.wao.entity">
+ <class abstract="false" name="fr.ifremer.wao.entity.ShipOwnerImpl" node="fr.ifremer.wao.entity.ShipOwnerImpl" proxy="fr.ifremer.wao.entity.ShipOwner" table="shipOwner">
<id length="255" name="topiaId" node="@topiaId" type="string"/>
<version name="topiaVersion" node="@topiaVersion" type="long"/>
<property name="topiaCreateDate" node="@topiaCreateDate" type="timestamp"/>
Modified: trunk/wao-business/src/main/resources/oldmappings/SuiviObsmerModel/0/fr/ifremer/suiviobsmer/entity/WaoUserImpl.hbm.xml
===================================================================
--- trunk/suiviobsmer-business/src/main/resources/oldmappings/SuiviObsmerModel/0/fr/ifremer/suiviobsmer/entity/WaoUserImpl.hbm.xml 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-business/src/main/resources/oldmappings/SuiviObsmerModel/0/fr/ifremer/suiviobsmer/entity/WaoUserImpl.hbm.xml 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,7 +1,7 @@
<?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 auto-import="true" default-access="field" package="fr.ifremer.suiviobsmer.entity">
- <class abstract="false" name="fr.ifremer.suiviobsmer.entity.WaoUserImpl" node="fr.ifremer.suiviobsmer.entity.WaoUserImpl" proxy="fr.ifremer.suiviobsmer.entity.WaoUser" table="waoUser">
+<hibernate-mapping auto-import="true" default-access="field" package="fr.ifremer.wao.entity">
+ <class abstract="false" name="fr.ifremer.wao.entity.WaoUserImpl" node="fr.ifremer.wao.entity.WaoUserImpl" proxy="fr.ifremer.wao.entity.WaoUser" table="waoUser">
<id length="255" name="topiaId" node="@topiaId" type="string"/>
<version name="topiaVersion" node="@topiaVersion" type="long"/>
<property name="topiaCreateDate" node="@topiaCreateDate" type="timestamp"/>
@@ -12,10 +12,10 @@
<property access="field" column="password" name="password" node="password" type="text"/>
<property access="field" column="active" name="active" node="active" type="boolean"/>
<property access="field" column="admin" name="admin" node="admin" type="boolean"/>
- <many-to-one class="fr.ifremer.suiviobsmer.entity.CompanyImpl" column="company" embed-xml="false" name="company" node="company/@topiaId"/>
+ <many-to-one class="fr.ifremer.wao.entity.CompanyImpl" column="company" embed-xml="false" name="company" node="company/@topiaId"/>
<bag embed-xml="false" inverse="true" lazy="true" name="contact" node="contact">
<key column="observer"/>
- <one-to-many class="fr.ifremer.suiviobsmer.entity.ContactImpl" embed-xml="false" node="topiaId"/>
+ <one-to-many class="fr.ifremer.wao.entity.ContactImpl" embed-xml="false" node="topiaId"/>
</bag>
</class>
</hibernate-mapping>
Modified: trunk/wao-business/src/main/resources/oldmappings/SuiviObsmerModel/0.4/fr/ifremer/suiviobsmer/entity/ActivityCalendarImpl.hbm.xml
===================================================================
--- trunk/suiviobsmer-business/src/main/resources/oldmappings/SuiviObsmerModel/0.4/fr/ifremer/suiviobsmer/entity/ActivityCalendarImpl.hbm.xml 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-business/src/main/resources/oldmappings/SuiviObsmerModel/0.4/fr/ifremer/suiviobsmer/entity/ActivityCalendarImpl.hbm.xml 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,7 +1,7 @@
<?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.suiviobsmer.entity">
- <class name="fr.ifremer.suiviobsmer.entity.ActivityCalendarImpl" table="activityCalendar" node="fr.ifremer.suiviobsmer.entity.ActivityCalendarImpl" abstract="false" proxy="fr.ifremer.suiviobsmer.entity.ActivityCalendar" >
+<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"/>
@@ -9,8 +9,8 @@
<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.suiviobsmer.entity.ActivityMonthImpl" node="topiaId" embed-xml="false"/>
+ <one-to-many class="fr.ifremer.wao.entity.ActivityMonthImpl" node="topiaId" embed-xml="false"/>
</bag>
- <many-to-one name="boat" class="fr.ifremer.suiviobsmer.entity.BoatImpl" column="boat" node="boat/@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>
Modified: trunk/wao-business/src/main/resources/oldmappings/SuiviObsmerModel/0.4/fr/ifremer/suiviobsmer/entity/ActivityMonthImpl.hbm.xml
===================================================================
--- trunk/suiviobsmer-business/src/main/resources/oldmappings/SuiviObsmerModel/0.4/fr/ifremer/suiviobsmer/entity/ActivityMonthImpl.hbm.xml 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-business/src/main/resources/oldmappings/SuiviObsmerModel/0.4/fr/ifremer/suiviobsmer/entity/ActivityMonthImpl.hbm.xml 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,7 +1,7 @@
<?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.suiviobsmer.entity">
- <class name="fr.ifremer.suiviobsmer.entity.ActivityMonthImpl" table="activityMonth" node="fr.ifremer.suiviobsmer.entity.ActivityMonthImpl" abstract="false" proxy="fr.ifremer.suiviobsmer.entity.ActivityMonth" >
+<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"/>
@@ -15,8 +15,8 @@
<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.suiviobsmer.entity.ActivityProfessionImpl" node="topiaId" embed-xml="false"/>
+ <one-to-many class="fr.ifremer.wao.entity.ActivityProfessionImpl" node="topiaId" embed-xml="false"/>
</bag>
- <many-to-one name="activityCalendar" class="fr.ifremer.suiviobsmer.entity.ActivityCalendarImpl" column="activityCalendar" node="activityCalendar/@topiaId" embed-xml="false"/>
+ <many-to-one name="activityCalendar" class="fr.ifremer.wao.entity.ActivityCalendarImpl" column="activityCalendar" node="activityCalendar/@topiaId" embed-xml="false"/>
</class>
</hibernate-mapping>
Modified: trunk/wao-business/src/main/resources/oldmappings/SuiviObsmerModel/0.4/fr/ifremer/suiviobsmer/entity/ActivityProfessionImpl.hbm.xml
===================================================================
--- trunk/suiviobsmer-business/src/main/resources/oldmappings/SuiviObsmerModel/0.4/fr/ifremer/suiviobsmer/entity/ActivityProfessionImpl.hbm.xml 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-business/src/main/resources/oldmappings/SuiviObsmerModel/0.4/fr/ifremer/suiviobsmer/entity/ActivityProfessionImpl.hbm.xml 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,7 +1,7 @@
<?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.suiviobsmer.entity">
- <class name="fr.ifremer.suiviobsmer.entity.ActivityProfessionImpl" table="activityProfession" node="fr.ifremer.suiviobsmer.entity.ActivityProfessionImpl" abstract="false" proxy="fr.ifremer.suiviobsmer.entity.ActivityProfession" >
+<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"/>
@@ -9,10 +9,10 @@
<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.suiviobsmer.entity.ActivityMonthImpl" column="activityMonth" node="activityMonth/@topiaId" embed-xml="false"/>
+ <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.suiviobsmer.entity.ActivityZoneImpl" node="topiaId" embed-xml="false"/>
+ <one-to-many class="fr.ifremer.wao.entity.ActivityZoneImpl" node="topiaId" embed-xml="false"/>
</bag>
</class>
</hibernate-mapping>
Modified: trunk/wao-business/src/main/resources/oldmappings/SuiviObsmerModel/0.4/fr/ifremer/suiviobsmer/entity/ActivityZoneImpl.hbm.xml
===================================================================
--- trunk/suiviobsmer-business/src/main/resources/oldmappings/SuiviObsmerModel/0.4/fr/ifremer/suiviobsmer/entity/ActivityZoneImpl.hbm.xml 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-business/src/main/resources/oldmappings/SuiviObsmerModel/0.4/fr/ifremer/suiviobsmer/entity/ActivityZoneImpl.hbm.xml 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,7 +1,7 @@
<?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.suiviobsmer.entity">
- <class name="fr.ifremer.suiviobsmer.entity.ActivityZoneImpl" table="activityZone" node="fr.ifremer.suiviobsmer.entity.ActivityZoneImpl" abstract="false" proxy="fr.ifremer.suiviobsmer.entity.ActivityZone" >
+<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"/>
@@ -10,6 +10,6 @@
<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.suiviobsmer.entity.ActivityProfessionImpl" column="activityProfession" node="activityProfession/@topiaId" embed-xml="false"/>
+ <many-to-one name="activityProfession" class="fr.ifremer.wao.entity.ActivityProfessionImpl" column="activityProfession" node="activityProfession/@topiaId" embed-xml="false"/>
</class>
</hibernate-mapping>
Modified: trunk/wao-business/src/main/resources/oldmappings/SuiviObsmerModel/0.4/fr/ifremer/suiviobsmer/entity/BoatImpl.hbm.xml
===================================================================
--- trunk/suiviobsmer-business/src/main/resources/oldmappings/SuiviObsmerModel/0.4/fr/ifremer/suiviobsmer/entity/BoatImpl.hbm.xml 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-business/src/main/resources/oldmappings/SuiviObsmerModel/0.4/fr/ifremer/suiviobsmer/entity/BoatImpl.hbm.xml 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,7 +1,7 @@
<?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.suiviobsmer.entity">
- <class name="fr.ifremer.suiviobsmer.entity.BoatImpl" table="boat" node="fr.ifremer.suiviobsmer.entity.BoatImpl" abstract="false" proxy="fr.ifremer.suiviobsmer.entity.Boat" >
+<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"/>
@@ -11,18 +11,18 @@
<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.suiviobsmer.entity.ShipOwnerImpl" column="shipOwner" lazy="false" node="shipOwner/@topiaId" embed-xml="false"/>
+ <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.suiviobsmer.entity.BoatInfosImpl" node="topiaId" embed-xml="false"/>
+ <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.suiviobsmer.entity.ActivityCalendarImpl" node="topiaId" embed-xml="false"/>
+ <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.suiviobsmer.entity.ElligibleBoatImpl" node="topiaId" embed-xml="false"/>
+ <one-to-many class="fr.ifremer.wao.entity.ElligibleBoatImpl" node="topiaId" embed-xml="false"/>
</bag>
</class>
</hibernate-mapping>
Modified: trunk/wao-business/src/main/resources/oldmappings/SuiviObsmerModel/0.4/fr/ifremer/suiviobsmer/entity/BoatInfosImpl.hbm.xml
===================================================================
--- trunk/suiviobsmer-business/src/main/resources/oldmappings/SuiviObsmerModel/0.4/fr/ifremer/suiviobsmer/entity/BoatInfosImpl.hbm.xml 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-business/src/main/resources/oldmappings/SuiviObsmerModel/0.4/fr/ifremer/suiviobsmer/entity/BoatInfosImpl.hbm.xml 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,7 +1,7 @@
<?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.suiviobsmer.entity">
- <class name="fr.ifremer.suiviobsmer.entity.BoatInfosImpl" table="boatInfos" node="fr.ifremer.suiviobsmer.entity.BoatInfosImpl" abstract="false" proxy="fr.ifremer.suiviobsmer.entity.BoatInfos" >
+<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"/>
@@ -11,7 +11,7 @@
<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.suiviobsmer.entity.CompanyImpl" column="company" node="company/@topiaId" embed-xml="false" />
- <many-to-one name="boat" class="fr.ifremer.suiviobsmer.entity.BoatImpl" column="boat" node="boat/@topiaId" embed-xml="false" />
+ <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>
Modified: trunk/wao-business/src/main/resources/oldmappings/SuiviObsmerModel/0.4/fr/ifremer/suiviobsmer/entity/CompanyImpl.hbm.xml
===================================================================
--- trunk/suiviobsmer-business/src/main/resources/oldmappings/SuiviObsmerModel/0.4/fr/ifremer/suiviobsmer/entity/CompanyImpl.hbm.xml 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-business/src/main/resources/oldmappings/SuiviObsmerModel/0.4/fr/ifremer/suiviobsmer/entity/CompanyImpl.hbm.xml 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,7 +1,7 @@
<?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.suiviobsmer.entity">
- <class name="fr.ifremer.suiviobsmer.entity.CompanyImpl" table="company" node="fr.ifremer.suiviobsmer.entity.CompanyImpl" abstract="false" proxy="fr.ifremer.suiviobsmer.entity.Company" >
+<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"/>
@@ -15,11 +15,11 @@
<property name="postalCode" type="int" access="field" column="postalCode" node="postalCode"/>
<bag name="waoUser" inverse="true" lazy="false" cascade="all,delete-orphan" node="waoUser" embed-xml="false">
<key column="company"/>
- <one-to-many class="fr.ifremer.suiviobsmer.entity.WaoUserImpl" node="topiaId" embed-xml="false"/>
+ <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.suiviobsmer.entity.BoatInfosImpl" node="topiaId" embed-xml="false"/>
+ <one-to-many class="fr.ifremer.wao.entity.BoatInfosImpl" node="topiaId" embed-xml="false"/>
</bag>
</class>
</hibernate-mapping>
Modified: trunk/wao-business/src/main/resources/oldmappings/SuiviObsmerModel/0.4/fr/ifremer/suiviobsmer/entity/ContactImpl.hbm.xml
===================================================================
--- trunk/suiviobsmer-business/src/main/resources/oldmappings/SuiviObsmerModel/0.4/fr/ifremer/suiviobsmer/entity/ContactImpl.hbm.xml 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-business/src/main/resources/oldmappings/SuiviObsmerModel/0.4/fr/ifremer/suiviobsmer/entity/ContactImpl.hbm.xml 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,7 +1,7 @@
<?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.suiviobsmer.entity">
- <class name="fr.ifremer.suiviobsmer.entity.ContactImpl" table="contact" node="fr.ifremer.suiviobsmer.entity.ContactImpl" abstract="false" proxy="fr.ifremer.suiviobsmer.entity.Contact" >
+<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"/>
@@ -16,8 +16,8 @@
<property name="comment" type="text" access="field" column="comment" node="comment"/>
<property name="state" type="text" 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.suiviobsmer.entity.WaoUserImpl" column="observer" node="observer/@topiaId" embed-xml="false"/>
- <many-to-one name="sampleRow" class="fr.ifremer.suiviobsmer.entity.SampleRowImpl" column="sampleRow" lazy="false" node="sampleRow/@topiaId" embed-xml="false"/>
- <many-to-one name="boat" class="fr.ifremer.suiviobsmer.entity.BoatImpl" column="boat" lazy="false" node="boat/@topiaId" embed-xml="false"/>
+ <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>
Modified: trunk/wao-business/src/main/resources/oldmappings/SuiviObsmerModel/0.4/fr/ifremer/suiviobsmer/entity/ElligibleBoatImpl.hbm.xml
===================================================================
--- trunk/suiviobsmer-business/src/main/resources/oldmappings/SuiviObsmerModel/0.4/fr/ifremer/suiviobsmer/entity/ElligibleBoatImpl.hbm.xml 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-business/src/main/resources/oldmappings/SuiviObsmerModel/0.4/fr/ifremer/suiviobsmer/entity/ElligibleBoatImpl.hbm.xml 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,13 +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.suiviobsmer.entity">
- <class name="fr.ifremer.suiviobsmer.entity.ElligibleBoatImpl" table="elligibleBoat" node="fr.ifremer.suiviobsmer.entity.ElligibleBoatImpl" abstract="false" proxy="fr.ifremer.suiviobsmer.entity.ElligibleBoat" >
+<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.suiviobsmer.entity.BoatImpl" column="boat" lazy="false" node="boat/@topiaId" embed-xml="false"/>
- <many-to-one name="sampleRow" class="fr.ifremer.suiviobsmer.entity.SampleRowImpl" column="sampleRow" 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"/>
+ <many-to-one name="sampleRow" class="fr.ifremer.wao.entity.SampleRowImpl" column="sampleRow" node="sampleRow/@topiaId" embed-xml="false"/>
</class>
</hibernate-mapping>
Modified: trunk/wao-business/src/main/resources/oldmappings/SuiviObsmerModel/0.4/fr/ifremer/suiviobsmer/entity/FishingZoneImpl.hbm.xml
===================================================================
--- trunk/suiviobsmer-business/src/main/resources/oldmappings/SuiviObsmerModel/0.4/fr/ifremer/suiviobsmer/entity/FishingZoneImpl.hbm.xml 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-business/src/main/resources/oldmappings/SuiviObsmerModel/0.4/fr/ifremer/suiviobsmer/entity/FishingZoneImpl.hbm.xml 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,7 +1,7 @@
<?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.suiviobsmer.entity">
- <class name="fr.ifremer.suiviobsmer.entity.FishingZoneImpl" table="fishingZone" node="fr.ifremer.suiviobsmer.entity.FishingZoneImpl" abstract="false" proxy="fr.ifremer.suiviobsmer.entity.FishingZone" >
+<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"/>
@@ -10,7 +10,7 @@
<property name="districtCode" type="text" access="field" column="districtCode" node="districtCode"/>
<bag name="sampleRow" table="fishingzone_samplerow" lazy="true" node="sampleRow" embed-xml="true">
<key column="fishingZone"/>
- <many-to-many class="fr.ifremer.suiviobsmer.entity.SampleRowImpl" column="sampleRow" order-by="code" node="topiaId"/>
+ <many-to-many class="fr.ifremer.wao.entity.SampleRowImpl" column="sampleRow" order-by="code" node="topiaId"/>
</bag>
</class>
</hibernate-mapping>
Modified: trunk/wao-business/src/main/resources/oldmappings/SuiviObsmerModel/0.4/fr/ifremer/suiviobsmer/entity/NewsImpl.hbm.xml
===================================================================
--- trunk/suiviobsmer-business/src/main/resources/oldmappings/SuiviObsmerModel/0.4/fr/ifremer/suiviobsmer/entity/NewsImpl.hbm.xml 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-business/src/main/resources/oldmappings/SuiviObsmerModel/0.4/fr/ifremer/suiviobsmer/entity/NewsImpl.hbm.xml 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,7 +1,7 @@
<?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.suiviobsmer.entity">
- <class name="fr.ifremer.suiviobsmer.entity.NewsImpl" table="news" node="fr.ifremer.suiviobsmer.entity.NewsImpl" abstract="false" proxy="fr.ifremer.suiviobsmer.entity.News" >
+<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"/>
Modified: trunk/wao-business/src/main/resources/oldmappings/SuiviObsmerModel/0.4/fr/ifremer/suiviobsmer/entity/ProfessionImpl.hbm.xml
===================================================================
--- trunk/suiviobsmer-business/src/main/resources/oldmappings/SuiviObsmerModel/0.4/fr/ifremer/suiviobsmer/entity/ProfessionImpl.hbm.xml 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-business/src/main/resources/oldmappings/SuiviObsmerModel/0.4/fr/ifremer/suiviobsmer/entity/ProfessionImpl.hbm.xml 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,7 +1,7 @@
<?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.suiviobsmer.entity">
- <class name="fr.ifremer.suiviobsmer.entity.ProfessionImpl" table="profession" node="fr.ifremer.suiviobsmer.entity.ProfessionImpl" abstract="false" proxy="fr.ifremer.suiviobsmer.entity.Profession" >
+<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"/>
Modified: trunk/wao-business/src/main/resources/oldmappings/SuiviObsmerModel/0.4/fr/ifremer/suiviobsmer/entity/SampleMonthImpl.hbm.xml
===================================================================
--- trunk/suiviobsmer-business/src/main/resources/oldmappings/SuiviObsmerModel/0.4/fr/ifremer/suiviobsmer/entity/SampleMonthImpl.hbm.xml 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-business/src/main/resources/oldmappings/SuiviObsmerModel/0.4/fr/ifremer/suiviobsmer/entity/SampleMonthImpl.hbm.xml 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,13 +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.suiviobsmer.entity">
- <class name="fr.ifremer.suiviobsmer.entity.SampleMonthImpl" table="sampleMonth" node="fr.ifremer.suiviobsmer.entity.SampleMonthImpl" abstract="false" proxy="fr.ifremer.suiviobsmer.entity.SampleMonth" >
+<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.suiviobsmer.entity.SampleRowImpl" column="sampleRow" node="sampleRow/@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>
Modified: trunk/wao-business/src/main/resources/oldmappings/SuiviObsmerModel/0.4/fr/ifremer/suiviobsmer/entity/SampleRowImpl.hbm.xml
===================================================================
--- trunk/suiviobsmer-business/src/main/resources/oldmappings/SuiviObsmerModel/0.4/fr/ifremer/suiviobsmer/entity/SampleRowImpl.hbm.xml 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-business/src/main/resources/oldmappings/SuiviObsmerModel/0.4/fr/ifremer/suiviobsmer/entity/SampleRowImpl.hbm.xml 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,7 +1,7 @@
<?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.suiviobsmer.entity">
- <class name="fr.ifremer.suiviobsmer.entity.SampleRowImpl" table="sampleRow" node="fr.ifremer.suiviobsmer.entity.SampleRowImpl" abstract="false" proxy="fr.ifremer.suiviobsmer.entity.SampleRow" >
+<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"/>
@@ -13,27 +13,27 @@
<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.suiviobsmer.entity.ProfessionImpl" column="profession" lazy="false" node="profession/@topiaId" embed-xml="false"/>
+ <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="false" cascade="all,delete-orphan" node="sampleMonth" embed-xml="false">
<key column="sampleRow"/>
- <one-to-many class="fr.ifremer.suiviobsmer.entity.SampleMonthImpl" node="topiaId" embed-xml="false"/>
+ <one-to-many class="fr.ifremer.wao.entity.SampleMonthImpl" node="topiaId" embed-xml="false"/>
</bag>
- <many-to-one name="company" class="fr.ifremer.suiviobsmer.entity.CompanyImpl" column="company" lazy="false" node="company/@topiaId" embed-xml="false"/>
+ <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="false" cascade="all,delete-orphan" node="sampleRowLog" embed-xml="false">
<key column="sampleRow"/>
- <one-to-many class="fr.ifremer.suiviobsmer.entity.SampleRowLogImpl" node="topiaId" embed-xml="false"/>
+ <one-to-many class="fr.ifremer.wao.entity.SampleRowLogImpl" node="topiaId" embed-xml="false"/>
</bag>
<bag name="elligibleBoat" inverse="true" order-by="companyActive" lazy="false" cascade="all,delete-orphan" node="elligibleBoat" embed-xml="false">
<key column="sampleRow"/>
- <one-to-many class="fr.ifremer.suiviobsmer.entity.ElligibleBoatImpl" node="topiaId" embed-xml="false"/>
+ <one-to-many class="fr.ifremer.wao.entity.ElligibleBoatImpl" node="topiaId" embed-xml="false"/>
</bag>
<bag name="fishingZone" table="fishingzone_samplerow" inverse="true" lazy="false" node="fishingZone" embed-xml="true">
<key column="sampleRow"/>
- <many-to-many class="fr.ifremer.suiviobsmer.entity.FishingZoneImpl" column="fishingZone" order-by="facadeName,sectorName,districtCode" node="topiaId"/>
+ <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.suiviobsmer.entity.ContactImpl" node="topiaId" embed-xml="false"/>
+ <one-to-many class="fr.ifremer.wao.entity.ContactImpl" node="topiaId" embed-xml="false"/>
</bag>
</class>
</hibernate-mapping>
Modified: trunk/wao-business/src/main/resources/oldmappings/SuiviObsmerModel/0.4/fr/ifremer/suiviobsmer/entity/SampleRowLogImpl.hbm.xml
===================================================================
--- trunk/suiviobsmer-business/src/main/resources/oldmappings/SuiviObsmerModel/0.4/fr/ifremer/suiviobsmer/entity/SampleRowLogImpl.hbm.xml 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-business/src/main/resources/oldmappings/SuiviObsmerModel/0.4/fr/ifremer/suiviobsmer/entity/SampleRowLogImpl.hbm.xml 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,13 +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.suiviobsmer.entity">
- <class name="fr.ifremer.suiviobsmer.entity.SampleRowLogImpl" table="sampleRowLog" node="fr.ifremer.suiviobsmer.entity.SampleRowLogImpl" abstract="false" proxy="fr.ifremer.suiviobsmer.entity.SampleRowLog" >
+<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.suiviobsmer.entity.SampleRowImpl" column="sampleRow" node="sampleRow/@topiaId" embed-xml="false"/>
- <many-to-one name="admin" class="fr.ifremer.suiviobsmer.entity.WaoUserImpl" column="admin" lazy="false" node="admin/@topiaId" embed-xml="false"/>
+ <many-to-one name="sampleRow" class="fr.ifremer.wao.entity.SampleRowImpl" column="sampleRow" node="sampleRow/@topiaId" embed-xml="false"/>
+ <many-to-one name="admin" class="fr.ifremer.wao.entity.WaoUserImpl" column="admin" lazy="false" node="admin/@topiaId" embed-xml="false"/>
</class>
</hibernate-mapping>
Modified: trunk/wao-business/src/main/resources/oldmappings/SuiviObsmerModel/0.4/fr/ifremer/suiviobsmer/entity/ShipOwnerImpl.hbm.xml
===================================================================
--- trunk/suiviobsmer-business/src/main/resources/oldmappings/SuiviObsmerModel/0.4/fr/ifremer/suiviobsmer/entity/ShipOwnerImpl.hbm.xml 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-business/src/main/resources/oldmappings/SuiviObsmerModel/0.4/fr/ifremer/suiviobsmer/entity/ShipOwnerImpl.hbm.xml 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,7 +1,7 @@
<?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.suiviobsmer.entity">
- <class name="fr.ifremer.suiviobsmer.entity.ShipOwnerImpl" table="shipOwner" node="fr.ifremer.suiviobsmer.entity.ShipOwnerImpl" abstract="false" proxy="fr.ifremer.suiviobsmer.entity.ShipOwner" >
+<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"/>
Modified: trunk/wao-business/src/main/resources/oldmappings/SuiviObsmerModel/0.4/fr/ifremer/suiviobsmer/entity/WaoUserImpl.hbm.xml
===================================================================
--- trunk/suiviobsmer-business/src/main/resources/oldmappings/SuiviObsmerModel/0.4/fr/ifremer/suiviobsmer/entity/WaoUserImpl.hbm.xml 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-business/src/main/resources/oldmappings/SuiviObsmerModel/0.4/fr/ifremer/suiviobsmer/entity/WaoUserImpl.hbm.xml 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,7 +1,7 @@
<?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.suiviobsmer.entity">
- <class name="fr.ifremer.suiviobsmer.entity.WaoUserImpl" table="waoUser" node="fr.ifremer.suiviobsmer.entity.WaoUserImpl" abstract="false" proxy="fr.ifremer.suiviobsmer.entity.WaoUser" >
+<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"/>
@@ -12,10 +12,10 @@
<property name="password" type="text" access="field" column="password" node="password"/>
<property name="active" type="boolean" access="field" column="active" node="active"/>
<property name="admin" type="boolean" access="field" column="admin" node="admin"/>
- <many-to-one name="company" class="fr.ifremer.suiviobsmer.entity.CompanyImpl" column="company" node="company/@topiaId" embed-xml="false"/>
+ <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.suiviobsmer.entity.ContactImpl" node="topiaId" embed-xml="false"/>
+ <one-to-many class="fr.ifremer.wao.entity.ContactImpl" node="topiaId" embed-xml="false"/>
</bag>
</class>
</hibernate-mapping>
Modified: trunk/wao-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/ActivityCalendarImpl.hbm.xml
===================================================================
--- trunk/suiviobsmer-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/ActivityCalendarImpl.hbm.xml 2010-02-16 12:00:05 UTC (rev 354)
+++ trunk/wao-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/ActivityCalendarImpl.hbm.xml 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,7 +1,7 @@
<?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.suiviobsmer.entity">
- <class name="fr.ifremer.suiviobsmer.entity.ActivityCalendarImpl" table="activityCalendar" node="fr.ifremer.suiviobsmer.entity.ActivityCalendarImpl" abstract="false" proxy="fr.ifremer.suiviobsmer.entity.ActivityCalendar" >
+<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"/>
@@ -9,8 +9,8 @@
<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.suiviobsmer.entity.ActivityMonthImpl" node="topiaId" embed-xml="false"/>
+ <one-to-many class="fr.ifremer.wao.entity.ActivityMonthImpl" node="topiaId" embed-xml="false"/>
</bag>
- <many-to-one name="boat" class="fr.ifremer.suiviobsmer.entity.BoatImpl" column="boat" node="boat/@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>
Modified: trunk/wao-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/ActivityMonthImpl.hbm.xml
===================================================================
--- trunk/suiviobsmer-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/ActivityMonthImpl.hbm.xml 2010-02-16 12:00:05 UTC (rev 354)
+++ trunk/wao-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/ActivityMonthImpl.hbm.xml 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,7 +1,7 @@
<?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.suiviobsmer.entity">
- <class name="fr.ifremer.suiviobsmer.entity.ActivityMonthImpl" table="activityMonth" node="fr.ifremer.suiviobsmer.entity.ActivityMonthImpl" abstract="false" proxy="fr.ifremer.suiviobsmer.entity.ActivityMonth" >
+<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"/>
@@ -15,8 +15,8 @@
<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.suiviobsmer.entity.ActivityProfessionImpl" node="topiaId" embed-xml="false"/>
+ <one-to-many class="fr.ifremer.wao.entity.ActivityProfessionImpl" node="topiaId" embed-xml="false"/>
</bag>
- <many-to-one name="activityCalendar" class="fr.ifremer.suiviobsmer.entity.ActivityCalendarImpl" column="activityCalendar" node="activityCalendar/@topiaId" embed-xml="false"/>
+ <many-to-one name="activityCalendar" class="fr.ifremer.wao.entity.ActivityCalendarImpl" column="activityCalendar" node="activityCalendar/@topiaId" embed-xml="false"/>
</class>
</hibernate-mapping>
Modified: trunk/wao-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/ActivityProfessionImpl.hbm.xml
===================================================================
--- trunk/suiviobsmer-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/ActivityProfessionImpl.hbm.xml 2010-02-16 12:00:05 UTC (rev 354)
+++ trunk/wao-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/ActivityProfessionImpl.hbm.xml 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,7 +1,7 @@
<?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.suiviobsmer.entity">
- <class name="fr.ifremer.suiviobsmer.entity.ActivityProfessionImpl" table="activityProfession" node="fr.ifremer.suiviobsmer.entity.ActivityProfessionImpl" abstract="false" proxy="fr.ifremer.suiviobsmer.entity.ActivityProfession" >
+<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"/>
@@ -9,10 +9,10 @@
<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.suiviobsmer.entity.ActivityMonthImpl" column="activityMonth" node="activityMonth/@topiaId" embed-xml="false"/>
+ <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.suiviobsmer.entity.ActivityZoneImpl" node="topiaId" embed-xml="false"/>
+ <one-to-many class="fr.ifremer.wao.entity.ActivityZoneImpl" node="topiaId" embed-xml="false"/>
</bag>
</class>
</hibernate-mapping>
Modified: trunk/wao-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/ActivityZoneImpl.hbm.xml
===================================================================
--- trunk/suiviobsmer-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/ActivityZoneImpl.hbm.xml 2010-02-16 12:00:05 UTC (rev 354)
+++ trunk/wao-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/ActivityZoneImpl.hbm.xml 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,7 +1,7 @@
<?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.suiviobsmer.entity">
- <class name="fr.ifremer.suiviobsmer.entity.ActivityZoneImpl" table="activityZone" node="fr.ifremer.suiviobsmer.entity.ActivityZoneImpl" abstract="false" proxy="fr.ifremer.suiviobsmer.entity.ActivityZone" >
+<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"/>
@@ -10,6 +10,6 @@
<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.suiviobsmer.entity.ActivityProfessionImpl" column="activityProfession" node="activityProfession/@topiaId" embed-xml="false"/>
+ <many-to-one name="activityProfession" class="fr.ifremer.wao.entity.ActivityProfessionImpl" column="activityProfession" node="activityProfession/@topiaId" embed-xml="false"/>
</class>
</hibernate-mapping>
Modified: trunk/wao-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/BoatImpl.hbm.xml
===================================================================
--- trunk/suiviobsmer-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/BoatImpl.hbm.xml 2010-02-16 12:00:05 UTC (rev 354)
+++ trunk/wao-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/BoatImpl.hbm.xml 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,7 +1,7 @@
<?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.suiviobsmer.entity">
- <class name="fr.ifremer.suiviobsmer.entity.BoatImpl" table="boat" node="fr.ifremer.suiviobsmer.entity.BoatImpl" abstract="false" proxy="fr.ifremer.suiviobsmer.entity.Boat" >
+<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"/>
@@ -11,18 +11,18 @@
<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.suiviobsmer.entity.ShipOwnerImpl" column="shipOwner" lazy="false" node="shipOwner/@topiaId" embed-xml="false"/>
+ <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.suiviobsmer.entity.BoatInfosImpl" node="topiaId" embed-xml="false"/>
+ <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.suiviobsmer.entity.ActivityCalendarImpl" node="topiaId" embed-xml="false"/>
+ <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.suiviobsmer.entity.ElligibleBoatImpl" node="topiaId" embed-xml="false"/>
+ <one-to-many class="fr.ifremer.wao.entity.ElligibleBoatImpl" node="topiaId" embed-xml="false"/>
</bag>
</class>
</hibernate-mapping>
Modified: trunk/wao-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/BoatInfosImpl.hbm.xml
===================================================================
--- trunk/suiviobsmer-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/BoatInfosImpl.hbm.xml 2010-02-16 12:00:05 UTC (rev 354)
+++ trunk/wao-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/BoatInfosImpl.hbm.xml 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,7 +1,7 @@
<?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.suiviobsmer.entity">
- <class name="fr.ifremer.suiviobsmer.entity.BoatInfosImpl" table="boatInfos" node="fr.ifremer.suiviobsmer.entity.BoatInfosImpl" abstract="false" proxy="fr.ifremer.suiviobsmer.entity.BoatInfos" >
+<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"/>
@@ -11,7 +11,7 @@
<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.suiviobsmer.entity.CompanyImpl" column="company" node="company/@topiaId" embed-xml="false" />
- <many-to-one name="boat" class="fr.ifremer.suiviobsmer.entity.BoatImpl" column="boat" node="boat/@topiaId" embed-xml="false" />
+ <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>
Modified: trunk/wao-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/CompanyImpl.hbm.xml
===================================================================
--- trunk/suiviobsmer-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/CompanyImpl.hbm.xml 2010-02-16 12:00:05 UTC (rev 354)
+++ trunk/wao-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/CompanyImpl.hbm.xml 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,7 +1,7 @@
<?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.suiviobsmer.entity">
- <class name="fr.ifremer.suiviobsmer.entity.CompanyImpl" table="company" node="fr.ifremer.suiviobsmer.entity.CompanyImpl" abstract="false" proxy="fr.ifremer.suiviobsmer.entity.Company" >
+<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"/>
@@ -15,11 +15,11 @@
<property name="postalCode" type="int" access="field" column="postalCode" node="postalCode"/>
<bag name="waoUser" inverse="true" lazy="false" cascade="all,delete-orphan" node="waoUser" embed-xml="false">
<key column="company"/>
- <one-to-many class="fr.ifremer.suiviobsmer.entity.WaoUserImpl" node="topiaId" embed-xml="false"/>
+ <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.suiviobsmer.entity.BoatInfosImpl" node="topiaId" embed-xml="false"/>
+ <one-to-many class="fr.ifremer.wao.entity.BoatInfosImpl" node="topiaId" embed-xml="false"/>
</bag>
</class>
</hibernate-mapping>
Modified: trunk/wao-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/ContactImpl.hbm.xml
===================================================================
--- trunk/suiviobsmer-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/ContactImpl.hbm.xml 2010-02-16 12:00:05 UTC (rev 354)
+++ trunk/wao-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/ContactImpl.hbm.xml 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,7 +1,7 @@
<?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.suiviobsmer.entity">
- <class name="fr.ifremer.suiviobsmer.entity.ContactImpl" table="contact" node="fr.ifremer.suiviobsmer.entity.ContactImpl" abstract="false" proxy="fr.ifremer.suiviobsmer.entity.Contact" >
+<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"/>
@@ -16,8 +16,8 @@
<property name="comment" type="text" access="field" column="comment" node="comment"/>
<property name="state" type="text" 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.suiviobsmer.entity.WaoUserImpl" column="observer" node="observer/@topiaId" embed-xml="false"/>
- <many-to-one name="sampleRow" class="fr.ifremer.suiviobsmer.entity.SampleRowImpl" column="sampleRow" lazy="false" node="sampleRow/@topiaId" embed-xml="false"/>
- <many-to-one name="boat" class="fr.ifremer.suiviobsmer.entity.BoatImpl" column="boat" lazy="false" node="boat/@topiaId" embed-xml="false"/>
+ <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>
Modified: trunk/wao-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/ElligibleBoatImpl.hbm.xml
===================================================================
--- trunk/suiviobsmer-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/ElligibleBoatImpl.hbm.xml 2010-02-16 12:00:05 UTC (rev 354)
+++ trunk/wao-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/ElligibleBoatImpl.hbm.xml 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,13 +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.suiviobsmer.entity">
- <class name="fr.ifremer.suiviobsmer.entity.ElligibleBoatImpl" table="elligibleBoat" node="fr.ifremer.suiviobsmer.entity.ElligibleBoatImpl" abstract="false" proxy="fr.ifremer.suiviobsmer.entity.ElligibleBoat" >
+<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.suiviobsmer.entity.BoatImpl" column="boat" lazy="false" node="boat/@topiaId" embed-xml="false"/>
- <many-to-one name="sampleRow" class="fr.ifremer.suiviobsmer.entity.SampleRowImpl" column="sampleRow" 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"/>
+ <many-to-one name="sampleRow" class="fr.ifremer.wao.entity.SampleRowImpl" column="sampleRow" node="sampleRow/@topiaId" embed-xml="false"/>
</class>
</hibernate-mapping>
Modified: trunk/wao-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/FishingZoneImpl.hbm.xml
===================================================================
--- trunk/suiviobsmer-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/FishingZoneImpl.hbm.xml 2010-02-16 12:00:05 UTC (rev 354)
+++ trunk/wao-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/FishingZoneImpl.hbm.xml 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,7 +1,7 @@
<?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.suiviobsmer.entity">
- <class name="fr.ifremer.suiviobsmer.entity.FishingZoneImpl" table="fishingZone" node="fr.ifremer.suiviobsmer.entity.FishingZoneImpl" abstract="false" proxy="fr.ifremer.suiviobsmer.entity.FishingZone" >
+<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"/>
@@ -10,7 +10,7 @@
<property name="districtCode" type="text" access="field" column="districtCode" node="districtCode"/>
<bag name="sampleRow" table="fishingzone_samplerow" lazy="true" node="sampleRow" embed-xml="true">
<key column="fishingZone"/>
- <many-to-many class="fr.ifremer.suiviobsmer.entity.SampleRowImpl" column="sampleRow" order-by="code" node="topiaId"/>
+ <many-to-many class="fr.ifremer.wao.entity.SampleRowImpl" column="sampleRow" order-by="code" node="topiaId"/>
</bag>
</class>
</hibernate-mapping>
Modified: trunk/wao-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/NewsImpl.hbm.xml
===================================================================
--- trunk/suiviobsmer-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/NewsImpl.hbm.xml 2010-02-16 12:00:05 UTC (rev 354)
+++ trunk/wao-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/NewsImpl.hbm.xml 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,7 +1,7 @@
<?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.suiviobsmer.entity">
- <class name="fr.ifremer.suiviobsmer.entity.NewsImpl" table="news" node="fr.ifremer.suiviobsmer.entity.NewsImpl" abstract="false" proxy="fr.ifremer.suiviobsmer.entity.News" >
+<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"/>
Modified: trunk/wao-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/ProfessionImpl.hbm.xml
===================================================================
--- trunk/suiviobsmer-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/ProfessionImpl.hbm.xml 2010-02-16 12:00:05 UTC (rev 354)
+++ trunk/wao-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/ProfessionImpl.hbm.xml 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,7 +1,7 @@
<?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.suiviobsmer.entity">
- <class name="fr.ifremer.suiviobsmer.entity.ProfessionImpl" table="profession" node="fr.ifremer.suiviobsmer.entity.ProfessionImpl" abstract="false" proxy="fr.ifremer.suiviobsmer.entity.Profession" >
+<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"/>
Modified: trunk/wao-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/SampleMonthImpl.hbm.xml
===================================================================
--- trunk/suiviobsmer-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/SampleMonthImpl.hbm.xml 2010-02-16 12:00:05 UTC (rev 354)
+++ trunk/wao-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/SampleMonthImpl.hbm.xml 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,13 +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.suiviobsmer.entity">
- <class name="fr.ifremer.suiviobsmer.entity.SampleMonthImpl" table="sampleMonth" node="fr.ifremer.suiviobsmer.entity.SampleMonthImpl" abstract="false" proxy="fr.ifremer.suiviobsmer.entity.SampleMonth" >
+<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.suiviobsmer.entity.SampleRowImpl" column="sampleRow" node="sampleRow/@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>
Modified: trunk/wao-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/SampleRowImpl.hbm.xml
===================================================================
--- trunk/suiviobsmer-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/SampleRowImpl.hbm.xml 2010-02-16 12:00:05 UTC (rev 354)
+++ trunk/wao-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/SampleRowImpl.hbm.xml 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,7 +1,7 @@
<?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.suiviobsmer.entity">
- <class name="fr.ifremer.suiviobsmer.entity.SampleRowImpl" table="sampleRow" node="fr.ifremer.suiviobsmer.entity.SampleRowImpl" abstract="false" proxy="fr.ifremer.suiviobsmer.entity.SampleRow" >
+<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"/>
@@ -13,27 +13,27 @@
<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.suiviobsmer.entity.ProfessionImpl" column="profession" lazy="false" node="profession/@topiaId" embed-xml="false"/>
+ <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="false" cascade="all,delete-orphan" node="sampleMonth" embed-xml="false">
<key column="sampleRow"/>
- <one-to-many class="fr.ifremer.suiviobsmer.entity.SampleMonthImpl" node="topiaId" embed-xml="false"/>
+ <one-to-many class="fr.ifremer.wao.entity.SampleMonthImpl" node="topiaId" embed-xml="false"/>
</bag>
- <many-to-one name="company" class="fr.ifremer.suiviobsmer.entity.CompanyImpl" column="company" lazy="false" node="company/@topiaId" embed-xml="false"/>
+ <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="false" cascade="all,delete-orphan" node="sampleRowLog" embed-xml="false">
<key column="sampleRow"/>
- <one-to-many class="fr.ifremer.suiviobsmer.entity.SampleRowLogImpl" node="topiaId" embed-xml="false"/>
+ <one-to-many class="fr.ifremer.wao.entity.SampleRowLogImpl" node="topiaId" embed-xml="false"/>
</bag>
<bag name="elligibleBoat" inverse="true" order-by="companyActive" lazy="false" cascade="all,delete-orphan" node="elligibleBoat" embed-xml="false">
<key column="sampleRow"/>
- <one-to-many class="fr.ifremer.suiviobsmer.entity.ElligibleBoatImpl" node="topiaId" embed-xml="false"/>
+ <one-to-many class="fr.ifremer.wao.entity.ElligibleBoatImpl" node="topiaId" embed-xml="false"/>
</bag>
<bag name="fishingZone" table="fishingzone_samplerow" inverse="true" lazy="false" node="fishingZone" embed-xml="true">
<key column="sampleRow"/>
- <many-to-many class="fr.ifremer.suiviobsmer.entity.FishingZoneImpl" column="fishingZone" order-by="facadeName,sectorName,districtCode" node="topiaId"/>
+ <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.suiviobsmer.entity.ContactImpl" node="topiaId" embed-xml="false"/>
+ <one-to-many class="fr.ifremer.wao.entity.ContactImpl" node="topiaId" embed-xml="false"/>
</bag>
</class>
</hibernate-mapping>
Modified: trunk/wao-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/SampleRowLogImpl.hbm.xml
===================================================================
--- trunk/suiviobsmer-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/SampleRowLogImpl.hbm.xml 2010-02-16 12:00:05 UTC (rev 354)
+++ trunk/wao-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/SampleRowLogImpl.hbm.xml 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,13 +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.suiviobsmer.entity">
- <class name="fr.ifremer.suiviobsmer.entity.SampleRowLogImpl" table="sampleRowLog" node="fr.ifremer.suiviobsmer.entity.SampleRowLogImpl" abstract="false" proxy="fr.ifremer.suiviobsmer.entity.SampleRowLog" >
+<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.suiviobsmer.entity.SampleRowImpl" column="sampleRow" node="sampleRow/@topiaId" embed-xml="false"/>
- <many-to-one name="admin" class="fr.ifremer.suiviobsmer.entity.WaoUserImpl" column="admin" lazy="false" node="admin/@topiaId" embed-xml="false"/>
+ <many-to-one name="sampleRow" class="fr.ifremer.wao.entity.SampleRowImpl" column="sampleRow" node="sampleRow/@topiaId" embed-xml="false"/>
+ <many-to-one name="admin" class="fr.ifremer.wao.entity.WaoUserImpl" column="admin" lazy="false" node="admin/@topiaId" embed-xml="false"/>
</class>
</hibernate-mapping>
Modified: trunk/wao-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/ShipOwnerImpl.hbm.xml
===================================================================
--- trunk/suiviobsmer-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/ShipOwnerImpl.hbm.xml 2010-02-16 12:00:05 UTC (rev 354)
+++ trunk/wao-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/ShipOwnerImpl.hbm.xml 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,7 +1,7 @@
<?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.suiviobsmer.entity">
- <class name="fr.ifremer.suiviobsmer.entity.ShipOwnerImpl" table="shipOwner" node="fr.ifremer.suiviobsmer.entity.ShipOwnerImpl" abstract="false" proxy="fr.ifremer.suiviobsmer.entity.ShipOwner" >
+<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"/>
Modified: trunk/wao-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/WaoUserImpl.hbm.xml
===================================================================
--- trunk/suiviobsmer-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/WaoUserImpl.hbm.xml 2010-02-16 12:00:05 UTC (rev 354)
+++ trunk/wao-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/WaoUserImpl.hbm.xml 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,7 +1,7 @@
<?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.suiviobsmer.entity">
- <class name="fr.ifremer.suiviobsmer.entity.WaoUserImpl" table="waoUser" node="fr.ifremer.suiviobsmer.entity.WaoUserImpl" abstract="false" proxy="fr.ifremer.suiviobsmer.entity.WaoUser" >
+<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"/>
@@ -12,10 +12,10 @@
<property name="password" type="text" access="field" column="password" node="password"/>
<property name="active" type="boolean" access="field" column="active" node="active"/>
<property name="admin" type="boolean" access="field" column="admin" node="admin"/>
- <many-to-one name="company" class="fr.ifremer.suiviobsmer.entity.CompanyImpl" column="company" node="company/@topiaId" embed-xml="false"/>
+ <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.suiviobsmer.entity.ContactImpl" node="topiaId" embed-xml="false"/>
+ <one-to-many class="fr.ifremer.wao.entity.ContactImpl" node="topiaId" embed-xml="false"/>
</bag>
</class>
</hibernate-mapping>
Deleted: trunk/wao-business/src/main/xmi/suiviobsmer.properties
===================================================================
--- trunk/suiviobsmer-business/src/main/xmi/suiviobsmer.properties 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-business/src/main/xmi/suiviobsmer.properties 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,32 +0,0 @@
-model.tagvalue.copyright=/* *##%\n Copyright (C) 2009 SuiviObsmer\n *##%*/
-model.tagvalue.java.lang.String=text
-fr.ifremer.suiviobsmer.entity.Company.attribute.waoUser.tagvalue.lazy=false
-
-fr.ifremer.suiviobsmer.entity.SampleRow.attribute.sampleMonth.tagvalue.lazy=false
-fr.ifremer.suiviobsmer.entity.SampleRow.attribute.sampleMonth.tagvalue.orderBy=periodDate
-fr.ifremer.suiviobsmer.entity.SampleRow.attribute.fishingZone.tagvalue.lazy=false
-fr.ifremer.suiviobsmer.entity.SampleRow.attribute.fishingZone.tagvalue.orderBy=facadeName,sectorName,districtCode
-fr.ifremer.suiviobsmer.entity.SampleRow.attribute.profession.tagvalue.lazy=false
-fr.ifremer.suiviobsmer.entity.SampleRow.attribute.company.tagvalue.lazy=false
-#fr.ifremer.suiviobsmer.entity.SampleRow.attribute.pogram.tagvalue.lazy=false
-fr.ifremer.suiviobsmer.entity.SampleRow.attribute.elligibleBoat.tagvalue.lazy=false
-fr.ifremer.suiviobsmer.entity.SampleRow.attribute.elligibleBoat.tagvalue.orderBy=companyActive
-fr.ifremer.suiviobsmer.entity.SampleRow.attribute.sampleRowLog.tagvalue.lazy=false
-fr.ifremer.suiviobsmer.entity.SampleRow.attribute.sampleRowLog.tagvalue.orderBy=topiaCreateDate desc
-fr.ifremer.suiviobsmer.entity.SampleRowLog.attribute.admin.tagvalue.lazy=false
-
-fr.ifremer.suiviobsmer.entity.FishingZone.attribute.sampleRow.tagvalue.orderBy=code
-
-fr.ifremer.suiviobsmer.entity.Boat.attribute.shipOwner.tagvalue.lazy=false
-fr.ifremer.suiviobsmer.entity.Boat.attribute.elligibleBoat.tagvalue.orderBy=companyActive
-
-fr.ifremer.suiviobsmer.entity.ElligibleBoat.attribute.boat.tagvalue.lazy=false
-
-fr.ifremer.suiviobsmer.entity.Contact.attribute.sampleRow.tagvalue.lazy=false
-fr.ifremer.suiviobsmer.entity.Contact.attribute.boat.tagvalue.lazy=false
-
-#fr.ifremer.suiviobsmer.entity.Boat.attribute.elligibleBoat.tagvalue.lazy=false
-#fr.ifremer.suiviobsmer.entity.ElligibleBoat.attribute.sampleRow.tagvalue.lazy=false
-#fr.ifremer.suiviobsmer.entity.ElligibleBoat.attribute.company.tagvalue.lazy=false
-#fr.ifremer.suiviobsmer.entity.SampleRow.attribute.program.tagvalue.lazy=false
-#fr.ifremer.suiviobsmer.entity.SampleRow.attribute.company.tagvalue.lazy=false
\ No newline at end of file
Deleted: trunk/wao-business/src/main/xmi/suiviobsmer.zargo
===================================================================
(Binary files differ)
Copied: trunk/wao-business/src/main/xmi/wao.properties (from rev 354, trunk/suiviobsmer-business/src/main/xmi/wao.properties)
===================================================================
--- trunk/wao-business/src/main/xmi/wao.properties (rev 0)
+++ trunk/wao-business/src/main/xmi/wao.properties 2010-02-16 13:56:07 UTC (rev 355)
@@ -0,0 +1,32 @@
+model.tagvalue.copyright=/* *##%\n Copyright (C) 2009 Wao\n *##%*/
+model.tagvalue.java.lang.String=text
+fr.ifremer.wao.entity.Company.attribute.waoUser.tagvalue.lazy=false
+
+fr.ifremer.wao.entity.SampleRow.attribute.sampleMonth.tagvalue.lazy=false
+fr.ifremer.wao.entity.SampleRow.attribute.sampleMonth.tagvalue.orderBy=periodDate
+fr.ifremer.wao.entity.SampleRow.attribute.fishingZone.tagvalue.lazy=false
+fr.ifremer.wao.entity.SampleRow.attribute.fishingZone.tagvalue.orderBy=facadeName,sectorName,districtCode
+fr.ifremer.wao.entity.SampleRow.attribute.profession.tagvalue.lazy=false
+fr.ifremer.wao.entity.SampleRow.attribute.company.tagvalue.lazy=false
+#fr.ifremer.wao.entity.SampleRow.attribute.pogram.tagvalue.lazy=false
+fr.ifremer.wao.entity.SampleRow.attribute.elligibleBoat.tagvalue.lazy=false
+fr.ifremer.wao.entity.SampleRow.attribute.elligibleBoat.tagvalue.orderBy=companyActive
+fr.ifremer.wao.entity.SampleRow.attribute.sampleRowLog.tagvalue.lazy=false
+fr.ifremer.wao.entity.SampleRow.attribute.sampleRowLog.tagvalue.orderBy=topiaCreateDate desc
+fr.ifremer.wao.entity.SampleRowLog.attribute.admin.tagvalue.lazy=false
+
+fr.ifremer.wao.entity.FishingZone.attribute.sampleRow.tagvalue.orderBy=code
+
+fr.ifremer.wao.entity.Boat.attribute.shipOwner.tagvalue.lazy=false
+fr.ifremer.wao.entity.Boat.attribute.elligibleBoat.tagvalue.orderBy=companyActive
+
+fr.ifremer.wao.entity.ElligibleBoat.attribute.boat.tagvalue.lazy=false
+
+fr.ifremer.wao.entity.Contact.attribute.sampleRow.tagvalue.lazy=false
+fr.ifremer.wao.entity.Contact.attribute.boat.tagvalue.lazy=false
+
+#fr.ifremer.wao.entity.Boat.attribute.elligibleBoat.tagvalue.lazy=false
+#fr.ifremer.wao.entity.ElligibleBoat.attribute.sampleRow.tagvalue.lazy=false
+#fr.ifremer.wao.entity.ElligibleBoat.attribute.company.tagvalue.lazy=false
+#fr.ifremer.wao.entity.SampleRow.attribute.program.tagvalue.lazy=false
+#fr.ifremer.wao.entity.SampleRow.attribute.company.tagvalue.lazy=false
\ No newline at end of file
Copied: trunk/wao-business/src/main/xmi/wao.zargo (from rev 354, trunk/suiviobsmer-business/src/main/xmi/wao.zargo)
===================================================================
(Binary files differ)
Property changes on: trunk/wao-business/src/test/java/fr/ifremer/wao
___________________________________________________________________
Added: svn:mergeinfo
+
Deleted: trunk/wao-business/src/test/java/fr/ifremer/wao/ImportHelperTest.java
===================================================================
--- trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/ImportHelperTest.java 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-business/src/test/java/fr/ifremer/wao/ImportHelperTest.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,249 +0,0 @@
-/*
- * *##%
- * SuiviObsmer :: 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.suiviobsmer;
-
-import com.csvreader.CsvReader;
-import fr.ifremer.suiviobsmer.io.ImportHelper;
-import fr.ifremer.suiviobsmer.io.WaoCsvHeader.CONTACT;
-import fr.ifremer.suiviobsmer.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 SuiviObsmerRunner runner;
-
- private static final Logger log = LoggerFactory.getLogger(ImportHelperTest.class);
-
- private CsvReader reader;
-
- public ImportHelperTest() {
- runner = new SuiviObsmerRunnerTest();
- }
-
- @BeforeClass
- public static void setUpClass() throws Exception {
-
- }
-
- @AfterClass
- public static void tearDownClass() throws Exception {
-
- }
-
- @Before
- public void setUp() throws SuiviObsmerException, 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 SuiviObsmerException {
- 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 = SuiviObsmerContext.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 = SuiviObsmerContext.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/ImportHelperTest.java (from rev 354, trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/ImportHelperTest.java)
===================================================================
--- trunk/wao-business/src/test/java/fr/ifremer/wao/ImportHelperTest.java (rev 0)
+++ trunk/wao-business/src/test/java/fr/ifremer/wao/ImportHelperTest.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -0,0 +1,249 @@
+/*
+ * *##%
+ * 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");
+ }
+
+}
Deleted: trunk/wao-business/src/test/java/fr/ifremer/wao/SuiviObsmerGlobalTest.java
===================================================================
--- trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/SuiviObsmerGlobalTest.java 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-business/src/test/java/fr/ifremer/wao/SuiviObsmerGlobalTest.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,104 +0,0 @@
-/*
- * *##%
- * SuiviObsmer :: 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.suiviobsmer;
-
-import fr.ifremer.suiviobsmer.entity.Company;
-import fr.ifremer.suiviobsmer.entity.WaoUser;
-import fr.ifremer.suiviobsmer.services.ServiceUserImpl;
-import fr.ifremer.suiviobsmer.services.ServiceUser;
-import java.util.List;
-import static org.junit.Assert.*;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * SuiviObsmerGlobalTest
- *
- * Created: 27 nov. 2009
- *
- * @author fdesbois
- * @version $Revision$
- *
- * Mise a jour: $Date$
- * par : $Author$
- */
-public class SuiviObsmerGlobalTest {
-
- private static SuiviObsmerRunner runner;
-
- private static final Logger log = LoggerFactory.getLogger(SuiviObsmerGlobalTest.class);
-
- public SuiviObsmerGlobalTest() {
- runner = new SuiviObsmerRunnerTest();
- }
-
- @BeforeClass
- public static void setUpClass() throws Exception {
-
- }
-
- @AfterClass
- public static void tearDownClass() throws Exception {
-
- }
-
- @Before
- public void setUp() throws SuiviObsmerException {
- runner.start();
- }
-
- @After
- public void tearDown() throws SuiviObsmerException {
- runner.stop();
- }
-
- /**
- * Test of initApplication method, of class SuiviObsmerGlobal.
- */
- @Test
- public void testCreateDefaultAdmin() throws Exception {
- System.out.println("createDefaultAdmin");
-
- SuiviObsmerGlobal.createDefaultAdmin();
-
- ServiceUser serviceUser = new ServiceUserImpl();
-
- List<Company> companies = serviceUser.getCompanies(false);
- assertEquals(1, companies.size());
-
- Company company = companies.get(0);
- assertEquals("ADMIN", company.getName());
-
- List<WaoUser> users = company.getWaoUser();
- assertEquals(1, users.size());
-
- WaoUser user = users.get(0);
- assertEquals("admin", user.getLogin());
-
- }
-
-}
Deleted: trunk/wao-business/src/test/java/fr/ifremer/wao/SuiviObsmerRunnerTest.java
===================================================================
--- trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/SuiviObsmerRunnerTest.java 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-business/src/test/java/fr/ifremer/wao/SuiviObsmerRunnerTest.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,150 +0,0 @@
-/*
- * *##%
- * SuiviObsmer :: 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.suiviobsmer;
-
-import fr.ifremer.suiviobsmer.entity.Company;
-import fr.ifremer.suiviobsmer.entity.CompanyImpl;
-import fr.ifremer.suiviobsmer.entity.WaoUser;
-import fr.ifremer.suiviobsmer.entity.WaoUserImpl;
-import fr.ifremer.suiviobsmer.services.*;
-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;
-
-/**
- * ContextUtilObsmerTest
- *
- * Created: 23 nov. 2009
- *
- * @author fdesbois
- * @version $Revision$
- *
- * Mise a jour: $Date$
- * par : $Author$
- */
- at Ignore
-public class SuiviObsmerRunnerTest implements SuiviObsmerRunner {
-
- private static final Logger log = LoggerFactory.getLogger(SuiviObsmerRunnerTest.class);
-
- private ApplicationConfig _configuration;
-
- @Override
- public void start() throws SuiviObsmerException {
- if (log.isDebugEnabled()) {
- log.debug("TEST START : loadConfiguration");
- }
- try {
- Properties options = loadFileProperties("TopiaContextSuiviObsmer.properties");
- options.setProperty("topia.persistence.classes",
- SuiviObsmerModelDAOHelper.getImplementationClassesAsString());
-
- _configuration = new ApplicationConfig();
- _configuration.setOptions(options);
-
- SuiviObsmerContext.setRunner(this);
- } catch (Exception eee) {
- SuiviObsmerContext.serviceException(null, "Error during loadConfiguration from " +
- "'TopiaContextSuiviObsmer.properties' file", eee);
- }
- }
-
- @Override
- public void stop() throws SuiviObsmerException {
- if (log.isDebugEnabled()) {
- log.debug("TEST STOP : clearContext");
- }
- try {
- SuiviObsmerContext.getTopiaRootContext().clear(true);
- } catch (TopiaException eee) {
- SuiviObsmerContext.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 SuiviObsmerException {
- 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);
- }
-
-}
Deleted: trunk/wao-business/src/test/java/fr/ifremer/wao/SuiviObsmerUtilsTest.java
===================================================================
--- trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/SuiviObsmerUtilsTest.java 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-business/src/test/java/fr/ifremer/wao/SuiviObsmerUtilsTest.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,138 +0,0 @@
-/*
- * *##%
- * SuiviObsmer :: 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.suiviobsmer;
-
-import fr.ifremer.suiviobsmer.entity.Company;
-import fr.ifremer.suiviobsmer.entity.CompanyImpl;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import static org.junit.Assert.*;
-
-/**
- * SuiviObsmerUtilsTest
- *
- * Created: 27 nov. 2009
- *
- * @author fdesbois
- * @version $Revision$
- *
- * Mise a jour: $Date$
- * par : $Author$
- */
-public class SuiviObsmerUtilsTest {
-
- private static SuiviObsmerRunner runner;
-
- private static final Logger log = LoggerFactory.getLogger(SuiviObsmerUtilsTest.class);
-
- public SuiviObsmerUtilsTest() {
- runner = new SuiviObsmerRunnerTest();
- }
-
- @BeforeClass
- public static void setUpClass() throws Exception {
-
- }
-
- @AfterClass
- public static void tearDownClass() throws Exception {
-
- }
-
- @Before
- public void setUp() throws SuiviObsmerException {
- runner.start();
- }
-
- @After
- public void tearDown() throws SuiviObsmerException {
- runner.stop();
- }
-
- /**
- * Test of getTopiaRootContext method, of class SuiviObsmerUtils.
- */
- //@Test
- public void testGetTopiaRootContext() throws Exception {
- System.out.println("getTopiaRootContext");
- }
-
- /**
- * Test of loadConfiguration method, of class SuiviObsmerUtils.
- */
- //@Test
- public void testLoadConfiguration() throws Exception {
- System.out.println("loadConfiguration");
- }
-
- /**
- * Test of serviceException method, of class SuiviObsmerUtils.
- */
- //@Test
- public void testServiceException() throws Exception {
- System.out.println("serviceException");
- }
-
- /**
- * Test of createRandomString method, of class SuiviObsmerUtils.
- */
- //@Test
- public void testCreateRandomString() {
- System.out.println("createRandomString");
- }
-
- /**
- * Test of encodeString method, of class SuiviObsmerUtils.
- */
- //@Test
- public void testEncodeString() {
- System.out.println("encodeString");
- }
-
- /**
- * Test of convertId method, of class SuiviObsmerUtils.
- */
- //@Test
- public void testConvertId() {
- System.out.println("convertId");
- }
-
- /**
- * Test of prepareTopiaId method, of class SuiviObsmerUtils.
- */
- @Test
- public void testPrepareTopiaId() {
- log.info("prepareTopiaId");
-
- Company company = new CompanyImpl();
-
- SuiviObsmerContext.prepareTopiaId(Company.class, company);
- assertNotNull(company.getTopiaId());
- log.debug("topiaId for Company : " + company.getTopiaId());
- }
-
-}
Copied: trunk/wao-business/src/test/java/fr/ifremer/wao/WaoGlobalTest.java (from rev 354, trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/WaoGlobalTest.java)
===================================================================
--- trunk/wao-business/src/test/java/fr/ifremer/wao/WaoGlobalTest.java (rev 0)
+++ trunk/wao-business/src/test/java/fr/ifremer/wao/WaoGlobalTest.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -0,0 +1,104 @@
+/*
+ * *##%
+ * 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.WaoUser;
+import fr.ifremer.wao.service.ServiceUserImpl;
+import fr.ifremer.wao.service.ServiceUser;
+import java.util.List;
+import static org.junit.Assert.*;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * WaoGlobalTest
+ *
+ * Created: 27 nov. 2009
+ *
+ * @author fdesbois
+ * @version $Revision$
+ *
+ * Mise a jour: $Date$
+ * par : $Author$
+ */
+public class WaoGlobalTest {
+
+ private static WaoRunner runner;
+
+ private static final Logger log = LoggerFactory.getLogger(WaoGlobalTest.class);
+
+ public WaoGlobalTest() {
+ runner = new WaoRunnerTest();
+ }
+
+ @BeforeClass
+ public static void setUpClass() throws Exception {
+
+ }
+
+ @AfterClass
+ public static void tearDownClass() throws Exception {
+
+ }
+
+ @Before
+ public void setUp() throws WaoException {
+ runner.start();
+ }
+
+ @After
+ public void tearDown() throws WaoException {
+ runner.stop();
+ }
+
+ /**
+ * Test of initApplication method, of class WaoGlobal.
+ */
+ @Test
+ public void testCreateDefaultAdmin() throws Exception {
+ System.out.println("createDefaultAdmin");
+
+ WaoGlobal.createDefaultAdmin();
+
+ ServiceUser serviceUser = new ServiceUserImpl();
+
+ List<Company> companies = serviceUser.getCompanies(false);
+ assertEquals(1, companies.size());
+
+ Company company = companies.get(0);
+ assertEquals("ADMIN", company.getName());
+
+ List<WaoUser> users = company.getWaoUser();
+ assertEquals(1, users.size());
+
+ WaoUser user = users.get(0);
+ assertEquals("admin", user.getLogin());
+
+ }
+
+}
Copied: trunk/wao-business/src/test/java/fr/ifremer/wao/WaoRunnerTest.java (from rev 354, trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/WaoRunnerTest.java)
===================================================================
--- trunk/wao-business/src/test/java/fr/ifremer/wao/WaoRunnerTest.java (rev 0)
+++ trunk/wao-business/src/test/java/fr/ifremer/wao/WaoRunnerTest.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -0,0 +1,150 @@
+/*
+ * *##%
+ * 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);
+ }
+
+}
Copied: trunk/wao-business/src/test/java/fr/ifremer/wao/WaoUtilsTest.java (from rev 354, trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/WaoUtilsTest.java)
===================================================================
--- trunk/wao-business/src/test/java/fr/ifremer/wao/WaoUtilsTest.java (rev 0)
+++ trunk/wao-business/src/test/java/fr/ifremer/wao/WaoUtilsTest.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -0,0 +1,138 @@
+/*
+ * *##%
+ * 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 org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import static org.junit.Assert.*;
+
+/**
+ * WaoUtilsTest
+ *
+ * Created: 27 nov. 2009
+ *
+ * @author fdesbois
+ * @version $Revision$
+ *
+ * Mise a jour: $Date$
+ * par : $Author$
+ */
+public class WaoUtilsTest {
+
+ private static WaoRunner runner;
+
+ private static final Logger log = LoggerFactory.getLogger(WaoUtilsTest.class);
+
+ public WaoUtilsTest() {
+ runner = new WaoRunnerTest();
+ }
+
+ @BeforeClass
+ public static void setUpClass() throws Exception {
+
+ }
+
+ @AfterClass
+ public static void tearDownClass() throws Exception {
+
+ }
+
+ @Before
+ public void setUp() throws WaoException {
+ runner.start();
+ }
+
+ @After
+ public void tearDown() throws WaoException {
+ runner.stop();
+ }
+
+ /**
+ * Test of getTopiaRootContext method, of class WaoUtils.
+ */
+ //@Test
+ public void testGetTopiaRootContext() throws Exception {
+ System.out.println("getTopiaRootContext");
+ }
+
+ /**
+ * Test of loadConfiguration method, of class WaoUtils.
+ */
+ //@Test
+ public void testLoadConfiguration() throws Exception {
+ System.out.println("loadConfiguration");
+ }
+
+ /**
+ * Test of serviceException method, of class WaoUtils.
+ */
+ //@Test
+ public void testServiceException() throws Exception {
+ System.out.println("serviceException");
+ }
+
+ /**
+ * Test of createRandomString method, of class WaoUtils.
+ */
+ //@Test
+ public void testCreateRandomString() {
+ System.out.println("createRandomString");
+ }
+
+ /**
+ * Test of encodeString method, of class WaoUtils.
+ */
+ //@Test
+ public void testEncodeString() {
+ System.out.println("encodeString");
+ }
+
+ /**
+ * Test of convertId method, of class WaoUtils.
+ */
+ //@Test
+ public void testConvertId() {
+ System.out.println("convertId");
+ }
+
+ /**
+ * Test of prepareTopiaId method, of class WaoUtils.
+ */
+ @Test
+ public void testPrepareTopiaId() {
+ log.info("prepareTopiaId");
+
+ Company company = new CompanyImpl();
+
+ WaoContext.prepareTopiaId(Company.class, company);
+ assertNotNull(company.getTopiaId());
+ log.debug("topiaId for Company : " + company.getTopiaId());
+ }
+
+}
Deleted: trunk/wao-business/src/test/java/fr/ifremer/wao/entity/BoatImplTest.java
===================================================================
--- trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/entity/BoatImplTest.java 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-business/src/test/java/fr/ifremer/wao/entity/BoatImplTest.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,276 +0,0 @@
-/*
- * *##%
- * SuiviObsmer :: 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.suiviobsmer.entity;
-
-import fr.ifremer.suiviobsmer.SuiviObsmerContext;
-import fr.ifremer.suiviobsmer.SuiviObsmerModelDAOHelper;
-import fr.ifremer.suiviobsmer.SuiviObsmerRunner;
-import fr.ifremer.suiviobsmer.bean.ContactState;
-import fr.ifremer.suiviobsmer.SuiviObsmerRunnerTest;
-import fr.ifremer.suiviobsmer.services.ServiceBoatImpl;
-import fr.ifremer.suiviobsmer.services.ServiceContactImpl;
-import fr.ifremer.suiviobsmer.services.ServiceSamplingImpl;
-import fr.ifremer.suiviobsmer.services.ServiceUserImpl;
-import fr.ifremer.suiviobsmer.services.ServiceBoat;
-import fr.ifremer.suiviobsmer.services.ServiceContact;
-import fr.ifremer.suiviobsmer.services.ServiceSampling;
-import fr.ifremer.suiviobsmer.services.ServiceUser;
-import java.io.InputStream;
-import java.util.Date;
-import java.util.List;
-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.topia.TopiaContext;
-import org.nuiton.util.DateUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * BoatImplTest
- *
- * Created: 15 déc. 2009
- *
- * @author fdesbois
- * @version $Revision$
- *
- * Mise a jour: $Date$
- * par : $Author$
- */
-public class BoatImplTest {
-
- private static SuiviObsmerRunner runner;
-
- private static final Logger log = LoggerFactory.getLogger(BoatImplTest.class);
-
- public BoatImplTest() {
- }
-
- @BeforeClass
- public static void setUpClass() throws Exception {
- runner = new SuiviObsmerRunnerTest();
- }
-
- @AfterClass
- public static void tearDownClass() throws Exception {
- }
-
- @Before
- public void setUp() throws Exception {
- runner.start();
- }
-
- @After
- public void tearDown() throws Exception {
- runner.stop();
- }
-
- /**
- * Test of canCreateContact method, of class BoatImpl.
- */
- @Test
- public void testCanCreateContact() throws Exception {
- log.info("canCreateContact");
- /** PREPARE DATA **/
- ServiceUser serviceUser = new ServiceUserImpl();
- Company company = new CompanyImpl();
- company.setName("TARTANPION");
- serviceUser.createUpdateCompany(company);
- Company company2 = new CompanyImpl();
- company2.setName("BIS");
- serviceUser.createUpdateCompany(company2);
-
- WaoUser user = new WaoUserImpl();
- user.setLogin("user");
- user.setFirstName("Jean");
- user.setLastName("Michmuche");
- user.setCompany(company);
- serviceUser.createUpdateUser(user, true);
-
- InputStream input = getClass().getResourceAsStream("/import/navires.csv");
- ServiceBoat serviceBoat = new ServiceBoatImpl();
- serviceBoat.importBoatCsv(input);
- List<Boat> boats = serviceBoat.getBoatsByImmatriculations("174258");
- Boat boat = boats.get(0);
-
- TopiaContext transaction = SuiviObsmerContext.getTopiaRootContext().beginTransaction();
-
- FishingZoneDAO zoneDAO = SuiviObsmerModelDAOHelper.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");
-
- transaction.commitTransaction();
-
- ServiceSampling serviceSampling = new ServiceSamplingImpl();
- input = getClass().getResourceAsStream("/import/echantillonnage.csv");
- serviceSampling.importSamplingPlanCsv(input);
-
- SampleRowDAO rowDAO = SuiviObsmerModelDAOHelper.getSampleRowDAO(transaction);
- SampleRow row = rowDAO.findByCode("2010_0001");
- row.getCompany();
- row.getProfession();
- transaction.closeContext();
-
- row.setCompany(company);
- serviceSampling.createUpdateSampleRow(row, boats, new SampleRowLogImpl());
-
- ServiceContact serviceContact = new ServiceContactImpl();
- Contact contact1 = serviceContact.getNewContact(user, row, boat);
- contact1.setState(ContactState.CONTACT_START.toString());
- serviceContact.saveContact(contact1, false);
-
- /** EXEC METHOD **/
- boolean result = boat.canCreateContact(company);
- // contact still open
- Assert.assertFalse(result);
-
- contact1.setState(ContactState.BOAT_DEFINITIVE_REFUSED.toString());
- contact1.setValidationProgram(Boolean.TRUE);
- serviceContact.saveContact(contact1, false);
-
- result = boat.canCreateContact(company);
- // contact have a definitive refused for this boat
- Assert.assertTrue(result);
-
- contact1.setState(ContactState.BOARDING_DONE.toString());
- serviceContact.saveContact(contact1, false);
-
- result = boat.canCreateContact(company);
- // contact is finished
- Assert.assertTrue(result);
-
- contact1.setState(ContactState.BOAT_UNAVAILABLE.toString());
- serviceContact.saveContact(contact1, false);
-
- result = boat.canCreateContact(company);
- // contact is finished
- Assert.assertTrue(result);
-
- contact1.setState(ContactState.BOAT_REFUSED.toString());
- serviceContact.saveContact(contact1, false);
-
- result = boat.canCreateContact(company);
- // contact is finished
- Assert.assertTrue(result);
- }
-
- /**
- * Test of getNbBoarding method, of class BoatInfosImpl.
- */
- @Test
- public void testGetNbBoarding() throws Exception {
- log.info("getNbBoarding");
-
- /** PREPARE DATA **/
- InputStream input = getClass().getResourceAsStream("/import/navires.csv");
- ServiceBoat serviceBoat = new ServiceBoatImpl();
- serviceBoat.importBoatCsv(input);
- List<Boat> boats = serviceBoat.getBoatsByImmatriculations("174258");
- Boat boat = boats.get(0);
-
- TopiaContext transaction = SuiviObsmerContext.getTopiaRootContext().beginTransaction();
-
- CompanyDAO companyDAO = SuiviObsmerModelDAOHelper.getCompanyDAO(transaction);
- Company company = companyDAO.create(Company.NAME, "TARTANPION");
- Company company2 = companyDAO.create(Company.NAME, "BIS");
-
- WaoUserDAO userDAO = SuiviObsmerModelDAOHelper.getWaoUserDAO(transaction);
- WaoUser user = userDAO.create(WaoUser.FIRST_NAME,"Jean", WaoUser.LAST_NAME, "Michmuche",
- WaoUser.COMPANY, company);
- company.addWaoUser(user);
- WaoUser user2 = userDAO.create(WaoUser.FIRST_NAME,"Bill", WaoUser.LAST_NAME, "Murray",
- WaoUser.COMPANY, company2);
- company2.addWaoUser(user2);
-
-// BoatInfosDAO boatInfosDAO = SuiviObsmerModelDAOHelper.getBoatInfosDAO(transaction);
-// BoatInfos boatInfos = boatInfosDAO.create(BoatInfos.BOAT, boat, BoatInfos.COMPANY, company);
-
- transaction.commitTransaction();
- transaction.closeContext();
-
- ServiceContact serviceContact = new ServiceContactImpl();
- // First contact : OK
- Contact contact1 = new ContactImpl();
- contact1.setBoat(boat);
- contact1.setObserver(user);
- contact1.setState(ContactState.BOARDING_DONE.toString());
- Date begin = DateUtils.createDate(3, 3, 2009);
- contact1.setTideBeginDate(begin);
- contact1.setValidationCompany(Boolean.TRUE);
- serviceContact.saveContact(contact1, false);
-
- /** EXEC METHOD **/
-
- Date fromDate = DateUtils.createDate(1, 1, 2009);
- int result = boat.getNbBoarding(fromDate);
- Assert.assertEquals(1, result);
-
- Contact contact2 = new ContactImpl();
- // Second contact with ValidationProgram = FALSE
- contact2.setBoat(boat);
- contact2.setObserver(user);
- contact2.setState(ContactState.BOARDING_DONE.toString());
- begin = DateUtils.createDate(3, 8, 2009);
- contact2.setTideBeginDate(begin);
- contact2.setValidationCompany(Boolean.TRUE);
- contact2.setValidationProgram(Boolean.FALSE);
- serviceContact.saveContact(contact2, false);
-
- result = boat.getNbBoarding(fromDate);
- Assert.assertEquals(1, result);
-
- Contact contact3 = new ContactImpl();
- // Third contact with tideBeginDate < fromDate
- contact3.setBoat(boat);
- contact3.setObserver(user);
- contact3.setState(ContactState.BOARDING_DONE.toString());
- begin = DateUtils.createDate(3, 8, 2008);
- contact3.setTideBeginDate(begin);
- contact3.setValidationCompany(Boolean.TRUE);
- serviceContact.saveContact(contact3, false);
-
- result = boat.getNbBoarding(fromDate);
- Assert.assertEquals(1, result);
-
- Contact contact4 = new ContactImpl();
- // Fourth contact : OK with an other company
- contact4.setBoat(boat);
- contact4.setObserver(user2);
- contact4.setState(ContactState.BOARDING_DONE.toString());
- begin = DateUtils.createDate(3, 4, 2009);
- contact4.setTideBeginDate(begin);
- contact4.setValidationCompany(Boolean.TRUE);
- serviceContact.saveContact(contact4, false);
-
- result = boat.getNbBoarding(fromDate);
- Assert.assertEquals(2, result);
-
- // Calcul with a fromDate null
- result = boat.getNbBoarding(null);
- Assert.assertEquals(3, result);
- }
-
-}
Copied: trunk/wao-business/src/test/java/fr/ifremer/wao/entity/BoatImplTest.java (from rev 354, trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/entity/BoatImplTest.java)
===================================================================
--- trunk/wao-business/src/test/java/fr/ifremer/wao/entity/BoatImplTest.java (rev 0)
+++ trunk/wao-business/src/test/java/fr/ifremer/wao/entity/BoatImplTest.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -0,0 +1,276 @@
+/*
+ * *##%
+ * 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.entity;
+
+import fr.ifremer.wao.WaoContext;
+import fr.ifremer.wao.WaoModelDAOHelper;
+import fr.ifremer.wao.WaoRunner;
+import fr.ifremer.wao.bean.ContactState;
+import fr.ifremer.wao.WaoRunnerTest;
+import fr.ifremer.wao.service.ServiceBoatImpl;
+import fr.ifremer.wao.service.ServiceContactImpl;
+import fr.ifremer.wao.service.ServiceSamplingImpl;
+import fr.ifremer.wao.service.ServiceUserImpl;
+import fr.ifremer.wao.service.ServiceBoat;
+import fr.ifremer.wao.service.ServiceContact;
+import fr.ifremer.wao.service.ServiceSampling;
+import fr.ifremer.wao.service.ServiceUser;
+import java.io.InputStream;
+import java.util.Date;
+import java.util.List;
+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.topia.TopiaContext;
+import org.nuiton.util.DateUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * BoatImplTest
+ *
+ * Created: 15 déc. 2009
+ *
+ * @author fdesbois
+ * @version $Revision$
+ *
+ * Mise a jour: $Date$
+ * par : $Author$
+ */
+public class BoatImplTest {
+
+ private static WaoRunner runner;
+
+ private static final Logger log = LoggerFactory.getLogger(BoatImplTest.class);
+
+ public BoatImplTest() {
+ }
+
+ @BeforeClass
+ public static void setUpClass() throws Exception {
+ runner = new WaoRunnerTest();
+ }
+
+ @AfterClass
+ public static void tearDownClass() throws Exception {
+ }
+
+ @Before
+ public void setUp() throws Exception {
+ runner.start();
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ runner.stop();
+ }
+
+ /**
+ * Test of canCreateContact method, of class BoatImpl.
+ */
+ @Test
+ public void testCanCreateContact() throws Exception {
+ log.info("canCreateContact");
+ /** PREPARE DATA **/
+ ServiceUser serviceUser = new ServiceUserImpl();
+ Company company = new CompanyImpl();
+ company.setName("TARTANPION");
+ serviceUser.createUpdateCompany(company);
+ Company company2 = new CompanyImpl();
+ company2.setName("BIS");
+ serviceUser.createUpdateCompany(company2);
+
+ WaoUser user = new WaoUserImpl();
+ user.setLogin("user");
+ user.setFirstName("Jean");
+ user.setLastName("Michmuche");
+ user.setCompany(company);
+ serviceUser.createUpdateUser(user, true);
+
+ InputStream input = getClass().getResourceAsStream("/import/navires.csv");
+ ServiceBoat serviceBoat = new ServiceBoatImpl();
+ serviceBoat.importBoatCsv(input);
+ List<Boat> boats = serviceBoat.getBoatsByImmatriculations("174258");
+ Boat boat = boats.get(0);
+
+ TopiaContext transaction = WaoContext.getTopiaRootContext().beginTransaction();
+
+ FishingZoneDAO zoneDAO = WaoModelDAOHelper.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");
+
+ transaction.commitTransaction();
+
+ ServiceSampling serviceSampling = new ServiceSamplingImpl();
+ input = getClass().getResourceAsStream("/import/echantillonnage.csv");
+ serviceSampling.importSamplingPlanCsv(input);
+
+ SampleRowDAO rowDAO = WaoModelDAOHelper.getSampleRowDAO(transaction);
+ SampleRow row = rowDAO.findByCode("2010_0001");
+ row.getCompany();
+ row.getProfession();
+ transaction.closeContext();
+
+ row.setCompany(company);
+ serviceSampling.createUpdateSampleRow(row, boats, new SampleRowLogImpl());
+
+ ServiceContact serviceContact = new ServiceContactImpl();
+ Contact contact1 = serviceContact.getNewContact(user, row, boat);
+ contact1.setState(ContactState.CONTACT_START.toString());
+ serviceContact.saveContact(contact1, false);
+
+ /** EXEC METHOD **/
+ boolean result = boat.canCreateContact(company);
+ // contact still open
+ Assert.assertFalse(result);
+
+ contact1.setState(ContactState.BOAT_DEFINITIVE_REFUSED.toString());
+ contact1.setValidationProgram(Boolean.TRUE);
+ serviceContact.saveContact(contact1, false);
+
+ result = boat.canCreateContact(company);
+ // contact have a definitive refused for this boat
+ Assert.assertTrue(result);
+
+ contact1.setState(ContactState.BOARDING_DONE.toString());
+ serviceContact.saveContact(contact1, false);
+
+ result = boat.canCreateContact(company);
+ // contact is finished
+ Assert.assertTrue(result);
+
+ contact1.setState(ContactState.BOAT_UNAVAILABLE.toString());
+ serviceContact.saveContact(contact1, false);
+
+ result = boat.canCreateContact(company);
+ // contact is finished
+ Assert.assertTrue(result);
+
+ contact1.setState(ContactState.BOAT_REFUSED.toString());
+ serviceContact.saveContact(contact1, false);
+
+ result = boat.canCreateContact(company);
+ // contact is finished
+ Assert.assertTrue(result);
+ }
+
+ /**
+ * Test of getNbBoarding method, of class BoatInfosImpl.
+ */
+ @Test
+ public void testGetNbBoarding() throws Exception {
+ log.info("getNbBoarding");
+
+ /** PREPARE DATA **/
+ InputStream input = getClass().getResourceAsStream("/import/navires.csv");
+ ServiceBoat serviceBoat = new ServiceBoatImpl();
+ serviceBoat.importBoatCsv(input);
+ List<Boat> boats = serviceBoat.getBoatsByImmatriculations("174258");
+ Boat boat = boats.get(0);
+
+ TopiaContext transaction = WaoContext.getTopiaRootContext().beginTransaction();
+
+ CompanyDAO companyDAO = WaoModelDAOHelper.getCompanyDAO(transaction);
+ Company company = companyDAO.create(Company.NAME, "TARTANPION");
+ Company company2 = companyDAO.create(Company.NAME, "BIS");
+
+ WaoUserDAO userDAO = WaoModelDAOHelper.getWaoUserDAO(transaction);
+ WaoUser user = userDAO.create(WaoUser.FIRST_NAME,"Jean", WaoUser.LAST_NAME, "Michmuche",
+ WaoUser.COMPANY, company);
+ company.addWaoUser(user);
+ WaoUser user2 = userDAO.create(WaoUser.FIRST_NAME,"Bill", WaoUser.LAST_NAME, "Murray",
+ WaoUser.COMPANY, company2);
+ company2.addWaoUser(user2);
+
+// BoatInfosDAO boatInfosDAO = WaoModelDAOHelper.getBoatInfosDAO(transaction);
+// BoatInfos boatInfos = boatInfosDAO.create(BoatInfos.BOAT, boat, BoatInfos.COMPANY, company);
+
+ transaction.commitTransaction();
+ transaction.closeContext();
+
+ ServiceContact serviceContact = new ServiceContactImpl();
+ // First contact : OK
+ Contact contact1 = new ContactImpl();
+ contact1.setBoat(boat);
+ contact1.setObserver(user);
+ contact1.setState(ContactState.BOARDING_DONE.toString());
+ Date begin = DateUtils.createDate(3, 3, 2009);
+ contact1.setTideBeginDate(begin);
+ contact1.setValidationCompany(Boolean.TRUE);
+ serviceContact.saveContact(contact1, false);
+
+ /** EXEC METHOD **/
+
+ Date fromDate = DateUtils.createDate(1, 1, 2009);
+ int result = boat.getNbBoarding(fromDate);
+ Assert.assertEquals(1, result);
+
+ Contact contact2 = new ContactImpl();
+ // Second contact with ValidationProgram = FALSE
+ contact2.setBoat(boat);
+ contact2.setObserver(user);
+ contact2.setState(ContactState.BOARDING_DONE.toString());
+ begin = DateUtils.createDate(3, 8, 2009);
+ contact2.setTideBeginDate(begin);
+ contact2.setValidationCompany(Boolean.TRUE);
+ contact2.setValidationProgram(Boolean.FALSE);
+ serviceContact.saveContact(contact2, false);
+
+ result = boat.getNbBoarding(fromDate);
+ Assert.assertEquals(1, result);
+
+ Contact contact3 = new ContactImpl();
+ // Third contact with tideBeginDate < fromDate
+ contact3.setBoat(boat);
+ contact3.setObserver(user);
+ contact3.setState(ContactState.BOARDING_DONE.toString());
+ begin = DateUtils.createDate(3, 8, 2008);
+ contact3.setTideBeginDate(begin);
+ contact3.setValidationCompany(Boolean.TRUE);
+ serviceContact.saveContact(contact3, false);
+
+ result = boat.getNbBoarding(fromDate);
+ Assert.assertEquals(1, result);
+
+ Contact contact4 = new ContactImpl();
+ // Fourth contact : OK with an other company
+ contact4.setBoat(boat);
+ contact4.setObserver(user2);
+ contact4.setState(ContactState.BOARDING_DONE.toString());
+ begin = DateUtils.createDate(3, 4, 2009);
+ contact4.setTideBeginDate(begin);
+ contact4.setValidationCompany(Boolean.TRUE);
+ serviceContact.saveContact(contact4, false);
+
+ result = boat.getNbBoarding(fromDate);
+ Assert.assertEquals(2, result);
+
+ // Calcul with a fromDate null
+ result = boat.getNbBoarding(null);
+ Assert.assertEquals(3, result);
+ }
+
+}
Deleted: trunk/wao-business/src/test/java/fr/ifremer/wao/entity/BoatInfosImplTest.java
===================================================================
--- trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/entity/BoatInfosImplTest.java 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-business/src/test/java/fr/ifremer/wao/entity/BoatInfosImplTest.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,83 +0,0 @@
-/*
- * *##%
- * SuiviObsmer :: 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.suiviobsmer.entity;
-
-import fr.ifremer.suiviobsmer.SuiviObsmerRunner;
-import fr.ifremer.suiviobsmer.SuiviObsmerRunnerTest;
-import fr.ifremer.suiviobsmer.services.ServiceBoatImpl;
-import fr.ifremer.suiviobsmer.services.ServiceContactImpl;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * BoatInfosImplTest
- *
- * Created: 21 déc. 2009
- *
- * @author fdesbois
- * @version $Revision$
- *
- * Mise a jour: $Date$
- * par : $Author$
- */
-public class BoatInfosImplTest {
-
- private static SuiviObsmerRunner runner;
-
- private static final Logger log = LoggerFactory.getLogger(BoatInfosImplTest.class);
-
- public BoatInfosImplTest() {
- }
-
- @BeforeClass
- public static void setUpClass() throws Exception {
- runner = new SuiviObsmerRunnerTest();
- }
-
- @AfterClass
- public static void tearDownClass() throws Exception {
- }
-
- @Before
- public void setUp() throws Exception {
- runner.start();
- }
-
- @After
- public void tearDown() throws Exception {
- runner.stop();
- }
-
- /**
- * Test of getNbBoardingForCompany method, of class BoatInfosImpl.
- */
- @Test
- public void testGetNbBoardingForCompany() {
- System.out.println("getNbBoardingForCompany");
- }
-
-}
Copied: trunk/wao-business/src/test/java/fr/ifremer/wao/entity/BoatInfosImplTest.java (from rev 354, trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/entity/BoatInfosImplTest.java)
===================================================================
--- trunk/wao-business/src/test/java/fr/ifremer/wao/entity/BoatInfosImplTest.java (rev 0)
+++ trunk/wao-business/src/test/java/fr/ifremer/wao/entity/BoatInfosImplTest.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -0,0 +1,83 @@
+/*
+ * *##%
+ * 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.entity;
+
+import fr.ifremer.wao.WaoRunner;
+import fr.ifremer.wao.WaoRunnerTest;
+import fr.ifremer.wao.service.ServiceBoatImpl;
+import fr.ifremer.wao.service.ServiceContactImpl;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * BoatInfosImplTest
+ *
+ * Created: 21 déc. 2009
+ *
+ * @author fdesbois
+ * @version $Revision$
+ *
+ * Mise a jour: $Date$
+ * par : $Author$
+ */
+public class BoatInfosImplTest {
+
+ private static WaoRunner runner;
+
+ private static final Logger log = LoggerFactory.getLogger(BoatInfosImplTest.class);
+
+ public BoatInfosImplTest() {
+ }
+
+ @BeforeClass
+ public static void setUpClass() throws Exception {
+ runner = new WaoRunnerTest();
+ }
+
+ @AfterClass
+ public static void tearDownClass() throws Exception {
+ }
+
+ @Before
+ public void setUp() throws Exception {
+ runner.start();
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ runner.stop();
+ }
+
+ /**
+ * Test of getNbBoardingForCompany method, of class BoatInfosImpl.
+ */
+ @Test
+ public void testGetNbBoardingForCompany() {
+ System.out.println("getNbBoardingForCompany");
+ }
+
+}
Deleted: trunk/wao-business/src/test/java/fr/ifremer/wao/entity/SampleRowImplTest.java
===================================================================
--- trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/entity/SampleRowImplTest.java 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-business/src/test/java/fr/ifremer/wao/entity/SampleRowImplTest.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,186 +0,0 @@
-/*
- * *##%
- * SuiviObsmer :: 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.suiviobsmer.entity;
-
-import fr.ifremer.suiviobsmer.SuiviObsmerException;
-import fr.ifremer.suiviobsmer.SuiviObsmerModelDAOHelper;
-import fr.ifremer.suiviobsmer.SuiviObsmerRunner;
-import fr.ifremer.suiviobsmer.SuiviObsmerContext;
-import fr.ifremer.suiviobsmer.SuiviObsmerRunnerTest;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.GregorianCalendar;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.nuiton.topia.TopiaContext;
-import org.nuiton.topia.TopiaException;
-import org.nuiton.util.DateUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import static org.junit.Assert.*;
-
-/**
- * SampleRowImplTest
- *
- * Created: 30 nov. 2009
- *
- * @author fdesbois
- * @version $Revision$
- *
- * Mise a jour: $Date$
- * par : $Author$
- */
-public class SampleRowImplTest {
-
- private static SuiviObsmerRunner runner;
-
- private static final Logger log = LoggerFactory.getLogger(SampleRowImplTest.class);
-
- public SampleRowImplTest() {
- }
-
- @BeforeClass
- public static void setUpClass() throws Exception {
- runner = new SuiviObsmerRunnerTest();
- }
-
- @AfterClass
- public static void tearDownClass() throws Exception {
- }
-
- @Before
- public void setUp() throws Exception {
- runner.start();
- }
-
- @After
- public void tearDown() throws Exception {
- runner.stop();
- }
-
- private SampleRow prepareData() throws SuiviObsmerException, TopiaException {
- TopiaContext transaction = SuiviObsmerContext.getTopiaRootContext().beginTransaction();
-
- SampleRowDAO dao = SuiviObsmerModelDAOHelper.getSampleRowDAO(transaction);
-
- SampleRow row = dao.create();
- row.setCode("2010_1");
-
- SampleMonthDAO monthDAO = SuiviObsmerModelDAOHelper.getSampleMonthDAO(transaction);
-
- SampleMonth month = monthDAO.create(SampleMonth.SAMPLE_ROW, row);
- Calendar calendar = new GregorianCalendar(2009, 3, 1);
- month.setPeriodDate(calendar.getTime());
- row.addSampleMonth(month);
-
- transaction.commitTransaction();
- SampleRow myRow = dao.findByCode("2010_1");
- transaction.closeContext();
- return myRow;
- }
-
- private SampleRow getRowFromContext() throws SuiviObsmerException, TopiaException {
- TopiaContext transaction = SuiviObsmerContext.getTopiaRootContext().beginTransaction();
- SampleRowDAO dao = SuiviObsmerModelDAOHelper.getSampleRowDAO(transaction);
- SampleRow resultRow = dao.findByCode("2010_1");
- transaction.closeContext();
- return resultRow;
- }
-
- @Test
- public void testAddRealTideTime() throws Exception {
- log.info("addRealTideTime");
-
- /** PREPARE DATA **/
- SampleRow row = prepareData();
-
- Contact contact = new ContactImpl();
- Date beginDate = DateUtils.createDate(12, 4, 2009);
- Date endDate = DateUtils.createDate(15, 4, 2009);
- contact.setTideBeginDate(beginDate);
- contact.setTideEndDate(endDate);
-
- /** EXEC METHOD **/
- row.addRealTideTime(contact);
- SampleMonth result = getRowFromContext().getSampleMonth(beginDate);
- assertEquals(1, result.getRealTidesValue());
-
-// // Reinit result for next test
-// result.addRealTideTime(-1);
-// // Test with a more than one day interval dates from contact
-// endDate = DateUtils.createDate(18, 4, 2009);
-// contact.setTideEndDate(endDate);
-//
-// getRowFromContext().addRealTideTime(contact);
-// result = getRowFromContext().getSampleMonth(beginDate);
-// assertEquals(1, result.getRealTidesValue());
- }
-
- @Test
- public void testRemoveRealTideTime() throws Exception {
- log.info("addRealTideTime");
-
- /** PREPARE DATA **/
- SampleRow row = prepareData();
-
- Contact contact = new ContactImpl();
- Date beginDate = DateUtils.createDate(12, 4, 2009);
- Date endDate = DateUtils.createDate(12, 4, 2009);
- contact.setTideBeginDate(beginDate);
- contact.setTideEndDate(endDate);
-
- /** EXEC METHOD **/
- row.removeRealTideTime(contact);
- SampleMonth result = getRowFromContext().getSampleMonth(beginDate);
- // result stay at 0, can't remove 1 tide from 0
- assertEquals(0, result.getRealTidesValue());
-
- // Reinit result for next test
- result.addRealTideTime(12);
-
- // Test with a more than one day interval dates from contact : only one tide to remove
- endDate = DateUtils.createDate(18, 4, 2009);
- contact.setTideEndDate(endDate);
-
- getRowFromContext().removeRealTideTime(contact);
- result = getRowFromContext().getSampleMonth(beginDate);
- assertEquals(11, result.getRealTidesValue());
- }
-
- @Test
- public void testIsFinished() throws Exception {
- log.info("isFinished()");
-
- SampleRow row = new SampleRowImpl();
-
- Calendar calendar = new GregorianCalendar(2009, 8, 23);
- row.setPeriodEnd(calendar.getTime());
-
- // with a gap of one month, the row is not considered as finished
- assertFalse(row.isFinished(-1));
-
-
- }
-}
Copied: trunk/wao-business/src/test/java/fr/ifremer/wao/entity/SampleRowImplTest.java (from rev 354, trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/entity/SampleRowImplTest.java)
===================================================================
--- trunk/wao-business/src/test/java/fr/ifremer/wao/entity/SampleRowImplTest.java (rev 0)
+++ trunk/wao-business/src/test/java/fr/ifremer/wao/entity/SampleRowImplTest.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -0,0 +1,186 @@
+/*
+ * *##%
+ * 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.entity;
+
+import fr.ifremer.wao.WaoException;
+import fr.ifremer.wao.WaoModelDAOHelper;
+import fr.ifremer.wao.WaoRunner;
+import fr.ifremer.wao.WaoContext;
+import fr.ifremer.wao.WaoRunnerTest;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.GregorianCalendar;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.nuiton.topia.TopiaContext;
+import org.nuiton.topia.TopiaException;
+import org.nuiton.util.DateUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import static org.junit.Assert.*;
+
+/**
+ * SampleRowImplTest
+ *
+ * Created: 30 nov. 2009
+ *
+ * @author fdesbois
+ * @version $Revision$
+ *
+ * Mise a jour: $Date$
+ * par : $Author$
+ */
+public class SampleRowImplTest {
+
+ private static WaoRunner runner;
+
+ private static final Logger log = LoggerFactory.getLogger(SampleRowImplTest.class);
+
+ public SampleRowImplTest() {
+ }
+
+ @BeforeClass
+ public static void setUpClass() throws Exception {
+ runner = new WaoRunnerTest();
+ }
+
+ @AfterClass
+ public static void tearDownClass() throws Exception {
+ }
+
+ @Before
+ public void setUp() throws Exception {
+ runner.start();
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ runner.stop();
+ }
+
+ private SampleRow prepareData() throws WaoException, TopiaException {
+ TopiaContext transaction = WaoContext.getTopiaRootContext().beginTransaction();
+
+ SampleRowDAO dao = WaoModelDAOHelper.getSampleRowDAO(transaction);
+
+ SampleRow row = dao.create();
+ row.setCode("2010_1");
+
+ SampleMonthDAO monthDAO = WaoModelDAOHelper.getSampleMonthDAO(transaction);
+
+ SampleMonth month = monthDAO.create(SampleMonth.SAMPLE_ROW, row);
+ Calendar calendar = new GregorianCalendar(2009, 3, 1);
+ month.setPeriodDate(calendar.getTime());
+ row.addSampleMonth(month);
+
+ transaction.commitTransaction();
+ SampleRow myRow = dao.findByCode("2010_1");
+ transaction.closeContext();
+ return myRow;
+ }
+
+ private SampleRow getRowFromContext() throws WaoException, TopiaException {
+ TopiaContext transaction = WaoContext.getTopiaRootContext().beginTransaction();
+ SampleRowDAO dao = WaoModelDAOHelper.getSampleRowDAO(transaction);
+ SampleRow resultRow = dao.findByCode("2010_1");
+ transaction.closeContext();
+ return resultRow;
+ }
+
+ @Test
+ public void testAddRealTideTime() throws Exception {
+ log.info("addRealTideTime");
+
+ /** PREPARE DATA **/
+ SampleRow row = prepareData();
+
+ Contact contact = new ContactImpl();
+ Date beginDate = DateUtils.createDate(12, 4, 2009);
+ Date endDate = DateUtils.createDate(15, 4, 2009);
+ contact.setTideBeginDate(beginDate);
+ contact.setTideEndDate(endDate);
+
+ /** EXEC METHOD **/
+ row.addRealTideTime(contact);
+ SampleMonth result = getRowFromContext().getSampleMonth(beginDate);
+ assertEquals(1, result.getRealTidesValue());
+
+// // Reinit result for next test
+// result.addRealTideTime(-1);
+// // Test with a more than one day interval dates from contact
+// endDate = DateUtils.createDate(18, 4, 2009);
+// contact.setTideEndDate(endDate);
+//
+// getRowFromContext().addRealTideTime(contact);
+// result = getRowFromContext().getSampleMonth(beginDate);
+// assertEquals(1, result.getRealTidesValue());
+ }
+
+ @Test
+ public void testRemoveRealTideTime() throws Exception {
+ log.info("addRealTideTime");
+
+ /** PREPARE DATA **/
+ SampleRow row = prepareData();
+
+ Contact contact = new ContactImpl();
+ Date beginDate = DateUtils.createDate(12, 4, 2009);
+ Date endDate = DateUtils.createDate(12, 4, 2009);
+ contact.setTideBeginDate(beginDate);
+ contact.setTideEndDate(endDate);
+
+ /** EXEC METHOD **/
+ row.removeRealTideTime(contact);
+ SampleMonth result = getRowFromContext().getSampleMonth(beginDate);
+ // result stay at 0, can't remove 1 tide from 0
+ assertEquals(0, result.getRealTidesValue());
+
+ // Reinit result for next test
+ result.addRealTideTime(12);
+
+ // Test with a more than one day interval dates from contact : only one tide to remove
+ endDate = DateUtils.createDate(18, 4, 2009);
+ contact.setTideEndDate(endDate);
+
+ getRowFromContext().removeRealTideTime(contact);
+ result = getRowFromContext().getSampleMonth(beginDate);
+ assertEquals(11, result.getRealTidesValue());
+ }
+
+ @Test
+ public void testIsFinished() throws Exception {
+ log.info("isFinished()");
+
+ SampleRow row = new SampleRowImpl();
+
+ Calendar calendar = new GregorianCalendar(2009, 8, 23);
+ row.setPeriodEnd(calendar.getTime());
+
+ // with a gap of one month, the row is not considered as finished
+ assertFalse(row.isFinished(-1));
+
+
+ }
+}
Deleted: trunk/wao-business/src/test/java/fr/ifremer/wao/services/ActivityCalendarImportTest.java
===================================================================
--- trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/services/ActivityCalendarImportTest.java 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-business/src/test/java/fr/ifremer/wao/services/ActivityCalendarImportTest.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,116 +0,0 @@
-/*
- * *##%
- * SuiviObsmer :: 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.suiviobsmer.services;
-
-import fr.ifremer.suiviobsmer.SuiviObsmerContext;
-import fr.ifremer.suiviobsmer.SuiviObsmerException;
-import fr.ifremer.suiviobsmer.SuiviObsmerRunner;
-import fr.ifremer.suiviobsmer.SuiviObsmerRunnerTest;
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.zip.GZIPInputStream;
-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.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import static org.junit.Assert.*;
-
-/**
- * ActivityCalendarImport
- *
- * Created: 11 déc. 2009
- *
- * @author fdesbois
- * @version $Revision$
- *
- * Mise a jour: $Date$
- * par : $Author$
- */
-public class ActivityCalendarImportTest {
-
- private static SuiviObsmerRunner runner;
-
- private static final Logger log = LoggerFactory.getLogger(ActivityCalendarImportTest.class);
-
- public ActivityCalendarImportTest() {
- }
-
- @BeforeClass
- public static void setUpClass() throws Exception {
- runner = new SuiviObsmerRunnerTest();
- }
-
- @AfterClass
- public static void tearDownClass() throws Exception {
- }
-
- @Before
- public void setUp() throws SuiviObsmerException {
- runner.start();
- }
-
- @After
- public void tearDown() throws SuiviObsmerException {
- runner.stop();
- }
-
- /**
- * Test of run method, of class ActivityCalendarImport.
- */
- @Test
- public void testRun() throws IOException, InterruptedException, SuiviObsmerException {
- log.info("run");
-
- ServiceBoat serviceBoat = new ServiceBoatImpl();
- 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);
-
- Thread t = new Thread(instance);
- t.start();
- t.join();
-
- String filename = SuiviObsmerContext.getProperty(
- SuiviObsmerContext.PROP_FILENAME_LOG_ACTIVITY_IMPORT);
-
- File file = new File(filename);
- Assert.assertTrue(file.exists());
-
- BufferedReader reader = new BufferedReader(new FileReader(file));
- String line = null;
- while ((line = reader.readLine()) != null) {
- log.info(line);
- }
- }
-
-}
Copied: trunk/wao-business/src/test/java/fr/ifremer/wao/services/ActivityCalendarImportTest.java (from rev 354, trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/services/ActivityCalendarImportTest.java)
===================================================================
--- trunk/wao-business/src/test/java/fr/ifremer/wao/services/ActivityCalendarImportTest.java (rev 0)
+++ trunk/wao-business/src/test/java/fr/ifremer/wao/services/ActivityCalendarImportTest.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -0,0 +1,116 @@
+/*
+ * *##%
+ * 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.service;
+
+import fr.ifremer.wao.WaoContext;
+import fr.ifremer.wao.WaoException;
+import fr.ifremer.wao.WaoRunner;
+import fr.ifremer.wao.WaoRunnerTest;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.zip.GZIPInputStream;
+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.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import static org.junit.Assert.*;
+
+/**
+ * ActivityCalendarImport
+ *
+ * Created: 11 déc. 2009
+ *
+ * @author fdesbois
+ * @version $Revision$
+ *
+ * Mise a jour: $Date$
+ * par : $Author$
+ */
+public class ActivityCalendarImportTest {
+
+ private static WaoRunner runner;
+
+ private static final Logger log = LoggerFactory.getLogger(ActivityCalendarImportTest.class);
+
+ public ActivityCalendarImportTest() {
+ }
+
+ @BeforeClass
+ public static void setUpClass() throws Exception {
+ runner = new WaoRunnerTest();
+ }
+
+ @AfterClass
+ public static void tearDownClass() throws Exception {
+ }
+
+ @Before
+ public void setUp() throws WaoException {
+ runner.start();
+ }
+
+ @After
+ public void tearDown() throws WaoException {
+ runner.stop();
+ }
+
+ /**
+ * Test of run method, of class ActivityCalendarImport.
+ */
+ @Test
+ public void testRun() throws IOException, InterruptedException, WaoException {
+ log.info("run");
+
+ ServiceBoat serviceBoat = new ServiceBoatImpl();
+ 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);
+
+ Thread t = new Thread(instance);
+ t.start();
+ t.join();
+
+ String filename = WaoContext.getProperty(
+ WaoContext.PROP_FILENAME_LOG_ACTIVITY_IMPORT);
+
+ File file = new File(filename);
+ Assert.assertTrue(file.exists());
+
+ BufferedReader reader = new BufferedReader(new FileReader(file));
+ String line = null;
+ while ((line = reader.readLine()) != null) {
+ log.info(line);
+ }
+ }
+
+}
Deleted: trunk/wao-business/src/test/java/fr/ifremer/wao/services/ServiceBoatImplTest.java
===================================================================
--- trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/services/ServiceBoatImplTest.java 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-business/src/test/java/fr/ifremer/wao/services/ServiceBoatImplTest.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,408 +0,0 @@
-/*
- * *##%
- * SuiviObsmer :: 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.suiviobsmer.services;
-
-import fr.ifremer.suiviobsmer.SuiviObsmerException;
-import fr.ifremer.suiviobsmer.SuiviObsmerModelDAOHelper;
-import fr.ifremer.suiviobsmer.SuiviObsmerRunner;
-import fr.ifremer.suiviobsmer.SuiviObsmerContext;
-import fr.ifremer.suiviobsmer.bean.BoatFilterImpl;
-import fr.ifremer.suiviobsmer.SuiviObsmerRunnerTest;
-import fr.ifremer.suiviobsmer.bean.BoatFilter;
-import fr.ifremer.suiviobsmer.bean.CompanyBoatInfos;
-import fr.ifremer.suiviobsmer.bean.ContactState;
-import fr.ifremer.suiviobsmer.entity.ActivityCalendar;
-import fr.ifremer.suiviobsmer.entity.ActivityCalendarDAO;
-import fr.ifremer.suiviobsmer.entity.Boat;
-import fr.ifremer.suiviobsmer.entity.BoatDAO;
-import fr.ifremer.suiviobsmer.entity.BoatInfos;
-import fr.ifremer.suiviobsmer.entity.Company;
-import fr.ifremer.suiviobsmer.entity.CompanyDAO;
-import fr.ifremer.suiviobsmer.entity.CompanyImpl;
-import fr.ifremer.suiviobsmer.entity.Contact;
-import fr.ifremer.suiviobsmer.entity.ElligibleBoat;
-import fr.ifremer.suiviobsmer.entity.SampleRow;
-import fr.ifremer.suiviobsmer.entity.SampleRowDAO;
-import fr.ifremer.suiviobsmer.entity.SampleRowLogImpl;
-import fr.ifremer.suiviobsmer.entity.WaoUser;
-import fr.ifremer.suiviobsmer.entity.WaoUserImpl;
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileReader;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Map;
-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.topia.TopiaContext;
-import org.nuiton.topia.TopiaException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import static org.junit.Assert.*;
-
-/**
- *
- * @author fdesbois
- */
-public class ServiceBoatImplTest {
-
- private static SuiviObsmerRunner runner;
-
- private static final Logger log = LoggerFactory.getLogger(ServiceBoatImplTest.class);
-
- private ServiceBoatImpl service;
-
- public ServiceBoatImplTest() {
- }
-
- @BeforeClass
- public static void setUpClass() throws Exception {
- runner = new SuiviObsmerRunnerTest();
- }
-
- @AfterClass
- public static void tearDownClass() throws Exception {
- }
-
- @Before
- public void setUp() throws Exception {
- runner.start();
- service = new ServiceBoatImpl();
- }
-
- @After
- public void tearDown() throws Exception {
- runner.stop();
- }
-
- /**
- * Test of getBoatsByFilter method, of class ServiceBoatImpl.
- * @throws Exception
- */
- @Test
- public void testGetBoatsByFilter() throws Exception {
- log.info("getBoatsByFilter");
-
- InputStream input = getClass().getResourceAsStream("/import/navires.csv");
- service.importBoatCsv(input);
-
- ServiceUser serviceUser = new ServiceUserImpl();
- Company company = new CompanyImpl();
- company.setName("TARTANPION");
- serviceUser.createUpdateCompany(company);
- WaoUser user = new WaoUserImpl();
- user.setLogin("login");
- user.setFirstName("Jean");
- user.setLastName("Michmuche");
- user.setCompany(company);
- serviceUser.createUpdateUser(user, true);
- List<SampleRow> rows = prepareSampleRows(company);
-
- BoatFilter filter = new BoatFilterImpl();
-
- // Exec with no filter
- Map<Integer, Boat> boats = service.getBoatsByFilter(filter);
- assertEquals(6, boats.size());
- // first boat of the file
- Boat boat = boats.get(273129);
- assertNotNull(boat);
-
- // Exec with filter on Immatriculation
- filter.setBoatImmatriculation(273129);
- boats = service.getBoatsByFilter(filter);
- assertEquals(1, boats.size());
-
- // Exec with filter on Name : start with "M"
- filter = new BoatFilterImpl();
- filter.setBoatName("M");
- boats = service.getBoatsByFilter(filter);
- assertEquals(2, boats.size());
-
- // Exec with filter on DistrictCode
- filter = new BoatFilterImpl();
- filter.setBoatDistrictCode("UN");
- boats = service.getBoatsByFilter(filter);
- assertEquals(4, boats.size());
-
- // Exec with filter on SampleRowCode and company
- filter = new BoatFilterImpl();
- filter.setSampleRow(rows.get(0)); // Code = 2009_03
- filter.setCompany(company);
- boats = service.getBoatsByFilter(filter);
- assertEquals(2, boats.size());
- }
-
- @Test
- public void testGetBoats() throws Exception {
- log.info("getBoats");
-
- InputStream input = getClass().getResourceAsStream("/import/navires.csv");
- service.importBoatCsv(input);
-
- String immatriculations = "174592 978419 273129";
- List<Boat> results = service.getBoatsByImmatriculations(immatriculations);
- assertEquals(3, results.size());
- immatriculations = "174592 \\ èè-- ç999 àà \n\n 978419 00 ççç 273129";
- results = service.getBoatsByImmatriculations(immatriculations);
- assertEquals(3, results.size());
- }
-
- /**
- * Test of getBoatInfos method, of class ServiceBoatImpl.
- * @throws Exception
- */
- //@Test
- public void testGetBoatInfos() throws Exception {
- }
-
-
- @Test
- public void testGetElligibleBoats() throws Exception {
- log.info("getElligibleBoats");
-
- /** PREPARE DATA **/
- InputStream input = getClass().getResourceAsStream("/import/navires.csv");
- service.importBoatCsv(input);
-
- Company company = new CompanyImpl();
- company.setName("TARTANPION");
- prepareSampleRows(company);
-
- /** EXEC METHOD **/
-
- CompanyBoatInfos result = service.getCompanyBoatInfos(174592, company);
- assertNotNull(result);
- assertEquals(174592, result.getBoatInfos().getBoat().getImmatriculation());
- assertEquals("TARTANPION", result.getCompany().getName());
- // only row1 is getting
- assertEquals(1, result.getElligibleBoatsValues().size());
- }
-
- private List<SampleRow> prepareSampleRows(Company company)
- throws SuiviObsmerException, TopiaException {
- ServiceReferential serviceReferential = new ServiceReferentialImpl();
- InputStream input = getClass().getResourceAsStream("/import/zonesPeche.csv");
- serviceReferential.importFishingZoneCsv(input);
-
- TopiaContext transaction = SuiviObsmerContext.getTopiaRootContext().beginTransaction();
- // Create a company
- CompanyDAO companyDAO = SuiviObsmerModelDAOHelper.getCompanyDAO(transaction);
- SuiviObsmerContext.prepareTopiaId(Company.class, company);
- companyDAO.update(company);
- companyDAO.create(Company.NAME, "BIS");
- transaction.commitTransaction();
-
- ServiceSampling serviceSampling = new ServiceSamplingImpl();
- input = getClass().getResourceAsStream("/import/echantillonnage.csv");
- serviceSampling.importSamplingPlanCsv(input);
-
- // Get two SampleRows : 2009_3 & 2010_4
- SampleRowDAO rowDAO = SuiviObsmerModelDAOHelper.getSampleRowDAO(transaction);
- SampleRow row1 = rowDAO.findByCode("2009_0003");
- row1.getProfession();
- SampleRow row2 = rowDAO.findByCode("2010_0004");
- row2.getProfession();
-
- transaction.commitTransaction();
-
- transaction.closeContext();
-
- // Set company and elligibleBoats '174592 177474' for row1
- List<Boat> boats = service.getBoatsByImmatriculations("174592 177474");
- row1.setCompany(company);
- serviceSampling.createUpdateSampleRow(row1, boats, new SampleRowLogImpl());
- // Set company only for row2
- row2.setCompany(company);
- serviceSampling.createUpdateSampleRow(row2, new ArrayList<Boat>(), new SampleRowLogImpl());
-
- return Arrays.asList(new SampleRow[] { row1, row2});
- }
-
- @Test
- public void testCreateUpdateBoatInfos() throws Exception {
- log.info("createUpdateBoatInfos");
-
- /** PREPARE DATA **/
- InputStream input = getClass().getResourceAsStream("/import/navires.csv");
- service.importBoatCsv(input);
-
- List<Boat> boats = service.getBoatsByImmatriculations("174592");
- Boat boat = boats.get(0);
-
- // Two rows created : 2009_3 & 2010_4 and one Company : "TARTANPION"
- ServiceUser serviceUser = new ServiceUserImpl();
- Company company = new CompanyImpl();
- company.setName("TARTANPION");
- serviceUser.createUpdateCompany(company);
- WaoUser user = new WaoUserImpl();
- user.setLogin("user");
- user.setFirstName("Jean");
- user.setLastName("Michmuche");
- user.setCompany(company);
- serviceUser.createUpdateUser(user, true);
- List<SampleRow> rows = prepareSampleRows(company);
-
- TopiaContext transaction = SuiviObsmerContext.getTopiaRootContext().beginTransaction();
- SampleRowDAO rowDAO = SuiviObsmerModelDAOHelper.getSampleRowDAO(transaction);
- SampleRow row = rowDAO.findByCode("2010_0001");
- row.getCompany();
- row.getProfession();
- transaction.closeContext();
-
- ServiceContact serviceContact = new ServiceContactImpl();
- Contact contact1 = serviceContact.getNewContact(user, row, boat);
- contact1.setState(ContactState.CONTACT_START.toString());
- serviceContact.saveContact(contact1, false);
-
- CompanyBoatInfos companyBoatInfos = service.getCompanyBoatInfos(174592, company);
-
- /** EXEC METHOD **/
- BoatInfos boatInfos = companyBoatInfos.getBoatInfos();
-
- boatInfos.setDup(2);
- boatInfos.setContactFirstName("Jean-Paul");
- boatInfos.setContactLastName("Belmondo");
-
- /** TEST1 **/
- // ajout d'une nouvelle ligne "2010_4" non mise en elligible auparavent
- companyBoatInfos.setNewElligibleBoat(rows.get(1));
- // ligne deja elligible mise en inactive
- companyBoatInfos.removeElligibleBoat("2009_0003");
-
- service.createUpdateCompanyBoatInfos(companyBoatInfos);
-
- companyBoatInfos = service.getCompanyBoatInfos(174592, company);
-
- Map<String, ElligibleBoat> results = companyBoatInfos.getElligibleBoats();
- assertEquals(2, results.size());
-
- ElligibleBoat elligible = companyBoatInfos.getElligibleBoat("2009_0003");
- assertNotNull(elligible.getCompanyActive());
- assertFalse(elligible.getCompanyActive());
-
- elligible = companyBoatInfos.getElligibleBoat("2010_0004");
- assertTrue(elligible.getCompanyActive());
-
- /** TEST2 **/
- // Suppression ligne lié elligible pour la société
- companyBoatInfos.removeElligibleBoat("2010_0004");
- // Reactivation ligne mise en inactive juste avant
- companyBoatInfos.activeElligibleBoat("2009_0003");
-
- service.createUpdateCompanyBoatInfos(companyBoatInfos);
-
- companyBoatInfos = service.getCompanyBoatInfos(174592, company);
-
- results = companyBoatInfos.getElligibleBoats();
- assertEquals(1, results.size());
-
- elligible = companyBoatInfos.getElligibleBoat("2009_0003");
- assertNull(elligible.getCompanyActive());
- assertTrue(elligible.getGlobalActive());
-
- /** EXEC METHOD **/
- Contact result = companyBoatInfos.getLastContact();
- Assert.assertEquals(contact1.getTopiaId(), result.getTopiaId());
- }
-
- /**
- * Test of importBoatCsv method, of class ServiceBoatImpl.
- * @throws Exception
- */
- @Test
- public void testImportBoatCsv() throws Exception {
- log.info("importBoatCsv");
-
- InputStream input = getClass().getResourceAsStream("/import/navires.csv");
- int[] nbBoats = service.importBoatCsv(input);
- assertEquals(6, nbBoats[0]);
- // new boats added
- assertEquals(6, nbBoats[1]);
-
- // Check boat 174592 is active &nd boat 177474 is inactive
- List<Boat> results = service.getBoatsByImmatriculations("174592 177474");
- assertTrue(results.get(0).getActive());
- assertFalse(results.get(1).getActive());
- }
-
- @Test
- public void testGetLastActivityCalendar() throws Exception {
- log.info("getLastActivityCalendar");
-
- /** PREPARE DATA **/
- TopiaContext transaction = SuiviObsmerContext.getTopiaRootContext().beginTransaction();
-
- BoatDAO boatDAO = SuiviObsmerModelDAOHelper.getBoatDAO(transaction);
- Boat boat = boatDAO.create(
- Boat.NAME, "TESTBOAT",
- Boat.IMMATRICULATION, 174592);
-
- ActivityCalendarDAO dao = SuiviObsmerModelDAOHelper.getActivityCalendarDAO(transaction);
-
- ActivityCalendar calendar1 = dao.create(
- ActivityCalendar.BOAT, boat,
- ActivityCalendar.YEAR, 2008);
-
- ActivityCalendar calendar2 = dao.create(
- ActivityCalendar.BOAT, boat,
- ActivityCalendar.YEAR, 2007);
-
- ActivityCalendar calendar3 = dao.create(
- ActivityCalendar.BOAT, boat,
- ActivityCalendar.YEAR, 2009);
-
- transaction.commitTransaction();
- transaction.closeContext();
-
- /** EXEC METHOD **/
- WaoUser user = new WaoUserImpl();
- user.setFirstName("Jean");
- user.setLastName("Michmuche");
- Company company = new CompanyImpl();
- company.setName("TARTANPION");
- user.setCompany(company);
-
- ActivityCalendar result = service.getLastActivityCalendar(user, boat);
- Assert.assertNotNull(result);
- Assert.assertEquals(2009, result.getYear());
-
- String filename = SuiviObsmerContext.getProperty(
- SuiviObsmerContext.PROP_FILENAME_LOG_ACTIVITY_ACCESS);
-
- File file = new File(filename);
- Assert.assertTrue(file.exists());
-
- BufferedReader reader = new BufferedReader(new FileReader(file));
- String line = reader.readLine();
- Assert.assertTrue(line.contains("Jean Michmuche"));
- Assert.assertTrue(line.contains("TARTANPION"));
- Assert.assertTrue(line.contains("TESTBOAT"));
- Assert.assertTrue(line.contains("174592"));
- }
-
-}
Copied: trunk/wao-business/src/test/java/fr/ifremer/wao/services/ServiceBoatImplTest.java (from rev 354, trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/services/ServiceBoatImplTest.java)
===================================================================
--- trunk/wao-business/src/test/java/fr/ifremer/wao/services/ServiceBoatImplTest.java (rev 0)
+++ trunk/wao-business/src/test/java/fr/ifremer/wao/services/ServiceBoatImplTest.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -0,0 +1,408 @@
+/*
+ * *##%
+ * 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.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.bean.BoatFilterImpl;
+import fr.ifremer.wao.WaoRunnerTest;
+import fr.ifremer.wao.bean.BoatFilter;
+import fr.ifremer.wao.bean.CompanyBoatInfos;
+import fr.ifremer.wao.bean.ContactState;
+import fr.ifremer.wao.entity.ActivityCalendar;
+import fr.ifremer.wao.entity.ActivityCalendarDAO;
+import fr.ifremer.wao.entity.Boat;
+import fr.ifremer.wao.entity.BoatDAO;
+import fr.ifremer.wao.entity.BoatInfos;
+import fr.ifremer.wao.entity.Company;
+import fr.ifremer.wao.entity.CompanyDAO;
+import fr.ifremer.wao.entity.CompanyImpl;
+import fr.ifremer.wao.entity.Contact;
+import fr.ifremer.wao.entity.ElligibleBoat;
+import fr.ifremer.wao.entity.SampleRow;
+import fr.ifremer.wao.entity.SampleRowDAO;
+import fr.ifremer.wao.entity.SampleRowLogImpl;
+import fr.ifremer.wao.entity.WaoUser;
+import fr.ifremer.wao.entity.WaoUserImpl;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+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.topia.TopiaContext;
+import org.nuiton.topia.TopiaException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import static org.junit.Assert.*;
+
+/**
+ *
+ * @author fdesbois
+ */
+public class ServiceBoatImplTest {
+
+ private static WaoRunner runner;
+
+ private static final Logger log = LoggerFactory.getLogger(ServiceBoatImplTest.class);
+
+ private ServiceBoatImpl service;
+
+ public ServiceBoatImplTest() {
+ }
+
+ @BeforeClass
+ public static void setUpClass() throws Exception {
+ runner = new WaoRunnerTest();
+ }
+
+ @AfterClass
+ public static void tearDownClass() throws Exception {
+ }
+
+ @Before
+ public void setUp() throws Exception {
+ runner.start();
+ service = new ServiceBoatImpl();
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ runner.stop();
+ }
+
+ /**
+ * Test of getBoatsByFilter method, of class ServiceBoatImpl.
+ * @throws Exception
+ */
+ @Test
+ public void testGetBoatsByFilter() throws Exception {
+ log.info("getBoatsByFilter");
+
+ InputStream input = getClass().getResourceAsStream("/import/navires.csv");
+ service.importBoatCsv(input);
+
+ ServiceUser serviceUser = new ServiceUserImpl();
+ Company company = new CompanyImpl();
+ company.setName("TARTANPION");
+ serviceUser.createUpdateCompany(company);
+ WaoUser user = new WaoUserImpl();
+ user.setLogin("login");
+ user.setFirstName("Jean");
+ user.setLastName("Michmuche");
+ user.setCompany(company);
+ serviceUser.createUpdateUser(user, true);
+ List<SampleRow> rows = prepareSampleRows(company);
+
+ BoatFilter filter = new BoatFilterImpl();
+
+ // Exec with no filter
+ Map<Integer, Boat> boats = service.getBoatsByFilter(filter);
+ assertEquals(6, boats.size());
+ // first boat of the file
+ Boat boat = boats.get(273129);
+ assertNotNull(boat);
+
+ // Exec with filter on Immatriculation
+ filter.setBoatImmatriculation(273129);
+ boats = service.getBoatsByFilter(filter);
+ assertEquals(1, boats.size());
+
+ // Exec with filter on Name : start with "M"
+ filter = new BoatFilterImpl();
+ filter.setBoatName("M");
+ boats = service.getBoatsByFilter(filter);
+ assertEquals(2, boats.size());
+
+ // Exec with filter on DistrictCode
+ filter = new BoatFilterImpl();
+ filter.setBoatDistrictCode("UN");
+ boats = service.getBoatsByFilter(filter);
+ assertEquals(4, boats.size());
+
+ // Exec with filter on SampleRowCode and company
+ filter = new BoatFilterImpl();
+ filter.setSampleRow(rows.get(0)); // Code = 2009_03
+ filter.setCompany(company);
+ boats = service.getBoatsByFilter(filter);
+ assertEquals(2, boats.size());
+ }
+
+ @Test
+ public void testGetBoats() throws Exception {
+ log.info("getBoats");
+
+ InputStream input = getClass().getResourceAsStream("/import/navires.csv");
+ service.importBoatCsv(input);
+
+ String immatriculations = "174592 978419 273129";
+ List<Boat> results = service.getBoatsByImmatriculations(immatriculations);
+ assertEquals(3, results.size());
+ immatriculations = "174592 \\ èè-- ç999 àà \n\n 978419 00 ççç 273129";
+ results = service.getBoatsByImmatriculations(immatriculations);
+ assertEquals(3, results.size());
+ }
+
+ /**
+ * Test of getBoatInfos method, of class ServiceBoatImpl.
+ * @throws Exception
+ */
+ //@Test
+ public void testGetBoatInfos() throws Exception {
+ }
+
+
+ @Test
+ public void testGetElligibleBoats() throws Exception {
+ log.info("getElligibleBoats");
+
+ /** PREPARE DATA **/
+ InputStream input = getClass().getResourceAsStream("/import/navires.csv");
+ service.importBoatCsv(input);
+
+ Company company = new CompanyImpl();
+ company.setName("TARTANPION");
+ prepareSampleRows(company);
+
+ /** EXEC METHOD **/
+
+ CompanyBoatInfos result = service.getCompanyBoatInfos(174592, company);
+ assertNotNull(result);
+ assertEquals(174592, result.getBoatInfos().getBoat().getImmatriculation());
+ assertEquals("TARTANPION", result.getCompany().getName());
+ // only row1 is getting
+ assertEquals(1, result.getElligibleBoatsValues().size());
+ }
+
+ private List<SampleRow> prepareSampleRows(Company company)
+ throws WaoException, TopiaException {
+ ServiceReferential serviceReferential = new ServiceReferentialImpl();
+ InputStream input = getClass().getResourceAsStream("/import/zonesPeche.csv");
+ serviceReferential.importFishingZoneCsv(input);
+
+ TopiaContext transaction = WaoContext.getTopiaRootContext().beginTransaction();
+ // Create a company
+ CompanyDAO companyDAO = WaoModelDAOHelper.getCompanyDAO(transaction);
+ WaoContext.prepareTopiaId(Company.class, company);
+ companyDAO.update(company);
+ companyDAO.create(Company.NAME, "BIS");
+ transaction.commitTransaction();
+
+ ServiceSampling serviceSampling = new ServiceSamplingImpl();
+ input = getClass().getResourceAsStream("/import/echantillonnage.csv");
+ serviceSampling.importSamplingPlanCsv(input);
+
+ // Get two SampleRows : 2009_3 & 2010_4
+ SampleRowDAO rowDAO = WaoModelDAOHelper.getSampleRowDAO(transaction);
+ SampleRow row1 = rowDAO.findByCode("2009_0003");
+ row1.getProfession();
+ SampleRow row2 = rowDAO.findByCode("2010_0004");
+ row2.getProfession();
+
+ transaction.commitTransaction();
+
+ transaction.closeContext();
+
+ // Set company and elligibleBoats '174592 177474' for row1
+ List<Boat> boats = service.getBoatsByImmatriculations("174592 177474");
+ row1.setCompany(company);
+ serviceSampling.createUpdateSampleRow(row1, boats, new SampleRowLogImpl());
+ // Set company only for row2
+ row2.setCompany(company);
+ serviceSampling.createUpdateSampleRow(row2, new ArrayList<Boat>(), new SampleRowLogImpl());
+
+ return Arrays.asList(new SampleRow[] { row1, row2});
+ }
+
+ @Test
+ public void testCreateUpdateBoatInfos() throws Exception {
+ log.info("createUpdateBoatInfos");
+
+ /** PREPARE DATA **/
+ InputStream input = getClass().getResourceAsStream("/import/navires.csv");
+ service.importBoatCsv(input);
+
+ List<Boat> boats = service.getBoatsByImmatriculations("174592");
+ Boat boat = boats.get(0);
+
+ // Two rows created : 2009_3 & 2010_4 and one Company : "TARTANPION"
+ ServiceUser serviceUser = new ServiceUserImpl();
+ Company company = new CompanyImpl();
+ company.setName("TARTANPION");
+ serviceUser.createUpdateCompany(company);
+ WaoUser user = new WaoUserImpl();
+ user.setLogin("user");
+ user.setFirstName("Jean");
+ user.setLastName("Michmuche");
+ user.setCompany(company);
+ serviceUser.createUpdateUser(user, true);
+ List<SampleRow> rows = prepareSampleRows(company);
+
+ TopiaContext transaction = WaoContext.getTopiaRootContext().beginTransaction();
+ SampleRowDAO rowDAO = WaoModelDAOHelper.getSampleRowDAO(transaction);
+ SampleRow row = rowDAO.findByCode("2010_0001");
+ row.getCompany();
+ row.getProfession();
+ transaction.closeContext();
+
+ ServiceContact serviceContact = new ServiceContactImpl();
+ Contact contact1 = serviceContact.getNewContact(user, row, boat);
+ contact1.setState(ContactState.CONTACT_START.toString());
+ serviceContact.saveContact(contact1, false);
+
+ CompanyBoatInfos companyBoatInfos = service.getCompanyBoatInfos(174592, company);
+
+ /** EXEC METHOD **/
+ BoatInfos boatInfos = companyBoatInfos.getBoatInfos();
+
+ boatInfos.setDup(2);
+ boatInfos.setContactFirstName("Jean-Paul");
+ boatInfos.setContactLastName("Belmondo");
+
+ /** TEST1 **/
+ // ajout d'une nouvelle ligne "2010_4" non mise en elligible auparavent
+ companyBoatInfos.setNewElligibleBoat(rows.get(1));
+ // ligne deja elligible mise en inactive
+ companyBoatInfos.removeElligibleBoat("2009_0003");
+
+ service.createUpdateCompanyBoatInfos(companyBoatInfos);
+
+ companyBoatInfos = service.getCompanyBoatInfos(174592, company);
+
+ Map<String, ElligibleBoat> results = companyBoatInfos.getElligibleBoats();
+ assertEquals(2, results.size());
+
+ ElligibleBoat elligible = companyBoatInfos.getElligibleBoat("2009_0003");
+ assertNotNull(elligible.getCompanyActive());
+ assertFalse(elligible.getCompanyActive());
+
+ elligible = companyBoatInfos.getElligibleBoat("2010_0004");
+ assertTrue(elligible.getCompanyActive());
+
+ /** TEST2 **/
+ // Suppression ligne lié elligible pour la société
+ companyBoatInfos.removeElligibleBoat("2010_0004");
+ // Reactivation ligne mise en inactive juste avant
+ companyBoatInfos.activeElligibleBoat("2009_0003");
+
+ service.createUpdateCompanyBoatInfos(companyBoatInfos);
+
+ companyBoatInfos = service.getCompanyBoatInfos(174592, company);
+
+ results = companyBoatInfos.getElligibleBoats();
+ assertEquals(1, results.size());
+
+ elligible = companyBoatInfos.getElligibleBoat("2009_0003");
+ assertNull(elligible.getCompanyActive());
+ assertTrue(elligible.getGlobalActive());
+
+ /** EXEC METHOD **/
+ Contact result = companyBoatInfos.getLastContact();
+ Assert.assertEquals(contact1.getTopiaId(), result.getTopiaId());
+ }
+
+ /**
+ * Test of importBoatCsv method, of class ServiceBoatImpl.
+ * @throws Exception
+ */
+ @Test
+ public void testImportBoatCsv() throws Exception {
+ log.info("importBoatCsv");
+
+ InputStream input = getClass().getResourceAsStream("/import/navires.csv");
+ int[] nbBoats = service.importBoatCsv(input);
+ assertEquals(6, nbBoats[0]);
+ // new boats added
+ assertEquals(6, nbBoats[1]);
+
+ // Check boat 174592 is active &nd boat 177474 is inactive
+ List<Boat> results = service.getBoatsByImmatriculations("174592 177474");
+ assertTrue(results.get(0).getActive());
+ assertFalse(results.get(1).getActive());
+ }
+
+ @Test
+ public void testGetLastActivityCalendar() throws Exception {
+ log.info("getLastActivityCalendar");
+
+ /** PREPARE DATA **/
+ TopiaContext transaction = WaoContext.getTopiaRootContext().beginTransaction();
+
+ BoatDAO boatDAO = WaoModelDAOHelper.getBoatDAO(transaction);
+ Boat boat = boatDAO.create(
+ Boat.NAME, "TESTBOAT",
+ Boat.IMMATRICULATION, 174592);
+
+ ActivityCalendarDAO dao = WaoModelDAOHelper.getActivityCalendarDAO(transaction);
+
+ ActivityCalendar calendar1 = dao.create(
+ ActivityCalendar.BOAT, boat,
+ ActivityCalendar.YEAR, 2008);
+
+ ActivityCalendar calendar2 = dao.create(
+ ActivityCalendar.BOAT, boat,
+ ActivityCalendar.YEAR, 2007);
+
+ ActivityCalendar calendar3 = dao.create(
+ ActivityCalendar.BOAT, boat,
+ ActivityCalendar.YEAR, 2009);
+
+ transaction.commitTransaction();
+ transaction.closeContext();
+
+ /** EXEC METHOD **/
+ WaoUser user = new WaoUserImpl();
+ user.setFirstName("Jean");
+ user.setLastName("Michmuche");
+ Company company = new CompanyImpl();
+ company.setName("TARTANPION");
+ user.setCompany(company);
+
+ ActivityCalendar result = service.getLastActivityCalendar(user, boat);
+ Assert.assertNotNull(result);
+ Assert.assertEquals(2009, result.getYear());
+
+ String filename = WaoContext.getProperty(
+ WaoContext.PROP_FILENAME_LOG_ACTIVITY_ACCESS);
+
+ File file = new File(filename);
+ Assert.assertTrue(file.exists());
+
+ BufferedReader reader = new BufferedReader(new FileReader(file));
+ String line = reader.readLine();
+ Assert.assertTrue(line.contains("Jean Michmuche"));
+ Assert.assertTrue(line.contains("TARTANPION"));
+ Assert.assertTrue(line.contains("TESTBOAT"));
+ Assert.assertTrue(line.contains("174592"));
+ }
+
+}
Deleted: trunk/wao-business/src/test/java/fr/ifremer/wao/services/ServiceReferentialImplTest.java
===================================================================
--- trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/services/ServiceReferentialImplTest.java 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-business/src/test/java/fr/ifremer/wao/services/ServiceReferentialImplTest.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,155 +0,0 @@
-/*
- * *##%
- * SuiviObsmer :: 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.suiviobsmer.services;
-
-import fr.ifremer.suiviobsmer.SuiviObsmerException;
-import fr.ifremer.suiviobsmer.SuiviObsmerRunner;
-import fr.ifremer.suiviobsmer.SuiviObsmerRunnerTest;
-import fr.ifremer.suiviobsmer.bean.SamplingFilter;
-import fr.ifremer.suiviobsmer.bean.SamplingFilterImpl;
-import fr.ifremer.suiviobsmer.entity.FishingZone;
-import java.io.InputStream;
-import java.util.List;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import static org.junit.Assert.*;
-
-/**
- *
- * @author fdesbois
- */
-public class ServiceReferentialImplTest {
-
- private static SuiviObsmerRunner runner;
-
- private static final Logger log = LoggerFactory.getLogger(ServiceReferentialImplTest.class);
-
- private ServiceReferentialImpl service;
-
- public ServiceReferentialImplTest() {
- }
-
- @BeforeClass
- public static void setUpClass() throws Exception {
- runner = new SuiviObsmerRunnerTest();
- }
-
- @AfterClass
- public static void tearDownClass() throws Exception {
- }
-
- @Before
- public void setUp() throws Exception {
- runner.start();
- service = new ServiceReferentialImpl();
- }
-
- @After
- public void tearDown() throws Exception {
- runner.stop();
- }
-
- /**
- * Test of getFacades method, of class ServiceReferentialImpl.
- */
- @Test
- public void testGetFacades() throws Exception {
- log.info("getFacades");
-
- InputStream input = getClass().getResourceAsStream("/import/zonesPeche.csv");
- service.importFishingZoneCsv(input);
-
- List<String> facades = service.getFacades(new SamplingFilterImpl());
- assertEquals(3, facades.size());
- assertTrue(facades.contains("Atlantique"));
- assertTrue(facades.contains("Mer du Nord"));
- assertTrue(facades.contains("Méditerranée"));
- }
-
- @Test
- public void testGetSectors() throws Exception {
- log.info("getSectors");
-
- InputStream input = getClass().getResourceAsStream("/import/zonesPeche.csv");
- service.importFishingZoneCsv(input);
-
- SamplingFilter filter = new SamplingFilterImpl();
-
- List<String> sectors = service.getSectors(filter);
- assertEquals(5, sectors.size());
- assertTrue(sectors.contains("Manche"));
- assertTrue(sectors.contains("Mer du Nord"));
- assertTrue(sectors.contains("Manche Ouest"));
- assertTrue(sectors.contains("Golfe de Gascogne"));
- assertTrue(sectors.contains("Méditerranée"));
-
- filter.setFacadeName("Atlantique");
-
- sectors = service.getSectors(filter);
- assertEquals(2, sectors.size());
- assertTrue(sectors.contains("Manche Ouest"));
- assertTrue(sectors.contains("Golfe de Gascogne"));
- }
-
- /**
- * Test of getProfessions method, of class ServiceReferentialImpl.
- */
- //@Test
- public void testGetProfessions() throws Exception {
- System.out.println("getProfessions");
- }
-
- /**
- * Test of getFishingZones method, of class ServiceReferentialImpl.
- * @throws SuiviObsmerException if error during import or getFishingZones
- */
- @Test
- public void testGetFishingZones() throws SuiviObsmerException {
- log.info("getFishingZones");
-
- InputStream input = getClass().getResourceAsStream("/import/zonesPeche.csv");
- int nbNew = service.importFishingZoneCsv(input);
- // nbNew = 6
-
- List<FishingZone> results = service.getFishingZones();
- assertEquals(nbNew, results.size());
- }
-
- /**
- * Test of importFishingZoneCsv method, of class ServiceReferentialImpl.
- * @throws SuiviObsmerException if import error
- */
- @Test
- public void testImportFishingZoneCsv() throws SuiviObsmerException {
- log.info("importFishingZoneCsv");
-
- InputStream input = getClass().getResourceAsStream("/import/zonesPeche.csv");
- int result = service.importFishingZoneCsv(input);
- assertEquals(6, result);
- }
-
-}
Copied: trunk/wao-business/src/test/java/fr/ifremer/wao/services/ServiceReferentialImplTest.java (from rev 354, trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/services/ServiceReferentialImplTest.java)
===================================================================
--- trunk/wao-business/src/test/java/fr/ifremer/wao/services/ServiceReferentialImplTest.java (rev 0)
+++ trunk/wao-business/src/test/java/fr/ifremer/wao/services/ServiceReferentialImplTest.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -0,0 +1,155 @@
+/*
+ * *##%
+ * 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.service;
+
+import fr.ifremer.wao.WaoException;
+import fr.ifremer.wao.WaoRunner;
+import fr.ifremer.wao.WaoRunnerTest;
+import fr.ifremer.wao.bean.SamplingFilter;
+import fr.ifremer.wao.bean.SamplingFilterImpl;
+import fr.ifremer.wao.entity.FishingZone;
+import java.io.InputStream;
+import java.util.List;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import static org.junit.Assert.*;
+
+/**
+ *
+ * @author fdesbois
+ */
+public class ServiceReferentialImplTest {
+
+ private static WaoRunner runner;
+
+ private static final Logger log = LoggerFactory.getLogger(ServiceReferentialImplTest.class);
+
+ private ServiceReferentialImpl service;
+
+ public ServiceReferentialImplTest() {
+ }
+
+ @BeforeClass
+ public static void setUpClass() throws Exception {
+ runner = new WaoRunnerTest();
+ }
+
+ @AfterClass
+ public static void tearDownClass() throws Exception {
+ }
+
+ @Before
+ public void setUp() throws Exception {
+ runner.start();
+ service = new ServiceReferentialImpl();
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ runner.stop();
+ }
+
+ /**
+ * Test of getFacades method, of class ServiceReferentialImpl.
+ */
+ @Test
+ public void testGetFacades() throws Exception {
+ log.info("getFacades");
+
+ InputStream input = getClass().getResourceAsStream("/import/zonesPeche.csv");
+ service.importFishingZoneCsv(input);
+
+ List<String> facades = service.getFacades(new SamplingFilterImpl());
+ assertEquals(3, facades.size());
+ assertTrue(facades.contains("Atlantique"));
+ assertTrue(facades.contains("Mer du Nord"));
+ assertTrue(facades.contains("Méditerranée"));
+ }
+
+ @Test
+ public void testGetSectors() throws Exception {
+ log.info("getSectors");
+
+ InputStream input = getClass().getResourceAsStream("/import/zonesPeche.csv");
+ service.importFishingZoneCsv(input);
+
+ SamplingFilter filter = new SamplingFilterImpl();
+
+ List<String> sectors = service.getSectors(filter);
+ assertEquals(5, sectors.size());
+ assertTrue(sectors.contains("Manche"));
+ assertTrue(sectors.contains("Mer du Nord"));
+ assertTrue(sectors.contains("Manche Ouest"));
+ assertTrue(sectors.contains("Golfe de Gascogne"));
+ assertTrue(sectors.contains("Méditerranée"));
+
+ filter.setFacadeName("Atlantique");
+
+ sectors = service.getSectors(filter);
+ assertEquals(2, sectors.size());
+ assertTrue(sectors.contains("Manche Ouest"));
+ assertTrue(sectors.contains("Golfe de Gascogne"));
+ }
+
+ /**
+ * Test of getProfessions method, of class ServiceReferentialImpl.
+ */
+ //@Test
+ public void testGetProfessions() throws Exception {
+ System.out.println("getProfessions");
+ }
+
+ /**
+ * Test of getFishingZones method, of class ServiceReferentialImpl.
+ * @throws WaoException if error during import or getFishingZones
+ */
+ @Test
+ public void testGetFishingZones() throws WaoException {
+ log.info("getFishingZones");
+
+ InputStream input = getClass().getResourceAsStream("/import/zonesPeche.csv");
+ int nbNew = service.importFishingZoneCsv(input);
+ // nbNew = 6
+
+ List<FishingZone> results = service.getFishingZones();
+ assertEquals(nbNew, results.size());
+ }
+
+ /**
+ * Test of importFishingZoneCsv method, of class ServiceReferentialImpl.
+ * @throws WaoException if import error
+ */
+ @Test
+ public void testImportFishingZoneCsv() throws WaoException {
+ log.info("importFishingZoneCsv");
+
+ InputStream input = getClass().getResourceAsStream("/import/zonesPeche.csv");
+ int result = service.importFishingZoneCsv(input);
+ assertEquals(6, result);
+ }
+
+}
Deleted: trunk/wao-business/src/test/java/fr/ifremer/wao/services/ServiceSamplingImplTest.java
===================================================================
--- trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/services/ServiceSamplingImplTest.java 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-business/src/test/java/fr/ifremer/wao/services/ServiceSamplingImplTest.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,583 +0,0 @@
-/*
- * *##%
- * SuiviObsmer :: 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.suiviobsmer.services;
-
-import fr.ifremer.suiviobsmer.SuiviObsmerException;
-import fr.ifremer.suiviobsmer.SuiviObsmerModelDAOHelper;
-import fr.ifremer.suiviobsmer.SuiviObsmerRunner;
-import fr.ifremer.suiviobsmer.SuiviObsmerContext;
-import fr.ifremer.suiviobsmer.bean.ImportResults;
-import fr.ifremer.suiviobsmer.bean.SamplingFilter;
-import fr.ifremer.suiviobsmer.bean.SamplingFilterImpl;
-import fr.ifremer.suiviobsmer.SuiviObsmerRunnerTest;
-import fr.ifremer.suiviobsmer.bean.FacadeRow;
-import fr.ifremer.suiviobsmer.entity.Boat;
-import fr.ifremer.suiviobsmer.entity.Company;
-import fr.ifremer.suiviobsmer.entity.CompanyDAO;
-import fr.ifremer.suiviobsmer.entity.ElligibleBoat;
-import fr.ifremer.suiviobsmer.entity.ElligibleBoatDAO;
-import fr.ifremer.suiviobsmer.entity.FishingZone;
-import fr.ifremer.suiviobsmer.entity.FishingZoneDAO;
-import fr.ifremer.suiviobsmer.entity.Profession;
-import fr.ifremer.suiviobsmer.entity.ProfessionDAO;
-import fr.ifremer.suiviobsmer.entity.ProfessionImpl;
-import fr.ifremer.suiviobsmer.entity.SampleMonth;
-import fr.ifremer.suiviobsmer.entity.SampleMonthImpl;
-import fr.ifremer.suiviobsmer.entity.SampleRow;
-import fr.ifremer.suiviobsmer.entity.SampleRowDAO;
-import fr.ifremer.suiviobsmer.entity.SampleRowLogImpl;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Collection;
-import java.util.Date;
-import java.util.GregorianCalendar;
-import java.util.List;
-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.topia.TopiaContext;
-import org.nuiton.topia.TopiaException;
-import org.nuiton.util.DateUtils;
-import org.nuiton.util.PeriodDates;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import static org.junit.Assert.*;
-
-/**
- * ServiceSamplingImplTest
- *
- * Created: 30 nov. 2009
- *
- * @author fdesbois
- * @version $Revision$
- *
- * Mise a jour: $Date$
- * par : $Author$
- */
-public class ServiceSamplingImplTest {
-
- private static SuiviObsmerRunner runner;
-
- private static final Logger log = LoggerFactory.getLogger(ServiceSamplingImplTest.class);
-
- private ServiceSamplingImpl service;
-
- public ServiceSamplingImplTest() {
- }
-
- @BeforeClass
- public static void setUpClass() throws Exception {
- runner = new SuiviObsmerRunnerTest();
- }
-
- @AfterClass
- public static void tearDownClass() throws Exception {
- }
-
- @Before
- public void setUp() throws Exception {
- runner.start();
- service = new ServiceSamplingImpl();
- }
-
- @After
- public void tearDown() throws Exception {
- runner.stop();
- }
-
- @Test
- public void testCreateUpdateSampleRow() throws Exception {
- log.info("createUpdateSampleRow");
-
- /** PREPARE DATA **/
- TopiaContext transaction = SuiviObsmerContext.getTopiaRootContext().beginTransaction();
-
- List<FishingZone> zones = prepareFishingZones(transaction);
-
- InputStream input = getClass().getResourceAsStream("/import/navires.csv");
- ServiceBoat serviceBoat = new ServiceBoatImpl();
- serviceBoat.importBoatCsv(input);
-
- transaction.closeContext();
-
- // CREATE
- Profession profession1 = new ProfessionImpl();
- profession1.setCodeDCF5("OORR-BDP");
- profession1.setMeshSize(">=18");
- profession1.setSize("90-1000");
- profession1.setLibelle("Chalutage de poissons tubes");
-
- List<SampleMonth> months = new ArrayList<SampleMonth>();
- for (int i = 0; i < 12; i++) {
- SampleMonth month = new SampleMonthImpl();
- Calendar calendar = new GregorianCalendar(2009, i, 1);
- month.setPeriodDate(calendar.getTime());
- month.setExpectedTidesValue(3);
- months.add(month);
- }
- for (int i = 0; i < 3; i++) {
- SampleMonth month = new SampleMonthImpl();
- Calendar calendar = new GregorianCalendar(2010, i, 1);
- month.setPeriodDate(calendar.getTime());
- month.setExpectedTidesValue(4);
- months.add(month);
- }
-
- SampleRow row = service.getNewSampleRow();
- row.setCode("2010_03");
- row.setNbObservants(3);
- row.setAverageTideTime(2.5);
- row.setProgramName("DPMA-2009");
- row.setPeriodBegin(DateUtils.createDate(1, 1, 2009));
- row.setPeriodEnd(DateUtils.createDate(31, 3, 2010));
- row.setProfession(profession1);
- row.setSampleMonth(months);
- row.setFishingZone(zones);
- row.setFishingZonesInfos("port tres loin du champ");
-
- /** EXEC CREATE **/
- List<Boat> boats = serviceBoat.getBoatsByImmatriculations("174592 978419 273129");
- service.createUpdateSampleRow(row, boats, new SampleRowLogImpl());
- assertNotNull(row.getTopiaId());
- assertNotNull(row.getProfession().getTopiaId());
-
- SampleRow result = service.getSampleRow(row.getTopiaId());
- assertEquals(3, result.getFishingZone().size());
- assertEquals(3, result.getElligibleBoat().size());
-
- // TEST FOR DELETE ELLIGIBLE BOAT
- boats.remove(2);
- service.createUpdateSampleRow(result, boats, new SampleRowLogImpl());
-
- result = service.getSampleRow(row.getTopiaId());
- assertEquals(2, result.getElligibleBoat().size());
-
- }
-
- /**
- * Test of getSampleRowsOrderedByFishingZone method, of class ServiceSamplingImpl.
- */
- @Test
- public void testGetSampleRowsOrderedByFishingZone() throws Exception {
- log.info("getSampleRowsOrderedByFishingZone");
-
-
- /** PREPARE DATA **/
-
- TopiaContext transaction = SuiviObsmerContext.getTopiaRootContext().beginTransaction();
-
- List<FishingZone> zones = prepareFishingZones(transaction);
-
- //Program program1 = programDAO.create(Program.NAME, "DPMA-2009");
- Date dateBegin1 = DateUtils.createDate(1, 1, 2009);
- Date dateEnd1 = DateUtils.createDate(1, 3, 2010);
- PeriodDates period1 = new PeriodDates(dateBegin1, dateEnd1);
-
- //Program program2 = programDAO.create(Program.NAME, "PPDA-2008");
- Date dateBegin2 = DateUtils.createDate(1, 1, 2008);
- Date dateEnd2 = DateUtils.createDate(1, 12, 2008);
- PeriodDates period2 = new PeriodDates(dateBegin2, dateEnd2);
-
- SampleRowDAO dao = SuiviObsmerModelDAOHelper.getSampleRowDAO(transaction);
-
- SampleRow row1 = dao.create();
- row1.setCode("2010_0001");
- row1.addFishingZone(zones.get(2));
- row1.setProgramName("DPMA-2009");
- row1.setPeriod(period1);
-
- log.info(row1.getCode() + " :: " + row1.getFacade() + " :: " + row1.getSectors());
-
- SampleRow row2 = dao.create();
- row2.setCode("2010_0002");
- row2.addFishingZone(zones.get(0));
- row2.setProgramName("DPMA-2009");
- row2.setPeriod(period1);
-
- log.info(row2.getCode() + " :: " + row2.getFacade() + " :: " + row2.getSectors());
-
- SampleRow row3 = dao.create();
- row3.setCode("2010_0003");
- row3.addFishingZone(zones.get(1));
- row3.addFishingZone(zones.get(2));
- row3.addFishingZone(zones.get(0));
- row3.setProgramName("PPDA-2008");
- row3.setPeriod(period2);
-
- log.info(row3.getCode() + " :: " + row3.getFacade() + " :: " + row3.getSectors());
-
- SampleRow row4 = dao.create();
- row4.setCode("2010_0004");
- row4.addFishingZone(zones.get(0)); // Mer du Nord :: Manche
- row4.setProgramName("DPMA-2009");
- row4.setPeriod(period1);
-
- log.info(row4.getCode() + " :: " + row4.getFacade() + " :: " + row4.getSectors());
-
- transaction.commitTransaction();
-
- /** EXEC service method **/
-
- // FIRST TEST :
- // ORDER by FishingZone (facadeName, sectorName, districtCode)
- // BIG PERIOD, included program1 and program2
- // NO COMPANY (= null)
- Calendar begin = new GregorianCalendar(2000, 0, 1, 0, 0, 0);
- Calendar end = new GregorianCalendar(2020, 11, 31, 0, 0, 0);
- PeriodDates period = new PeriodDates(begin, end);
- // RESULT : [2010_0002, 2010_0004, 2010_0001, 2010_0003]
- FacadeRow facade = service.getSampleRowsOrderedByFishingZone(period, null);
- List<SampleRow> rows = facade.getValues();
- assertEquals(4, rows.size());
- SampleRow resultRow0 = rows.get(0);
- assertEquals("2010_0002", resultRow0.getCode());
- SampleRow resultRow1 = rows.get(1);
- assertEquals("2010_0004", resultRow1.getCode());
-
-// List<FishingZone> zoneRow1 = resultRow1.getFishingZone();
-// assertEquals(3, zoneRow1.size());
-// FishingZone resultZone0 = zoneRow1.get(0);
-// assertEquals("VIIb", resultZone0.getDistrictCode());
-// FishingZone resultZone1 = zoneRow1.get(1);
-// assertEquals("VI", resultZone1.getDistrictCode());
-// FishingZone resultZone2 = zoneRow1.get(2);
-// assertEquals("V", resultZone2.getDistrictCode());
-
- SampleRow resultRow2 = rows.get(2);
- assertEquals("2010_0003", resultRow2.getCode());
- SampleRow resultRow3 = rows.get(3);
- assertEquals("2010_0001", resultRow3.getCode());
-
- // SECOND TEST :
- // ORDER by FishingZone (facadeName, sectorName, districtCode)
- // BIG PERIOD, not included program2
- // NO COMPANY (= null)
- begin = new GregorianCalendar(2009, 0, 1, 0, 0, 0);
- end = new GregorianCalendar(2020, 11, 31, 0, 0, 0);
- period = new PeriodDates(begin, end);
- // RESULT : [2010_0002, 2010_0004, 2010_0001]
- facade = service.getSampleRowsOrderedByFishingZone(period, null);
- rows = facade.getValues();
- assertEquals(3, rows.size());
- resultRow0 = rows.get(0);
- assertEquals("2010_0002", resultRow0.getCode());
- resultRow1 = rows.get(1);
- assertEquals("2010_0004", resultRow1.getCode());
- resultRow2 = rows.get(2);
- assertEquals("2010_0001", resultRow2.getCode());
-
- }
-
- private List<FishingZone> prepareFishingZones(TopiaContext transaction) throws SuiviObsmerException, TopiaException {
-
- FishingZoneDAO fishingZoneDAO = SuiviObsmerModelDAOHelper.getFishingZoneDAO(transaction);
-
- FishingZone fishingZone1 = fishingZoneDAO.create();
- fishingZone1.setFacadeName("Atlantique");
- fishingZone1.setSectorName("Secteur Mer Celtique et Ouest Irlande centré Pays bigouden");
- fishingZone1.setDistrictCode("VIIb");
-
- FishingZone fishingZone2 = fishingZoneDAO.create();
- fishingZone2.setFacadeName("Manche");
- fishingZone2.setSectorName("Secteur Cherbourg Honfleur centré sur Port-en-Bessin");
- fishingZone2.setDistrictCode("VI");
-
- FishingZone fishingZone3 = fishingZoneDAO.create();
- fishingZone3.setFacadeName("Manche");
- fishingZone3.setSectorName("Secteur du Havre à Dunkerque centré sur Boulogne");
- fishingZone3.setDistrictCode("V");
-
- transaction.commitTransaction();
-
- return fishingZoneDAO.findAll();
- }
-
- public void testGetSampleRowsForUser() throws Exception {
- log.info("getSampleRowsForUser");
- /** PREPARE DATA **/
- TopiaContext transaction = SuiviObsmerContext.getTopiaRootContext().beginTransaction();
-
- FishingZoneDAO zoneDAO = SuiviObsmerModelDAOHelper.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 = SuiviObsmerModelDAOHelper.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 = SuiviObsmerModelDAOHelper.getSampleRowDAO(transaction);
- SampleRow row = sampleRowDAO.create(
- SampleRow.CODE,"2010_178",
- SampleRow.COMPANY,company,
- SampleRow.PROGRAM_NAME, "DPMA-2009",
- SampleRow.PERIOD_BEGIN, begin.getTime(),
- SampleRow.PERIOD_END, end.getTime());
-
-
- transaction.commitTransaction();
- transaction.closeContext();
-
- InputStream input = getClass().getResourceAsStream("/import/echantillonnage.csv");
- service.importSamplingPlanCsv(input);
-
- /** EXEC METHOD **/
- SamplingFilter filter = new SamplingFilterImpl();
-// User admin = new UserImpl();
-// admin.setAdmin(true);
-// filter.setCompany()
- filter.setNbMonthFinishedFromToday(0);
- List<SampleRow> results = service.getSampleRowsByFilter(filter);
- // total in file : 11, 1 refused, 1 finished
- assertEquals(9, results.size());
-
-// User user = new UserImpl();
-// user.setCompany(company);
- filter.setCompany(company);
- results = service.getSampleRowsByFilter(filter);
- assertEquals(1, results.size());
- }
-
- /**
- * Test of getHistoric method, of class ServiceSamplingImpl.
- */
- //@Test
- public void testGetHistoric() throws Exception {
- System.out.println("getHistoric");
- }
-
- /**
- * Test of getSampleRow method, of class ServiceSamplingImpl.
- */
- //@Test
- public void testGetSampleRow() throws Exception {
- System.out.println("getSampleRow");
- }
-
- @Test
- public void testGetNewProfession() throws Exception {
- log.info("getNewProfession");
-
- /** PREPARE DATA **/
-
- TopiaContext transaction = SuiviObsmerContext.getTopiaRootContext().beginTransaction();
-
- ProfessionDAO dao = SuiviObsmerModelDAOHelper.getProfessionDAO(transaction);
-
- Profession profession = dao.create(
- Profession.CODE_DCF5, "OBR",
- Profession.LIBELLE, "Fileyage en barre",
- Profession.MESH_SIZE, "< 80",
- Profession.OTHER, "90mm",
- Profession.SPECIES, "barre, lieu noir, saumon des plages");
-
- transaction.commitTransaction();
- transaction.closeContext();
-
- /** EXEC METHOD **/
- Profession newProfession = service.getNewProfession(profession);
- Assert.assertNotSame(profession, newProfession);
- Assert.assertEquals("OBR", newProfession.getCodeDCF5());
- Assert.assertEquals("Fileyage en barre", newProfession.getLibelle());
- Assert.assertEquals("< 80", newProfession.getMeshSize());
- Assert.assertEquals("90mm", newProfession.getOther());
- Assert.assertEquals("barre, lieu noir, saumon des plages", newProfession.getSpecies());
-
- }
-
- @Test
- public void testDeleteSampleRow() throws Exception {
- log.info("deleteSampleRow");
-
- /** PREPARE DATA **/
- TopiaContext transaction = SuiviObsmerContext.getTopiaRootContext().beginTransaction();
-
- FishingZoneDAO zoneDAO = SuiviObsmerModelDAOHelper.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 = SuiviObsmerModelDAOHelper.getCompanyDAO(transaction);
- companyDAO.create(Company.NAME, "TARTANPION");
- companyDAO.create(Company.NAME, "BIS");
- transaction.commitTransaction();
-
-
- InputStream input = getClass().getResourceAsStream("/import/echantillonnage.csv");
- service.importSamplingPlanCsv(input);
-
- SampleRowDAO rowDAO = SuiviObsmerModelDAOHelper.getSampleRowDAO(transaction);
- SampleRow row = rowDAO.findByCode("2010_0001");
- row.getProfession();
- row.getCompany();
- transaction.closeContext();
-
- input = getClass().getResourceAsStream("/import/navires.csv");
- ServiceBoat serviceBoat = new ServiceBoatImpl();
- serviceBoat.importBoatCsv(input);
- List<Boat> boats = serviceBoat.getBoatsByImmatriculations("174592 978419 273129");
-
- service.createUpdateSampleRow(row, boats, new SampleRowLogImpl());
- /** EXEC METHOD **/
-
- service.deleteSampleRow(row);
- transaction = SuiviObsmerContext.getTopiaRootContext().beginTransaction();
- rowDAO = SuiviObsmerModelDAOHelper.getSampleRowDAO(transaction);
- row = rowDAO.findByCode("2010_0001");
- assertNull(row);
-
- ElligibleBoatDAO elligibleDAO = SuiviObsmerModelDAOHelper.getElligibleBoatDAO(transaction);
- List<ElligibleBoat> elligibles = elligibleDAO.findAll();
- assertEquals(0, elligibles.size());
- transaction.closeContext();
- }
-
- @Test
- public void testImportSamplingPlanCsv() throws SuiviObsmerException, TopiaException {
- log.info("importSamplingPlanCsv");
-
- /** PREPARE DATA **/
- TopiaContext transaction = SuiviObsmerContext.getTopiaRootContext().beginTransaction();
-
- FishingZoneDAO zoneDAO = SuiviObsmerModelDAOHelper.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 = SuiviObsmerModelDAOHelper.getCompanyDAO(transaction);
- companyDAO.create(Company.NAME, "TARTANPION");
- companyDAO.create(Company.NAME, "BIS");
- transaction.commitTransaction();
- transaction.closeContext();
-
- /** EXEC METHOD **/
- InputStream input = getClass().getResourceAsStream("/import/echantillonnage.csv");
- ImportResults result = service.importSamplingPlanCsv(input);
-
- // total imported
- assertEquals(10, result.getNbRowsImported());
- // total refused
- assertEquals(1, result.getNbRowsRefused());
-
- /** CHECK VALUES **/
- transaction = SuiviObsmerContext.getTopiaRootContext().beginTransaction();
-
- ProfessionDAO professionDAO = SuiviObsmerModelDAOHelper.getProfessionDAO(transaction);
-
- List<Profession> professions = professionDAO.findAll();
- assertEquals(9, professions.size());
-
- SampleRowDAO rowDAO = SuiviObsmerModelDAOHelper.getSampleRowDAO(transaction);
-
- SampleRow row1 = rowDAO.findByCode("2010_0001");
- assertNotNull(row1);
- assertEquals(1, row1.getNbObservants());
- assertEquals(1.5, row1.getAverageTideTime(), 0.1);
- assertEquals("Un petit commentaire", row1.getComment());
-
- assertEquals("MA-2009", row1.getProgramName());
-
- Profession profession = row1.getProfession();
- assertNotNull(profession);
- assertEquals("DB_MOL", profession.getCodeDCF5());
-
- List<SampleMonth> months = row1.getSampleMonth();
- assertEquals(11, months.size());
-
- Collection<FishingZone> zones = row1.getFishingZone();
- assertEquals(2, zones.size());
- zones.contains(zoneI);
- zones.contains(zoneIId);
-
- transaction.closeContext();
- }
-
- @Test
- public void testGetPrograms() throws Exception {
- /** PREPARE DATA **/
- TopiaContext transaction = SuiviObsmerContext.getTopiaRootContext().beginTransaction();
-
- FishingZoneDAO zoneDAO = SuiviObsmerModelDAOHelper.getFishingZoneDAO(transaction);
- zoneDAO.create(FishingZone.DISTRICT_CODE, "IId");
- zoneDAO.create(FishingZone.DISTRICT_CODE, "IV");
- zoneDAO.create(FishingZone.DISTRICT_CODE, "I");
-
- CompanyDAO companyDAO = SuiviObsmerModelDAOHelper.getCompanyDAO(transaction);
- companyDAO.create(Company.NAME, "TARTANPION");
- companyDAO.create(Company.NAME, "BIS");
- transaction.commitTransaction();
- transaction.closeContext();
-
- InputStream input = getClass().getResourceAsStream("/import/echantillonnage.csv");
- service.importSamplingPlanCsv(input);
-
- /** EXEC METHOD **/
- List<String> programs = service.getPrograms(null);
- assertEquals(4, programs.size());
- }
-
-
- @Test
- public void testGetNewSampleRowCode() throws Exception {
- log.info("getNewSampleRowCode");
-
- /** PREPARE DATA **/
- TopiaContext transaction = SuiviObsmerContext.getTopiaRootContext().beginTransaction();
-
- FishingZoneDAO zoneDAO = SuiviObsmerModelDAOHelper.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 = SuiviObsmerModelDAOHelper.getCompanyDAO(transaction);
- companyDAO.create(Company.NAME, "TARTANPION");
- companyDAO.create(Company.NAME, "BIS");
- transaction.commitTransaction();
-
- ServiceSampling serviceSampling = new ServiceSamplingImpl();
- InputStream input = getClass().getResourceAsStream("/import/echantillonnage.csv");
- serviceSampling.importSamplingPlanCsv(input);
-
- transaction.closeContext();
-
- /** EXEC METHOD **/
-
- Calendar begin = new GregorianCalendar(2009, 11, 1);
-
- String result = service.getNewSampleRowCode(begin.getTime());
- Assert.assertEquals("2009_0007", result);
-
- // Test regex for replacment in importSamplingPlanCsv
-// String code = "2010_1";
-// code = code.replaceFirst("_(\\d)$", "_0$1");
-// Assert.assertEquals("2010_01", code);
-//
-// code = "2010_04";
-// code = code.replaceFirst("_(\\d)$", "_0$1");
-// Assert.assertEquals("2010_04", code);
- }
-
-}
Copied: trunk/wao-business/src/test/java/fr/ifremer/wao/services/ServiceSamplingImplTest.java (from rev 354, trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/services/ServiceSamplingImplTest.java)
===================================================================
--- trunk/wao-business/src/test/java/fr/ifremer/wao/services/ServiceSamplingImplTest.java (rev 0)
+++ trunk/wao-business/src/test/java/fr/ifremer/wao/services/ServiceSamplingImplTest.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -0,0 +1,583 @@
+/*
+ * *##%
+ * 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.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.bean.ImportResults;
+import fr.ifremer.wao.bean.SamplingFilter;
+import fr.ifremer.wao.bean.SamplingFilterImpl;
+import fr.ifremer.wao.WaoRunnerTest;
+import fr.ifremer.wao.bean.FacadeRow;
+import fr.ifremer.wao.entity.Boat;
+import fr.ifremer.wao.entity.Company;
+import fr.ifremer.wao.entity.CompanyDAO;
+import fr.ifremer.wao.entity.ElligibleBoat;
+import fr.ifremer.wao.entity.ElligibleBoatDAO;
+import fr.ifremer.wao.entity.FishingZone;
+import fr.ifremer.wao.entity.FishingZoneDAO;
+import fr.ifremer.wao.entity.Profession;
+import fr.ifremer.wao.entity.ProfessionDAO;
+import fr.ifremer.wao.entity.ProfessionImpl;
+import fr.ifremer.wao.entity.SampleMonth;
+import fr.ifremer.wao.entity.SampleMonthImpl;
+import fr.ifremer.wao.entity.SampleRow;
+import fr.ifremer.wao.entity.SampleRowDAO;
+import fr.ifremer.wao.entity.SampleRowLogImpl;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Collection;
+import java.util.Date;
+import java.util.GregorianCalendar;
+import java.util.List;
+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.topia.TopiaContext;
+import org.nuiton.topia.TopiaException;
+import org.nuiton.util.DateUtils;
+import org.nuiton.util.PeriodDates;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import static org.junit.Assert.*;
+
+/**
+ * ServiceSamplingImplTest
+ *
+ * Created: 30 nov. 2009
+ *
+ * @author fdesbois
+ * @version $Revision$
+ *
+ * Mise a jour: $Date$
+ * par : $Author$
+ */
+public class ServiceSamplingImplTest {
+
+ private static WaoRunner runner;
+
+ private static final Logger log = LoggerFactory.getLogger(ServiceSamplingImplTest.class);
+
+ private ServiceSamplingImpl service;
+
+ public ServiceSamplingImplTest() {
+ }
+
+ @BeforeClass
+ public static void setUpClass() throws Exception {
+ runner = new WaoRunnerTest();
+ }
+
+ @AfterClass
+ public static void tearDownClass() throws Exception {
+ }
+
+ @Before
+ public void setUp() throws Exception {
+ runner.start();
+ service = new ServiceSamplingImpl();
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ runner.stop();
+ }
+
+ @Test
+ public void testCreateUpdateSampleRow() throws Exception {
+ log.info("createUpdateSampleRow");
+
+ /** PREPARE DATA **/
+ TopiaContext transaction = WaoContext.getTopiaRootContext().beginTransaction();
+
+ List<FishingZone> zones = prepareFishingZones(transaction);
+
+ InputStream input = getClass().getResourceAsStream("/import/navires.csv");
+ ServiceBoat serviceBoat = new ServiceBoatImpl();
+ serviceBoat.importBoatCsv(input);
+
+ transaction.closeContext();
+
+ // CREATE
+ Profession profession1 = new ProfessionImpl();
+ profession1.setCodeDCF5("OORR-BDP");
+ profession1.setMeshSize(">=18");
+ profession1.setSize("90-1000");
+ profession1.setLibelle("Chalutage de poissons tubes");
+
+ List<SampleMonth> months = new ArrayList<SampleMonth>();
+ for (int i = 0; i < 12; i++) {
+ SampleMonth month = new SampleMonthImpl();
+ Calendar calendar = new GregorianCalendar(2009, i, 1);
+ month.setPeriodDate(calendar.getTime());
+ month.setExpectedTidesValue(3);
+ months.add(month);
+ }
+ for (int i = 0; i < 3; i++) {
+ SampleMonth month = new SampleMonthImpl();
+ Calendar calendar = new GregorianCalendar(2010, i, 1);
+ month.setPeriodDate(calendar.getTime());
+ month.setExpectedTidesValue(4);
+ months.add(month);
+ }
+
+ SampleRow row = service.getNewSampleRow();
+ row.setCode("2010_03");
+ row.setNbObservants(3);
+ row.setAverageTideTime(2.5);
+ row.setProgramName("DPMA-2009");
+ row.setPeriodBegin(DateUtils.createDate(1, 1, 2009));
+ row.setPeriodEnd(DateUtils.createDate(31, 3, 2010));
+ row.setProfession(profession1);
+ row.setSampleMonth(months);
+ row.setFishingZone(zones);
+ row.setFishingZonesInfos("port tres loin du champ");
+
+ /** EXEC CREATE **/
+ List<Boat> boats = serviceBoat.getBoatsByImmatriculations("174592 978419 273129");
+ service.createUpdateSampleRow(row, boats, new SampleRowLogImpl());
+ assertNotNull(row.getTopiaId());
+ assertNotNull(row.getProfession().getTopiaId());
+
+ SampleRow result = service.getSampleRow(row.getTopiaId());
+ assertEquals(3, result.getFishingZone().size());
+ assertEquals(3, result.getElligibleBoat().size());
+
+ // TEST FOR DELETE ELLIGIBLE BOAT
+ boats.remove(2);
+ service.createUpdateSampleRow(result, boats, new SampleRowLogImpl());
+
+ result = service.getSampleRow(row.getTopiaId());
+ assertEquals(2, result.getElligibleBoat().size());
+
+ }
+
+ /**
+ * Test of getSampleRowsOrderedByFishingZone method, of class ServiceSamplingImpl.
+ */
+ @Test
+ public void testGetSampleRowsOrderedByFishingZone() throws Exception {
+ log.info("getSampleRowsOrderedByFishingZone");
+
+
+ /** PREPARE DATA **/
+
+ TopiaContext transaction = WaoContext.getTopiaRootContext().beginTransaction();
+
+ List<FishingZone> zones = prepareFishingZones(transaction);
+
+ //Program program1 = programDAO.create(Program.NAME, "DPMA-2009");
+ Date dateBegin1 = DateUtils.createDate(1, 1, 2009);
+ Date dateEnd1 = DateUtils.createDate(1, 3, 2010);
+ PeriodDates period1 = new PeriodDates(dateBegin1, dateEnd1);
+
+ //Program program2 = programDAO.create(Program.NAME, "PPDA-2008");
+ Date dateBegin2 = DateUtils.createDate(1, 1, 2008);
+ Date dateEnd2 = DateUtils.createDate(1, 12, 2008);
+ PeriodDates period2 = new PeriodDates(dateBegin2, dateEnd2);
+
+ SampleRowDAO dao = WaoModelDAOHelper.getSampleRowDAO(transaction);
+
+ SampleRow row1 = dao.create();
+ row1.setCode("2010_0001");
+ row1.addFishingZone(zones.get(2));
+ row1.setProgramName("DPMA-2009");
+ row1.setPeriod(period1);
+
+ log.info(row1.getCode() + " :: " + row1.getFacade() + " :: " + row1.getSectors());
+
+ SampleRow row2 = dao.create();
+ row2.setCode("2010_0002");
+ row2.addFishingZone(zones.get(0));
+ row2.setProgramName("DPMA-2009");
+ row2.setPeriod(period1);
+
+ log.info(row2.getCode() + " :: " + row2.getFacade() + " :: " + row2.getSectors());
+
+ SampleRow row3 = dao.create();
+ row3.setCode("2010_0003");
+ row3.addFishingZone(zones.get(1));
+ row3.addFishingZone(zones.get(2));
+ row3.addFishingZone(zones.get(0));
+ row3.setProgramName("PPDA-2008");
+ row3.setPeriod(period2);
+
+ log.info(row3.getCode() + " :: " + row3.getFacade() + " :: " + row3.getSectors());
+
+ SampleRow row4 = dao.create();
+ row4.setCode("2010_0004");
+ row4.addFishingZone(zones.get(0)); // Mer du Nord :: Manche
+ row4.setProgramName("DPMA-2009");
+ row4.setPeriod(period1);
+
+ log.info(row4.getCode() + " :: " + row4.getFacade() + " :: " + row4.getSectors());
+
+ transaction.commitTransaction();
+
+ /** EXEC service method **/
+
+ // FIRST TEST :
+ // ORDER by FishingZone (facadeName, sectorName, districtCode)
+ // BIG PERIOD, included program1 and program2
+ // NO COMPANY (= null)
+ Calendar begin = new GregorianCalendar(2000, 0, 1, 0, 0, 0);
+ Calendar end = new GregorianCalendar(2020, 11, 31, 0, 0, 0);
+ PeriodDates period = new PeriodDates(begin, end);
+ // RESULT : [2010_0002, 2010_0004, 2010_0001, 2010_0003]
+ FacadeRow facade = service.getSampleRowsOrderedByFishingZone(period, null);
+ List<SampleRow> rows = facade.getValues();
+ assertEquals(4, rows.size());
+ SampleRow resultRow0 = rows.get(0);
+ assertEquals("2010_0002", resultRow0.getCode());
+ SampleRow resultRow1 = rows.get(1);
+ assertEquals("2010_0004", resultRow1.getCode());
+
+// List<FishingZone> zoneRow1 = resultRow1.getFishingZone();
+// assertEquals(3, zoneRow1.size());
+// FishingZone resultZone0 = zoneRow1.get(0);
+// assertEquals("VIIb", resultZone0.getDistrictCode());
+// FishingZone resultZone1 = zoneRow1.get(1);
+// assertEquals("VI", resultZone1.getDistrictCode());
+// FishingZone resultZone2 = zoneRow1.get(2);
+// assertEquals("V", resultZone2.getDistrictCode());
+
+ SampleRow resultRow2 = rows.get(2);
+ assertEquals("2010_0003", resultRow2.getCode());
+ SampleRow resultRow3 = rows.get(3);
+ assertEquals("2010_0001", resultRow3.getCode());
+
+ // SECOND TEST :
+ // ORDER by FishingZone (facadeName, sectorName, districtCode)
+ // BIG PERIOD, not included program2
+ // NO COMPANY (= null)
+ begin = new GregorianCalendar(2009, 0, 1, 0, 0, 0);
+ end = new GregorianCalendar(2020, 11, 31, 0, 0, 0);
+ period = new PeriodDates(begin, end);
+ // RESULT : [2010_0002, 2010_0004, 2010_0001]
+ facade = service.getSampleRowsOrderedByFishingZone(period, null);
+ rows = facade.getValues();
+ assertEquals(3, rows.size());
+ resultRow0 = rows.get(0);
+ assertEquals("2010_0002", resultRow0.getCode());
+ resultRow1 = rows.get(1);
+ assertEquals("2010_0004", resultRow1.getCode());
+ resultRow2 = rows.get(2);
+ assertEquals("2010_0001", resultRow2.getCode());
+
+ }
+
+ private List<FishingZone> prepareFishingZones(TopiaContext transaction) throws WaoException, TopiaException {
+
+ FishingZoneDAO fishingZoneDAO = WaoModelDAOHelper.getFishingZoneDAO(transaction);
+
+ FishingZone fishingZone1 = fishingZoneDAO.create();
+ fishingZone1.setFacadeName("Atlantique");
+ fishingZone1.setSectorName("Secteur Mer Celtique et Ouest Irlande centré Pays bigouden");
+ fishingZone1.setDistrictCode("VIIb");
+
+ FishingZone fishingZone2 = fishingZoneDAO.create();
+ fishingZone2.setFacadeName("Manche");
+ fishingZone2.setSectorName("Secteur Cherbourg Honfleur centré sur Port-en-Bessin");
+ fishingZone2.setDistrictCode("VI");
+
+ FishingZone fishingZone3 = fishingZoneDAO.create();
+ fishingZone3.setFacadeName("Manche");
+ fishingZone3.setSectorName("Secteur du Havre à Dunkerque centré sur Boulogne");
+ fishingZone3.setDistrictCode("V");
+
+ transaction.commitTransaction();
+
+ return fishingZoneDAO.findAll();
+ }
+
+ public void testGetSampleRowsForUser() throws Exception {
+ log.info("getSampleRowsForUser");
+ /** PREPARE DATA **/
+ TopiaContext transaction = WaoContext.getTopiaRootContext().beginTransaction();
+
+ FishingZoneDAO zoneDAO = WaoModelDAOHelper.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);
+ 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);
+ SampleRow row = sampleRowDAO.create(
+ SampleRow.CODE,"2010_178",
+ SampleRow.COMPANY,company,
+ SampleRow.PROGRAM_NAME, "DPMA-2009",
+ SampleRow.PERIOD_BEGIN, begin.getTime(),
+ SampleRow.PERIOD_END, end.getTime());
+
+
+ transaction.commitTransaction();
+ transaction.closeContext();
+
+ InputStream input = getClass().getResourceAsStream("/import/echantillonnage.csv");
+ service.importSamplingPlanCsv(input);
+
+ /** EXEC METHOD **/
+ SamplingFilter filter = new SamplingFilterImpl();
+// User admin = new UserImpl();
+// admin.setAdmin(true);
+// filter.setCompany()
+ filter.setNbMonthFinishedFromToday(0);
+ List<SampleRow> results = service.getSampleRowsByFilter(filter);
+ // total in file : 11, 1 refused, 1 finished
+ assertEquals(9, results.size());
+
+// User user = new UserImpl();
+// user.setCompany(company);
+ filter.setCompany(company);
+ results = service.getSampleRowsByFilter(filter);
+ assertEquals(1, results.size());
+ }
+
+ /**
+ * Test of getHistoric method, of class ServiceSamplingImpl.
+ */
+ //@Test
+ public void testGetHistoric() throws Exception {
+ System.out.println("getHistoric");
+ }
+
+ /**
+ * Test of getSampleRow method, of class ServiceSamplingImpl.
+ */
+ //@Test
+ public void testGetSampleRow() throws Exception {
+ System.out.println("getSampleRow");
+ }
+
+ @Test
+ public void testGetNewProfession() throws Exception {
+ log.info("getNewProfession");
+
+ /** PREPARE DATA **/
+
+ TopiaContext transaction = WaoContext.getTopiaRootContext().beginTransaction();
+
+ ProfessionDAO dao = WaoModelDAOHelper.getProfessionDAO(transaction);
+
+ Profession profession = dao.create(
+ Profession.CODE_DCF5, "OBR",
+ Profession.LIBELLE, "Fileyage en barre",
+ Profession.MESH_SIZE, "< 80",
+ Profession.OTHER, "90mm",
+ Profession.SPECIES, "barre, lieu noir, saumon des plages");
+
+ transaction.commitTransaction();
+ transaction.closeContext();
+
+ /** EXEC METHOD **/
+ Profession newProfession = service.getNewProfession(profession);
+ Assert.assertNotSame(profession, newProfession);
+ Assert.assertEquals("OBR", newProfession.getCodeDCF5());
+ Assert.assertEquals("Fileyage en barre", newProfession.getLibelle());
+ Assert.assertEquals("< 80", newProfession.getMeshSize());
+ Assert.assertEquals("90mm", newProfession.getOther());
+ Assert.assertEquals("barre, lieu noir, saumon des plages", newProfession.getSpecies());
+
+ }
+
+ @Test
+ public void testDeleteSampleRow() throws Exception {
+ log.info("deleteSampleRow");
+
+ /** PREPARE DATA **/
+ TopiaContext transaction = WaoContext.getTopiaRootContext().beginTransaction();
+
+ FishingZoneDAO zoneDAO = WaoModelDAOHelper.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.create(Company.NAME, "TARTANPION");
+ companyDAO.create(Company.NAME, "BIS");
+ transaction.commitTransaction();
+
+
+ InputStream input = getClass().getResourceAsStream("/import/echantillonnage.csv");
+ service.importSamplingPlanCsv(input);
+
+ SampleRowDAO rowDAO = WaoModelDAOHelper.getSampleRowDAO(transaction);
+ SampleRow row = rowDAO.findByCode("2010_0001");
+ row.getProfession();
+ row.getCompany();
+ transaction.closeContext();
+
+ input = getClass().getResourceAsStream("/import/navires.csv");
+ ServiceBoat serviceBoat = new ServiceBoatImpl();
+ serviceBoat.importBoatCsv(input);
+ List<Boat> boats = serviceBoat.getBoatsByImmatriculations("174592 978419 273129");
+
+ service.createUpdateSampleRow(row, boats, new SampleRowLogImpl());
+ /** EXEC METHOD **/
+
+ service.deleteSampleRow(row);
+ transaction = WaoContext.getTopiaRootContext().beginTransaction();
+ rowDAO = WaoModelDAOHelper.getSampleRowDAO(transaction);
+ row = rowDAO.findByCode("2010_0001");
+ assertNull(row);
+
+ ElligibleBoatDAO elligibleDAO = WaoModelDAOHelper.getElligibleBoatDAO(transaction);
+ List<ElligibleBoat> elligibles = elligibleDAO.findAll();
+ assertEquals(0, elligibles.size());
+ transaction.closeContext();
+ }
+
+ @Test
+ public void testImportSamplingPlanCsv() throws WaoException, TopiaException {
+ log.info("importSamplingPlanCsv");
+
+ /** PREPARE DATA **/
+ TopiaContext transaction = WaoContext.getTopiaRootContext().beginTransaction();
+
+ FishingZoneDAO zoneDAO = WaoModelDAOHelper.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.create(Company.NAME, "TARTANPION");
+ companyDAO.create(Company.NAME, "BIS");
+ transaction.commitTransaction();
+ transaction.closeContext();
+
+ /** EXEC METHOD **/
+ InputStream input = getClass().getResourceAsStream("/import/echantillonnage.csv");
+ ImportResults result = service.importSamplingPlanCsv(input);
+
+ // total imported
+ assertEquals(10, result.getNbRowsImported());
+ // total refused
+ assertEquals(1, result.getNbRowsRefused());
+
+ /** CHECK VALUES **/
+ transaction = WaoContext.getTopiaRootContext().beginTransaction();
+
+ ProfessionDAO professionDAO = WaoModelDAOHelper.getProfessionDAO(transaction);
+
+ List<Profession> professions = professionDAO.findAll();
+ assertEquals(9, professions.size());
+
+ SampleRowDAO rowDAO = WaoModelDAOHelper.getSampleRowDAO(transaction);
+
+ SampleRow row1 = rowDAO.findByCode("2010_0001");
+ assertNotNull(row1);
+ assertEquals(1, row1.getNbObservants());
+ assertEquals(1.5, row1.getAverageTideTime(), 0.1);
+ assertEquals("Un petit commentaire", row1.getComment());
+
+ assertEquals("MA-2009", row1.getProgramName());
+
+ Profession profession = row1.getProfession();
+ assertNotNull(profession);
+ assertEquals("DB_MOL", profession.getCodeDCF5());
+
+ List<SampleMonth> months = row1.getSampleMonth();
+ assertEquals(11, months.size());
+
+ Collection<FishingZone> zones = row1.getFishingZone();
+ assertEquals(2, zones.size());
+ zones.contains(zoneI);
+ zones.contains(zoneIId);
+
+ transaction.closeContext();
+ }
+
+ @Test
+ public void testGetPrograms() throws Exception {
+ /** PREPARE DATA **/
+ TopiaContext transaction = WaoContext.getTopiaRootContext().beginTransaction();
+
+ FishingZoneDAO zoneDAO = WaoModelDAOHelper.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.create(Company.NAME, "TARTANPION");
+ companyDAO.create(Company.NAME, "BIS");
+ transaction.commitTransaction();
+ transaction.closeContext();
+
+ InputStream input = getClass().getResourceAsStream("/import/echantillonnage.csv");
+ service.importSamplingPlanCsv(input);
+
+ /** EXEC METHOD **/
+ List<String> programs = service.getPrograms(null);
+ assertEquals(4, programs.size());
+ }
+
+
+ @Test
+ public void testGetNewSampleRowCode() throws Exception {
+ log.info("getNewSampleRowCode");
+
+ /** PREPARE DATA **/
+ TopiaContext transaction = WaoContext.getTopiaRootContext().beginTransaction();
+
+ FishingZoneDAO zoneDAO = WaoModelDAOHelper.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.create(Company.NAME, "TARTANPION");
+ companyDAO.create(Company.NAME, "BIS");
+ transaction.commitTransaction();
+
+ ServiceSampling serviceSampling = new ServiceSamplingImpl();
+ InputStream input = getClass().getResourceAsStream("/import/echantillonnage.csv");
+ serviceSampling.importSamplingPlanCsv(input);
+
+ transaction.closeContext();
+
+ /** EXEC METHOD **/
+
+ Calendar begin = new GregorianCalendar(2009, 11, 1);
+
+ String result = service.getNewSampleRowCode(begin.getTime());
+ Assert.assertEquals("2009_0007", result);
+
+ // Test regex for replacment in importSamplingPlanCsv
+// String code = "2010_1";
+// code = code.replaceFirst("_(\\d)$", "_0$1");
+// Assert.assertEquals("2010_01", code);
+//
+// code = "2010_04";
+// code = code.replaceFirst("_(\\d)$", "_0$1");
+// Assert.assertEquals("2010_04", code);
+ }
+
+}
Deleted: trunk/wao-business/src/test/java/fr/ifremer/wao/services/ServiceSynthesisImplTest.java
===================================================================
--- trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/services/ServiceSynthesisImplTest.java 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-business/src/test/java/fr/ifremer/wao/services/ServiceSynthesisImplTest.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,511 +0,0 @@
-
-package fr.ifremer.suiviobsmer.services;
-
-import fr.ifremer.suiviobsmer.SuiviObsmerContext;
-import fr.ifremer.suiviobsmer.SuiviObsmerModelDAOHelper;
-import fr.ifremer.suiviobsmer.SuiviObsmerRunner;
-import fr.ifremer.suiviobsmer.SuiviObsmerRunnerTest;
-import fr.ifremer.suiviobsmer.bean.BoardingResult;
-import fr.ifremer.suiviobsmer.bean.ContactState;
-import fr.ifremer.suiviobsmer.bean.ContactStateStatistics;
-import fr.ifremer.suiviobsmer.entity.Boat;
-import fr.ifremer.suiviobsmer.entity.Company;
-import fr.ifremer.suiviobsmer.entity.CompanyDAO;
-import fr.ifremer.suiviobsmer.entity.Contact;
-import fr.ifremer.suiviobsmer.entity.ContactImpl;
-import fr.ifremer.suiviobsmer.entity.SampleRow;
-import fr.ifremer.suiviobsmer.entity.SampleRowDAO;
-import fr.ifremer.suiviobsmer.entity.WaoUser;
-import fr.ifremer.suiviobsmer.entity.WaoUserDAO;
-import java.io.InputStream;
-import java.util.Collection;
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
-import org.apache.commons.collections.CollectionUtils;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.nuiton.topia.TopiaContext;
-import org.nuiton.util.DateUtils;
-import org.nuiton.util.PeriodDates;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import static org.junit.Assert.*;
-
-/**
- *
- * @author fdesbois
- */
-public class ServiceSynthesisImplTest {
-
- private static SuiviObsmerRunner runner;
-
- private static final Logger log = LoggerFactory.getLogger(ServiceSynthesisImplTest.class);
-
- private ServiceSynthesisImpl service;
-
- public ServiceSynthesisImplTest() {
- }
-
- @BeforeClass
- public static void setUpClass() throws Exception {
- runner = new SuiviObsmerRunnerTest();
- }
-
- @AfterClass
- public static void tearDownClass() throws Exception {
- }
-
- @Before
- public void setUp() throws Exception {
- runner.start();
- service = new ServiceSynthesisImpl();
- }
-
- @After
- public void tearDown() throws Exception {
- runner.stop();
- }
-
- /**
- * Test of getDataSampling method, of class ServiceSynthesisImpl.
- */
- //@Test
- public void testGetDataSampling() throws Exception {
- System.out.println("getDataSampling");
- }
-
- /**
- * Test of getBoardingBoats method, of class ServiceSynthesisImpl.
- */
- @Test
- public void testGetBoardingBoats() throws Exception {
- log.info("getBoardingBoats");
- /** PREPARE DATA **/
- InputStream input = getClass().getResourceAsStream("/import/navires.csv");
- ServiceBoat serviceBoat = new ServiceBoatImpl();
- serviceBoat.importBoatCsv(input);
- List<Boat> boats = serviceBoat.getBoatsByImmatriculations("174258");
- Boat boat = boats.get(0);
-
- List<Boat> boats2 = serviceBoat.getBoatsByImmatriculations("177474");
- Boat boat2 = boats2.get(0);
-
- TopiaContext transaction = SuiviObsmerContext.getTopiaRootContext().beginTransaction();
-
- CompanyDAO companyDAO = SuiviObsmerModelDAOHelper.getCompanyDAO(transaction);
- Company company = companyDAO.create(Company.NAME, "TARTANPION");
- Company company2 = companyDAO.create(Company.NAME, "BIS");
-
- WaoUserDAO userDAO = SuiviObsmerModelDAOHelper.getWaoUserDAO(transaction);
- WaoUser user = userDAO.create(WaoUser.FIRST_NAME,"Jean", WaoUser.LAST_NAME, "Michmuche",
- WaoUser.COMPANY, company);
- company.addWaoUser(user);
- WaoUser user2 = userDAO.create(WaoUser.FIRST_NAME,"Bill", WaoUser.LAST_NAME, "Murray",
- WaoUser.COMPANY, company2);
- company2.addWaoUser(user2);
-
- transaction.commitTransaction();
-
- input = getClass().getResourceAsStream("/import/zonesPeche.csv");
- ServiceReferential serviceReferential = new ServiceReferentialImpl();
- serviceReferential.importFishingZoneCsv(input);
-
- input = getClass().getResourceAsStream("/import/echantillonnage.csv");
- ServiceSampling serviceSampling = new ServiceSamplingImpl();
- serviceSampling.importSamplingPlanCsv(input);
-
- SampleRowDAO rowDAO = SuiviObsmerModelDAOHelper.getSampleRowDAO(transaction);
- SampleRow row = rowDAO.findByCode("2010_0001");
-
- transaction.closeContext();
-
-
- ServiceContact serviceContact = new ServiceContactImpl();
- // First contact : OK
- Contact contact1 = new ContactImpl();
- contact1.setBoat(boat);
- contact1.setObserver(user);
- contact1.setSampleRow(row);
- contact1.setState(ContactState.BOARDING_DONE.toString());
- Date begin = DateUtils.createDate(3, 3, 2009);
- contact1.setTideBeginDate(begin);
- contact1.setValidationCompany(Boolean.TRUE);
- serviceContact.saveContact(contact1, false);
-
- Contact contact2 = new ContactImpl();
- contact2.setBoat(boat);
- contact2.setObserver(user);
- contact2.setSampleRow(row);
- contact2.setState(ContactState.BOARDING_DONE.toString());
- begin = DateUtils.createDate(3, 3, 2009);
- contact2.setTideBeginDate(begin);
- contact2.setValidationCompany(Boolean.TRUE);
- serviceContact.saveContact(contact2, false);
-
- Contact contact3 = new ContactImpl();
- contact3.setBoat(boat2);
- contact3.setObserver(user);
- contact3.setSampleRow(row);
- contact3.setState(ContactState.BOARDING_DONE.toString());
- begin = DateUtils.createDate(3, 3, 2009);
- contact3.setTideBeginDate(begin);
- contact3.setValidationCompany(Boolean.TRUE);
- serviceContact.saveContact(contact3, false);
-
- /** EXEC METHOD **/
- BoardingResult result = service.getBoardingBoats(null, null);
- // one boat with one boarding (177474)
- assertEquals(1, result.getData().get("1").intValue());
- // one boat with two boardings (174258)
- assertEquals(1, result.getData().get("2").intValue());
- assertEquals(2, result.getMaxBoardingValue());
- assertEquals(174258, result.getMaxBoardingBoat().getImmatriculation());
- }
-
- /**
- * Test of getBoardingBoats method, of class ServiceSynthesisImpl.
- */
- @Test
- public void testGetNonComplianceBoardingIndicator() throws Exception {
- log.info("getNonComplianceBoardingIndicator");
- /** PREPARE DATA **/
- InputStream input = getClass().getResourceAsStream("/import/navires.csv");
- ServiceBoat serviceBoat = new ServiceBoatImpl();
- serviceBoat.importBoatCsv(input);
- List<Boat> boats = serviceBoat.getBoatsByImmatriculations("174258");
- Boat boat = boats.get(0);
-
- List<Boat> boats2 = serviceBoat.getBoatsByImmatriculations("177474");
- Boat boat2 = boats2.get(0);
-
- TopiaContext transaction = SuiviObsmerContext.getTopiaRootContext().beginTransaction();
-
- CompanyDAO companyDAO = SuiviObsmerModelDAOHelper.getCompanyDAO(transaction);
- Company company = companyDAO.create(Company.NAME, "TARTANPION");
- Company company2 = companyDAO.create(Company.NAME, "BIS");
-
- WaoUserDAO userDAO = SuiviObsmerModelDAOHelper.getWaoUserDAO(transaction);
- WaoUser user = userDAO.create(WaoUser.FIRST_NAME,"Jean", WaoUser.LAST_NAME, "Michmuche",
- WaoUser.COMPANY, company);
- company.addWaoUser(user);
- WaoUser user2 = userDAO.create(WaoUser.FIRST_NAME,"Bill", WaoUser.LAST_NAME, "Murray",
- WaoUser.COMPANY, company2);
- company2.addWaoUser(user2);
-
- transaction.commitTransaction();
-
- input = getClass().getResourceAsStream("/import/zonesPeche.csv");
- ServiceReferential serviceReferential = new ServiceReferentialImpl();
- serviceReferential.importFishingZoneCsv(input);
-
- input = getClass().getResourceAsStream("/import/echantillonnage.csv");
- ServiceSampling serviceSampling = new ServiceSamplingImpl();
- serviceSampling.importSamplingPlanCsv(input);
-
- SampleRowDAO rowDAO = SuiviObsmerModelDAOHelper.getSampleRowDAO(transaction);
- SampleRow row = rowDAO.findByCode("2010_0001");
- SampleRow row2 = rowDAO.findByCode("2009_0006");
-
- transaction.closeContext();
-
-
- ServiceContact serviceContact = new ServiceContactImpl();
- // First contact : OK
- Contact contact1 = new ContactImpl();
- contact1.setBoat(boat);
- contact1.setObserver(user);
- contact1.setSampleRow(row);
- // 1 real observer over 1
- contact1.setNbObservants(1);
- contact1.setState(ContactState.BOARDING_DONE.toString());
- Date begin = DateUtils.createDate(3, 3, 2009);
- contact1.setTideBeginDate(begin);
- contact1.setValidationCompany(Boolean.TRUE);
- serviceContact.saveContact(contact1, false);
-
- Contact contact2 = new ContactImpl();
- contact2.setBoat(boat);
- contact2.setObserver(user);
- contact2.setSampleRow(row);
- // 2 real observer over 1
- contact2.setNbObservants(2);
- contact2.setState(ContactState.BOARDING_DONE.toString());
- begin = DateUtils.createDate(3, 3, 2009);
- contact2.setTideBeginDate(begin);
- contact2.setValidationCompany(Boolean.TRUE);
- serviceContact.saveContact(contact2, false);
-
- Contact contact3 = new ContactImpl();
- contact3.setBoat(boat2);
- contact3.setObserver(user2);
- contact3.setSampleRow(row2);
- // 1 real observer over 2
- contact3.setNbObservants(1);
- contact3.setState(ContactState.BOARDING_DONE.toString());
- begin = DateUtils.createDate(3, 3, 2009);
- contact3.setTideBeginDate(begin);
- contact3.setValidationCompany(Boolean.TRUE);
- serviceContact.saveContact(contact3, false);
-
- /** EXEC METHOD **/
-
- // result for company TARTANPION
- Map<String, Double> results =
- service.getNonComplianceBoardingIndicator(company);
-
- assertEquals(1, results.size());
-
- // 0% of non compliance
- Double value = results.get(company.getName());
- assertEquals(0., value, 0);
-
- // result for company BIS using admin mode (no company filtered)
- results = service.getNonComplianceBoardingIndicator(null);
-
- assertEquals(2, results.size());
-
- // 100% of non compliance
- value = results.get(company2.getName());
- assertEquals(1., value, 0);
- }
-
- /**
- * Test of getBoardingBoats method, of class ServiceSynthesisImpl.
- */
- @Test
- public void testGetContactStateStatistics() throws Exception {
- log.info("getContactStateStatistics");
- /** PREPARE DATA **/
- InputStream input = getClass().getResourceAsStream("/import/navires.csv");
- ServiceBoat serviceBoat = new ServiceBoatImpl();
- serviceBoat.importBoatCsv(input);
- List<Boat> boats = serviceBoat.getBoatsByImmatriculations("174258");
- Boat boat = boats.get(0);
-
- List<Boat> boats2 = serviceBoat.getBoatsByImmatriculations("177474");
- Boat boat2 = boats2.get(0);
-
- TopiaContext transaction = SuiviObsmerContext.getTopiaRootContext().beginTransaction();
-
- CompanyDAO companyDAO = SuiviObsmerModelDAOHelper.getCompanyDAO(transaction);
- Company company = companyDAO.create(Company.NAME, "TARTANPION");
- Company company2 = companyDAO.create(Company.NAME, "BIS");
-
- WaoUserDAO userDAO = SuiviObsmerModelDAOHelper.getWaoUserDAO(transaction);
- WaoUser user = userDAO.create(WaoUser.FIRST_NAME,"Jean", WaoUser.LAST_NAME, "Michmuche",
- WaoUser.COMPANY, company);
- company.addWaoUser(user);
- WaoUser user2 = userDAO.create(WaoUser.FIRST_NAME,"Bill", WaoUser.LAST_NAME, "Murray",
- WaoUser.COMPANY, company2);
- company2.addWaoUser(user2);
-
- transaction.commitTransaction();
-
- input = getClass().getResourceAsStream("/import/zonesPeche.csv");
- ServiceReferential serviceReferential = new ServiceReferentialImpl();
- serviceReferential.importFishingZoneCsv(input);
-
- input = getClass().getResourceAsStream("/import/echantillonnage.csv");
- ServiceSampling serviceSampling = new ServiceSamplingImpl();
- serviceSampling.importSamplingPlanCsv(input);
-
- SampleRowDAO rowDAO = SuiviObsmerModelDAOHelper.getSampleRowDAO(transaction);
- SampleRow row = rowDAO.findByCode("2010_0001");
-
- transaction.closeContext();
-
-
- ServiceContact serviceContact = new ServiceContactImpl();
-
- // Contacts for company TARTANPION
- Contact contact1 = new ContactImpl();
- contact1.setObserver(user);
- contact1.setState(ContactState.BOARDING_DONE.toString());
- Date begin = DateUtils.createDate(3, 3, 2009);
- contact1.setTideBeginDate(begin);
- serviceContact.saveContact(contact1, false);
-
- Contact contact2 = new ContactImpl();
- contact2.setObserver(user);
- contact2.setState(ContactState.BOARDING_DONE.toString());
- begin = DateUtils.createDate(3, 10, 2009);
- contact2.setTideBeginDate(begin);
- serviceContact.saveContact(contact2, false);
-
- Contact contact3 = new ContactImpl();
- contact3.setObserver(user);
- contact3.setState(ContactState.BOAT_REFUSED.toString());
- begin = DateUtils.createDate(3, 5, 2009);
- contact3.setTopiaCreateDate(begin);
- serviceContact.saveContact(contact3, false);
-
- // Contacts for company BIS
- Contact contact4 = new ContactImpl();
- contact4.setObserver(user2);
- contact4.setState(ContactState.BOARDING_EXPECTED.toString());
- begin = DateUtils.createDate(3, 5, 2009);
- contact4.setTopiaCreateDate(begin);
- serviceContact.saveContact(contact4, false);
-
- Contact contact5 = new ContactImpl();
- contact5.setObserver(user2);
- contact5.setState(ContactState.BOAT_UNAVAILABLE.toString());
- begin = DateUtils.createDate(3, 3, 2010);
- contact5.setTopiaCreateDate(begin);
- serviceContact.saveContact(contact5, false);
-
- // Contact refused by program, will not be in result
- Contact contact6 = new ContactImpl();
- contact6.setObserver(user2);
- contact6.setState(ContactState.BOAT_UNAVAILABLE.toString());
- begin = DateUtils.createDate(3, 3, 2010);
- contact6.setTopiaCreateDate(begin);
- contact6.setValidationProgram(Boolean.FALSE);
- serviceContact.saveContact(contact6, false);
-
- /** EXEC METHOD **/
-
- // result for company TARTANPION with no period
- Collection<ContactStateStatistics> results =
- service.getContactStateStatistics(company, null);
-
- assertEquals(1, results.size());
- ContactStateStatistics result = (ContactStateStatistics)CollectionUtils.get(results, 0);
- assertEquals(3, result.getTotal());
- Map<ContactState, Integer> data = result.getData();
- assertNotNull(data);
-
- assertEquals(ContactState.values().length, data.size());
- assertEquals(2, data.get(ContactState.BOARDING_DONE).intValue());
- assertEquals(1, data.get(ContactState.BOAT_REFUSED).intValue());
-
- // result for company BIS using admin mode
- results = service.getContactStateStatistics(null, null);
- assertEquals(2, results.size());
-
- result = null;
- for (ContactStateStatistics stats : results) {
- if (stats.getCompanyName().equals(company2.getName())) {
- result = stats;
- break;
- }
- }
-
- assertEquals(2, result.getTotal());
- data = result.getData();
- assertEquals(1, data.get(ContactState.BOARDING_EXPECTED).intValue());
- assertEquals(1, data.get(ContactState.BOAT_UNAVAILABLE).intValue());
-
- // result for period 3/5/2009 to 3/10/2009 for BIS company
- begin = DateUtils.createDate(3, 5, 2009);
- Date end = DateUtils.createDate(31, 10, 2009);
- PeriodDates period = new PeriodDates(begin, end);
-
- results = service.getContactStateStatistics(company2, period);
- assertEquals(1, results.size());
-
- result = (ContactStateStatistics)CollectionUtils.get(results, 0);
-
- assertEquals(1, result.getTotal());
- data = result.getData();
- assertEquals(1, data.get(ContactState.BOARDING_EXPECTED).intValue());
- assertEquals(0, data.get(ContactState.BOAT_UNAVAILABLE).intValue());
- }
-
- /**
- * Test of getBoardingBoats method, of class ServiceSynthesisImpl.
- */
- @Test
- public void testGetContactDataInputDateReactivity() throws Exception {
- log.info("getContactDataInputDateReactivity");
- /** PREPARE DATA **/
- InputStream input = getClass().getResourceAsStream("/import/navires.csv");
- ServiceBoat serviceBoat = new ServiceBoatImpl();
- serviceBoat.importBoatCsv(input);
- List<Boat> boats = serviceBoat.getBoatsByImmatriculations("174258");
- Boat boat = boats.get(0);
-
- List<Boat> boats2 = serviceBoat.getBoatsByImmatriculations("177474");
- Boat boat2 = boats2.get(0);
-
- TopiaContext transaction = SuiviObsmerContext.getTopiaRootContext().beginTransaction();
-
- CompanyDAO companyDAO = SuiviObsmerModelDAOHelper.getCompanyDAO(transaction);
- Company company = companyDAO.create(Company.NAME, "TARTANPION");
- Company company2 = companyDAO.create(Company.NAME, "BIS");
-
- WaoUserDAO userDAO = SuiviObsmerModelDAOHelper.getWaoUserDAO(transaction);
- WaoUser user = userDAO.create(WaoUser.FIRST_NAME,"Jean", WaoUser.LAST_NAME, "Michmuche",
- WaoUser.COMPANY, company);
- company.addWaoUser(user);
- WaoUser user2 = userDAO.create(WaoUser.FIRST_NAME,"Bill", WaoUser.LAST_NAME, "Murray",
- WaoUser.COMPANY, company2);
- company2.addWaoUser(user2);
-
- transaction.commitTransaction();
-
- input = getClass().getResourceAsStream("/import/zonesPeche.csv");
- ServiceReferential serviceReferential = new ServiceReferentialImpl();
- serviceReferential.importFishingZoneCsv(input);
-
- input = getClass().getResourceAsStream("/import/echantillonnage.csv");
- ServiceSampling serviceSampling = new ServiceSamplingImpl();
- serviceSampling.importSamplingPlanCsv(input);
-
- SampleRowDAO rowDAO = SuiviObsmerModelDAOHelper.getSampleRowDAO(transaction);
- SampleRow row = rowDAO.findByCode("2010_0001");
- SampleRow row2 = rowDAO.findByCode("2009_0006");
-
- transaction.closeContext();
-
-
- ServiceContact serviceContact = new ServiceContactImpl();
- // First contact : OK
- Contact contact1 = new ContactImpl();
- contact1.setObserver(user);
- Date begin = DateUtils.createDate(3, 3, 2009);
- contact1.setTideBeginDate(begin);
- Date inputDate = DateUtils.createDate(15, 4, 2009);
- contact1.setDataInputDate(inputDate);
- serviceContact.saveContact(contact1, false);
-
- Contact contact2 = new ContactImpl();
- contact2.setObserver(user);
- begin = DateUtils.createDate(3, 3, 2009);
- contact2.setTideBeginDate(begin);
- inputDate = DateUtils.createDate(15, 3, 2009);
- contact2.setDataInputDate(inputDate);
- serviceContact.saveContact(contact2, false);
-
- Contact contact3 = new ContactImpl();
- contact3.setObserver(user2);
- begin = DateUtils.createDate(3, 3, 2009);
- contact3.setTideBeginDate(begin);
- contact3.setDataInputDate(begin);
- serviceContact.saveContact(contact3, false);
-
- /** EXEC METHOD **/
-
- PeriodDates period = new PeriodDates(begin, begin);
-
- // result for company TARTANPION
- Map<String, Double> results =
- service.getContactDataInputDateReactivity(company, period);
-
- assertEquals(1, results.size());
-
- // 12 days for contact1 + 43 days for contact2 / 2 = 27.5 days
- assertEquals(28, results.get(company.getName()), 0.01);
-
- // result for company BIS using admin mode (no company filtered)
- results = service.getContactDataInputDateReactivity(null, period);
-
- // 0 days for contact3 / 1 = O days
- assertEquals(0, results.get(company2.getName()), 0.01);
- }
-
-}
\ No newline at end of file
Copied: trunk/wao-business/src/test/java/fr/ifremer/wao/services/ServiceSynthesisImplTest.java (from rev 354, trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/services/ServiceSynthesisImplTest.java)
===================================================================
--- trunk/wao-business/src/test/java/fr/ifremer/wao/services/ServiceSynthesisImplTest.java (rev 0)
+++ trunk/wao-business/src/test/java/fr/ifremer/wao/services/ServiceSynthesisImplTest.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -0,0 +1,544 @@
+/*
+ * *##%
+ * 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.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.bean.BoardingResult;
+import fr.ifremer.wao.bean.ContactAverageReactivity;
+import fr.ifremer.wao.bean.ContactState;
+import fr.ifremer.wao.bean.ContactStateStatistics;
+import fr.ifremer.wao.entity.Boat;
+import fr.ifremer.wao.entity.Company;
+import fr.ifremer.wao.entity.CompanyDAO;
+import fr.ifremer.wao.entity.Contact;
+import fr.ifremer.wao.entity.ContactImpl;
+import fr.ifremer.wao.entity.SampleRow;
+import fr.ifremer.wao.entity.SampleRowDAO;
+import fr.ifremer.wao.entity.WaoUser;
+import fr.ifremer.wao.entity.WaoUserDAO;
+import java.io.InputStream;
+import java.util.Collection;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import org.apache.commons.collections.CollectionUtils;
+import org.junit.After;
+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;
+import org.nuiton.util.PeriodDates;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import static org.junit.Assert.*;
+
+/**
+ *
+ * @author fdesbois
+ */
+public class ServiceSynthesisImplTest {
+
+ private static WaoRunner runner;
+
+ private static final Logger log = LoggerFactory.getLogger(ServiceSynthesisImplTest.class);
+
+ private ServiceSynthesisImpl service;
+
+ public ServiceSynthesisImplTest() {
+ }
+
+ @BeforeClass
+ public static void setUpClass() throws Exception {
+ runner = new WaoRunnerTest();
+ }
+
+ @AfterClass
+ public static void tearDownClass() throws Exception {
+ }
+
+ @Before
+ public void setUp() throws Exception {
+ runner.start();
+ service = new ServiceSynthesisImpl();
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ runner.stop();
+ }
+
+ /**
+ * Test of getDataSampling method, of class ServiceSynthesisImpl.
+ */
+ //@Test
+ public void testGetDataSampling() throws Exception {
+ System.out.println("getDataSampling");
+ }
+
+ /**
+ * Test of getBoardingBoats method, of class ServiceSynthesisImpl.
+ */
+ @Test
+ public void testGetBoardingBoats() throws Exception {
+ log.info("getBoardingBoats");
+ /** PREPARE DATA **/
+ InputStream input = getClass().getResourceAsStream("/import/navires.csv");
+ ServiceBoat serviceBoat = new ServiceBoatImpl();
+ serviceBoat.importBoatCsv(input);
+ List<Boat> boats = serviceBoat.getBoatsByImmatriculations("174258");
+ Boat boat = boats.get(0);
+
+ List<Boat> boats2 = serviceBoat.getBoatsByImmatriculations("177474");
+ Boat boat2 = boats2.get(0);
+
+ TopiaContext transaction = WaoContext.getTopiaRootContext().beginTransaction();
+
+ CompanyDAO companyDAO = WaoModelDAOHelper.getCompanyDAO(transaction);
+ Company company = companyDAO.create(Company.NAME, "TARTANPION");
+ Company company2 = companyDAO.create(Company.NAME, "BIS");
+
+ WaoUserDAO userDAO = WaoModelDAOHelper.getWaoUserDAO(transaction);
+ WaoUser user = userDAO.create(WaoUser.FIRST_NAME,"Jean", WaoUser.LAST_NAME, "Michmuche",
+ WaoUser.COMPANY, company);
+ company.addWaoUser(user);
+ WaoUser user2 = userDAO.create(WaoUser.FIRST_NAME,"Bill", WaoUser.LAST_NAME, "Murray",
+ WaoUser.COMPANY, company2);
+ company2.addWaoUser(user2);
+
+ transaction.commitTransaction();
+
+ input = getClass().getResourceAsStream("/import/zonesPeche.csv");
+ ServiceReferential serviceReferential = new ServiceReferentialImpl();
+ serviceReferential.importFishingZoneCsv(input);
+
+ input = getClass().getResourceAsStream("/import/echantillonnage.csv");
+ ServiceSampling serviceSampling = new ServiceSamplingImpl();
+ serviceSampling.importSamplingPlanCsv(input);
+
+ SampleRowDAO rowDAO = WaoModelDAOHelper.getSampleRowDAO(transaction);
+ SampleRow row = rowDAO.findByCode("2010_0001");
+
+ transaction.closeContext();
+
+
+ ServiceContact serviceContact = new ServiceContactImpl();
+ // First contact : OK
+ Contact contact1 = new ContactImpl();
+ contact1.setBoat(boat);
+ contact1.setObserver(user);
+ contact1.setSampleRow(row);
+ contact1.setState(ContactState.BOARDING_DONE.toString());
+ Date begin = DateUtils.createDate(3, 3, 2009);
+ contact1.setTideBeginDate(begin);
+ contact1.setValidationCompany(Boolean.TRUE);
+ serviceContact.saveContact(contact1, false);
+
+ Contact contact2 = new ContactImpl();
+ contact2.setBoat(boat);
+ contact2.setObserver(user);
+ contact2.setSampleRow(row);
+ contact2.setState(ContactState.BOARDING_DONE.toString());
+ begin = DateUtils.createDate(3, 3, 2009);
+ contact2.setTideBeginDate(begin);
+ contact2.setValidationCompany(Boolean.TRUE);
+ serviceContact.saveContact(contact2, false);
+
+ Contact contact3 = new ContactImpl();
+ contact3.setBoat(boat2);
+ contact3.setObserver(user);
+ contact3.setSampleRow(row);
+ contact3.setState(ContactState.BOARDING_DONE.toString());
+ begin = DateUtils.createDate(3, 3, 2009);
+ contact3.setTideBeginDate(begin);
+ contact3.setValidationCompany(Boolean.TRUE);
+ serviceContact.saveContact(contact3, false);
+
+ /** EXEC METHOD **/
+ BoardingResult result = service.getBoardingBoats(null, null);
+ // one boat with one boarding (177474)
+ assertEquals(1, result.getData().get("1").intValue());
+ // one boat with two boardings (174258)
+ assertEquals(1, result.getData().get("2").intValue());
+ assertEquals(2, result.getMaxBoardingValue());
+ assertEquals(174258, result.getMaxBoardingBoat().getImmatriculation());
+ }
+
+ /**
+ * Test of getBoardingBoats method, of class ServiceSynthesisImpl.
+ */
+ @Test
+ public void testGetNonComplianceBoardingIndicator() throws Exception {
+ log.info("getNonComplianceBoardingIndicator");
+ /** PREPARE DATA **/
+ InputStream input = getClass().getResourceAsStream("/import/navires.csv");
+ ServiceBoat serviceBoat = new ServiceBoatImpl();
+ serviceBoat.importBoatCsv(input);
+ List<Boat> boats = serviceBoat.getBoatsByImmatriculations("174258");
+ Boat boat = boats.get(0);
+
+ List<Boat> boats2 = serviceBoat.getBoatsByImmatriculations("177474");
+ Boat boat2 = boats2.get(0);
+
+ TopiaContext transaction = WaoContext.getTopiaRootContext().beginTransaction();
+
+ CompanyDAO companyDAO = WaoModelDAOHelper.getCompanyDAO(transaction);
+ Company company = companyDAO.create(Company.NAME, "TARTANPION");
+ Company company2 = companyDAO.create(Company.NAME, "BIS");
+
+ WaoUserDAO userDAO = WaoModelDAOHelper.getWaoUserDAO(transaction);
+ WaoUser user = userDAO.create(WaoUser.FIRST_NAME,"Jean", WaoUser.LAST_NAME, "Michmuche",
+ WaoUser.COMPANY, company);
+ company.addWaoUser(user);
+ WaoUser user2 = userDAO.create(WaoUser.FIRST_NAME,"Bill", WaoUser.LAST_NAME, "Murray",
+ WaoUser.COMPANY, company2);
+ company2.addWaoUser(user2);
+
+ transaction.commitTransaction();
+
+ input = getClass().getResourceAsStream("/import/zonesPeche.csv");
+ ServiceReferential serviceReferential = new ServiceReferentialImpl();
+ serviceReferential.importFishingZoneCsv(input);
+
+ input = getClass().getResourceAsStream("/import/echantillonnage.csv");
+ ServiceSampling serviceSampling = new ServiceSamplingImpl();
+ serviceSampling.importSamplingPlanCsv(input);
+
+ SampleRowDAO rowDAO = WaoModelDAOHelper.getSampleRowDAO(transaction);
+ SampleRow row = rowDAO.findByCode("2010_0001");
+ SampleRow row2 = rowDAO.findByCode("2009_0006");
+
+ transaction.closeContext();
+
+
+ ServiceContact serviceContact = new ServiceContactImpl();
+ // First contact : OK
+ Contact contact1 = new ContactImpl();
+ contact1.setBoat(boat);
+ contact1.setObserver(user);
+ contact1.setSampleRow(row);
+ // 1 real observer over 1
+ contact1.setNbObservants(1);
+ contact1.setState(ContactState.BOARDING_DONE.toString());
+ Date begin = DateUtils.createDate(3, 3, 2009);
+ contact1.setTideBeginDate(begin);
+ contact1.setValidationCompany(Boolean.TRUE);
+ serviceContact.saveContact(contact1, false);
+
+ Contact contact2 = new ContactImpl();
+ contact2.setBoat(boat);
+ contact2.setObserver(user);
+ contact2.setSampleRow(row);
+ // 2 real observer over 1
+ contact2.setNbObservants(2);
+ contact2.setState(ContactState.BOARDING_DONE.toString());
+ begin = DateUtils.createDate(3, 3, 2009);
+ contact2.setTideBeginDate(begin);
+ contact2.setValidationCompany(Boolean.TRUE);
+ serviceContact.saveContact(contact2, false);
+
+ Contact contact3 = new ContactImpl();
+ contact3.setBoat(boat2);
+ contact3.setObserver(user2);
+ contact3.setSampleRow(row2);
+ // 1 real observer over 2
+ contact3.setNbObservants(1);
+ contact3.setState(ContactState.BOARDING_DONE.toString());
+ begin = DateUtils.createDate(3, 3, 2009);
+ contact3.setTideBeginDate(begin);
+ contact3.setValidationCompany(Boolean.TRUE);
+ serviceContact.saveContact(contact3, false);
+
+ /** EXEC METHOD **/
+
+ // result for company TARTANPION
+ Map<String, Double> results =
+ service.getNonComplianceBoardingIndicator(company);
+
+ assertEquals(1, results.size());
+
+ // 0% of non compliance
+ Double value = results.get(company.getName());
+ assertEquals(0., value, 0);
+
+ // result for company BIS using admin mode (no company filtered)
+ results = service.getNonComplianceBoardingIndicator(null);
+
+ assertEquals(2, results.size());
+
+ // 100% of non compliance
+ value = results.get(company2.getName());
+ assertEquals(1., value, 0);
+ }
+
+ /**
+ * Test of getBoardingBoats method, of class ServiceSynthesisImpl.
+ */
+ @Test
+ public void testGetContactStateStatistics() throws Exception {
+ log.info("getContactStateStatistics");
+ /** PREPARE DATA **/
+ InputStream input = getClass().getResourceAsStream("/import/navires.csv");
+ ServiceBoat serviceBoat = new ServiceBoatImpl();
+ serviceBoat.importBoatCsv(input);
+ List<Boat> boats = serviceBoat.getBoatsByImmatriculations("174258");
+ Boat boat = boats.get(0);
+
+ List<Boat> boats2 = serviceBoat.getBoatsByImmatriculations("177474");
+ Boat boat2 = boats2.get(0);
+
+ TopiaContext transaction = WaoContext.getTopiaRootContext().beginTransaction();
+
+ CompanyDAO companyDAO = WaoModelDAOHelper.getCompanyDAO(transaction);
+ Company company = companyDAO.create(Company.NAME, "TARTANPION");
+ Company company2 = companyDAO.create(Company.NAME, "BIS");
+
+ WaoUserDAO userDAO = WaoModelDAOHelper.getWaoUserDAO(transaction);
+ WaoUser user = userDAO.create(WaoUser.FIRST_NAME,"Jean", WaoUser.LAST_NAME, "Michmuche",
+ WaoUser.COMPANY, company);
+ company.addWaoUser(user);
+ WaoUser user2 = userDAO.create(WaoUser.FIRST_NAME,"Bill", WaoUser.LAST_NAME, "Murray",
+ WaoUser.COMPANY, company2);
+ company2.addWaoUser(user2);
+
+ transaction.commitTransaction();
+
+ input = getClass().getResourceAsStream("/import/zonesPeche.csv");
+ ServiceReferential serviceReferential = new ServiceReferentialImpl();
+ serviceReferential.importFishingZoneCsv(input);
+
+ input = getClass().getResourceAsStream("/import/echantillonnage.csv");
+ ServiceSampling serviceSampling = new ServiceSamplingImpl();
+ serviceSampling.importSamplingPlanCsv(input);
+
+ SampleRowDAO rowDAO = WaoModelDAOHelper.getSampleRowDAO(transaction);
+ SampleRow row = rowDAO.findByCode("2010_0001");
+
+ transaction.closeContext();
+
+
+ ServiceContact serviceContact = new ServiceContactImpl();
+
+ // Contacts for company TARTANPION
+ Contact contact1 = new ContactImpl();
+ contact1.setObserver(user);
+ contact1.setState(ContactState.BOARDING_DONE.toString());
+ Date begin = DateUtils.createDate(3, 3, 2009);
+ contact1.setTideBeginDate(begin);
+ serviceContact.saveContact(contact1, false);
+
+ Contact contact2 = new ContactImpl();
+ contact2.setObserver(user);
+ contact2.setState(ContactState.BOARDING_DONE.toString());
+ begin = DateUtils.createDate(3, 10, 2009);
+ contact2.setTideBeginDate(begin);
+ serviceContact.saveContact(contact2, false);
+
+ Contact contact3 = new ContactImpl();
+ contact3.setObserver(user);
+ contact3.setState(ContactState.BOAT_REFUSED.toString());
+ begin = DateUtils.createDate(3, 5, 2009);
+ contact3.setTopiaCreateDate(begin);
+ serviceContact.saveContact(contact3, false);
+
+ // Contacts for company BIS
+ Contact contact4 = new ContactImpl();
+ contact4.setObserver(user2);
+ contact4.setState(ContactState.BOARDING_EXPECTED.toString());
+ begin = DateUtils.createDate(3, 5, 2009);
+ contact4.setTopiaCreateDate(begin);
+ serviceContact.saveContact(contact4, false);
+
+ Contact contact5 = new ContactImpl();
+ contact5.setObserver(user2);
+ contact5.setState(ContactState.BOAT_UNAVAILABLE.toString());
+ begin = DateUtils.createDate(3, 3, 2010);
+ contact5.setTopiaCreateDate(begin);
+ serviceContact.saveContact(contact5, false);
+
+ // Contact refused by program, will not be in result
+ Contact contact6 = new ContactImpl();
+ contact6.setObserver(user2);
+ contact6.setState(ContactState.BOAT_UNAVAILABLE.toString());
+ begin = DateUtils.createDate(3, 3, 2010);
+ contact6.setTopiaCreateDate(begin);
+ contact6.setValidationProgram(Boolean.FALSE);
+ serviceContact.saveContact(contact6, false);
+
+ /** EXEC METHOD **/
+
+ // result for company TARTANPION with no period
+ Collection<ContactStateStatistics> results =
+ service.getContactStateStatistics(company, null);
+
+ assertEquals(1, results.size());
+ ContactStateStatistics result = (ContactStateStatistics)CollectionUtils.get(results, 0);
+ assertEquals(3, result.getTotal());
+ Map<ContactState, Integer> data = result.getData();
+ assertNotNull(data);
+
+ assertEquals(ContactState.values().length, data.size());
+ assertEquals(2, data.get(ContactState.BOARDING_DONE).intValue());
+ assertEquals(1, data.get(ContactState.BOAT_REFUSED).intValue());
+
+ // result for company BIS using admin mode
+ results = service.getContactStateStatistics(null, null);
+ assertEquals(2, results.size());
+
+ result = null;
+ for (ContactStateStatistics stats : results) {
+ if (stats.getCompanyName().equals(company2.getName())) {
+ result = stats;
+ break;
+ }
+ }
+
+ assertEquals(2, result.getTotal());
+ data = result.getData();
+ assertEquals(1, data.get(ContactState.BOARDING_EXPECTED).intValue());
+ assertEquals(1, data.get(ContactState.BOAT_UNAVAILABLE).intValue());
+
+ // result for period 3/5/2009 to 3/10/2009 for BIS company
+ begin = DateUtils.createDate(3, 5, 2009);
+ Date end = DateUtils.createDate(31, 10, 2009);
+ PeriodDates period = new PeriodDates(begin, end);
+
+ results = service.getContactStateStatistics(company2, period);
+ assertEquals(1, results.size());
+
+ result = (ContactStateStatistics)CollectionUtils.get(results, 0);
+
+ assertEquals(1, result.getTotal());
+ data = result.getData();
+ assertEquals(1, data.get(ContactState.BOARDING_EXPECTED).intValue());
+ assertEquals(0, data.get(ContactState.BOAT_UNAVAILABLE).intValue());
+ }
+
+ /**
+ * Test of getBoardingBoats method, of class ServiceSynthesisImpl.
+ */
+ @Test
+ public void testGetContactDataInputDateReactivity() throws Exception {
+ log.info("getContactDataInputDateReactivity");
+ /** PREPARE DATA **/
+ InputStream input = getClass().getResourceAsStream("/import/navires.csv");
+ ServiceBoat serviceBoat = new ServiceBoatImpl();
+ serviceBoat.importBoatCsv(input);
+ List<Boat> boats = serviceBoat.getBoatsByImmatriculations("174258");
+ Boat boat = boats.get(0);
+
+ List<Boat> boats2 = serviceBoat.getBoatsByImmatriculations("177474");
+ Boat boat2 = boats2.get(0);
+
+ TopiaContext transaction = WaoContext.getTopiaRootContext().beginTransaction();
+
+ CompanyDAO companyDAO = WaoModelDAOHelper.getCompanyDAO(transaction);
+ Company company = companyDAO.create(Company.NAME, "TARTANPION");
+ Company company2 = companyDAO.create(Company.NAME, "BIS");
+
+ WaoUserDAO userDAO = WaoModelDAOHelper.getWaoUserDAO(transaction);
+ WaoUser user = userDAO.create(WaoUser.FIRST_NAME,"Jean", WaoUser.LAST_NAME, "Michmuche",
+ WaoUser.COMPANY, company);
+ company.addWaoUser(user);
+ WaoUser user2 = userDAO.create(WaoUser.FIRST_NAME,"Bill", WaoUser.LAST_NAME, "Murray",
+ WaoUser.COMPANY, company2);
+ company2.addWaoUser(user2);
+
+ transaction.commitTransaction();
+
+ input = getClass().getResourceAsStream("/import/zonesPeche.csv");
+ ServiceReferential serviceReferential = new ServiceReferentialImpl();
+ serviceReferential.importFishingZoneCsv(input);
+
+ input = getClass().getResourceAsStream("/import/echantillonnage.csv");
+ ServiceSampling serviceSampling = new ServiceSamplingImpl();
+ serviceSampling.importSamplingPlanCsv(input);
+
+ SampleRowDAO rowDAO = WaoModelDAOHelper.getSampleRowDAO(transaction);
+ SampleRow row = rowDAO.findByCode("2010_0001");
+ SampleRow row2 = rowDAO.findByCode("2009_0006");
+
+ transaction.closeContext();
+
+
+ ServiceContact serviceContact = new ServiceContactImpl();
+ // First contact : OK
+ Contact contact1 = new ContactImpl();
+ contact1.setObserver(user);
+ Date begin = DateUtils.createDate(3, 3, 2009);
+ contact1.setTideBeginDate(begin);
+ Date inputDate = DateUtils.createDate(15, 4, 2009);
+ contact1.setDataInputDate(inputDate);
+ contact1.setState(ContactState.BOARDING_DONE.toString());
+ contact1.setValidationCompany(Boolean.TRUE);
+ serviceContact.saveContact(contact1, false);
+
+ Contact contact2 = new ContactImpl();
+ contact2.setObserver(user);
+ begin = DateUtils.createDate(3, 3, 2009);
+ contact2.setTideBeginDate(begin);
+ inputDate = DateUtils.createDate(15, 3, 2009);
+ contact2.setDataInputDate(inputDate);
+ contact2.setState(ContactState.BOARDING_DONE.toString());
+ contact2.setValidationCompany(Boolean.TRUE);
+ serviceContact.saveContact(contact2, false);
+
+ Contact contact3 = new ContactImpl();
+ contact3.setObserver(user2);
+ begin = DateUtils.createDate(3, 3, 2009);
+ contact3.setTideBeginDate(begin);
+ contact3.setDataInputDate(begin);
+ contact3.setState(ContactState.BOARDING_DONE.toString());
+ contact3.setValidationCompany(Boolean.TRUE);
+ serviceContact.saveContact(contact3, false);
+
+ /** EXEC METHOD **/
+
+ PeriodDates period = new PeriodDates(begin, begin);
+
+ // result for company TARTANPION
+ Collection<ContactAverageReactivity> results =
+ service.getContactDataInputDateReactivity(company, period);
+
+ assertEquals(1, results.size());
+
+ // 12 days for contact1 + 43 days for contact2 / 2 = 27.5 days
+ ContactAverageReactivity res =
+ (ContactAverageReactivity)CollectionUtils.get(results, 0);
+
+ assertEquals(27., res.getResult(), 0.01);
+
+ // result for company BIS using admin mode (no company filtered)
+ results = service.getContactDataInputDateReactivity(null, period);
+
+ // 0 days for contact3 / 1 = O days
+ res = (ContactAverageReactivity)CollectionUtils.get(results, 0);
+
+ assertEquals(0, res.getResult(), 0.01);
+ }
+
+}
\ No newline at end of file
Deleted: trunk/wao-business/src/test/resources/TopiaContextSuiviObsmer.properties
===================================================================
--- trunk/suiviobsmer-business/src/test/resources/TopiaContextSuiviObsmer.properties 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-business/src/test/resources/TopiaContextSuiviObsmer.properties 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,12 +0,0 @@
-# Propri\u00C3\u00A9t\u00C3\u00A9s par d\u00C3\u00A9faut pour une base de donn\u00C3\u00A9es de type H2
-hibernate.hbm2ddl.auto=update
-hibernate.show_sql=false
-
-hibernate.dialect=org.hibernate.dialect.H2Dialect
-hibernate.connection.username=sa
-hibernate.connection.password=
-hibernate.connection.driver_class=org.h2.Driver
-hibernate.connection.url=jdbc:h2:file:target/db/h2data
-
-suiviobsmer.log.activityCalendar.import=target/log/activity.log
-suiviobsmer.log.activityCalendar.access=target/log/activity-access.log
\ No newline at end of file
Copied: trunk/wao-business/src/test/resources/WaoTest.properties (from rev 354, trunk/suiviobsmer-business/src/test/resources/WaoTest.properties)
===================================================================
--- trunk/wao-business/src/test/resources/WaoTest.properties (rev 0)
+++ trunk/wao-business/src/test/resources/WaoTest.properties 2010-02-16 13:56:07 UTC (rev 355)
@@ -0,0 +1,11 @@
+hibernate.hbm2ddl.auto=update
+hibernate.show_sql=false
+
+hibernate.dialect=org.hibernate.dialect.H2Dialect
+hibernate.connection.username=sa
+hibernate.connection.password=
+hibernate.connection.driver_class=org.h2.Driver
+hibernate.connection.url=jdbc:h2:file:target/db/h2data
+
+wao.log.activityCalendar.import=target/log/activity.log
+wao.log.activityCalendar.access=target/log/activity-access.log
\ No newline at end of file
Modified: trunk/wao-business/src/test/resources/log4j.properties
===================================================================
--- trunk/suiviobsmer-business/src/test/resources/log4j.properties 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-business/src/test/resources/log4j.properties 2010-02-16 13:56:07 UTC (rev 355)
@@ -8,5 +8,5 @@
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
log4j.appender.A1.layout.ConversionPattern=%d [%p] %c{2} %m%n
-log4j.logger.fr.ifremer.suiviobsmer=INFO
+log4j.logger.fr.ifremer.wao=INFO
log4j.logger.org.nuiton.util=INFO
Property changes on: trunk/wao-ui
___________________________________________________________________
Added: svn:ignore
+ target
*.iml
*.ipr
*.iws
Added: svn:mergeinfo
+
Deleted: trunk/wao-ui/pom.xml
===================================================================
--- trunk/suiviobsmer-ui/pom.xml 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-ui/pom.xml 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,141 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-
- <modelVersion>4.0.0</modelVersion>
-
- <!-- ************************************************************* -->
- <!-- *** POM Relationships *************************************** -->
- <!-- ************************************************************* -->
-
- <parent>
- <groupId>fr.ifremer</groupId>
- <artifactId>suiviobsmer</artifactId>
- <version>1.0.0-SNAPSHOT</version>
- </parent>
-
- <groupId>fr.ifremer.suiviobsmer</groupId>
- <artifactId>suiviobsmer-ui</artifactId>
-
-
- <dependencies>
- <dependency>
- <groupId>fr.ifremer.suiviobsmer</groupId>
- <artifactId>suiviobsmer-business</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>commons-lang</groupId>
- <artifactId>commons-lang</artifactId>
- </dependency>
- <dependency>
- <groupId>org.nuiton</groupId>
- <artifactId>nuiton-utils</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.tapestry</groupId>
- <artifactId>tapestry-core</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.tapestry</groupId>
- <artifactId>tapestry-upload</artifactId>
- </dependency>
- <dependency>
- <groupId>org.chenillekit</groupId>
- <artifactId>chenillekit-tapestry</artifactId>
- </dependency>
- <dependency>
- <groupId>com.orientimport</groupId>
- <artifactId>t5-easy-fckeditor</artifactId>
- </dependency>
- <dependency>
- <groupId>jfree</groupId>
- <artifactId>jfreechart</artifactId>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-log4j12</artifactId>
- </dependency>
- <dependency>
- <groupId>org.jvnet.hudson.winstone</groupId>
- <artifactId>winstone</artifactId>
- <scope>provided</scope>
- </dependency>
- </dependencies>
-
-
- <!-- ************************************************************* -->
- <!-- *** Project Information ************************************* -->
- <!-- ************************************************************* -->
-
- <name>SuiviObsmer :: Web Interface</name>
- <description>Interface utilisateur du SuiviObsmer</description>
-
- <!-- ************************************************************* -->
- <!-- *** Build Settings ****************************************** -->
- <!-- ************************************************************* -->
-
- <packaging>war</packaging>
-
- <!-- ************************************************************* -->
- <!-- *** Build Environment ************************************** -->
- <!-- ************************************************************* -->
- <build>
- <!-- call result war : suiviobsmer-xxx.war -->
- <finalName>wao-${project.version}</finalName>
-
- <!-- Add main class into war to make it executable -->
- <plugins>
- <plugin>
- <artifactId>maven-war-plugin</artifactId>
- <configuration>
- <archive>
- <manifest>
- <mainClass>org.nuiton.util.war.WinstoneLauncher</mainClass>
- </manifest>
- </archive>
- <overlays>
- <overlay>
- <groupId>org.nuiton</groupId>
- <artifactId>nuiton-utils</artifactId>
- <type>jar</type>
- <includes>
- <include>**/war/Winstone*</include>
- </includes>
- </overlay>
- <overlay>
- <groupId>org.jvnet.hudson.winstone</groupId>
- <artifactId>winstone</artifactId>
- <type>jar</type>
- </overlay>
- </overlays>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
- <repositories>
-
- <repository>
- <id>m2-release-repository.orientimport.kenai.com</id>
- <name>Orient Import Oy Maven Release Repository</name>
- <url>http://kenai.com/svn/t5-easy-fckeditor~maven-release-repository</url>
- <layout>default</layout>
- </repository>
-
- </repositories>
-
- <scm>
- <url>http://labs.libre-entreprise.org/scm/viewvc.php/trunk/suiviobsmer-ui/?root=…</url>
- <connection>scm:svn:svn://anonymous at labs.libre-entreprise.org/svnroot/suiviobsmer/trunk/suiviobsmer-ui</connection>
- <developerConnection>scm:svn:svn+ssh://fdesbois at labs.libre-entreprise.org/svnroot/suiviobsmer/trunk/suiviobsmer-ui</developerConnection>
- </scm>
-
-</project>
Copied: trunk/wao-ui/pom.xml (from rev 354, trunk/suiviobsmer-ui/pom.xml)
===================================================================
--- trunk/wao-ui/pom.xml (rev 0)
+++ trunk/wao-ui/pom.xml 2010-02-16 13:56:07 UTC (rev 355)
@@ -0,0 +1,149 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <!-- ************************************************************* -->
+ <!-- *** POM Relationships *************************************** -->
+ <!-- ************************************************************* -->
+
+ <parent>
+ <groupId>fr.ifremer</groupId>
+ <artifactId>wao</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </parent>
+
+ <groupId>fr.ifremer.wao</groupId>
+ <artifactId>wao-ui</artifactId>
+
+
+ <dependencies>
+ <!-- Wao business : services and entities -->
+ <dependency>
+ <groupId>fr.ifremer.wao</groupId>
+ <artifactId>wao-business</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-lang</groupId>
+ <artifactId>commons-lang</artifactId>
+ </dependency>
+ <!-- Utils -->
+ <dependency>
+ <groupId>org.nuiton</groupId>
+ <artifactId>nuiton-utils</artifactId>
+ </dependency>
+ <!-- Tapestry framework + components -->
+ <dependency>
+ <groupId>org.apache.tapestry</groupId>
+ <artifactId>tapestry-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tapestry</groupId>
+ <artifactId>tapestry-upload</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.chenillekit</groupId>
+ <artifactId>chenillekit-tapestry</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.orientimport</groupId>
+ <artifactId>t5-easy-fckeditor</artifactId>
+ </dependency>
+ <!-- Graph library for synthesis -->
+ <dependency>
+ <groupId>jfree</groupId>
+ <artifactId>jfreechart</artifactId>
+ </dependency>
+ <!-- Tests -->
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </dependency>
+ <!-- Logging -->
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ </dependency>
+ <!-- Embedded war lib for Nuiton-utils WarLauncher -->
+ <dependency>
+ <groupId>org.jvnet.hudson.winstone</groupId>
+ <artifactId>winstone</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+
+
+ <!-- ************************************************************* -->
+ <!-- *** Project Information ************************************* -->
+ <!-- ************************************************************* -->
+
+ <name>Wao :: Web Interface</name>
+ <description>Interface utilisateur du Wao</description>
+
+ <!-- ************************************************************* -->
+ <!-- *** Build Settings ****************************************** -->
+ <!-- ************************************************************* -->
+
+ <packaging>war</packaging>
+
+ <!-- ************************************************************* -->
+ <!-- *** Build Environment ************************************** -->
+ <!-- ************************************************************* -->
+ <build>
+ <!-- call result war : suiviobsmer-xxx.war -->
+ <!--<finalName>wao-${project.version}</finalName>-->
+
+ <!-- Add main class into war to make it executable -->
+ <plugins>
+ <plugin>
+ <artifactId>maven-war-plugin</artifactId>
+ <configuration>
+ <archive>
+ <manifest>
+ <mainClass>org.nuiton.util.war.WinstoneLauncher</mainClass>
+ </manifest>
+ </archive>
+ <overlays>
+ <overlay>
+ <groupId>org.nuiton</groupId>
+ <artifactId>nuiton-utils</artifactId>
+ <type>jar</type>
+ <includes>
+ <include>**/war/Winstone*</include>
+ </includes>
+ </overlay>
+ <overlay>
+ <groupId>org.jvnet.hudson.winstone</groupId>
+ <artifactId>winstone</artifactId>
+ <type>jar</type>
+ </overlay>
+ </overlays>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <repositories>
+
+ <!-- Repository for fckeditor component needed for News page -->
+ <repository>
+ <id>m2-release-repository.orientimport.kenai.com</id>
+ <name>Orient Import Oy Maven Release Repository</name>
+ <url>http://kenai.com/svn/t5-easy-fckeditor~maven-release-repository</url>
+ <layout>default</layout>
+ </repository>
+
+ </repositories>
+
+ <scm>
+ <url>http://labs.libre-entreprise.org/scm/viewvc.php/trunk/suiviobsmer-ui/?root=…</url>
+ <connection>scm:svn:svn://anonymous at labs.libre-entreprise.org/svnroot/suiviobsmer/trunk/suiviobsmer-ui</connection>
+ <developerConnection>scm:svn:svn+ssh://fdesbois at labs.libre-entreprise.org/svnroot/suiviobsmer/trunk/suiviobsmer-ui</developerConnection>
+ </scm>
+
+</project>
Property changes on: trunk/wao-ui/src/main/java/fr/ifremer/wao
___________________________________________________________________
Added: svn:mergeinfo
+
Deleted: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/base/AbstractFilteredPage.java
===================================================================
--- trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/base/AbstractFilteredPage.java 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/base/AbstractFilteredPage.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,471 +0,0 @@
-/*
- * *##%
- * SuiviObsmer :: Web Interface
- * 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.suiviobsmer.ui.base;
-
-import fr.ifremer.suiviobsmer.SuiviObsmerException;
-import fr.ifremer.suiviobsmer.bean.BoatFilter;
-import fr.ifremer.suiviobsmer.entity.Company;
-import fr.ifremer.suiviobsmer.entity.SampleRow;
-import fr.ifremer.suiviobsmer.entity.WaoUser;
-import fr.ifremer.suiviobsmer.services.ServiceBoat;
-import fr.ifremer.suiviobsmer.services.ServiceReferential;
-import fr.ifremer.suiviobsmer.services.ServiceSampling;
-import fr.ifremer.suiviobsmer.services.ServiceUser;
-import java.util.ArrayList;
-import java.util.List;
-import org.apache.tapestry5.OptionModel;
-import org.apache.tapestry5.SelectModel;
-import org.apache.tapestry5.annotations.Persist;
-import org.apache.tapestry5.annotations.Property;
-import org.apache.tapestry5.annotations.SessionState;
-import org.apache.tapestry5.internal.OptionModelImpl;
-import org.apache.tapestry5.internal.SelectModelImpl;
-import org.apache.tapestry5.ioc.annotations.Inject;
-import org.apache.tapestry5.ioc.services.PropertyAccess;
-import org.slf4j.Logger;
-
-/**
- * AbstractFilteredPage
- *
- * Created: 14 janv. 2010
- *
- * This class uses the BoatFilter bean (also SamplingFilter and UserFilter which
- * are supertypes).
- *
- * Known implementations are {@link fr.ifremer.suiviobsmer.ui.pages.Synthesis }
- * and {@link fr.ifremer.suiviobsmer.ui.pages.Contacts }
- *
- * You must override the three abstract methods and call {@link #initFilter() }
- * in the setupRender of the page.
- * <pre>
- * - BoatName uses an Autocomplete mixins :
- * <t:textfield t:id="boatName" t:value="filter.boatName" t:mixins="Autocomplete"/>
- * - SampleRow select value is sampleRowId :
- * <input t:type="select" t:id="sampleRow" t:model="sampleRowSelectModel" value="sampleRowId" />
- * - Company select value is companyId :
- * <input t:type="select" t:id="company" t:model="companySelectModel" value="companyId" />
- * - Observer select value is observerId :
- * <input t:type="select" t:id="observer" t:model="observerSelectModel" value="observerId" />
- *
- * Use submit button with specific ids to refresh data depends on select change:
- * - id="refreshByCompany" : refresh facadeSelect, sectorSelect, sampleRowSelect
- * and observerSelect
- * - id="refreshByFacade" : refresh sectorSelect and sampleRowSelect
- * - id="refreshBySector" : refresh sampleRowSelect
- *
- * </pre>
- *
- * @author fdesbois
- * @version $Revision$
- *
- * Mise a jour: $Date$
- * par : $Author$
- */
-public abstract class AbstractFilteredPage {
-
- @Inject
- private Logger log;
-
- @SessionState
- private WaoUser user;
-
- @Inject
- private PropertyAccess propertyAccess;
-
- @Inject
- private ServiceReferential serviceReferential;
-
- @Inject
- private ServiceSampling serviceSampling;
-
- @Inject
- private ServiceBoat serviceBoat;
-
- @Inject
- private ServiceUser serviceUser;
-
- @Persist
- private GenericSelectModel<SampleRow> sampleRowSelectModel;
-
- @Property
- private String sampleRowId;
-
- @Persist
- private SelectModel facadeSelectModel;
-
- @Persist
- private SelectModel sectorSelectModel;
-
- @Persist
- private GenericSelectModel<Company> companySelectModel;
-
- @Property
- private String companyId;
-
- @Persist
- private GenericSelectModel<WaoUser> observerSelectModel;
-
- @Property
- private String observerId;
-
- @Persist
- private SelectModel programSelectModel;
-
- @Persist
- private boolean observerSelect;
-
- @Persist
- private boolean programSelect;
- /**
- * Initialize all select for filters. By default, only facade, sector and
- * sampleRow selects will be initialized.
- *
- * @param companySelect if true, company select will be initialized
- * @param observerSelect if true, observer select will be initialized
- * @throws SuiviObsmerException
- */
- protected void initSelectFilters(boolean companySelect, boolean observerSelect, boolean programSelect) throws SuiviObsmerException {
- this.observerSelect = observerSelect;
- this.programSelect = programSelect;
-
- if (getFilter().getSampleRow() != null) {
- if (log.isDebugEnabled()) {
- log.debug("SampleRow filtered : " + getFilter().getSampleRow());
- }
- sampleRowId = getFilter().getSampleRow().getTopiaId();
- }
-
- if (user.getAdmin() && companySelect) {
- resetCompanySelect();
- if (getFilter().getCompany() != null) {
- companyId = getFilter().getCompany().getTopiaId();
- }
- } else if (!user.getAdmin()) {
- if (log.isDebugEnabled()) {
- log.debug("Company filtered : " + user.getCompany());
- }
- getFilter().setCompany(user.getCompany());
- }
-
- if (observerSelect) {
- observerSelectModel = null;
- getObserverSelectModel();
-
- if (getFilter().getObserver() != null) {
- observerId = getFilter().getObserver().getTopiaId();
- }
- }
-
- if (programSelect) {
- programSelectModel = null;
- getProgramSelectModel();
- }
-
- resetFacadeSelect();
- resetSectorSelect();
- resetSampleRowSelect();
- }
-
- protected void resetCompanySelect() throws SuiviObsmerException {
- companySelectModel = null;
- getCompanySelectModel();
- }
-
- protected void resetFacadeSelect() throws SuiviObsmerException {
- facadeSelectModel = null;
- getFacadeSelectModel();
- }
-
- protected void resetSectorSelect() throws SuiviObsmerException {
- sectorSelectModel = null;
- getSectorSelectModel();
- }
-
- protected void resetSampleRowSelect() throws SuiviObsmerException {
- sampleRowSelectModel = null;
- getSampleRowSelectModel();
- }
-
- /**
- * Get select model for fishingZone facade. Depends on company set in
- * filter.
- *
- * @return the SelectModel for facade names
- * @throws SuiviObsmerException
- */
- public SelectModel getFacadeSelectModel() throws SuiviObsmerException {
- 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));
- }
- facadeSelectModel = new SelectModelImpl(null, options);
- }
- return facadeSelectModel;
- }
-
- /**
- * Get select model for fishingZone sector. Depends on facadeName and
- * company set in filter.
- *
- * @return the SelectModel for sector names
- * @throws SuiviObsmerException
- */
- public SelectModel getSectorSelectModel() throws SuiviObsmerException {
- 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));
- }
- sectorSelectModel = new SelectModelImpl(null, options);
- }
- return sectorSelectModel;
- }
-
- /**
- * Get select model for sampleRows. Depends on filter (Sampling part only).
- * The sampleRow set from filter is temporarly extracted to avoid returning
- * only one element in the select.
- *
- * @return the GenericSelectModel<SampleRow> for sampleRows
- * @throws SuiviObsmerException
- */
- public GenericSelectModel<SampleRow> getSampleRowSelectModel() throws SuiviObsmerException {
- if (sampleRowSelectModel == null) {
- if (log.isInfoEnabled()) {
- log.info("BUSINESS REQUEST [getSampleRowsByFilter]");
- }
-
- // WARN : no use of sampleRow filter
- SampleRow rowFiltered = getFilter().getSampleRow();
- getFilter().setSampleRow(null);
- List<SampleRow> sampleRows = serviceSampling.getSampleRowsByFilter(getFilter());
- getFilter().setSampleRow(rowFiltered);
-
- sampleRowSelectModel = new GenericSelectModel<SampleRow>(sampleRows, SampleRow.class,
- "code", "topiaId", propertyAccess);
- }
- return sampleRowSelectModel;
- }
-
- /**
- * Get select model for companies. Depends on
- * {@link #getAvailableDataForFiltersOnly() } to return only activated
- * companies. This select model is only used by admin users.
- *
- * @return the GenericSelectModel<Company> for companies
- * @throws SuiviObsmerException
- */
- public GenericSelectModel<Company> getCompanySelectModel() throws SuiviObsmerException {
- 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);
- }
- return companySelectModel;
- }
-
- /**
- * Get the select model for observers. Depends on
- * {@link #getAvailableDataForFiltersOnly() } to return only activated
- * companies.
- *
- * @return the GenericSelectModel<WaoUser> for observers
- * @throws SuiviObsmerException
- */
- public GenericSelectModel<WaoUser> getObserverSelectModel() throws SuiviObsmerException {
- if (observerSelectModel == null) {
- List<WaoUser> observers = new ArrayList<WaoUser>();
- if (getFilter().getCompany() != null) {
- observers = getFilter().getCompany().getWaoUser();
- } else if (user.getAdmin()) {
- if (log.isInfoEnabled()) {
- log.info("BUSINESS REQUEST [getObservers]");
- }
- observers = serviceUser.getObservers(isAvailableDataForFiltersOnly());
- }
- observerSelectModel = new GenericSelectModel<WaoUser>(observers,WaoUser.class,
- "fullName","topiaId",propertyAccess);
- }
- return observerSelectModel;
- }
-
- /**
- * Get select model for sampleRow program. Depends on company set in
- * filter.
- *
- * @return the SelectModel for program names
- * @throws SuiviObsmerException
- */
- public SelectModel getProgramSelectModel() throws SuiviObsmerException {
- 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));
- }
- programSelectModel = new SelectModelImpl(null, options);
- }
- return programSelectModel;
- }
-
- protected abstract BoatFilter getFilter() throws SuiviObsmerException;
-
- /**
- * Used to show only active company and observers.
- *
- * @return true if only active users will be showed, false otherwise
- */
- protected abstract boolean isAvailableDataForFiltersOnly();
-
- public String[] onProvideCompletionsFromBoatName(String input) throws SuiviObsmerException {
- if (log.isInfoEnabled()) {
- log.info("BUSINESS REQUEST [getBoatNamesStartWith]");
- }
- List<String> results = serviceBoat.getBoatNamesStartWith(input);
- return results.toArray(new String[0]);
- }
-
- /**
- * Called when search submit button is pressed. This method is useful to
- * refresh all filters data from selects.
- *
- * @throws SuiviObsmerException
- */
- public void onSelectedFromSearch() throws SuiviObsmerException {
- if (log.isDebugEnabled()) {
- log.debug("REFRESH FILTERS DATA");
- }
- SampleRow row = getSampleRowSelectModel().findObject(sampleRowId);
- getFilter().setSampleRow(row);
- if (user.getAdmin()) {
- Company company = getCompanySelectModel().findObject(companyId);
- getFilter().setCompany(company);
- } else {
- getFilter().setCompany(user.getCompany());
- }
-
- if (observerSelect) {
- WaoUser observer = getObserverSelectModel().findObject(observerId);
- getFilter().setObserver(observer);
- }
- }
-
- private boolean edited;
-
- /**
- * EVENT :: selected on refreshByCompany submit button. Reset selects for
- * company selected : programs, facades, sectors, sampleRows and observers.
- * This method set the state to edited, you can use
- * {@link AbstractFilteredPage#isEdited() } method to test it.
- *
- * @throws SuiviObsmerException
- * @see AbstractFilteredPage#onSelectedFromRefreshByProgram()
- */
- public void onSelectedFromRefreshByCompany() throws SuiviObsmerException {
- // Reset programs (the behavior is needed even if programSelect is false)
- getFilter().setProgramName(null);
- onSelectedFromRefreshByProgram();
- if (observerSelect) {
- // Reset observers
- getFilter().setObserver(null);
- observerSelectModel = null;
- getObserverSelectModel();
- }
- if (programSelect) {
- programSelectModel = null;
- getProgramSelectModel();
- }
- edited = true;
- }
-
- /**
- * EVENT :: selected on refreshByProgram submit button. Reset selects for
- * program selected : facades, sectors and sampleRows.
- * This method set the state to edited, you can use
- * {@link AbstractFilteredPage#isEdited() } method to test it.
- *
- * @throws SuiviObsmerException
- * @see AbstractFilteredPage#onSelectedFromRefreshByFacade()
- */
- public void onSelectedFromRefreshByProgram() throws SuiviObsmerException {
- // Reset facades
- getFilter().setFacadeName(null);
- onSelectedFromRefreshByFacade();
- resetFacadeSelect();
- }
-
- /**
- * EVENT :: selected on refreshByFacade submit button. Reset selects for
- * facade selected : sectors and sampleRows.
- * This method set the state to edited, you can use
- * {@link AbstractFilteredPage#isEdited() } method to test it.
- *
- * @throws SuiviObsmerException
- * @see AbstractFilteredPage#onSelectedFromRefreshBySector()
- */
- public void onSelectedFromRefreshByFacade() throws SuiviObsmerException {
- // Reset sectors
- getFilter().setSectorName(null);
- onSelectedFromRefreshBySector();
- resetSectorSelect();
- }
-
- /**
- * EVENT :: selected on refreshBySector submit button. After refreshing
- * data selected, reset selects for sector selected : sampleRows.
- * This method set the state to edited, you can use
- * {@link AbstractFilteredPage#isEdited() } method to test it.
- *
- * @throws SuiviObsmerException
- * @see AbstractFilteredPage#onSelectedFromSearch()
- */
- public void onSelectedFromRefreshBySector() throws SuiviObsmerException {
- // Update selected data
- onSelectedFromSearch();
- // Reset sampleRows;
- getFilter().setSampleRow(null);
- resetSampleRowSelect();
- edited = true;
- }
-
- /**
- * Used to indicate that a refresh as been triggered.
- *
- * @return true if the page filter is in edited state.
- */
- protected boolean isEdited() {
- return edited;
- }
-
-}
Copied: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/base/AbstractFilteredPage.java (from rev 354, trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/base/AbstractFilteredPage.java)
===================================================================
--- trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/base/AbstractFilteredPage.java (rev 0)
+++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/base/AbstractFilteredPage.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -0,0 +1,471 @@
+/*
+ * *##%
+ * Wao :: Web Interface
+ * 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.ui.base;
+
+import fr.ifremer.wao.WaoException;
+import fr.ifremer.wao.bean.BoatFilter;
+import fr.ifremer.wao.entity.Company;
+import fr.ifremer.wao.entity.SampleRow;
+import fr.ifremer.wao.entity.WaoUser;
+import fr.ifremer.wao.service.ServiceBoat;
+import fr.ifremer.wao.service.ServiceReferential;
+import fr.ifremer.wao.service.ServiceSampling;
+import fr.ifremer.wao.service.ServiceUser;
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.tapestry5.OptionModel;
+import org.apache.tapestry5.SelectModel;
+import org.apache.tapestry5.annotations.Persist;
+import org.apache.tapestry5.annotations.Property;
+import org.apache.tapestry5.annotations.SessionState;
+import org.apache.tapestry5.internal.OptionModelImpl;
+import org.apache.tapestry5.internal.SelectModelImpl;
+import org.apache.tapestry5.ioc.annotations.Inject;
+import org.apache.tapestry5.ioc.services.PropertyAccess;
+import org.slf4j.Logger;
+
+/**
+ * AbstractFilteredPage
+ *
+ * Created: 14 janv. 2010
+ *
+ * This class uses the BoatFilter bean (also SamplingFilter and UserFilter which
+ * are supertypes).
+ *
+ * Known implementations are {@link fr.ifremer.wao.ui.pages.Synthesis }
+ * and {@link fr.ifremer.wao.ui.pages.Contacts }
+ *
+ * You must override the three abstract methods and call {@link #initFilter() }
+ * in the setupRender of the page.
+ * <pre>
+ * - BoatName uses an Autocomplete mixins :
+ * <t:textfield t:id="boatName" t:value="filter.boatName" t:mixins="Autocomplete"/>
+ * - SampleRow select value is sampleRowId :
+ * <input t:type="select" t:id="sampleRow" t:model="sampleRowSelectModel" value="sampleRowId" />
+ * - Company select value is companyId :
+ * <input t:type="select" t:id="company" t:model="companySelectModel" value="companyId" />
+ * - Observer select value is observerId :
+ * <input t:type="select" t:id="observer" t:model="observerSelectModel" value="observerId" />
+ *
+ * Use submit button with specific ids to refresh data depends on select change:
+ * - id="refreshByCompany" : refresh facadeSelect, sectorSelect, sampleRowSelect
+ * and observerSelect
+ * - id="refreshByFacade" : refresh sectorSelect and sampleRowSelect
+ * - id="refreshBySector" : refresh sampleRowSelect
+ *
+ * </pre>
+ *
+ * @author fdesbois
+ * @version $Revision$
+ *
+ * Mise a jour: $Date$
+ * par : $Author$
+ */
+public abstract class AbstractFilteredPage {
+
+ @Inject
+ private Logger log;
+
+ @SessionState
+ private WaoUser user;
+
+ @Inject
+ private PropertyAccess propertyAccess;
+
+ @Inject
+ private ServiceReferential serviceReferential;
+
+ @Inject
+ private ServiceSampling serviceSampling;
+
+ @Inject
+ private ServiceBoat serviceBoat;
+
+ @Inject
+ private ServiceUser serviceUser;
+
+ @Persist
+ private GenericSelectModel<SampleRow> sampleRowSelectModel;
+
+ @Property
+ private String sampleRowId;
+
+ @Persist
+ private SelectModel facadeSelectModel;
+
+ @Persist
+ private SelectModel sectorSelectModel;
+
+ @Persist
+ private GenericSelectModel<Company> companySelectModel;
+
+ @Property
+ private String companyId;
+
+ @Persist
+ private GenericSelectModel<WaoUser> observerSelectModel;
+
+ @Property
+ private String observerId;
+
+ @Persist
+ private SelectModel programSelectModel;
+
+ @Persist
+ private boolean observerSelect;
+
+ @Persist
+ private boolean programSelect;
+ /**
+ * Initialize all select for filters. By default, only facade, sector and
+ * sampleRow selects will be initialized.
+ *
+ * @param companySelect if true, company select will be initialized
+ * @param observerSelect if true, observer select will be initialized
+ * @throws WaoException
+ */
+ protected void initSelectFilters(boolean companySelect, boolean observerSelect, boolean programSelect) throws WaoException {
+ this.observerSelect = observerSelect;
+ this.programSelect = programSelect;
+
+ if (getFilter().getSampleRow() != null) {
+ if (log.isDebugEnabled()) {
+ log.debug("SampleRow filtered : " + getFilter().getSampleRow());
+ }
+ sampleRowId = getFilter().getSampleRow().getTopiaId();
+ }
+
+ if (user.getAdmin() && companySelect) {
+ resetCompanySelect();
+ if (getFilter().getCompany() != null) {
+ companyId = getFilter().getCompany().getTopiaId();
+ }
+ } else if (!user.getAdmin()) {
+ if (log.isDebugEnabled()) {
+ log.debug("Company filtered : " + user.getCompany());
+ }
+ getFilter().setCompany(user.getCompany());
+ }
+
+ if (observerSelect) {
+ observerSelectModel = null;
+ getObserverSelectModel();
+
+ if (getFilter().getObserver() != null) {
+ observerId = getFilter().getObserver().getTopiaId();
+ }
+ }
+
+ if (programSelect) {
+ programSelectModel = null;
+ getProgramSelectModel();
+ }
+
+ resetFacadeSelect();
+ resetSectorSelect();
+ resetSampleRowSelect();
+ }
+
+ protected void resetCompanySelect() throws WaoException {
+ companySelectModel = null;
+ getCompanySelectModel();
+ }
+
+ protected void resetFacadeSelect() throws WaoException {
+ facadeSelectModel = null;
+ getFacadeSelectModel();
+ }
+
+ protected void resetSectorSelect() throws WaoException {
+ sectorSelectModel = null;
+ getSectorSelectModel();
+ }
+
+ protected void resetSampleRowSelect() throws WaoException {
+ sampleRowSelectModel = null;
+ getSampleRowSelectModel();
+ }
+
+ /**
+ * Get select model for fishingZone facade. Depends on company set in
+ * filter.
+ *
+ * @return the SelectModel for facade names
+ * @throws WaoException
+ */
+ public SelectModel getFacadeSelectModel() throws WaoException {
+ 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));
+ }
+ facadeSelectModel = new SelectModelImpl(null, options);
+ }
+ return facadeSelectModel;
+ }
+
+ /**
+ * Get select model for fishingZone sector. Depends on facadeName and
+ * company set in filter.
+ *
+ * @return the SelectModel for sector names
+ * @throws WaoException
+ */
+ public SelectModel getSectorSelectModel() throws WaoException {
+ 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));
+ }
+ sectorSelectModel = new SelectModelImpl(null, options);
+ }
+ return sectorSelectModel;
+ }
+
+ /**
+ * Get select model for sampleRows. Depends on filter (Sampling part only).
+ * The sampleRow set from filter is temporarly extracted to avoid returning
+ * only one element in the select.
+ *
+ * @return the GenericSelectModel<SampleRow> for sampleRows
+ * @throws WaoException
+ */
+ public GenericSelectModel<SampleRow> getSampleRowSelectModel() throws WaoException {
+ if (sampleRowSelectModel == null) {
+ if (log.isInfoEnabled()) {
+ log.info("BUSINESS REQUEST [getSampleRowsByFilter]");
+ }
+
+ // WARN : no use of sampleRow filter
+ SampleRow rowFiltered = getFilter().getSampleRow();
+ getFilter().setSampleRow(null);
+ List<SampleRow> sampleRows = serviceSampling.getSampleRowsByFilter(getFilter());
+ getFilter().setSampleRow(rowFiltered);
+
+ sampleRowSelectModel = new GenericSelectModel<SampleRow>(sampleRows, SampleRow.class,
+ "code", "topiaId", propertyAccess);
+ }
+ return sampleRowSelectModel;
+ }
+
+ /**
+ * Get select model for companies. Depends on
+ * {@link #getAvailableDataForFiltersOnly() } to return only activated
+ * companies. This select model is only used by admin users.
+ *
+ * @return the GenericSelectModel<Company> for companies
+ * @throws WaoException
+ */
+ public GenericSelectModel<Company> getCompanySelectModel() throws WaoException {
+ 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);
+ }
+ return companySelectModel;
+ }
+
+ /**
+ * Get the select model for observers. Depends on
+ * {@link #getAvailableDataForFiltersOnly() } to return only activated
+ * companies.
+ *
+ * @return the GenericSelectModel<WaoUser> for observers
+ * @throws WaoException
+ */
+ public GenericSelectModel<WaoUser> getObserverSelectModel() throws WaoException {
+ if (observerSelectModel == null) {
+ List<WaoUser> observers = new ArrayList<WaoUser>();
+ if (getFilter().getCompany() != null) {
+ observers = getFilter().getCompany().getWaoUser();
+ } else if (user.getAdmin()) {
+ if (log.isInfoEnabled()) {
+ log.info("BUSINESS REQUEST [getObservers]");
+ }
+ observers = serviceUser.getObservers(isAvailableDataForFiltersOnly());
+ }
+ observerSelectModel = new GenericSelectModel<WaoUser>(observers,WaoUser.class,
+ "fullName","topiaId",propertyAccess);
+ }
+ return observerSelectModel;
+ }
+
+ /**
+ * Get select model for sampleRow program. Depends on company set in
+ * filter.
+ *
+ * @return the SelectModel for program names
+ * @throws WaoException
+ */
+ public SelectModel getProgramSelectModel() throws WaoException {
+ 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));
+ }
+ programSelectModel = new SelectModelImpl(null, options);
+ }
+ return programSelectModel;
+ }
+
+ protected abstract BoatFilter getFilter() throws WaoException;
+
+ /**
+ * Used to show only active company and observers.
+ *
+ * @return true if only active users will be showed, false otherwise
+ */
+ protected abstract boolean isAvailableDataForFiltersOnly();
+
+ public String[] onProvideCompletionsFromBoatName(String input) throws WaoException {
+ if (log.isInfoEnabled()) {
+ log.info("BUSINESS REQUEST [getBoatNamesStartWith]");
+ }
+ List<String> results = serviceBoat.getBoatNamesStartWith(input);
+ return results.toArray(new String[0]);
+ }
+
+ /**
+ * Called when search submit button is pressed. This method is useful to
+ * refresh all filters data from selects.
+ *
+ * @throws WaoException
+ */
+ public void onSelectedFromSearch() throws WaoException {
+ if (log.isDebugEnabled()) {
+ log.debug("REFRESH FILTERS DATA");
+ }
+ SampleRow row = getSampleRowSelectModel().findObject(sampleRowId);
+ getFilter().setSampleRow(row);
+ if (user.getAdmin()) {
+ Company company = getCompanySelectModel().findObject(companyId);
+ getFilter().setCompany(company);
+ } else {
+ getFilter().setCompany(user.getCompany());
+ }
+
+ if (observerSelect) {
+ WaoUser observer = getObserverSelectModel().findObject(observerId);
+ getFilter().setObserver(observer);
+ }
+ }
+
+ private boolean edited;
+
+ /**
+ * EVENT :: selected on refreshByCompany submit button. Reset selects for
+ * company selected : programs, facades, sectors, sampleRows and observers.
+ * This method set the state to edited, you can use
+ * {@link AbstractFilteredPage#isEdited() } method to test it.
+ *
+ * @throws WaoException
+ * @see AbstractFilteredPage#onSelectedFromRefreshByProgram()
+ */
+ public void onSelectedFromRefreshByCompany() throws WaoException {
+ // Reset programs (the behavior is needed even if programSelect is false)
+ getFilter().setProgramName(null);
+ onSelectedFromRefreshByProgram();
+ if (observerSelect) {
+ // Reset observers
+ getFilter().setObserver(null);
+ observerSelectModel = null;
+ getObserverSelectModel();
+ }
+ if (programSelect) {
+ programSelectModel = null;
+ getProgramSelectModel();
+ }
+ edited = true;
+ }
+
+ /**
+ * EVENT :: selected on refreshByProgram submit button. Reset selects for
+ * program selected : facades, sectors and sampleRows.
+ * This method set the state to edited, you can use
+ * {@link AbstractFilteredPage#isEdited() } method to test it.
+ *
+ * @throws WaoException
+ * @see AbstractFilteredPage#onSelectedFromRefreshByFacade()
+ */
+ public void onSelectedFromRefreshByProgram() throws WaoException {
+ // Reset facades
+ getFilter().setFacadeName(null);
+ onSelectedFromRefreshByFacade();
+ resetFacadeSelect();
+ }
+
+ /**
+ * EVENT :: selected on refreshByFacade submit button. Reset selects for
+ * facade selected : sectors and sampleRows.
+ * This method set the state to edited, you can use
+ * {@link AbstractFilteredPage#isEdited() } method to test it.
+ *
+ * @throws WaoException
+ * @see AbstractFilteredPage#onSelectedFromRefreshBySector()
+ */
+ public void onSelectedFromRefreshByFacade() throws WaoException {
+ // Reset sectors
+ getFilter().setSectorName(null);
+ onSelectedFromRefreshBySector();
+ resetSectorSelect();
+ }
+
+ /**
+ * EVENT :: selected on refreshBySector submit button. After refreshing
+ * data selected, reset selects for sector selected : sampleRows.
+ * This method set the state to edited, you can use
+ * {@link AbstractFilteredPage#isEdited() } method to test it.
+ *
+ * @throws WaoException
+ * @see AbstractFilteredPage#onSelectedFromSearch()
+ */
+ public void onSelectedFromRefreshBySector() throws WaoException {
+ // Update selected data
+ onSelectedFromSearch();
+ // Reset sampleRows;
+ getFilter().setSampleRow(null);
+ resetSampleRowSelect();
+ edited = true;
+ }
+
+ /**
+ * Used to indicate that a refresh as been triggered.
+ *
+ * @return true if the page filter is in edited state.
+ */
+ protected boolean isEdited() {
+ return edited;
+ }
+
+}
Deleted: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/base/GenericSelectModel.java
===================================================================
--- trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/base/GenericSelectModel.java 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/base/GenericSelectModel.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,163 +0,0 @@
-/**
- * *##%
- * SuiviObsmer :: Web Interface
- * 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.suiviobsmer.ui.base;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import java.util.Map;
-import org.apache.tapestry5.OptionGroupModel;
-import org.apache.tapestry5.OptionModel;
-import org.apache.tapestry5.internal.OptionGroupModelImpl;
-import org.apache.tapestry5.internal.OptionModelImpl;
-import org.apache.tapestry5.ioc.annotations.Inject;
-import org.apache.tapestry5.ioc.services.PropertyAccess;
-import org.apache.tapestry5.ioc.services.PropertyAdapter;
-import org.apache.tapestry5.util.AbstractSelectModel;
-import org.slf4j.Logger;
-
-/**
- * GenericSelectModel.java
- *
- * Based on IdSelectModel from <http://jumpstart.doublenegative.com.au:8080/jumpstart/examples/select/easyid>
- * A generic selection model whose value is the id of the chosen object, not the object itself.
- *
- * @param <T>
- * @author fdesbois
- * @version $Revision: 3 $
- *
- * Last update: $Date: 2009-07-31 16:54:15 +0200 (ven. 31 juil. 2009) $
- * by : $Author: fdesbois $
- */
-public class GenericSelectModel<T> extends AbstractSelectModel {
-
- private List<T> list;
- private Map<String, List<T>> map;
- private PropertyAdapter labelFieldAdapter;
- private PropertyAdapter idFieldAdapter;
-
- @Inject
- private Logger log;
-
- /**
- * @param list the list of objects you want modeled in a Select component. These objects MUST implement
- * equals(Object obj) and hashCode(). If the objects are JPA entities, ensure their implementations of
- * equals(Object obj) and hashCode() return the same thing for different instances of the same detached
- * entity.
- * @param clazz the class of objects in the list.
- * @param labelField the name of the field you want displayed as the label in the selection list, eg. "name".
- * @param idField the name of the field which is the unique identifier of each object in the list, eg. "id". This is
- * used in the value property of the Select component.
- * @param access Declare a PropertyAccess injected into your page (eg. Inject private PropertyAccess _access) then pass it in here.
- *
- */
- public GenericSelectModel(List<T> list, Class<T> clazz, String labelField, String idField, PropertyAccess access) {
- init(clazz, labelField, idField, access);
-
- this.list = list;
- }
-
- public GenericSelectModel(Map<String, List<T>> map, Class<T> clazz, String labelField, String idField, PropertyAccess access) {
- init(clazz, labelField, idField, access);
-
- this.map = map;
- }
-
- private void init(Class<T> clazz, String labelField, String idField, PropertyAccess access) {
- if (clazz == null) {
- throw new IllegalArgumentException("clazz is required.");
- }
- if (idField == null) {
- throw new IllegalArgumentException("idField is required.");
- }
- if (labelField == null) {
- throw new IllegalArgumentException("labelField is required.");
- }
-
- this.idFieldAdapter = access.getAdapter(clazz).getPropertyAdapter(idField);
- this.labelFieldAdapter = access.getAdapter(clazz).getPropertyAdapter(labelField);
-
- if (idFieldAdapter == null) {
- throw new IllegalArgumentException("idField " + idField + " does not exist in class " + clazz + ".");
- }
- if (labelFieldAdapter == null) {
- throw new IllegalArgumentException("labelField " + idField + " does not exist in class " + clazz + ".");
- }
- }
-
- @Override
- public List<OptionGroupModel> getOptionGroups() {
- if (list != null) {
- return null;
- }
- List<OptionGroupModel> optionGroupModelList = new ArrayList<OptionGroupModel>();
- for (String key : map.keySet()) {
- optionGroupModelList.add(new OptionGroupModelImpl(key, false, getOptions(map.get(key))));
- }
- return optionGroupModelList;
- }
-
- @Override
- public List<OptionModel> getOptions() {
- if (map != null) {
- return null;
- }
- return getOptions(list);
- }
-
- private List<OptionModel> getOptions(List<T> list) {
- List<OptionModel> optionModelList = new ArrayList<OptionModel>();
- for (T obj : list) {
- optionModelList.add(new OptionModelImpl(nvl(labelFieldAdapter.get(obj)), idFieldAdapter.get(obj)));
- }
- return optionModelList;
- }
-
- public List<T> getList() {
- List<T> results;
- if (map != null) {
- results = new ArrayList<T>();
- for (String key : map.keySet()) {
- results.addAll(map.get(key));
- }
- } else {
- results = list;
- }
- return results;
- }
-
- public T findObject(String id) {
- if (id != null) {
- for (T current : getList()) {
- Object currentId = idFieldAdapter.get(current);
- if (currentId.equals(id)) {
- return current;
- }
- }
- }
- return null;
- }
-
- private String nvl(Object o) {
- return o == null ? "" : o.toString();
- }
-}
-
Copied: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/base/GenericSelectModel.java (from rev 354, trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/base/GenericSelectModel.java)
===================================================================
--- trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/base/GenericSelectModel.java (rev 0)
+++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/base/GenericSelectModel.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -0,0 +1,163 @@
+/**
+ * *##%
+ * Wao :: Web Interface
+ * 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.ui.base;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import java.util.Map;
+import org.apache.tapestry5.OptionGroupModel;
+import org.apache.tapestry5.OptionModel;
+import org.apache.tapestry5.internal.OptionGroupModelImpl;
+import org.apache.tapestry5.internal.OptionModelImpl;
+import org.apache.tapestry5.ioc.annotations.Inject;
+import org.apache.tapestry5.ioc.services.PropertyAccess;
+import org.apache.tapestry5.ioc.services.PropertyAdapter;
+import org.apache.tapestry5.util.AbstractSelectModel;
+import org.slf4j.Logger;
+
+/**
+ * GenericSelectModel.java
+ *
+ * Based on IdSelectModel from <http://jumpstart.doublenegative.com.au:8080/jumpstart/examples/select/easyid>
+ * A generic selection model whose value is the id of the chosen object, not the object itself.
+ *
+ * @param <T>
+ * @author fdesbois
+ * @version $Revision: 3 $
+ *
+ * Last update: $Date: 2009-07-31 16:54:15 +0200 (ven. 31 juil. 2009) $
+ * by : $Author: fdesbois $
+ */
+public class GenericSelectModel<T> extends AbstractSelectModel {
+
+ private List<T> list;
+ private Map<String, List<T>> map;
+ private PropertyAdapter labelFieldAdapter;
+ private PropertyAdapter idFieldAdapter;
+
+ @Inject
+ private Logger log;
+
+ /**
+ * @param list the list of objects you want modeled in a Select component. These objects MUST implement
+ * equals(Object obj) and hashCode(). If the objects are JPA entities, ensure their implementations of
+ * equals(Object obj) and hashCode() return the same thing for different instances of the same detached
+ * entity.
+ * @param clazz the class of objects in the list.
+ * @param labelField the name of the field you want displayed as the label in the selection list, eg. "name".
+ * @param idField the name of the field which is the unique identifier of each object in the list, eg. "id". This is
+ * used in the value property of the Select component.
+ * @param access Declare a PropertyAccess injected into your page (eg. Inject private PropertyAccess _access) then pass it in here.
+ *
+ */
+ public GenericSelectModel(List<T> list, Class<T> clazz, String labelField, String idField, PropertyAccess access) {
+ init(clazz, labelField, idField, access);
+
+ this.list = list;
+ }
+
+ public GenericSelectModel(Map<String, List<T>> map, Class<T> clazz, String labelField, String idField, PropertyAccess access) {
+ init(clazz, labelField, idField, access);
+
+ this.map = map;
+ }
+
+ private void init(Class<T> clazz, String labelField, String idField, PropertyAccess access) {
+ if (clazz == null) {
+ throw new IllegalArgumentException("clazz is required.");
+ }
+ if (idField == null) {
+ throw new IllegalArgumentException("idField is required.");
+ }
+ if (labelField == null) {
+ throw new IllegalArgumentException("labelField is required.");
+ }
+
+ this.idFieldAdapter = access.getAdapter(clazz).getPropertyAdapter(idField);
+ this.labelFieldAdapter = access.getAdapter(clazz).getPropertyAdapter(labelField);
+
+ if (idFieldAdapter == null) {
+ throw new IllegalArgumentException("idField " + idField + " does not exist in class " + clazz + ".");
+ }
+ if (labelFieldAdapter == null) {
+ throw new IllegalArgumentException("labelField " + idField + " does not exist in class " + clazz + ".");
+ }
+ }
+
+ @Override
+ public List<OptionGroupModel> getOptionGroups() {
+ if (list != null) {
+ return null;
+ }
+ List<OptionGroupModel> optionGroupModelList = new ArrayList<OptionGroupModel>();
+ for (String key : map.keySet()) {
+ optionGroupModelList.add(new OptionGroupModelImpl(key, false, getOptions(map.get(key))));
+ }
+ return optionGroupModelList;
+ }
+
+ @Override
+ public List<OptionModel> getOptions() {
+ if (map != null) {
+ return null;
+ }
+ return getOptions(list);
+ }
+
+ private List<OptionModel> getOptions(List<T> list) {
+ List<OptionModel> optionModelList = new ArrayList<OptionModel>();
+ for (T obj : list) {
+ optionModelList.add(new OptionModelImpl(nvl(labelFieldAdapter.get(obj)), idFieldAdapter.get(obj)));
+ }
+ return optionModelList;
+ }
+
+ public List<T> getList() {
+ List<T> results;
+ if (map != null) {
+ results = new ArrayList<T>();
+ for (String key : map.keySet()) {
+ results.addAll(map.get(key));
+ }
+ } else {
+ results = list;
+ }
+ return results;
+ }
+
+ public T findObject(String id) {
+ if (id != null) {
+ for (T current : getList()) {
+ Object currentId = idFieldAdapter.get(current);
+ if (currentId.equals(id)) {
+ return current;
+ }
+ }
+ }
+ return null;
+ }
+
+ private String nvl(Object o) {
+ return o == null ? "" : o.toString();
+ }
+}
+
Deleted: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/base/SuiviObsmerPage.java
===================================================================
--- trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/base/SuiviObsmerPage.java 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/base/SuiviObsmerPage.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,39 +0,0 @@
-/*
- * *##%
- * SuiviObsmer :: Web Interface
- * 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.suiviobsmer.ui.base;
-
-/**
- * SuiviObsmerPage
- *
- * Created: 3 déc. 2009
- *
- * @author fdesbois
- * @version $Revision$
- *
- * Mise a jour: $Date$
- * par : $Author$
- */
-public interface SuiviObsmerPage {
-
- boolean isOnlyForAdmin();
-
-}
Copied: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/base/WaoPage.java (from rev 354, trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/base/WaoPage.java)
===================================================================
--- trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/base/WaoPage.java (rev 0)
+++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/base/WaoPage.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -0,0 +1,39 @@
+/*
+ * *##%
+ * Wao :: Web Interface
+ * 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.ui.base;
+
+/**
+ * WaoPage
+ *
+ * Created: 3 déc. 2009
+ *
+ * @author fdesbois
+ * @version $Revision$
+ *
+ * Mise a jour: $Date$
+ * par : $Author$
+ */
+public interface WaoPage {
+
+ boolean isOnlyForAdmin();
+
+}
Deleted: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/components/BooleanImage.java
===================================================================
--- trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/components/BooleanImage.java 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/components/BooleanImage.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,74 +0,0 @@
-/*
- * *##%
- * SuiviObsmer :: Web Interface
- * 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.suiviobsmer.ui.components;
-
-import org.apache.tapestry5.BindingConstants;
-import org.apache.tapestry5.annotations.Parameter;
-
-/**
- * BooleanImage
- *
- * Created: 18 nov. 2009
- *
- * @author fdesbois
- * @version $Revision$
- *
- * Mise a jour: $Date$
- * par : $Author$
- */
-public class BooleanImage {
-
- @Parameter(required = true)
- private Boolean value;
-
- @Parameter
- private boolean empty;
-
- @Parameter(defaultPrefix = BindingConstants.LITERAL)
- private String trueTitle;
-
- @Parameter(defaultPrefix = BindingConstants.LITERAL)
- private String falseTitle;
-
- @Parameter(defaultPrefix = BindingConstants.LITERAL)
- private String emptyTitle;
-
- public Boolean getValue() {
- return value;
- }
-
- public boolean isEmpty() {
- return empty;
- }
-
- public String getTrueTitle() {
- return trueTitle == null ? "yes" : trueTitle;
- }
-
- public String getFalseTitle() {
- return falseTitle == null ? "no" : falseTitle;
- }
-
- public String getEmptyTitle() {
- return emptyTitle == null ? "empty" : emptyTitle;
- }
-}
Copied: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/components/BooleanImage.java (from rev 354, trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/components/BooleanImage.java)
===================================================================
--- trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/components/BooleanImage.java (rev 0)
+++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/components/BooleanImage.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -0,0 +1,74 @@
+/*
+ * *##%
+ * Wao :: Web Interface
+ * 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.ui.components;
+
+import org.apache.tapestry5.BindingConstants;
+import org.apache.tapestry5.annotations.Parameter;
+
+/**
+ * BooleanImage
+ *
+ * Created: 18 nov. 2009
+ *
+ * @author fdesbois
+ * @version $Revision$
+ *
+ * Mise a jour: $Date$
+ * par : $Author$
+ */
+public class BooleanImage {
+
+ @Parameter(required = true)
+ private Boolean value;
+
+ @Parameter
+ private boolean empty;
+
+ @Parameter(defaultPrefix = BindingConstants.LITERAL)
+ private String trueTitle;
+
+ @Parameter(defaultPrefix = BindingConstants.LITERAL)
+ private String falseTitle;
+
+ @Parameter(defaultPrefix = BindingConstants.LITERAL)
+ private String emptyTitle;
+
+ public Boolean getValue() {
+ return value;
+ }
+
+ public boolean isEmpty() {
+ return empty;
+ }
+
+ public String getTrueTitle() {
+ return trueTitle == null ? "yes" : trueTitle;
+ }
+
+ public String getFalseTitle() {
+ return falseTitle == null ? "no" : falseTitle;
+ }
+
+ public String getEmptyTitle() {
+ return emptyTitle == null ? "empty" : emptyTitle;
+ }
+}
Deleted: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/components/Chart.java
===================================================================
--- trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/components/Chart.java 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/components/Chart.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,102 +0,0 @@
-/* *##%
- * SuiviObsmer :: Web Interface
- * 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.suiviobsmer.ui.components;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-
-import org.apache.tapestry5.ComponentResources;
-import org.apache.tapestry5.Link;
-import org.apache.tapestry5.MarkupWriter;
-import org.apache.tapestry5.StreamResponse;
-import org.apache.tapestry5.annotations.Parameter;
-import org.apache.tapestry5.annotations.Persist;
-import org.apache.tapestry5.ioc.annotations.Inject;
-import org.apache.tapestry5.services.Response;
-import org.jfree.chart.ChartUtilities;
-import org.jfree.chart.JFreeChart;
-
-/**
- *
- * @author rannou
- * @version $Id$
- */
-public class Chart {
-
- /** titre du diagramme */
- @Parameter
- private String title = "";
-
- @Parameter(required = true)
- private JFreeChart chart;
-
- @Parameter(required = true)
- private int width;
-
- @Parameter(required = true)
- private int height;
-
- @Persist
- private JFreeChart currentChart;
-
- @Inject
- private ComponentResources resources;
-
- void beginRender(MarkupWriter writer) {
-
- currentChart = chart;
-
- // event link params
- Object[] params = new Object[] { title, width, height };
-
- // generate event link
- Link link = resources.createEventLink("chart", params);
- writer.element("img", "src", link);
-
- resources.renderInformalParameters(writer);
- }
-
- void afterRender(MarkupWriter writer) {
- writer.end();
- }
-
- public StreamResponse onChart(final String title, final int width, final int height) {
- // return the image
- return new StreamResponse() {
- @Override
- public String getContentType() {
- return "image/png";
- }
-
- @Override
- public InputStream getStream() throws IOException {
- ByteArrayOutputStream output = new ByteArrayOutputStream();
- ChartUtilities.writeChartAsPNG(output, currentChart, width, height);
- return new ByteArrayInputStream(output.toByteArray());
- }
-
- @Override
- public void prepareResponse(Response response) {
- }
- };
- }
-}
Copied: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/components/Chart.java (from rev 354, trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/components/Chart.java)
===================================================================
--- trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/components/Chart.java (rev 0)
+++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/components/Chart.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -0,0 +1,102 @@
+/* *##%
+ * Wao :: Web Interface
+ * 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.ui.components;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.apache.tapestry5.ComponentResources;
+import org.apache.tapestry5.Link;
+import org.apache.tapestry5.MarkupWriter;
+import org.apache.tapestry5.StreamResponse;
+import org.apache.tapestry5.annotations.Parameter;
+import org.apache.tapestry5.annotations.Persist;
+import org.apache.tapestry5.ioc.annotations.Inject;
+import org.apache.tapestry5.services.Response;
+import org.jfree.chart.ChartUtilities;
+import org.jfree.chart.JFreeChart;
+
+/**
+ *
+ * @author rannou
+ * @version $Id$
+ */
+public class Chart {
+
+ /** titre du diagramme */
+ @Parameter
+ private String title = "";
+
+ @Parameter(required = true)
+ private JFreeChart chart;
+
+ @Parameter(required = true)
+ private int width;
+
+ @Parameter(required = true)
+ private int height;
+
+ @Persist
+ private JFreeChart currentChart;
+
+ @Inject
+ private ComponentResources resources;
+
+ void beginRender(MarkupWriter writer) {
+
+ currentChart = chart;
+
+ // event link params
+ Object[] params = new Object[] { title, width, height };
+
+ // generate event link
+ Link link = resources.createEventLink("chart", params);
+ writer.element("img", "src", link);
+
+ resources.renderInformalParameters(writer);
+ }
+
+ void afterRender(MarkupWriter writer) {
+ writer.end();
+ }
+
+ public StreamResponse onChart(final String title, final int width, final int height) {
+ // return the image
+ return new StreamResponse() {
+ @Override
+ public String getContentType() {
+ return "image/png";
+ }
+
+ @Override
+ public InputStream getStream() throws IOException {
+ ByteArrayOutputStream output = new ByteArrayOutputStream();
+ ChartUtilities.writeChartAsPNG(output, currentChart, width, height);
+ return new ByteArrayInputStream(output.toByteArray());
+ }
+
+ @Override
+ public void prepareResponse(Response response) {
+ }
+ };
+ }
+}
Deleted: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/components/FeedBack.java
===================================================================
--- trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/components/FeedBack.java 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/components/FeedBack.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,127 +0,0 @@
-/* *##%
- * SuiviObsmer :: Web Interface
- * 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.suiviobsmer.ui.components;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.tapestry5.ComponentResources;
-import org.apache.tapestry5.MarkupWriter;
-import org.apache.tapestry5.ioc.annotations.Inject;
-
-/**
- * Composant qui affiche des messages à l'utilisateur.
- *
- * Ce composant permet d'afficher des messages avec une apparence différente
- * selon leur type (info ou erreur). Lors de l'affichage de la page, les
- * messages seront affichés et la collection de messages sera vidée.
- *
- * Pour personnaliser l'apparence des messages il faut définir les classes
- * fb-error et fb-info dans le CSS.
- *
- * <pre>
- * Utilisation :
- * <t:feedback t:id="feedback"/>
- * @Component(id = "feedback") private FeedBack feedback;
- * feedback.addInfo("message d'info");
- * feedback.addError("message d'erreur");
- * </pre>
- *
- * @author rannou
- * @version $Id: FeedBack.java 2736 2009-08-19 15:48:01Z nrannou $
- */
-public class FeedBack {
-
- /** Messages d'erreur */
- private List<String> errorMessages;
-
- /** Messages d'info */
- private List<String> infoMessages;
-
- private boolean errors;
-
- @Inject
- private ComponentResources resources;
-
- public FeedBack() {
- errorMessages = new ArrayList<String>();
- infoMessages = new ArrayList<String>();
- }
-
- void beginRender(MarkupWriter writer) {
-
- // Rendu des messages d'erreur et vidage de la collection
- if (!errorMessages.isEmpty()) {
- errors = true;
- writer.element("div", "class", "fb-error");
- for (String message : errorMessages) {
- writer.write(message);
- writer.element("br");
- writer.end();
- }
- writer.end();
- }
- errorMessages.clear();
-
- // Rendu des messages d'info et vidage de la collection
- if (!infoMessages.isEmpty()) {
- writer.element("div", "class", "fb-info");
- for (String message : infoMessages) {
- writer.write(message);
- writer.element("br");
- writer.end();
- }
- writer.end();
- }
- infoMessages.clear();
-
- resources.renderInformalParameters(writer);
- }
-
- void afterRender(MarkupWriter writer) {
-
- }
-
- /**
- * Ajout d'un message d'info.
- *
- * @param message le message
- */
- public void addInfo(String message) {
- if (!infoMessages.contains(message)) {
- infoMessages.add(message);
- }
- }
-
- /**
- * Ajout d'un message d'erreur.
- *
- * @param message le message
- */
- public void addError(String message) {
- if (!errorMessages.contains(message)) {
- errorMessages.add(message);
- }
- }
-
- public boolean hasErrors() {
- return errors;
- }
-}
Copied: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/components/FeedBack.java (from rev 354, trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/components/FeedBack.java)
===================================================================
--- trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/components/FeedBack.java (rev 0)
+++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/components/FeedBack.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -0,0 +1,127 @@
+/* *##%
+ * Wao :: Web Interface
+ * 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.ui.components;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tapestry5.ComponentResources;
+import org.apache.tapestry5.MarkupWriter;
+import org.apache.tapestry5.ioc.annotations.Inject;
+
+/**
+ * Composant qui affiche des messages à l'utilisateur.
+ *
+ * Ce composant permet d'afficher des messages avec une apparence différente
+ * selon leur type (info ou erreur). Lors de l'affichage de la page, les
+ * messages seront affichés et la collection de messages sera vidée.
+ *
+ * Pour personnaliser l'apparence des messages il faut définir les classes
+ * fb-error et fb-info dans le CSS.
+ *
+ * <pre>
+ * Utilisation :
+ * <t:feedback t:id="feedback"/>
+ * @Component(id = "feedback") private FeedBack feedback;
+ * feedback.addInfo("message d'info");
+ * feedback.addError("message d'erreur");
+ * </pre>
+ *
+ * @author rannou
+ * @version $Id: FeedBack.java 2736 2009-08-19 15:48:01Z nrannou $
+ */
+public class FeedBack {
+
+ /** Messages d'erreur */
+ private List<String> errorMessages;
+
+ /** Messages d'info */
+ private List<String> infoMessages;
+
+ private boolean errors;
+
+ @Inject
+ private ComponentResources resources;
+
+ public FeedBack() {
+ errorMessages = new ArrayList<String>();
+ infoMessages = new ArrayList<String>();
+ }
+
+ void beginRender(MarkupWriter writer) {
+
+ // Rendu des messages d'erreur et vidage de la collection
+ if (!errorMessages.isEmpty()) {
+ errors = true;
+ writer.element("div", "class", "fb-error");
+ for (String message : errorMessages) {
+ writer.write(message);
+ writer.element("br");
+ writer.end();
+ }
+ writer.end();
+ }
+ errorMessages.clear();
+
+ // Rendu des messages d'info et vidage de la collection
+ if (!infoMessages.isEmpty()) {
+ writer.element("div", "class", "fb-info");
+ for (String message : infoMessages) {
+ writer.write(message);
+ writer.element("br");
+ writer.end();
+ }
+ writer.end();
+ }
+ infoMessages.clear();
+
+ resources.renderInformalParameters(writer);
+ }
+
+ void afterRender(MarkupWriter writer) {
+
+ }
+
+ /**
+ * Ajout d'un message d'info.
+ *
+ * @param message le message
+ */
+ public void addInfo(String message) {
+ if (!infoMessages.contains(message)) {
+ infoMessages.add(message);
+ }
+ }
+
+ /**
+ * Ajout d'un message d'erreur.
+ *
+ * @param message le message
+ */
+ public void addError(String message) {
+ if (!errorMessages.contains(message)) {
+ errorMessages.add(message);
+ }
+ }
+
+ public boolean hasErrors() {
+ return errors;
+ }
+}
Deleted: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/components/Layout.java
===================================================================
--- trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/components/Layout.java 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/components/Layout.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,220 +0,0 @@
-/*
- * *##%
- * SuiviObsmer :: Web Interface
- * 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.suiviobsmer.ui.components;
-
-import fr.ifremer.suiviobsmer.SuiviObsmerBusinessException;
-import fr.ifremer.suiviobsmer.SuiviObsmerBusinessException.Type;
-import fr.ifremer.suiviobsmer.SuiviObsmerContext;
-import fr.ifremer.suiviobsmer.SuiviObsmerException;
-import fr.ifremer.suiviobsmer.entity.WaoUser;
-import fr.ifremer.suiviobsmer.services.ServiceUser;
-import fr.ifremer.suiviobsmer.ui.base.SuiviObsmerPage;
-import fr.ifremer.suiviobsmer.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.Log;
-import org.apache.tapestry5.annotations.Parameter;
-import org.apache.tapestry5.annotations.Persist;
-import org.apache.tapestry5.annotations.Property;
-import org.apache.tapestry5.annotations.SessionState;
-import org.apache.tapestry5.ioc.annotations.Inject;
-import org.apache.tapestry5.services.Request;
-
-/**
- * Layout
- *
- * Created: 9 nov. 2009
- *
- * @author fdesbois
- * @version $Revision$
- *
- * Mise a jour: $Date$
- * par : $Author$
- */
-public class Layout {
-
- @Parameter(required = true, defaultPrefix = BindingConstants.LITERAL)
- private String pageTitle;
-
- @Parameter(required = true, defaultPrefix = BindingConstants.LITERAL)
- private String contentId;
-
- /**
- * Objet de session représentant l'utilisateur identifié
- */
- @SessionState
- private WaoUser currentUser;
-
- /**
- * vrai si l'utilisateur s'est identifié, faux sinon
- */
- //@SuppressWarnings("unused")
- //@Property
- //private boolean currentUserExists;
-
- @InjectComponent
- private FeedBack connexionFeedback;
-
- @InjectComponent
- private FeedBack contentFeedback;
-
- @InjectContainer
- private SuiviObsmerPage page;
-
- @Inject
- private ServiceUser serviceUser;
-
- @Inject
- private Request request;
-
- void setupRender() {
- if(isCurrentUserExists() && !canShowPage()) {
- contentFeedback.addError("Vous n'êtes pas autorisé à accéder à cette page !");
- }
- }
-
- /**
- * Test if the current user in session is a valid user.
- * Test topia id existence because WaoUser can be empty when session is lost
- *
- * @return true if the current user is a valide user (not empty).
- * @see fr.ifremer.suiviobsmer.ui.services.AppModule#
- * contributeApplicationStateManager(MappedConfiguration)
- */
- @Log
- public boolean isCurrentUserExists() {
- return StringUtils.isNotEmpty(currentUser.getTopiaId());
- }
-
- public String getContextPath() {
- return request.getContextPath();
- }
-
- public String getVersion() {
- return SuiviObsmerContext.getProperty(SuiviObsmerContext.PROP_VERSION);
- }
-
- /**
- * User for connexion form data
- */
- @Property
- private String login;
-
- @Property
- private String password;
-
- @Persist(PersistenceConstants.FLASH)
- @Property
- private String email;
-
- public String getPageTitle() {
- return this.pageTitle;
- }
-
- public String getContentId() {
- return this.contentId;
- }
-
- public void setCurrentUser(WaoUser user) {
- this.currentUser = user;
- }
-
- public WaoUser getCurrentUser() {
- return this.currentUser;
- }
-
- public FeedBack getFeedBack() {
- return this.contentFeedback;
- }
-
- public String getAdminClass() {
- return this.currentUser.getAdmin() ? " admin" : "";
- }
-
- public String getSamplingSelected() {
- return this.contentId.equals("so-sampling") ? "selected" : "";
- }
-
- public String getBoatsSelected() {
- return this.contentId.equals("so-boats") ? "selected" : "";
- }
-
- public String getContactsSelected() {
- return this.contentId.equals("so-contacts") ? "selected" : "";
- }
-
- public String getSynthesisSelected() {
- return this.contentId.equals("so-synthesis") ? "selected" : "";
- }
-
- public String getAdminSelected() {
- return this.contentId.equals("so-admin") ? "selected" : "";
- }
-
- public boolean canShowPage() {
- if (!currentUser.getAdmin()) {
- return !page.isOnlyForAdmin();
- }
- return true;
- }
-
- @Log
- Object onSuccessFromConnexionForm() throws SuiviObsmerException {
- try {
- // FIXME-FD20100120 Problem with NPE in Topia --> see Ano #243 on nuiton.org
- if (login != null && password != null) {
- currentUser = serviceUser.connect(login, password);
- }
- } catch (SuiviObsmerBusinessException eee) {
- if (eee.getType().equals(Type.BAD_CONNECTION)) {
- connexionFeedback.addError(eee.getMessage());
- email = login;
- } else if (eee.getType().equals(Type.ILLEGAL_CONNECTION)) {
- connexionFeedback.addInfo(eee.getMessage());
- }
- }
- return null;
- }
-
- public boolean hasConnexionErrors() {
- return connexionFeedback.hasErrors();
- }
- void onSuccessFromForgetPassword() throws SuiviObsmerException {
- try {
- serviceUser.forgetPassword(email);
- connexionFeedback.addInfo("Un email avec votre nouveau mot de passe vous a été envoyé.");
- } catch (SuiviObsmerBusinessException eee) {
- connexionFeedback.addError(eee.getMessage());
- }
- }
-
- @Log
- Object onActionFromExit() {
- setCurrentUser(null);
- request.getSession(false).invalidate();
- return Index.class;
- }
-
-}
Copied: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/components/Layout.java (from rev 354, trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/components/Layout.java)
===================================================================
--- trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/components/Layout.java (rev 0)
+++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/components/Layout.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -0,0 +1,220 @@
+/*
+ * *##%
+ * Wao :: Web Interface
+ * 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.ui.components;
+
+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.entity.WaoUser;
+import fr.ifremer.wao.service.ServiceUser;
+import fr.ifremer.wao.ui.base.WaoPage;
+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.Log;
+import org.apache.tapestry5.annotations.Parameter;
+import org.apache.tapestry5.annotations.Persist;
+import org.apache.tapestry5.annotations.Property;
+import org.apache.tapestry5.annotations.SessionState;
+import org.apache.tapestry5.ioc.annotations.Inject;
+import org.apache.tapestry5.services.Request;
+
+/**
+ * Layout
+ *
+ * Created: 9 nov. 2009
+ *
+ * @author fdesbois
+ * @version $Revision$
+ *
+ * Mise a jour: $Date$
+ * par : $Author$
+ */
+public class Layout {
+
+ @Parameter(required = true, defaultPrefix = BindingConstants.LITERAL)
+ private String pageTitle;
+
+ @Parameter(required = true, defaultPrefix = BindingConstants.LITERAL)
+ private String contentId;
+
+ /**
+ * Objet de session représentant l'utilisateur identifié
+ */
+ @SessionState
+ private WaoUser currentUser;
+
+ /**
+ * vrai si l'utilisateur s'est identifié, faux sinon
+ */
+ //@SuppressWarnings("unused")
+ //@Property
+ //private boolean currentUserExists;
+
+ @InjectComponent
+ private FeedBack connexionFeedback;
+
+ @InjectComponent
+ private FeedBack contentFeedback;
+
+ @InjectContainer
+ private WaoPage page;
+
+ @Inject
+ private ServiceUser serviceUser;
+
+ @Inject
+ private Request request;
+
+ void setupRender() {
+ if(isCurrentUserExists() && !canShowPage()) {
+ contentFeedback.addError("Vous n'êtes pas autorisé à accéder à cette page !");
+ }
+ }
+
+ /**
+ * Test if the current user in session is a valid user.
+ * Test topia id existence because WaoUser can be empty when session is lost
+ *
+ * @return true if the current user is a valide user (not empty).
+ * @see fr.ifremer.wao.ui.services.AppModule#
+ * contributeApplicationStateManager(MappedConfiguration)
+ */
+ @Log
+ public boolean isCurrentUserExists() {
+ return StringUtils.isNotEmpty(currentUser.getTopiaId());
+ }
+
+ public String getContextPath() {
+ return request.getContextPath();
+ }
+
+ public String getVersion() {
+ return WaoContext.getProperty(WaoContext.PROP_VERSION);
+ }
+
+ /**
+ * User for connexion form data
+ */
+ @Property
+ private String login;
+
+ @Property
+ private String password;
+
+ @Persist(PersistenceConstants.FLASH)
+ @Property
+ private String email;
+
+ public String getPageTitle() {
+ return this.pageTitle;
+ }
+
+ public String getContentId() {
+ return this.contentId;
+ }
+
+ public void setCurrentUser(WaoUser user) {
+ this.currentUser = user;
+ }
+
+ public WaoUser getCurrentUser() {
+ return this.currentUser;
+ }
+
+ public FeedBack getFeedBack() {
+ return this.contentFeedback;
+ }
+
+ public String getAdminClass() {
+ return this.currentUser.getAdmin() ? " admin" : "";
+ }
+
+ public String getSamplingSelected() {
+ return this.contentId.equals("so-sampling") ? "selected" : "";
+ }
+
+ public String getBoatsSelected() {
+ return this.contentId.equals("so-boats") ? "selected" : "";
+ }
+
+ public String getContactsSelected() {
+ return this.contentId.equals("so-contacts") ? "selected" : "";
+ }
+
+ public String getSynthesisSelected() {
+ return this.contentId.equals("so-synthesis") ? "selected" : "";
+ }
+
+ public String getAdminSelected() {
+ return this.contentId.equals("so-admin") ? "selected" : "";
+ }
+
+ public boolean canShowPage() {
+ if (!currentUser.getAdmin()) {
+ return !page.isOnlyForAdmin();
+ }
+ return true;
+ }
+
+ @Log
+ Object onSuccessFromConnexionForm() throws WaoException {
+ try {
+ // FIXME-FD20100120 Problem with NPE in Topia --> see Ano #243 on nuiton.org
+ if (login != null && password != null) {
+ currentUser = serviceUser.connect(login, password);
+ }
+ } catch (WaoBusinessException eee) {
+ if (eee.getType().equals(Type.BAD_CONNECTION)) {
+ connexionFeedback.addError(eee.getMessage());
+ email = login;
+ } else if (eee.getType().equals(Type.ILLEGAL_CONNECTION)) {
+ connexionFeedback.addInfo(eee.getMessage());
+ }
+ }
+ return null;
+ }
+
+ public boolean hasConnexionErrors() {
+ return connexionFeedback.hasErrors();
+ }
+ void onSuccessFromForgetPassword() throws WaoException {
+ try {
+ serviceUser.forgetPassword(email);
+ connexionFeedback.addInfo("Un email avec votre nouveau mot de passe vous a été envoyé.");
+ } catch (WaoBusinessException eee) {
+ connexionFeedback.addError(eee.getMessage());
+ }
+ }
+
+ @Log
+ Object onActionFromExit() {
+ setCurrentUser(null);
+ request.getSession(false).invalidate();
+ return Index.class;
+ }
+
+}
Deleted: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/components/SubmitContext.java
===================================================================
--- trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/components/SubmitContext.java 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/components/SubmitContext.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,141 +0,0 @@
-/*
- * *##%
- * SuiviObsmer :: Web Interface
- * 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>.
- * ##%*
- */
-// Copyright 2007 The Apache Software Foundation
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package fr.ifremer.suiviobsmer.ui.components;
-
-import org.apache.tapestry5.ComponentResources;
-import org.apache.tapestry5.MarkupWriter;
-import org.apache.tapestry5.annotations.Environmental;
-import org.apache.tapestry5.annotations.Parameter;
-import org.apache.tapestry5.corelib.base.AbstractField;
-import org.apache.tapestry5.ioc.annotations.Inject;
-import org.apache.tapestry5.services.FormSupport;
-import org.apache.tapestry5.services.Heartbeat;
-import org.apache.tapestry5.services.Request;
-
-/**
- * Corresponds to <input type="submit">, a client-side element that can force the
- * enclosing form to submit. The submit responsible for the form submission will post a
- * notification that allows the application to know that it was the responsible entity. The
- * notification is named "selected" and has a String context.
- */
-public final class SubmitContext extends AbstractField
-{
- static final String SELECTED_EVENT = "selected";
-
- /**
- * If true, then any notification sent by the component will be deferred until the end of
- * the form submission (this is usually desirable).
- */
- @Parameter
- private boolean defer = true;
-
- @Parameter
- private String context;
-
- @Environmental
- private FormSupport formSupport;
-
- @Environmental
- private Heartbeat heartbeat;
-
- @Inject
- private ComponentResources resources;
-
- @Inject
- private Request request;
-
- public SubmitContext() {
- }
-
- SubmitContext(Request request) {
- this.request = request;
- }
-
- void beginRender(MarkupWriter writer) {
- // write a hidden input for the context
- //String elementName = getElementName();
- String elementName = getControlName(); //Modified to work with 5.0.12
- writer.element("input", "type", "hidden", "name", elementName + "X", "value", context);
- writer.end();
-
- // now the submit
- writer.element("input", "type", "submit", "name", elementName, "id", getClientId());
- resources.renderInformalParameters(writer);
- }
-
- void afterRender(MarkupWriter writer) {
- writer.end();
- }
-
- @Override
- protected void processSubmission(String elementName) {
- String value = request.getParameter(elementName);
- final String cxt = request.getParameter(elementName + "X");
-
- if (value == null) {
- return;
- }
-
- Runnable sendNotification = new Runnable() {
- @Override
- public void run() {
- resources.triggerEvent(SELECTED_EVENT, new Object[] {cxt}, null);
- }
- };
-
- // When not deferred, don't wait, fire the event now (actually, at the end of the current
- // heartbeat). This is most likely because the Submit is inside a Loop and some contextual
- // information will change if we defer. Another option might be to wait until the next
- // heartbeak?
-
- if (defer) {
- formSupport.defer(sendNotification);
- } else {
- heartbeat.defer(sendNotification);
- }
- }
-
- // For testing:
-
- void setDefer(boolean defer) {
- this.defer = defer;
- }
-
- void setup(ComponentResources resources, FormSupport support, Heartbeat heartbeat) {
- this.resources = resources;
- formSupport = support;
- this.heartbeat = heartbeat;
- }
-}
Copied: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/components/SubmitContext.java (from rev 354, trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/components/SubmitContext.java)
===================================================================
--- trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/components/SubmitContext.java (rev 0)
+++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/components/SubmitContext.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -0,0 +1,141 @@
+/*
+ * *##%
+ * Wao :: Web Interface
+ * 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>.
+ * ##%*
+ */
+// Copyright 2007 The Apache Software Foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package fr.ifremer.wao.ui.components;
+
+import org.apache.tapestry5.ComponentResources;
+import org.apache.tapestry5.MarkupWriter;
+import org.apache.tapestry5.annotations.Environmental;
+import org.apache.tapestry5.annotations.Parameter;
+import org.apache.tapestry5.corelib.base.AbstractField;
+import org.apache.tapestry5.ioc.annotations.Inject;
+import org.apache.tapestry5.services.FormSupport;
+import org.apache.tapestry5.services.Heartbeat;
+import org.apache.tapestry5.services.Request;
+
+/**
+ * Corresponds to <input type="submit">, a client-side element that can force the
+ * enclosing form to submit. The submit responsible for the form submission will post a
+ * notification that allows the application to know that it was the responsible entity. The
+ * notification is named "selected" and has a String context.
+ */
+public final class SubmitContext extends AbstractField
+{
+ static final String SELECTED_EVENT = "selected";
+
+ /**
+ * If true, then any notification sent by the component will be deferred until the end of
+ * the form submission (this is usually desirable).
+ */
+ @Parameter
+ private boolean defer = true;
+
+ @Parameter
+ private String context;
+
+ @Environmental
+ private FormSupport formSupport;
+
+ @Environmental
+ private Heartbeat heartbeat;
+
+ @Inject
+ private ComponentResources resources;
+
+ @Inject
+ private Request request;
+
+ public SubmitContext() {
+ }
+
+ SubmitContext(Request request) {
+ this.request = request;
+ }
+
+ void beginRender(MarkupWriter writer) {
+ // write a hidden input for the context
+ //String elementName = getElementName();
+ String elementName = getControlName(); //Modified to work with 5.0.12
+ writer.element("input", "type", "hidden", "name", elementName + "X", "value", context);
+ writer.end();
+
+ // now the submit
+ writer.element("input", "type", "submit", "name", elementName, "id", getClientId());
+ resources.renderInformalParameters(writer);
+ }
+
+ void afterRender(MarkupWriter writer) {
+ writer.end();
+ }
+
+ @Override
+ protected void processSubmission(String elementName) {
+ String value = request.getParameter(elementName);
+ final String cxt = request.getParameter(elementName + "X");
+
+ if (value == null) {
+ return;
+ }
+
+ Runnable sendNotification = new Runnable() {
+ @Override
+ public void run() {
+ resources.triggerEvent(SELECTED_EVENT, new Object[] {cxt}, null);
+ }
+ };
+
+ // When not deferred, don't wait, fire the event now (actually, at the end of the current
+ // heartbeat). This is most likely because the Submit is inside a Loop and some contextual
+ // information will change if we defer. Another option might be to wait until the next
+ // heartbeak?
+
+ if (defer) {
+ formSupport.defer(sendNotification);
+ } else {
+ heartbeat.defer(sendNotification);
+ }
+ }
+
+ // For testing:
+
+ void setDefer(boolean defer) {
+ this.defer = defer;
+ }
+
+ void setup(ComponentResources resources, FormSupport support, Heartbeat heartbeat) {
+ this.resources = resources;
+ formSupport = support;
+ this.heartbeat = heartbeat;
+ }
+}
Deleted: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/data/AbstractMappedGridDataSource.java
===================================================================
--- trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/data/AbstractMappedGridDataSource.java 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/data/AbstractMappedGridDataSource.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,171 +0,0 @@
-
-package fr.ifremer.suiviobsmer.ui.data;
-
-import fr.ifremer.suiviobsmer.SuiviObsmerException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import org.apache.commons.collections.CollectionUtils;
-import org.apache.tapestry5.grid.ColumnSort;
-import org.apache.tapestry5.grid.GridDataSource;
-import org.apache.tapestry5.grid.SortConstraint;
-import org.apache.tapestry5.ioc.internal.util.TapestryException;
-import org.nuiton.topia.persistence.TopiaEntity;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * ContactDataSource
- *
- * Created: 18 janv. 2010
- *
- * @param <K> Type of the map key
- * @param <E> Type of the map value
- * @author fdesbois
- * @version $Revision$
- *
- * Mise a jour: $Date$
- * par : $Author$
- */
-public abstract class AbstractMappedGridDataSource<K, E extends TopiaEntity> implements GridDataSource {
-
-
- private Logger log = LoggerFactory.getLogger(AbstractMappedGridDataSource.class);
-
- private Map<K, E> mapResults;
-
- private List<E> listResults;
-
- private int nbRows = -1;
-
- private int nbRowsPerPage;
-
- @Override
- public int getAvailableRows() {
- if (nbRows < 0) {
- try {
- nbRows = count();
- if (log.isTraceEnabled()) {
- log.trace("Count : " + nbRows);
- }
- } catch (SuiviObsmerException eee) {
- throw new TapestryException("", eee);
- }
- }
- return nbRows;
- }
-
- @Override
- public void prepare(int startIndex, int endIndex, List<SortConstraint> sortConstraints) {
- if (log.isTraceEnabled()) {
- log.trace("Prepare results : " + startIndex + ", " + endIndex);
- }
- nbRowsPerPage = endIndex - startIndex + 1;
- try {
- mapResults = execute(startIndex, endIndex, getSortConstraint(sortConstraints));
- listResults = new ArrayList<E>(mapResults.values());
-
- // FIXME manage sort columns in execute ???? seems obvious --> needed for Contacts, done for Boats
- //sortResults(sortConstraints);
- } catch (SuiviObsmerException eee) {
- throw new TapestryException("", eee);
- }
- }
-
- protected abstract Map<K, E> execute(int startIndex, int endIndex, SortConstraint orderBy) throws SuiviObsmerException;
-
- protected abstract int count() throws SuiviObsmerException;
-
- protected SortConstraint getSortConstraint(List<SortConstraint> sortConstraints) {
- for (SortConstraint constraint : sortConstraints)
- {
- final ColumnSort sort = constraint.getColumnSort();
-
- if (sort != ColumnSort.UNSORTED) {
- return constraint;
- }
- }
- return null;
- }
-
-// protected void sortResults(List<SortConstraint> sortConstraints) {
-//
-// for (SortConstraint constraint : sortConstraints)
-// {
-// final ColumnSort sort = constraint.getColumnSort();
-//
-// if (sort == ColumnSort.UNSORTED) continue;
-//
-// final PropertyConduit conduit = constraint.getPropertyModel().getConduit();
-//
-// final Comparator valueComparator = new Comparator<Comparable>()
-// {
-// public int compare(Comparable o1, Comparable o2)
-// {
-// // Simplify comparison, and handle case where both are nulls.
-//
-// if (o1 == o2) return 0;
-//
-// if (o2 == null) return 1;
-//
-// if (o1 == null) return -1;
-//
-// return o1.compareTo(o2);
-// }
-// };
-//
-// final Comparator rowComparator = new Comparator()
-// {
-// public int compare(Object row1, Object row2)
-// {
-// Comparable value1 = (Comparable) conduit.get(row1);
-// Comparable value2 = (Comparable) conduit.get(row2);
-//
-// return valueComparator.compare(value1, value2);
-// }
-// };
-//
-// final Comparator reverseComparator = new Comparator()
-// {
-// public int compare(Object o1, Object o2)
-// {
-// int modifier = sort == ColumnSort.ASCENDING ? 1 : -1;
-//
-// return modifier * rowComparator.compare(o1, o2);
-// }
-// };
-//
-// // We can freely sort this list because its just a copy.
-//
-// Collections.sort(listResults, reverseComparator);
-// }
-// }
-
- @Override
- public Object getRowValue(int index) {
- index = index % nbRowsPerPage;
- if (index >= listResults.size()) {
- if (log.isErrorEnabled()) {
- log.error("Size error : " + index + " / " + listResults.size());
- }
- return null;
- }
- return CollectionUtils.get(listResults, index);
- }
-
- @Override
- public abstract Class<?> getRowType();
-
- public E get(K key) {
- return mapResults.get(key);
- }
-
- public List<E> values() {
- return listResults;
- }
-
- public boolean contains(K key) {
- return mapResults.containsKey(key);
- }
-
-}
Copied: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/data/AbstractMappedGridDataSource.java (from rev 354, trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/data/AbstractMappedGridDataSource.java)
===================================================================
--- trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/data/AbstractMappedGridDataSource.java (rev 0)
+++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/data/AbstractMappedGridDataSource.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -0,0 +1,191 @@
+/*
+ * *##%
+ * Wao :: Web Interface
+ * 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.ui.data;
+
+import fr.ifremer.wao.WaoException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.tapestry5.grid.ColumnSort;
+import org.apache.tapestry5.grid.GridDataSource;
+import org.apache.tapestry5.grid.SortConstraint;
+import org.apache.tapestry5.ioc.internal.util.TapestryException;
+import org.nuiton.topia.persistence.TopiaEntity;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * ContactDataSource
+ *
+ * Created: 18 janv. 2010
+ *
+ * @param <K> Type of the map key
+ * @param <E> Type of the map value
+ * @author fdesbois
+ * @version $Revision$
+ *
+ * Mise a jour: $Date$
+ * par : $Author$
+ */
+public abstract class AbstractMappedGridDataSource<K, E extends TopiaEntity> implements GridDataSource {
+
+
+ private Logger log = LoggerFactory.getLogger(AbstractMappedGridDataSource.class);
+
+ private Map<K, E> mapResults;
+
+ private List<E> listResults;
+
+ private int nbRows = -1;
+
+ private int nbRowsPerPage;
+
+ @Override
+ public int getAvailableRows() {
+ if (nbRows < 0) {
+ try {
+ nbRows = count();
+ if (log.isTraceEnabled()) {
+ log.trace("Count : " + nbRows);
+ }
+ } catch (WaoException eee) {
+ throw new TapestryException("", eee);
+ }
+ }
+ return nbRows;
+ }
+
+ @Override
+ public void prepare(int startIndex, int endIndex, List<SortConstraint> sortConstraints) {
+ if (log.isTraceEnabled()) {
+ log.trace("Prepare results : " + startIndex + ", " + endIndex);
+ }
+ nbRowsPerPage = endIndex - startIndex + 1;
+ try {
+ mapResults = execute(startIndex, endIndex, getSortConstraint(sortConstraints));
+ listResults = new ArrayList<E>(mapResults.values());
+
+ // FIXME manage sort columns in execute ???? seems obvious --> needed for Contacts, done for Boats
+ //sortResults(sortConstraints);
+ } catch (WaoException eee) {
+ throw new TapestryException("", eee);
+ }
+ }
+
+ protected abstract Map<K, E> execute(int startIndex, int endIndex, SortConstraint orderBy) throws WaoException;
+
+ protected abstract int count() throws WaoException;
+
+ protected SortConstraint getSortConstraint(List<SortConstraint> sortConstraints) {
+ for (SortConstraint constraint : sortConstraints)
+ {
+ final ColumnSort sort = constraint.getColumnSort();
+
+ if (sort != ColumnSort.UNSORTED) {
+ return constraint;
+ }
+ }
+ return null;
+ }
+
+// protected void sortResults(List<SortConstraint> sortConstraints) {
+//
+// for (SortConstraint constraint : sortConstraints)
+// {
+// final ColumnSort sort = constraint.getColumnSort();
+//
+// if (sort == ColumnSort.UNSORTED) continue;
+//
+// final PropertyConduit conduit = constraint.getPropertyModel().getConduit();
+//
+// final Comparator valueComparator = new Comparator<Comparable>()
+// {
+// public int compare(Comparable o1, Comparable o2)
+// {
+// // Simplify comparison, and handle case where both are nulls.
+//
+// if (o1 == o2) return 0;
+//
+// if (o2 == null) return 1;
+//
+// if (o1 == null) return -1;
+//
+// return o1.compareTo(o2);
+// }
+// };
+//
+// final Comparator rowComparator = new Comparator()
+// {
+// public int compare(Object row1, Object row2)
+// {
+// Comparable value1 = (Comparable) conduit.get(row1);
+// Comparable value2 = (Comparable) conduit.get(row2);
+//
+// return valueComparator.compare(value1, value2);
+// }
+// };
+//
+// final Comparator reverseComparator = new Comparator()
+// {
+// public int compare(Object o1, Object o2)
+// {
+// int modifier = sort == ColumnSort.ASCENDING ? 1 : -1;
+//
+// return modifier * rowComparator.compare(o1, o2);
+// }
+// };
+//
+// // We can freely sort this list because its just a copy.
+//
+// Collections.sort(listResults, reverseComparator);
+// }
+// }
+
+ @Override
+ public Object getRowValue(int index) {
+ index = index % nbRowsPerPage;
+ if (index >= listResults.size()) {
+ if (log.isErrorEnabled()) {
+ log.error("Size error : " + index + " / " + listResults.size());
+ }
+ return null;
+ }
+ return CollectionUtils.get(listResults, index);
+ }
+
+ @Override
+ public abstract Class<?> getRowType();
+
+ public E get(K key) {
+ return mapResults.get(key);
+ }
+
+ public List<E> values() {
+ return listResults;
+ }
+
+ public boolean contains(K key) {
+ return mapResults.containsKey(key);
+ }
+
+}
Deleted: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/data/BoatDataSource.java
===================================================================
--- trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/data/BoatDataSource.java 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/data/BoatDataSource.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,79 +0,0 @@
-
-package fr.ifremer.suiviobsmer.ui.data;
-
-import fr.ifremer.suiviobsmer.SuiviObsmerException;
-import fr.ifremer.suiviobsmer.bean.BoatFilter;
-import fr.ifremer.suiviobsmer.entity.Boat;
-import fr.ifremer.suiviobsmer.services.ServiceBoat;
-import java.util.Map;
-import org.apache.tapestry5.beaneditor.PropertyModel;
-import org.apache.tapestry5.grid.ColumnSort;
-import org.apache.tapestry5.grid.SortConstraint;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * BoatDataSource
- *
- * Created: 19 janv. 2010
- *
- * @author fdesbois
- * @version $Revision$
- *
- * Mise a jour: $Date$
- * par : $Author$
- */
-public class BoatDataSource extends AbstractMappedGridDataSource<Integer, Boat> {
-
- private static Logger log = LoggerFactory.getLogger(BoatDataSource.class);
-
- private BoatFilter filter;
-
- private ServiceBoat service;
-
- public BoatDataSource(BoatFilter filter, ServiceBoat service) {
- this.filter = filter;
- this.service = service;
- }
-
-
- @Override
- protected Map<Integer, Boat> execute(int startIndex, int endIndex, SortConstraint orderBy) throws SuiviObsmerException {
- if (log.isInfoEnabled()) {
- log.info("BUSINESS REQUEST [getBoatsByFilter]");
- }
- filter.setStartIndex(startIndex);
- filter.setEndIndex(endIndex);
-
- if (orderBy != null) {
- PropertyModel property = orderBy.getPropertyModel();
- String filterOrder = property.getPropertyName();
-
- ColumnSort sort = orderBy.getColumnSort();
- if (sort.equals(ColumnSort.DESCENDING)) {
- filterOrder += " desc";
- }
-
- if (log.isDebugEnabled()) {
- log.debug("Order : " + filterOrder);
- }
- filter.setOrderBy(filterOrder);
- }
-
- return service.getBoatsByFilter(filter);
- }
-
- @Override
- protected int count() throws SuiviObsmerException {
- if (log.isInfoEnabled()) {
- log.info("BUSINESS REQUEST [getNbBoatsByFilter]");
- }
- return service.getNbBoatsByFilter(filter);
- }
-
- @Override
- public Class<?> getRowType() {
- return Boat.class;
- }
-
-}
Copied: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/data/BoatDataSource.java (from rev 354, trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/data/BoatDataSource.java)
===================================================================
--- trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/data/BoatDataSource.java (rev 0)
+++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/data/BoatDataSource.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -0,0 +1,99 @@
+/*
+ * *##%
+ * Wao :: Web Interface
+ * 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.ui.data;
+
+import fr.ifremer.wao.WaoException;
+import fr.ifremer.wao.bean.BoatFilter;
+import fr.ifremer.wao.entity.Boat;
+import fr.ifremer.wao.service.ServiceBoat;
+import java.util.Map;
+import org.apache.tapestry5.beaneditor.PropertyModel;
+import org.apache.tapestry5.grid.ColumnSort;
+import org.apache.tapestry5.grid.SortConstraint;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * BoatDataSource
+ *
+ * Created: 19 janv. 2010
+ *
+ * @author fdesbois
+ * @version $Revision$
+ *
+ * Mise a jour: $Date$
+ * par : $Author$
+ */
+public class BoatDataSource extends AbstractMappedGridDataSource<Integer, Boat> {
+
+ private static Logger log = LoggerFactory.getLogger(BoatDataSource.class);
+
+ private BoatFilter filter;
+
+ private ServiceBoat service;
+
+ public BoatDataSource(BoatFilter filter, ServiceBoat service) {
+ this.filter = filter;
+ this.service = service;
+ }
+
+
+ @Override
+ protected Map<Integer, Boat> execute(int startIndex, int endIndex, SortConstraint orderBy) throws WaoException {
+ if (log.isInfoEnabled()) {
+ log.info("BUSINESS REQUEST [getBoatsByFilter]");
+ }
+ filter.setStartIndex(startIndex);
+ filter.setEndIndex(endIndex);
+
+ if (orderBy != null) {
+ PropertyModel property = orderBy.getPropertyModel();
+ String filterOrder = property.getPropertyName();
+
+ ColumnSort sort = orderBy.getColumnSort();
+ if (sort.equals(ColumnSort.DESCENDING)) {
+ filterOrder += " desc";
+ }
+
+ if (log.isDebugEnabled()) {
+ log.debug("Order : " + filterOrder);
+ }
+ filter.setOrderBy(filterOrder);
+ }
+
+ return service.getBoatsByFilter(filter);
+ }
+
+ @Override
+ protected int count() throws WaoException {
+ if (log.isInfoEnabled()) {
+ log.info("BUSINESS REQUEST [getNbBoatsByFilter]");
+ }
+ return service.getNbBoatsByFilter(filter);
+ }
+
+ @Override
+ public Class<?> getRowType() {
+ return Boat.class;
+ }
+
+}
Deleted: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/data/BusinessUtils.java
===================================================================
--- trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/data/BusinessUtils.java 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/data/BusinessUtils.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,148 +0,0 @@
-/*
- * *##%
- * SuiviObsmer :: Web Interface
- * 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.suiviobsmer.ui.data;
-
-import fr.ifremer.suiviobsmer.bean.ContactState;
-import fr.ifremer.suiviobsmer.bean.SamplingFilter;
-import fr.ifremer.suiviobsmer.entity.Boat;
-import fr.ifremer.suiviobsmer.entity.Contact;
-import fr.ifremer.suiviobsmer.entity.FishingZone;
-import fr.ifremer.suiviobsmer.entity.Profession;
-import fr.ifremer.suiviobsmer.entity.SampleRow;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import org.apache.commons.lang.BooleanUtils;
-import org.apache.commons.lang.StringUtils;
-
-/**
- * DataUtils
- *
- * Created: 3 déc. 2009
- *
- * @author fdesbois
- * @version $Revision$
- *
- * Mise a jour: $Date$
- * par : $Author$
- */
-public class BusinessUtils {
-
-
- public static String getTooltipSampleRow(SampleRow row) {
- String result = "";
- DateFormat dateFormat = new SimpleDateFormat("MM/yyyy");
- Profession profession = row.getProfession();
- result += "<strong>Métier : </strong>" + profession.getCodeDCF5();
- if (!StringUtils.isEmpty(profession.getMeshSize())) {
- result+= " " + profession.getMeshSize();
- }
- if (!StringUtils.isEmpty(profession.getSize())) {
- result+= " " + profession.getSize();
- }
- if (!StringUtils.isEmpty(profession.getOther())) {
- result+= " " + profession.getOther();
- }
- result += " - " + profession.getLibelle();
- if (!StringUtils.isEmpty(profession.getSpecies())) {
- result += "<br /><strong>Espèces cibles : </strong>" + profession.getSpecies();
- }
- result += "<br /><strong>Programme : </strong>" + row.getProgramName();
- result += "<br /><strong>Période : </strong> du " + dateFormat.format(row.getPeriodBegin()) +
- " au " + dateFormat.format(row.getPeriodEnd());
-
- for (FishingZone zone : row.getFishingZone()) {
- result += "<br /><strong>Zone de pêche : </strong>" + zone.getCode();
- }
-
- return result;
- }
-
- public static String getTooltipBoat(Boat boat) {
- String result = "";
- result += "<strong>" + boat.getImmatriculation() + "</strong>";
- result += "<br /><strong>Quartier : </strong>" + boat.getDistrictCode();
- result += "<br /><strong>Longueur : </strong>" + boat.getBoatLength() + " m";
- result += "<br /><strong>Année de construction : </strong>" + boat.getBuildYear();
- return result;
- }
-
- public static String getDataSamplingTitle(SamplingFilter filter) {
- String result = "Données des marées";
- boolean filtered = false;
- if (filter.getCompany() != null) {
- //result += !filtered ? " : " : ", ";
- result += " :\nSociété " + filter.getCompany().getName();
- filtered = true;
- }
- if (StringUtils.isNotEmpty(filter.getProgramName())) {
- result += !filtered ? " : " : ", ";
- result += "\nProgramme " + filter.getProgramName();
- filtered = true;
- }
- if (filter.getSampleRow() != null) {
- Profession profession = filter.getSampleRow().getProfession();
- result += !filtered ? " : " : ", ";
- result += "\nMétier " + profession.getCode();
- result += StringUtils.isNotEmpty(profession.getLibelle()) ? " - " + profession.getLibelle() : "";
- result += StringUtils.isNotEmpty(profession.getSpecies()) ? "\nEspèces (" + profession.getSpecies() + ")" : "";
- result += "\nZones de pêche (";
- for (FishingZone zone : filter.getSampleRow().getFishingZone()) {
- result += zone.getDistrictCode() + " ";
- }
- result += ")";
- filtered = true;
- } else {
- if (filter.getFacadeName() != null) {
- result += !filtered ? " : " : ", ";
- result += "\nFaçade " + filter.getFacadeName();
- filtered = true;
- }
- if (filter.getSectorName() != null) {
- result += !filtered ? " : " : ", ";
- result += "\nZone " + filter.getSectorName();
- //filtered = true;
- }
- }
- return result;
- }
-
- public static String getContactStyle(Contact contact, boolean admin) {
- String result = "";
- boolean accepted = BooleanUtils.isTrue(contact.getValidationProgram()) ||
- (!admin && BooleanUtils.isTrue(contact.getValidationCompany()));
-
- ContactState state = ContactState.createContactStateEnum(contact.getState());
- if (BooleanUtils.isFalse(contact.getValidationProgram()) ||
- (!admin && BooleanUtils.isFalse(contact.getValidationCompany()))) {
- result = "refused";
- } else if (accepted && state.equals(ContactState.BOARDING_DONE)) {
- result = "accepted";
- } else if (accepted && state.isUnfinishedState()) {
- result = "unfinished";
- } else if (state.isFinalState()) {
- result = "even";
- } else {
- result = "odd";
- }
- return result;
- }
-}
Copied: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/data/BusinessUtils.java (from rev 354, trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/data/BusinessUtils.java)
===================================================================
--- trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/data/BusinessUtils.java (rev 0)
+++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/data/BusinessUtils.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -0,0 +1,148 @@
+/*
+ * *##%
+ * Wao :: Web Interface
+ * 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.ui.data;
+
+import fr.ifremer.wao.bean.ContactState;
+import fr.ifremer.wao.bean.SamplingFilter;
+import fr.ifremer.wao.entity.Boat;
+import fr.ifremer.wao.entity.Contact;
+import fr.ifremer.wao.entity.FishingZone;
+import fr.ifremer.wao.entity.Profession;
+import fr.ifremer.wao.entity.SampleRow;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import org.apache.commons.lang.BooleanUtils;
+import org.apache.commons.lang.StringUtils;
+
+/**
+ * DataUtils
+ *
+ * Created: 3 déc. 2009
+ *
+ * @author fdesbois
+ * @version $Revision$
+ *
+ * Mise a jour: $Date$
+ * par : $Author$
+ */
+public class BusinessUtils {
+
+
+ public static String getTooltipSampleRow(SampleRow row) {
+ String result = "";
+ DateFormat dateFormat = new SimpleDateFormat("MM/yyyy");
+ Profession profession = row.getProfession();
+ result += "<strong>Métier : </strong>" + profession.getCodeDCF5();
+ if (!StringUtils.isEmpty(profession.getMeshSize())) {
+ result+= " " + profession.getMeshSize();
+ }
+ if (!StringUtils.isEmpty(profession.getSize())) {
+ result+= " " + profession.getSize();
+ }
+ if (!StringUtils.isEmpty(profession.getOther())) {
+ result+= " " + profession.getOther();
+ }
+ result += " - " + profession.getLibelle();
+ if (!StringUtils.isEmpty(profession.getSpecies())) {
+ result += "<br /><strong>Espèces cibles : </strong>" + profession.getSpecies();
+ }
+ result += "<br /><strong>Programme : </strong>" + row.getProgramName();
+ result += "<br /><strong>Période : </strong> du " + dateFormat.format(row.getPeriodBegin()) +
+ " au " + dateFormat.format(row.getPeriodEnd());
+
+ for (FishingZone zone : row.getFishingZone()) {
+ result += "<br /><strong>Zone de pêche : </strong>" + zone.getCode();
+ }
+
+ return result;
+ }
+
+ public static String getTooltipBoat(Boat boat) {
+ String result = "";
+ result += "<strong>" + boat.getImmatriculation() + "</strong>";
+ result += "<br /><strong>Quartier : </strong>" + boat.getDistrictCode();
+ result += "<br /><strong>Longueur : </strong>" + boat.getBoatLength() + " m";
+ result += "<br /><strong>Année de construction : </strong>" + boat.getBuildYear();
+ return result;
+ }
+
+ public static String getDataSamplingTitle(SamplingFilter filter) {
+ String result = "Données des marées";
+ boolean filtered = false;
+ if (filter.getCompany() != null) {
+ //result += !filtered ? " : " : ", ";
+ result += " :\nSociété " + filter.getCompany().getName();
+ filtered = true;
+ }
+ if (StringUtils.isNotEmpty(filter.getProgramName())) {
+ result += !filtered ? " : " : ", ";
+ result += "\nProgramme " + filter.getProgramName();
+ filtered = true;
+ }
+ if (filter.getSampleRow() != null) {
+ Profession profession = filter.getSampleRow().getProfession();
+ result += !filtered ? " : " : ", ";
+ result += "\nMétier " + profession.getCode();
+ result += StringUtils.isNotEmpty(profession.getLibelle()) ? " - " + profession.getLibelle() : "";
+ result += StringUtils.isNotEmpty(profession.getSpecies()) ? "\nEspèces (" + profession.getSpecies() + ")" : "";
+ result += "\nZones de pêche (";
+ for (FishingZone zone : filter.getSampleRow().getFishingZone()) {
+ result += zone.getDistrictCode() + " ";
+ }
+ result += ")";
+ filtered = true;
+ } else {
+ if (filter.getFacadeName() != null) {
+ result += !filtered ? " : " : ", ";
+ result += "\nFaçade " + filter.getFacadeName();
+ filtered = true;
+ }
+ if (filter.getSectorName() != null) {
+ result += !filtered ? " : " : ", ";
+ result += "\nZone " + filter.getSectorName();
+ //filtered = true;
+ }
+ }
+ return result;
+ }
+
+ public static String getContactStyle(Contact contact, boolean admin) {
+ String result = "";
+ boolean accepted = BooleanUtils.isTrue(contact.getValidationProgram()) ||
+ (!admin && BooleanUtils.isTrue(contact.getValidationCompany()));
+
+ ContactState state = ContactState.createContactStateEnum(contact.getState());
+ if (BooleanUtils.isFalse(contact.getValidationProgram()) ||
+ (!admin && BooleanUtils.isFalse(contact.getValidationCompany()))) {
+ result = "refused";
+ } else if (accepted && state.equals(ContactState.BOARDING_DONE)) {
+ result = "accepted";
+ } else if (accepted && state.isUnfinishedState()) {
+ result = "unfinished";
+ } else if (state.isFinalState()) {
+ result = "even";
+ } else {
+ result = "odd";
+ }
+ return result;
+ }
+}
Deleted: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/data/ChartUtils.java
===================================================================
--- trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/data/ChartUtils.java 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/data/ChartUtils.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,123 +0,0 @@
-/*
- * *##%
- * SuiviObsmer :: Web Interface
- * 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.suiviobsmer.ui.data;
-
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.Map;
-import org.jfree.chart.JFreeChart;
-import org.jfree.chart.axis.CategoryAxis;
-import org.jfree.chart.axis.CategoryLabelPositions;
-import org.jfree.chart.axis.NumberAxis;
-import org.jfree.chart.axis.ValueAxis;
-import org.jfree.chart.labels.StandardCategoryItemLabelGenerator;
-import org.jfree.chart.plot.CategoryPlot;
-import org.jfree.chart.plot.PlotOrientation;
-import org.jfree.chart.renderer.category.AbstractCategoryItemRenderer;
-import org.jfree.chart.renderer.category.AreaRenderer;
-import org.jfree.chart.renderer.category.BarRenderer;
-import org.jfree.chart.renderer.category.LineAndShapeRenderer;
-import org.jfree.data.category.DefaultCategoryDataset;
-import org.jfree.ui.RectangleInsets;
-
-/**
- * ChartUtils
- *
- * Created: 13 janv. 2010
- *
- * @author fdesbois
- * @version $Revision$
- *
- * Mise a jour: $Date$
- * par : $Author$
- */
-public class ChartUtils {
-
- public enum ChartType {
- BAR(BarRenderer.class, false), LINE(LineAndShapeRenderer.class, true), AREA(AreaRenderer.class, true);
-
- protected Class<? extends AbstractCategoryItemRenderer> rendererClass;
-
- protected boolean noCategoryMargin;
-
- ChartType(Class<? extends AbstractCategoryItemRenderer> rendererClass, boolean noCategoryMargin) {
- this.rendererClass = rendererClass;
- this.noCategoryMargin = noCategoryMargin;
- }
-
- public AbstractCategoryItemRenderer createRenderer() {
- try {
- return rendererClass.newInstance();
- } catch (Exception eee) {
- // will never happens
- throw new RuntimeException(eee);
- }
- }
- }
-
-
- public static JFreeChart createCategoryChart(String title, String axisName, String categoryName, ChartType type,
- Map<String, Map<?, Integer>> input) {
- DateFormat format = new SimpleDateFormat("MM/yyyy");
- boolean dateType = false;
-
- DefaultCategoryDataset dataset = new DefaultCategoryDataset();
-
- // Fill data in dataset
- for (Map.Entry<String, Map<?, Integer>> map : input.entrySet()) {
- for (Map.Entry<?, Integer> data : map.getValue().entrySet()) {
- Object dataKey = data.getKey();
- String columnKey = "";
- if (Date.class.isAssignableFrom(dataKey.getClass())) {
- columnKey = format.format((Date)dataKey);
- dateType = true;
- } else {
- columnKey = dataKey.toString();
- }
- dataset.setValue(data.getValue(), map.getKey(), columnKey);
- }
- }
-
- // Axises
- CategoryAxis categoryAxis = new CategoryAxis(categoryName);
- if (dateType) {
- categoryAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90);
- }
- if (type.noCategoryMargin) {
- categoryAxis.setCategoryMargin(0);
- }
- ValueAxis valueAxis = new NumberAxis(axisName);
- valueAxis.setUpperMargin(0.15);
-
- // Renderer for Category
- AbstractCategoryItemRenderer renderer = type.createRenderer();
- // Show labels on each element
- renderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());
- renderer.setBaseItemLabelsVisible(Boolean.TRUE);
-
- CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis, renderer);
- plot.setOrientation(PlotOrientation.VERTICAL);
- plot.setAxisOffset(RectangleInsets.ZERO_INSETS);
- return new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, true);
- }
-}
Copied: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/data/ChartUtils.java (from rev 354, trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/data/ChartUtils.java)
===================================================================
--- trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/data/ChartUtils.java (rev 0)
+++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/data/ChartUtils.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -0,0 +1,123 @@
+/*
+ * *##%
+ * Wao :: Web Interface
+ * 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.ui.data;
+
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Map;
+import org.jfree.chart.JFreeChart;
+import org.jfree.chart.axis.CategoryAxis;
+import org.jfree.chart.axis.CategoryLabelPositions;
+import org.jfree.chart.axis.NumberAxis;
+import org.jfree.chart.axis.ValueAxis;
+import org.jfree.chart.labels.StandardCategoryItemLabelGenerator;
+import org.jfree.chart.plot.CategoryPlot;
+import org.jfree.chart.plot.PlotOrientation;
+import org.jfree.chart.renderer.category.AbstractCategoryItemRenderer;
+import org.jfree.chart.renderer.category.AreaRenderer;
+import org.jfree.chart.renderer.category.BarRenderer;
+import org.jfree.chart.renderer.category.LineAndShapeRenderer;
+import org.jfree.data.category.DefaultCategoryDataset;
+import org.jfree.ui.RectangleInsets;
+
+/**
+ * ChartUtils
+ *
+ * Created: 13 janv. 2010
+ *
+ * @author fdesbois
+ * @version $Revision$
+ *
+ * Mise a jour: $Date$
+ * par : $Author$
+ */
+public class ChartUtils {
+
+ public enum ChartType {
+ BAR(BarRenderer.class, false), LINE(LineAndShapeRenderer.class, true), AREA(AreaRenderer.class, true);
+
+ protected Class<? extends AbstractCategoryItemRenderer> rendererClass;
+
+ protected boolean noCategoryMargin;
+
+ ChartType(Class<? extends AbstractCategoryItemRenderer> rendererClass, boolean noCategoryMargin) {
+ this.rendererClass = rendererClass;
+ this.noCategoryMargin = noCategoryMargin;
+ }
+
+ public AbstractCategoryItemRenderer createRenderer() {
+ try {
+ return rendererClass.newInstance();
+ } catch (Exception eee) {
+ // will never happens
+ throw new RuntimeException(eee);
+ }
+ }
+ }
+
+
+ public static JFreeChart createCategoryChart(String title, String axisName, String categoryName, ChartType type,
+ Map<String, Map<?, Integer>> input) {
+ DateFormat format = new SimpleDateFormat("MM/yyyy");
+ boolean dateType = false;
+
+ DefaultCategoryDataset dataset = new DefaultCategoryDataset();
+
+ // Fill data in dataset
+ for (Map.Entry<String, Map<?, Integer>> map : input.entrySet()) {
+ for (Map.Entry<?, Integer> data : map.getValue().entrySet()) {
+ Object dataKey = data.getKey();
+ String columnKey = "";
+ if (Date.class.isAssignableFrom(dataKey.getClass())) {
+ columnKey = format.format((Date)dataKey);
+ dateType = true;
+ } else {
+ columnKey = dataKey.toString();
+ }
+ dataset.setValue(data.getValue(), map.getKey(), columnKey);
+ }
+ }
+
+ // Axises
+ CategoryAxis categoryAxis = new CategoryAxis(categoryName);
+ if (dateType) {
+ categoryAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90);
+ }
+ if (type.noCategoryMargin) {
+ categoryAxis.setCategoryMargin(0);
+ }
+ ValueAxis valueAxis = new NumberAxis(axisName);
+ valueAxis.setUpperMargin(0.15);
+
+ // Renderer for Category
+ AbstractCategoryItemRenderer renderer = type.createRenderer();
+ // Show labels on each element
+ renderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());
+ renderer.setBaseItemLabelsVisible(Boolean.TRUE);
+
+ CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis, renderer);
+ plot.setOrientation(PlotOrientation.VERTICAL);
+ plot.setAxisOffset(RectangleInsets.ZERO_INSETS);
+ return new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, true);
+ }
+}
Deleted: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/data/ContactDataSource.java
===================================================================
--- trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/data/ContactDataSource.java 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/data/ContactDataSource.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,60 +0,0 @@
-
-package fr.ifremer.suiviobsmer.ui.data;
-
-import fr.ifremer.suiviobsmer.SuiviObsmerException;
-import fr.ifremer.suiviobsmer.bean.ContactFilter;
-import fr.ifremer.suiviobsmer.entity.Contact;
-import fr.ifremer.suiviobsmer.services.ServiceContact;
-import java.util.Map;
-import org.apache.tapestry5.grid.SortConstraint;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * ContactDataSource
- *
- * Created: 18 janv. 2010
- *
- * @author fdesbois
- * @version $Revision$
- *
- * Mise a jour: $Date$
- * par : $Author$
- */
-public class ContactDataSource extends AbstractMappedGridDataSource<String, Contact> {
-
- private static Logger log = LoggerFactory.getLogger(ContactDataSource.class);
-
- private ContactFilter filter;
-
- private ServiceContact serviceContact;
-
- public ContactDataSource(ContactFilter filter, ServiceContact service) {
- this.filter = filter;
- serviceContact = service;
- }
-
- @Override
- public Class<?> getRowType() {
- return Contact.class;
- }
-
- @Override
- protected Map<String, Contact> execute(int startIndex, int endIndex, SortConstraint orderBy) throws SuiviObsmerException {
- if (log.isInfoEnabled()) {
- log.info("BUSINESS REQUEST [getContactsByFilter]");
- }
- filter.setStartIndex(startIndex);
- filter.setEndIndex(endIndex);
- return serviceContact.getContacts(filter);
- }
-
- @Override
- protected int count() throws SuiviObsmerException {
- if (log.isInfoEnabled()) {
- log.info("BUSINESS REQUEST [getNbContacts]");
- }
- return serviceContact.getNbContacts(filter);
- }
-
-}
Copied: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/data/ContactDataSource.java (from rev 354, trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/data/ContactDataSource.java)
===================================================================
--- trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/data/ContactDataSource.java (rev 0)
+++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/data/ContactDataSource.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -0,0 +1,80 @@
+/*
+ * *##%
+ * Wao :: Web Interface
+ * 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.ui.data;
+
+import fr.ifremer.wao.WaoException;
+import fr.ifremer.wao.bean.ContactFilter;
+import fr.ifremer.wao.entity.Contact;
+import fr.ifremer.wao.service.ServiceContact;
+import java.util.Map;
+import org.apache.tapestry5.grid.SortConstraint;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * ContactDataSource
+ *
+ * Created: 18 janv. 2010
+ *
+ * @author fdesbois
+ * @version $Revision$
+ *
+ * Mise a jour: $Date$
+ * par : $Author$
+ */
+public class ContactDataSource extends AbstractMappedGridDataSource<String, Contact> {
+
+ private static Logger log = LoggerFactory.getLogger(ContactDataSource.class);
+
+ private ContactFilter filter;
+
+ private ServiceContact serviceContact;
+
+ public ContactDataSource(ContactFilter filter, ServiceContact service) {
+ this.filter = filter;
+ serviceContact = service;
+ }
+
+ @Override
+ public Class<?> getRowType() {
+ return Contact.class;
+ }
+
+ @Override
+ protected Map<String, Contact> execute(int startIndex, int endIndex, SortConstraint orderBy) throws WaoException {
+ if (log.isInfoEnabled()) {
+ log.info("BUSINESS REQUEST [getContactsByFilter]");
+ }
+ filter.setStartIndex(startIndex);
+ filter.setEndIndex(endIndex);
+ return serviceContact.getContacts(filter);
+ }
+
+ @Override
+ protected int count() throws WaoException {
+ if (log.isInfoEnabled()) {
+ log.info("BUSINESS REQUEST [getNbContacts]");
+ }
+ return serviceContact.getNbContacts(filter);
+ }
+
+}
Deleted: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/data/ExportStreamResponse.java
===================================================================
--- trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/data/ExportStreamResponse.java 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/data/ExportStreamResponse.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,57 +0,0 @@
-
-package fr.ifremer.suiviobsmer.ui.data;
-
-import fr.ifremer.suiviobsmer.SuiviObsmerContext;
-import java.util.Date;
-import org.apache.tapestry5.StreamResponse;
-import org.apache.tapestry5.services.Response;
-import org.nuiton.util.DateUtils;
-
-/**
- * Used to render CSV file from data export.
- *
- * Created: 2 févr. 2010
- *
- * @author fdesbois
- * @version $Revision$
- *
- * Mise a jour: $Date$
- * par : $Author$
- */
-public abstract class ExportStreamResponse implements StreamResponse {
-
- protected String filename;
-
- /**
- * Constructor with filename prefix for resulting file in response.
- *
- * @param filename prefix
- */
- public ExportStreamResponse(String filename) {
- this.filename = filename;
- }
-
- /**
- * Export only for CSV file with UTF-8 encoding.
- *
- * @return the contentType string
- */
- @Override
- public String getContentType() {
- return "text/csv;charset=utf-8";
- }
-
- /**
- * Prepare response for rendering result file with date in filename.
- *
- * @param response to prepare
- */
- @Override
- public void prepareResponse(Response response) {
- Date current = SuiviObsmerContext.getCurrentDate();
- filename += "-" + DateUtils.formatDate(current, "dd-MM-yyyy") + ".csv";
- response.setHeader("Content-Disposition",
- "attachment; filename=\"" + filename +"\"");
- }
-
-}
Copied: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/data/ExportStreamResponse.java (from rev 354, trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/data/ExportStreamResponse.java)
===================================================================
--- trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/data/ExportStreamResponse.java (rev 0)
+++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/data/ExportStreamResponse.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -0,0 +1,77 @@
+/*
+ * *##%
+ * Wao :: Web Interface
+ * 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.ui.data;
+
+import fr.ifremer.wao.WaoContext;
+import java.util.Date;
+import org.apache.tapestry5.StreamResponse;
+import org.apache.tapestry5.services.Response;
+import org.nuiton.util.DateUtils;
+
+/**
+ * Used to render CSV file from data export.
+ *
+ * Created: 2 févr. 2010
+ *
+ * @author fdesbois
+ * @version $Revision$
+ *
+ * Mise a jour: $Date$
+ * par : $Author$
+ */
+public abstract class ExportStreamResponse implements StreamResponse {
+
+ protected String filename;
+
+ /**
+ * Constructor with filename prefix for resulting file in response.
+ *
+ * @param filename prefix
+ */
+ public ExportStreamResponse(String filename) {
+ this.filename = filename;
+ }
+
+ /**
+ * Export only for CSV file with UTF-8 encoding.
+ *
+ * @return the contentType string
+ */
+ @Override
+ public String getContentType() {
+ return "text/csv;charset=utf-8";
+ }
+
+ /**
+ * Prepare response for rendering result file with date in filename.
+ *
+ * @param response to prepare
+ */
+ @Override
+ public void prepareResponse(Response response) {
+ Date current = WaoContext.getCurrentDate();
+ filename += "-" + DateUtils.formatDate(current, "dd-MM-yyyy") + ".csv";
+ response.setHeader("Content-Disposition",
+ "attachment; filename=\"" + filename +"\"");
+ }
+
+}
Deleted: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/data/SuiviObsmerPropertyChangeListener.java
===================================================================
--- trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/data/SuiviObsmerPropertyChangeListener.java 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/data/SuiviObsmerPropertyChangeListener.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,81 +0,0 @@
-/*
- * *##%
- * SuiviObsmer :: Web Interface
- * 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.suiviobsmer.ui.data;
-
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-import java.util.HashMap;
-import java.util.Map;
-import org.nuiton.topia.persistence.TopiaEntity;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * BoatInfosPropertyChangeListener
- *
- * Created: 18 nov. 2009
- *
- * @author fdesbois
- * @version $Revision$
- *
- * Mise a jour: $Date$
- * par : $Author$
- */
-public class SuiviObsmerPropertyChangeListener implements PropertyChangeListener {
-
- private static final Logger log = LoggerFactory.getLogger(SuiviObsmerPropertyChangeListener.class);
-
- //private boolean changed;
-
- private Map<String, Object> data;
-
- @Override
- public void propertyChange(PropertyChangeEvent evt) {
- if (log.isDebugEnabled()) {
- log.debug("property change : old = " + evt.getOldValue() +
- " _ new = " + evt.getNewValue());
- }
- TopiaEntity entity = (TopiaEntity)evt.getSource();
- getData().put(entity.getTopiaId(), entity);
- }
-
- protected Map<String, Object> getData() {
- if (data == null) {
- data = new HashMap<String, Object>();
- }
- return data;
- }
-
- public boolean hasChanged(String topiaId) {
-
- if (log.isTraceEnabled()) {
- log.trace("data size : " + getData().size());
- }
-
- return getData().containsKey(topiaId);
- }
-
- public void reset() {
- data = null;
- }
-
-}
Deleted: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/data/SynthesisId.java
===================================================================
--- trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/data/SynthesisId.java 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/data/SynthesisId.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,45 +0,0 @@
-package fr.ifremer.suiviobsmer.ui.data;
-
-/**
- * SynthesisID$
- *
- * Created: 9 févr. 2010
- *
- * @author fdesbois
- * @version $Revision$
- *
- * Mise a jour: $Date$
- * par : $Author$
- */
-public enum SynthesisId {
-
- GRAPH_SAMPLING("graph1"),
- GRAPH_BOARDING("graph2"),
- IND_NON_COMPLIANCE_BOARDING("ind1"),
- IND_CONTACT_STATE("ind2"),
- IND_ALLEGRO_REACTIVITY("ind3");
- private String blockId;
-
- SynthesisId(String blockId) {
- this.blockId = blockId;
- }
-
- public String getBlockId() {
- return blockId;
- }
-
- public static SynthesisId getSynthesisID(String blockId) {
- if (blockId.equals(GRAPH_SAMPLING.getBlockId())) {
- return GRAPH_SAMPLING;
- } else if (blockId.equals(GRAPH_BOARDING.getBlockId())) {
- return GRAPH_BOARDING;
- } else if (blockId.equals(IND_CONTACT_STATE.getBlockId())) {
- return IND_CONTACT_STATE;
- } else if (blockId.equals(IND_NON_COMPLIANCE_BOARDING.getBlockId())) {
- return IND_NON_COMPLIANCE_BOARDING;
- } else if (blockId.equals(IND_ALLEGRO_REACTIVITY.getBlockId())) {
- return IND_ALLEGRO_REACTIVITY;
- }
- return null;
- }
-}
Copied: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/data/SynthesisId.java (from rev 354, trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/data/SynthesisId.java)
===================================================================
--- trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/data/SynthesisId.java (rev 0)
+++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/data/SynthesisId.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -0,0 +1,65 @@
+/*
+ * *##%
+ * Wao :: Web Interface
+ * 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.ui.data;
+
+/**
+ * SynthesisID$
+ *
+ * Created: 9 févr. 2010
+ *
+ * @author fdesbois
+ * @version $Revision$
+ *
+ * Mise a jour: $Date$
+ * par : $Author$
+ */
+public enum SynthesisId {
+
+ GRAPH_SAMPLING("graph1"),
+ GRAPH_BOARDING("graph2"),
+ IND_NON_COMPLIANCE_BOARDING("ind1"),
+ IND_CONTACT_STATE("ind2"),
+ IND_ALLEGRO_REACTIVITY("ind3");
+ private String blockId;
+
+ SynthesisId(String blockId) {
+ this.blockId = blockId;
+ }
+
+ public String getBlockId() {
+ return blockId;
+ }
+
+ public static SynthesisId getSynthesisID(String blockId) {
+ if (blockId.equals(GRAPH_SAMPLING.getBlockId())) {
+ return GRAPH_SAMPLING;
+ } else if (blockId.equals(GRAPH_BOARDING.getBlockId())) {
+ return GRAPH_BOARDING;
+ } else if (blockId.equals(IND_CONTACT_STATE.getBlockId())) {
+ return IND_CONTACT_STATE;
+ } else if (blockId.equals(IND_NON_COMPLIANCE_BOARDING.getBlockId())) {
+ return IND_NON_COMPLIANCE_BOARDING;
+ } else if (blockId.equals(IND_ALLEGRO_REACTIVITY.getBlockId())) {
+ return IND_ALLEGRO_REACTIVITY;
+ }
+ return null;
+ }
+}
Copied: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/data/WaoPropertyChangeListener.java (from rev 354, trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/data/WaoPropertyChangeListener.java)
===================================================================
--- trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/data/WaoPropertyChangeListener.java (rev 0)
+++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/data/WaoPropertyChangeListener.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -0,0 +1,81 @@
+/*
+ * *##%
+ * Wao :: Web Interface
+ * 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.ui.data;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.util.HashMap;
+import java.util.Map;
+import org.nuiton.topia.persistence.TopiaEntity;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * BoatInfosPropertyChangeListener
+ *
+ * Created: 18 nov. 2009
+ *
+ * @author fdesbois
+ * @version $Revision$
+ *
+ * Mise a jour: $Date$
+ * par : $Author$
+ */
+public class WaoPropertyChangeListener implements PropertyChangeListener {
+
+ private static final Logger log = LoggerFactory.getLogger(WaoPropertyChangeListener.class);
+
+ //private boolean changed;
+
+ private Map<String, Object> data;
+
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+ if (log.isDebugEnabled()) {
+ log.debug("property change : old = " + evt.getOldValue() +
+ " _ new = " + evt.getNewValue());
+ }
+ TopiaEntity entity = (TopiaEntity)evt.getSource();
+ getData().put(entity.getTopiaId(), entity);
+ }
+
+ protected Map<String, Object> getData() {
+ if (data == null) {
+ data = new HashMap<String, Object>();
+ }
+ return data;
+ }
+
+ public boolean hasChanged(String topiaId) {
+
+ if (log.isTraceEnabled()) {
+ log.trace("data size : " + getData().size());
+ }
+
+ return getData().containsKey(topiaId);
+ }
+
+ public void reset() {
+ data = null;
+ }
+
+}
Deleted: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/mixins/Confirm.java
===================================================================
--- trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/mixins/Confirm.java 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/mixins/Confirm.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,67 +0,0 @@
-/**
- * *##%
- * SuiviObsmer :: Web Interface
- * 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.suiviobsmer.ui.mixins;
-
-import org.apache.tapestry5.BindingConstants;
-import org.apache.tapestry5.ClientElement;
-import org.apache.tapestry5.RenderSupport;
-import org.apache.tapestry5.annotations.AfterRender;
-import org.apache.tapestry5.annotations.IncludeJavaScriptLibrary;
-import org.apache.tapestry5.annotations.InjectContainer;
-import org.apache.tapestry5.annotations.Parameter;
-import org.apache.tapestry5.ioc.annotations.Inject;
-
-/**
- * Confirm.java
- *
- * A simple mixin for attaching a javascript confirmation box to the onclick
- * event of any component that implements ClientElement.
- *
- * @author fdesbois
- * @version $Revision: 3 $
- *
- * Last update: $Date: 2009-07-31 16:54:15 +0200 (ven. 31 juil. 2009) $
- * by : $Author: fdesbois $
- */
- at IncludeJavaScriptLibrary("context:js/dialog.js")
-public class Confirm {
-
- @Parameter(value = "Are you sure?", defaultPrefix = BindingConstants.LITERAL)
- private String message;
-
- @Inject
- private RenderSupport renderSupport;
-
- @InjectContainer
- private ClientElement element;
-
- @Parameter
- private boolean wDisabled;
-
- @AfterRender
- public void afterRender() {
- if (!wDisabled) {
- renderSupport.addScript(String.format("new Confirm('%s', '%s');",element.getClientId(), message));
- }
- }
-
-}
Copied: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/mixins/Confirm.java (from rev 354, trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/mixins/Confirm.java)
===================================================================
--- trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/mixins/Confirm.java (rev 0)
+++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/mixins/Confirm.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -0,0 +1,67 @@
+/**
+ * *##%
+ * Wao :: Web Interface
+ * 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.ui.mixins;
+
+import org.apache.tapestry5.BindingConstants;
+import org.apache.tapestry5.ClientElement;
+import org.apache.tapestry5.RenderSupport;
+import org.apache.tapestry5.annotations.AfterRender;
+import org.apache.tapestry5.annotations.IncludeJavaScriptLibrary;
+import org.apache.tapestry5.annotations.InjectContainer;
+import org.apache.tapestry5.annotations.Parameter;
+import org.apache.tapestry5.ioc.annotations.Inject;
+
+/**
+ * Confirm.java
+ *
+ * A simple mixin for attaching a javascript confirmation box to the onclick
+ * event of any component that implements ClientElement.
+ *
+ * @author fdesbois
+ * @version $Revision: 3 $
+ *
+ * Last update: $Date: 2009-07-31 16:54:15 +0200 (ven. 31 juil. 2009) $
+ * by : $Author: fdesbois $
+ */
+ at IncludeJavaScriptLibrary("context:js/dialog.js")
+public class Confirm {
+
+ @Parameter(value = "Are you sure?", defaultPrefix = BindingConstants.LITERAL)
+ private String message;
+
+ @Inject
+ private RenderSupport renderSupport;
+
+ @InjectContainer
+ private ClientElement element;
+
+ @Parameter
+ private boolean wDisabled;
+
+ @AfterRender
+ public void afterRender() {
+ if (!wDisabled) {
+ renderSupport.addScript(String.format("new Confirm('%s', '%s');",element.getClientId(), message));
+ }
+ }
+
+}
Deleted: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/mixins/PopupPageLink.java
===================================================================
--- trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/mixins/PopupPageLink.java 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/mixins/PopupPageLink.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,109 +0,0 @@
-/*
- * *##%
- * SuiviObsmer :: Web Interface
- * 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.suiviobsmer.ui.mixins;
-
-/**
- * PopupPageLink
- *
- * Created: 17 janv. 2010
- *
- * @author fdesbois
- * @version $Revision$
- *
- * Mise a jour: $Date$
- * par : $Author$
- */
-import org.apache.tapestry5.BindingConstants;
-
-import org.apache.tapestry5.ClientElement;
-
-import org.apache.tapestry5.ComponentResources;
-
-import org.apache.tapestry5.Link;
-
-import org.apache.tapestry5.RenderSupport;
-
-import org.apache.tapestry5.annotations.Environmental;
-
-import org.apache.tapestry5.annotations.IncludeJavaScriptLibrary;
-
-import org.apache.tapestry5.annotations.InjectContainer;
-
-import org.apache.tapestry5.annotations.Parameter;
-
-import org.apache.tapestry5.ioc.annotations.Inject;
-import org.apache.tapestry5.services.PageRenderLinkSource;
-
- at IncludeJavaScriptLibrary("context:js/dialog.js")
-
-public class PopupPageLink {
-
- @Inject
-
- private ComponentResources resources;
-
- @Environmental
-
- private RenderSupport renderSupport;
-
- @InjectContainer
-
- private ClientElement container;
-
- @Parameter(required = true, defaultPrefix = BindingConstants.LITERAL)
-
- private String page;
-
-
-
- @Parameter(defaultPrefix = BindingConstants.LITERAL, value="800")
-
- private String width;
-
-
-
- @Parameter(defaultPrefix = BindingConstants.LITERAL, value="600")
-
- private String height;
-
- @Parameter
-
- private Object[] context;
-
- @Inject
- private PageRenderLinkSource pageRender;
-
- void afterRender() {
- Link link = null;
- if (context != null) {
- link = pageRender.createPageRenderLinkWithContext(page, context);
- } else {
- link = pageRender.createPageRenderLink(page);
- }
-// Link link = null;
-// pageRender.createPageLink(page, true, context);
-
- renderSupport.addScript("new PopupPageLink('%s', '%s', %s, %s);", container.getClientId(), link, width, height);
-
- }
-
-}
Copied: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/mixins/PopupPageLink.java (from rev 354, trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/mixins/PopupPageLink.java)
===================================================================
--- trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/mixins/PopupPageLink.java (rev 0)
+++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/mixins/PopupPageLink.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -0,0 +1,109 @@
+/*
+ * *##%
+ * Wao :: Web Interface
+ * 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.ui.mixins;
+
+/**
+ * PopupPageLink
+ *
+ * Created: 17 janv. 2010
+ *
+ * @author fdesbois
+ * @version $Revision$
+ *
+ * Mise a jour: $Date$
+ * par : $Author$
+ */
+import org.apache.tapestry5.BindingConstants;
+
+import org.apache.tapestry5.ClientElement;
+
+import org.apache.tapestry5.ComponentResources;
+
+import org.apache.tapestry5.Link;
+
+import org.apache.tapestry5.RenderSupport;
+
+import org.apache.tapestry5.annotations.Environmental;
+
+import org.apache.tapestry5.annotations.IncludeJavaScriptLibrary;
+
+import org.apache.tapestry5.annotations.InjectContainer;
+
+import org.apache.tapestry5.annotations.Parameter;
+
+import org.apache.tapestry5.ioc.annotations.Inject;
+import org.apache.tapestry5.services.PageRenderLinkSource;
+
+ at IncludeJavaScriptLibrary("context:js/dialog.js")
+
+public class PopupPageLink {
+
+ @Inject
+
+ private ComponentResources resources;
+
+ @Environmental
+
+ private RenderSupport renderSupport;
+
+ @InjectContainer
+
+ private ClientElement container;
+
+ @Parameter(required = true, defaultPrefix = BindingConstants.LITERAL)
+
+ private String page;
+
+
+
+ @Parameter(defaultPrefix = BindingConstants.LITERAL, value="800")
+
+ private String width;
+
+
+
+ @Parameter(defaultPrefix = BindingConstants.LITERAL, value="600")
+
+ private String height;
+
+ @Parameter
+
+ private Object[] context;
+
+ @Inject
+ private PageRenderLinkSource pageRender;
+
+ void afterRender() {
+ Link link = null;
+ if (context != null) {
+ link = pageRender.createPageRenderLinkWithContext(page, context);
+ } else {
+ link = pageRender.createPageRenderLink(page);
+ }
+// Link link = null;
+// pageRender.createPageLink(page, true, context);
+
+ renderSupport.addScript("new PopupPageLink('%s', '%s', %s, %s);", container.getClientId(), link, width, height);
+
+ }
+
+}
Deleted: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/mixins/ZoneUpdater.java
===================================================================
--- trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/mixins/ZoneUpdater.java 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/mixins/ZoneUpdater.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,101 +0,0 @@
-/**
- * *##%
- * SuiviObsmer :: Web Interface
- * 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.suiviobsmer.ui.mixins;
-
-import org.apache.commons.lang.ArrayUtils;
-import org.apache.tapestry5.BindingConstants;
-import org.apache.tapestry5.ClientElement;
-import org.apache.tapestry5.ComponentResources;
-import org.apache.tapestry5.Link;
-import org.apache.tapestry5.RenderSupport;
-import org.apache.tapestry5.annotations.Environmental;
-import org.apache.tapestry5.annotations.IncludeJavaScriptLibrary;
-import org.apache.tapestry5.annotations.InjectContainer;
-import org.apache.tapestry5.annotations.Parameter;
-import org.apache.tapestry5.ioc.annotations.Inject;
-
-/**
- * ZoneUpdater.java
- *
- * From http://tinybits.blogspot.com/2009/05/update-zone-on-any-client-side-event.h… by ingesol
- *
- * @author ingesol
- * @version $Revision$
- *
- * Last update: $Date$
- * by : $Author: fdesbois $
- */
- at IncludeJavaScriptLibrary("context:js/ZoneUpdater.js")
-public class ZoneUpdater {
-
- public static final String PLACEHOLDER = "XXX";
-
- @Inject
- private ComponentResources resources;
-
- @Environmental
- private RenderSupport renderSupport;
-
- @Parameter(defaultPrefix = BindingConstants.LITERAL)
- private String clientEvent;
-
- @Parameter(defaultPrefix = BindingConstants.LITERAL, required = true)
- private String event;
-
- @InjectContainer
- private ClientElement element;
-
- @Parameter
- private Object[] context;
-
- @Parameter(defaultPrefix = BindingConstants.LITERAL)
- // To enable popups to fire events on this document, enter "document" here.
- private String listeningElement;
-
- @Parameter(defaultPrefix = BindingConstants.LITERAL, required = true)
- private String zone;
-
- protected Link createLink(Object[] context) {
-
- if (context == null) {
- context = new Object[]{PLACEHOLDER};
- } else {
- context = ArrayUtils.add(context, PLACEHOLDER); // To be replaced by javascript
- }
-
- return resources.createEventLink(event, context);
-
- }
-
- void afterRender() {
- String link = createLink(context).toAbsoluteURI();
- String elementId = element.getClientId();
- if (clientEvent == null) {
- clientEvent = event;
- }
-
- if (listeningElement == null) {
- listeningElement = "$('" + elementId + "')";
- }
- renderSupport.addScript("new ZoneUpdater('%s', %s, '%s', '%s', '%s', '%s')", elementId, listeningElement, clientEvent, link, zone, PLACEHOLDER);
-
- }
-}
Copied: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/mixins/ZoneUpdater.java (from rev 354, trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/mixins/ZoneUpdater.java)
===================================================================
--- trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/mixins/ZoneUpdater.java (rev 0)
+++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/mixins/ZoneUpdater.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -0,0 +1,101 @@
+/**
+ * *##%
+ * Wao :: Web Interface
+ * 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.ui.mixins;
+
+import org.apache.commons.lang.ArrayUtils;
+import org.apache.tapestry5.BindingConstants;
+import org.apache.tapestry5.ClientElement;
+import org.apache.tapestry5.ComponentResources;
+import org.apache.tapestry5.Link;
+import org.apache.tapestry5.RenderSupport;
+import org.apache.tapestry5.annotations.Environmental;
+import org.apache.tapestry5.annotations.IncludeJavaScriptLibrary;
+import org.apache.tapestry5.annotations.InjectContainer;
+import org.apache.tapestry5.annotations.Parameter;
+import org.apache.tapestry5.ioc.annotations.Inject;
+
+/**
+ * ZoneUpdater.java
+ *
+ * From http://tinybits.blogspot.com/2009/05/update-zone-on-any-client-side-event.h… by ingesol
+ *
+ * @author ingesol
+ * @version $Revision$
+ *
+ * Last update: $Date$
+ * by : $Author: fdesbois $
+ */
+ at IncludeJavaScriptLibrary("context:js/ZoneUpdater.js")
+public class ZoneUpdater {
+
+ public static final String PLACEHOLDER = "XXX";
+
+ @Inject
+ private ComponentResources resources;
+
+ @Environmental
+ private RenderSupport renderSupport;
+
+ @Parameter(defaultPrefix = BindingConstants.LITERAL)
+ private String clientEvent;
+
+ @Parameter(defaultPrefix = BindingConstants.LITERAL, required = true)
+ private String event;
+
+ @InjectContainer
+ private ClientElement element;
+
+ @Parameter
+ private Object[] context;
+
+ @Parameter(defaultPrefix = BindingConstants.LITERAL)
+ // To enable popups to fire events on this document, enter "document" here.
+ private String listeningElement;
+
+ @Parameter(defaultPrefix = BindingConstants.LITERAL, required = true)
+ private String zone;
+
+ protected Link createLink(Object[] context) {
+
+ if (context == null) {
+ context = new Object[]{PLACEHOLDER};
+ } else {
+ context = ArrayUtils.add(context, PLACEHOLDER); // To be replaced by javascript
+ }
+
+ return resources.createEventLink(event, context);
+
+ }
+
+ void afterRender() {
+ String link = createLink(context).toAbsoluteURI();
+ String elementId = element.getClientId();
+ if (clientEvent == null) {
+ clientEvent = event;
+ }
+
+ if (listeningElement == null) {
+ listeningElement = "$('" + elementId + "')";
+ }
+ renderSupport.addScript("new ZoneUpdater('%s', %s, '%s', '%s', '%s', '%s')", elementId, listeningElement, clientEvent, link, zone, PLACEHOLDER);
+
+ }
+}
Deleted: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Administration.java
===================================================================
--- trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/Administration.java 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Administration.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,280 +0,0 @@
-/*
- * *##%
- * SuiviObsmer :: Web Interface
- * 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.suiviobsmer.ui.pages;
-
-import fr.ifremer.suiviobsmer.SuiviObsmerBusinessException;
-import fr.ifremer.suiviobsmer.SuiviObsmerException;
-import fr.ifremer.suiviobsmer.entity.Company;
-import fr.ifremer.suiviobsmer.entity.CompanyImpl;
-import fr.ifremer.suiviobsmer.entity.WaoUser;
-import fr.ifremer.suiviobsmer.entity.WaoUserImpl;
-import fr.ifremer.suiviobsmer.services.ServiceReferential;
-import fr.ifremer.suiviobsmer.services.ServiceUser;
-import fr.ifremer.suiviobsmer.ui.base.GenericSelectModel;
-import fr.ifremer.suiviobsmer.ui.base.SuiviObsmerPage;
-import fr.ifremer.suiviobsmer.ui.components.Layout;
-import java.util.List;
-import org.apache.commons.lang.StringUtils;
-import org.apache.tapestry5.EventContext;
-import org.apache.tapestry5.annotations.IncludeStylesheet;
-import org.apache.tapestry5.annotations.InjectComponent;
-import org.apache.tapestry5.annotations.Log;
-import org.apache.tapestry5.annotations.Persist;
-import org.apache.tapestry5.annotations.Property;
-import org.apache.tapestry5.ioc.annotations.Inject;
-import org.apache.tapestry5.ioc.services.PropertyAccess;
-import org.apache.tapestry5.ioc.services.TypeCoercer;
-import org.apache.tapestry5.upload.services.UploadedFile;
-import org.slf4j.Logger;
-
-/**
- * Administration
- *
- * Created: 9 nov. 2009
- *
- * @author fdesbois
- * @version $Revision$
- *
- * Mise a jour: $Date$
- * par : $Author$
- */
- at IncludeStylesheet("context:css/administration.css")
-public class Administration implements SuiviObsmerPage {
-
- @Override
- public boolean isOnlyForAdmin() {
- return true;
- }
-
- @Inject
- private Logger log;
-
- @InjectComponent
- private Layout layout;
-
- @Inject
- private ServiceUser serviceUser;
-
- @Inject
- private ServiceReferential serviceReferential;
-
- @Inject
- private TypeCoercer typeCoercer;
-
- @Property
- private String companyId;
-
- @Property
- private String userId;
-
- @Persist
- private List<Company> companies;
-
- @Inject
- private PropertyAccess propertyAccess;
-
- private GenericSelectModel<Company> companiesSelectModel;
-
- private Company company;
-
- private GenericSelectModel<WaoUser> usersSelectModel;
-
- /**
- * User is persistant cause of autobuild problem ?!?
- */
- @Persist
- private WaoUser user;
-
- @Property
- private boolean generatePassword;
-
- @Property
- private String password;
-
- private boolean addNewCompanySelected;
- private boolean addNewUserSelected;
- private boolean deleteUserSelected;
-
- void setupRender() throws SuiviObsmerException {
- companies = null;
- getCompanies();
- user = null;
- }
-
- void onActivate(EventContext ec) {
- if (ec.getCount() > 0) {
- companyId = ec.get(String.class, 0);
- if (ec.getCount() > 1) {
- userId = ec.get(String.class, 1);
- }
- }
- }
-
- Object[] onPassivate() {
- return new String[] {companyId, userId};
- }
-
- /**************************** IMPORT (ADMIN) *******************************/
-
- /**
- * CSV File which contains fishing zones
- */
- @Property
- private UploadedFile fishingZoneCsvFile;
-
- @Log
- void onSuccessFromImportFishingZones() {
- try {
- int result = serviceReferential.importFishingZoneCsv(fishingZoneCsvFile.getStream());
- layout.getFeedBack().addInfo(result + " zones de pêche importées");
- } catch (SuiviObsmerException eee) {
- layout.getFeedBack().addError(eee.getMessage());
- }
- }
-
- /**************************** FORMS ****************************************/
-
- public List<Company> getCompanies() throws SuiviObsmerException {
- if (companies == null) {
- if (log.isInfoEnabled()) {
- log.info("BUSINESS REQUEST [getCompanies]");
- }
- companies = serviceUser.getCompanies(false);
- }
- return companies;
- }
-
- public GenericSelectModel<Company> getCompaniesSelectModel() throws SuiviObsmerException {
- if (companiesSelectModel == null) {
- companiesSelectModel = new GenericSelectModel<Company>(getCompanies(), Company.class, Company.NAME, "id", propertyAccess);
- }
- return companiesSelectModel;
- }
-
- public Company getCompany() throws SuiviObsmerException {
- if (company == null) {
- if (companyId != null) {
- company = getCompaniesSelectModel().findObject(companyId);
- } else {
- company = new CompanyImpl();
- }
- }
- return company;
- }
-
- public boolean isUsersAvailable() throws SuiviObsmerException {
- return !StringUtils.isEmpty(getCompany().getId()) && getCompany().getActive();
- }
-
- void onSelectedFromAddNewCompany() {
- addNewCompanySelected = true;
- }
-
- void onSuccessFromActionsForm() {
- if (addNewCompanySelected) {
- companyId = null;
- }
- userId = null;
- user = null;
- }
-
- void onSuccessFromCompany() throws SuiviObsmerException {
- serviceUser.createUpdateCompany(company);
- companyId = company.getId();
- }
-
- @Log
- public GenericSelectModel<WaoUser> getUsersSelectModel() throws SuiviObsmerException {
- if (usersSelectModel == null) {
- List<WaoUser> users = getCompany().getWaoUser();
- if (log.isDebugEnabled()) {
- log.debug("Nb users : " + users.size());
- }
- usersSelectModel = new GenericSelectModel<WaoUser>(users, WaoUser.class, "fullName", "id", propertyAccess);
- }
- return usersSelectModel;
- }
-
- @Log
- public WaoUser getUser() throws SuiviObsmerException {
- if (user == null) {
- if (userId != null) {
- if (log.isDebugEnabled()) {
- log.debug("User exist in selectModel : " + userId);
- }
- user = getUsersSelectModel().findObject(userId);
- } else {
- user = new WaoUserImpl();
- generatePassword = true;
- if (log.isDebugEnabled()) {
- log.debug("Set company for new user : " + getCompany().getName());
- }
- user.setCompany(getCompany());
- }
- }
- return user;
- }
-
- void onSelectedFromAddNewUser() {
- addNewUserSelected = true;
- }
-
- void onSelectedFromDeleteUser() {
- deleteUserSelected = true;
- }
-
- void onSuccessFromUserActionsForm() throws SuiviObsmerException {
- if (addNewUserSelected) {
- userId = null;
- } else if (deleteUserSelected && userId != null) {
- user = getUsersSelectModel().findObject(userId);
- try {
- serviceUser.deleteUser(user);
- user = null;
- userId = null;
- layout.getFeedBack().addInfo("Utilisateur supprimé avec succès !");
- } catch (SuiviObsmerBusinessException eee) {
- layout.getFeedBack().addError(eee.getMessage());
- }
- }
- }
-
- @Log
- void onSuccessFromUser() throws SuiviObsmerException {
- if (log.isDebugEnabled()) {
- log.debug("User : " + user);
- }
-
- if (!StringUtils.isEmpty(password)) {
- user.setPassword(password);
- user.setPasswordChanged(true);
- }
- try {
- // TODO return true if mail ok
- serviceUser.createUpdateUser(user, generatePassword);
- userId = user.getId();
- } catch (SuiviObsmerBusinessException eee) {
- layout.getFeedBack().addError(eee.getMessage());
- }
- }
-
-}
Copied: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Administration.java (from rev 354, trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/Administration.java)
===================================================================
--- trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Administration.java (rev 0)
+++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Administration.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -0,0 +1,280 @@
+/*
+ * *##%
+ * Wao :: Web Interface
+ * 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.ui.pages;
+
+import fr.ifremer.wao.WaoBusinessException;
+import fr.ifremer.wao.WaoException;
+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.ServiceReferential;
+import fr.ifremer.wao.service.ServiceUser;
+import fr.ifremer.wao.ui.base.GenericSelectModel;
+import fr.ifremer.wao.ui.base.WaoPage;
+import fr.ifremer.wao.ui.components.Layout;
+import java.util.List;
+import org.apache.commons.lang.StringUtils;
+import org.apache.tapestry5.EventContext;
+import org.apache.tapestry5.annotations.IncludeStylesheet;
+import org.apache.tapestry5.annotations.InjectComponent;
+import org.apache.tapestry5.annotations.Log;
+import org.apache.tapestry5.annotations.Persist;
+import org.apache.tapestry5.annotations.Property;
+import org.apache.tapestry5.ioc.annotations.Inject;
+import org.apache.tapestry5.ioc.services.PropertyAccess;
+import org.apache.tapestry5.ioc.services.TypeCoercer;
+import org.apache.tapestry5.upload.services.UploadedFile;
+import org.slf4j.Logger;
+
+/**
+ * Administration
+ *
+ * Created: 9 nov. 2009
+ *
+ * @author fdesbois
+ * @version $Revision$
+ *
+ * Mise a jour: $Date$
+ * par : $Author$
+ */
+ at IncludeStylesheet("context:css/administration.css")
+public class Administration implements WaoPage {
+
+ @Override
+ public boolean isOnlyForAdmin() {
+ return true;
+ }
+
+ @Inject
+ private Logger log;
+
+ @InjectComponent
+ private Layout layout;
+
+ @Inject
+ private ServiceUser serviceUser;
+
+ @Inject
+ private ServiceReferential serviceReferential;
+
+ @Inject
+ private TypeCoercer typeCoercer;
+
+ @Property
+ private String companyId;
+
+ @Property
+ private String userId;
+
+ @Persist
+ private List<Company> companies;
+
+ @Inject
+ private PropertyAccess propertyAccess;
+
+ private GenericSelectModel<Company> companiesSelectModel;
+
+ private Company company;
+
+ private GenericSelectModel<WaoUser> usersSelectModel;
+
+ /**
+ * User is persistant cause of autobuild problem ?!?
+ */
+ @Persist
+ private WaoUser user;
+
+ @Property
+ private boolean generatePassword;
+
+ @Property
+ private String password;
+
+ private boolean addNewCompanySelected;
+ private boolean addNewUserSelected;
+ private boolean deleteUserSelected;
+
+ void setupRender() throws WaoException {
+ companies = null;
+ getCompanies();
+ user = null;
+ }
+
+ void onActivate(EventContext ec) {
+ if (ec.getCount() > 0) {
+ companyId = ec.get(String.class, 0);
+ if (ec.getCount() > 1) {
+ userId = ec.get(String.class, 1);
+ }
+ }
+ }
+
+ Object[] onPassivate() {
+ return new String[] {companyId, userId};
+ }
+
+ /**************************** IMPORT (ADMIN) *******************************/
+
+ /**
+ * CSV File which contains fishing zones
+ */
+ @Property
+ private UploadedFile fishingZoneCsvFile;
+
+ @Log
+ void onSuccessFromImportFishingZones() {
+ try {
+ int result = serviceReferential.importFishingZoneCsv(fishingZoneCsvFile.getStream());
+ layout.getFeedBack().addInfo(result + " zones de pêche importées");
+ } catch (WaoException eee) {
+ layout.getFeedBack().addError(eee.getMessage());
+ }
+ }
+
+ /**************************** FORMS ****************************************/
+
+ public List<Company> getCompanies() throws WaoException {
+ if (companies == null) {
+ if (log.isInfoEnabled()) {
+ log.info("BUSINESS REQUEST [getCompanies]");
+ }
+ companies = serviceUser.getCompanies(false);
+ }
+ return companies;
+ }
+
+ public GenericSelectModel<Company> getCompaniesSelectModel() throws WaoException {
+ if (companiesSelectModel == null) {
+ companiesSelectModel = new GenericSelectModel<Company>(getCompanies(), Company.class, Company.NAME, "id", propertyAccess);
+ }
+ return companiesSelectModel;
+ }
+
+ public Company getCompany() throws WaoException {
+ if (company == null) {
+ if (companyId != null) {
+ company = getCompaniesSelectModel().findObject(companyId);
+ } else {
+ company = new CompanyImpl();
+ }
+ }
+ return company;
+ }
+
+ public boolean isUsersAvailable() throws WaoException {
+ return !StringUtils.isEmpty(getCompany().getId()) && getCompany().getActive();
+ }
+
+ void onSelectedFromAddNewCompany() {
+ addNewCompanySelected = true;
+ }
+
+ void onSuccessFromActionsForm() {
+ if (addNewCompanySelected) {
+ companyId = null;
+ }
+ userId = null;
+ user = null;
+ }
+
+ void onSuccessFromCompany() throws WaoException {
+ serviceUser.createUpdateCompany(company);
+ companyId = company.getId();
+ }
+
+ @Log
+ public GenericSelectModel<WaoUser> getUsersSelectModel() throws WaoException {
+ if (usersSelectModel == null) {
+ List<WaoUser> users = getCompany().getWaoUser();
+ if (log.isDebugEnabled()) {
+ log.debug("Nb users : " + users.size());
+ }
+ usersSelectModel = new GenericSelectModel<WaoUser>(users, WaoUser.class, "fullName", "id", propertyAccess);
+ }
+ return usersSelectModel;
+ }
+
+ @Log
+ public WaoUser getUser() throws WaoException {
+ if (user == null) {
+ if (userId != null) {
+ if (log.isDebugEnabled()) {
+ log.debug("User exist in selectModel : " + userId);
+ }
+ user = getUsersSelectModel().findObject(userId);
+ } else {
+ user = new WaoUserImpl();
+ generatePassword = true;
+ if (log.isDebugEnabled()) {
+ log.debug("Set company for new user : " + getCompany().getName());
+ }
+ user.setCompany(getCompany());
+ }
+ }
+ return user;
+ }
+
+ void onSelectedFromAddNewUser() {
+ addNewUserSelected = true;
+ }
+
+ void onSelectedFromDeleteUser() {
+ deleteUserSelected = true;
+ }
+
+ void onSuccessFromUserActionsForm() throws WaoException {
+ if (addNewUserSelected) {
+ userId = null;
+ } else if (deleteUserSelected && userId != null) {
+ user = getUsersSelectModel().findObject(userId);
+ try {
+ serviceUser.deleteUser(user);
+ user = null;
+ userId = null;
+ layout.getFeedBack().addInfo("Utilisateur supprimé avec succès !");
+ } catch (WaoBusinessException eee) {
+ layout.getFeedBack().addError(eee.getMessage());
+ }
+ }
+ }
+
+ @Log
+ void onSuccessFromUser() throws WaoException {
+ if (log.isDebugEnabled()) {
+ log.debug("User : " + user);
+ }
+
+ if (!StringUtils.isEmpty(password)) {
+ user.setPassword(password);
+ user.setPasswordChanged(true);
+ }
+ try {
+ // TODO return true if mail ok
+ serviceUser.createUpdateUser(user, generatePassword);
+ userId = user.getId();
+ } catch (WaoBusinessException eee) {
+ layout.getFeedBack().addError(eee.getMessage());
+ }
+ }
+
+}
Deleted: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/BoatActivityCalendar.java
===================================================================
--- trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/BoatActivityCalendar.java 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/BoatActivityCalendar.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,197 +0,0 @@
-/*
- * *##%
- * SuiviObsmer :: Web Interface
- * 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.suiviobsmer.ui.pages;
-
-import fr.ifremer.suiviobsmer.SuiviObsmerException;
-import fr.ifremer.suiviobsmer.entity.ActivityCalendar;
-import fr.ifremer.suiviobsmer.entity.ActivityMonth;
-import fr.ifremer.suiviobsmer.entity.ActivityProfession;
-import fr.ifremer.suiviobsmer.entity.ActivityZone;
-import fr.ifremer.suiviobsmer.entity.Boat;
-import fr.ifremer.suiviobsmer.entity.WaoUser;
-import fr.ifremer.suiviobsmer.services.ServiceBoat;
-import fr.ifremer.suiviobsmer.ui.base.SuiviObsmerPage;
-import java.util.Collections;
-import java.util.List;
-import org.apache.commons.lang.StringUtils;
-import org.apache.tapestry5.annotations.IncludeStylesheet;
-import org.apache.tapestry5.annotations.InjectPage;
-import org.apache.tapestry5.annotations.Persist;
-import org.apache.tapestry5.annotations.Property;
-import org.apache.tapestry5.annotations.SessionState;
-import org.apache.tapestry5.ioc.annotations.Inject;
-import org.nuiton.util.DateUtils;
-import org.slf4j.Logger;
-
-/**
- * ActivityCalendarPage
- *
- * Created: 14 déc. 2009
- *
- * @author fdesbois
- * @version $Revision$
- *
- * Mise a jour: $Date$
- * par : $Author$
- */
- at IncludeStylesheet("context:css/boats.css")
-public class BoatActivityCalendar implements SuiviObsmerPage {
-
- @Inject
- private Logger log;
-
- @Inject
- private ServiceBoat serviceBoat;
-
- @SessionState
- private WaoUser user;
-
- private ActivityCalendar activityCalendar;
-
-// @Property
-// private ActivityMonth activityMonth;
-
- @Property
- private int month;
-
- @Property
- private int professionIndex;
-
- @Property
- private int zoneIndex;
-
- @Persist
- private Boat boat;
-
- void setupRender() {
-
- }
-
- @Override
- public boolean isOnlyForAdmin() {
- return false;
- }
-
- public void setBoat(Boat boat) {
- this.boat = boat;
- }
-
- public Boat getBoat() {
- return this.boat;
- }
-
- public List<Boat> getBoats() {
- return Collections.singletonList(boat);
- }
-
- public ActivityCalendar getActivityCalendar() throws SuiviObsmerException {
- if (activityCalendar == null) {
- if (log.isInfoEnabled()) {
- log.info("BUSINESS REQUEST [getLastActivityCalendar]");
- }
- this.activityCalendar = serviceBoat.getLastActivityCalendar(user, getBoat());
- }
- return activityCalendar;
- }
-
- public ActivityMonth getActivityMonth() throws SuiviObsmerException {
- return getActivityCalendar().getActivityMonth(month);
- }
-
- public String getMonthName() {
- String libelle = DateUtils.getMonthLibelle(month);
- return StringUtils.capitalize(libelle);
- }
-
- public int getProfessionIndexMax() {
- int result = 0;
- for (ActivityMonth curr : activityCalendar.getActivityMonth()) {
- int nbProfessions = curr.sizeActivityProfession();
- if (nbProfessions > result) {
- result = nbProfessions;
- }
- }
- return result-1;
- }
-
- public boolean hasProfessions() {
- return getProfessionIndexMax() != -1;
- }
-
- public ActivityProfession getActivityProfession() throws SuiviObsmerException {
- if (getActivityMonth() == null) {
- return null;
- }
- if (professionIndex >= getActivityMonth().sizeActivityProfession()) {
- return null;
- }
- return getActivityMonth().getActivityProfession().get(professionIndex);
- }
-
- public int getZoneIndexMax() throws SuiviObsmerException {
- int result = 0;
- for (ActivityMonth activityMonth : activityCalendar.getActivityMonth()) {
- month = activityMonth.getMonth();
- ActivityProfession profession = getActivityProfession();
- if (profession != null) {
- int nbZones = profession.sizeActivityZone();
- if (nbZones > result) {
- result = nbZones;
- }
- }
- }
- return result-1;
- }
-
- /** Hack for pagelink to Boats page
- *
- * @return null
- */
- public String getNorow() {
- return null;
- }
-
-// public boolean hasZones() {
-// return getZoneIndexMax() != -1;
-// }
-
- public ActivityZone getActivityZone() throws SuiviObsmerException {
- ActivityProfession profession = getActivityProfession();
- if (profession == null) {
- return null;
- }
- if (zoneIndex >= profession.sizeActivityZone()) {
- return null;
- }
- return profession.getActivityZone().get(zoneIndex);
- }
-
- /*************************** RETURN LINK **********************************/
-
- @InjectPage
- private Boats boatsPage;
-
- Object onActionFromReturnToBoats() {
- boatsPage.setBoatSelectedImmatriculation(getBoat().getImmatriculation());
- return boatsPage;
- }
-}
Copied: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/BoatActivityCalendar.java (from rev 354, trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/BoatActivityCalendar.java)
===================================================================
--- trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/BoatActivityCalendar.java (rev 0)
+++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/BoatActivityCalendar.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -0,0 +1,197 @@
+/*
+ * *##%
+ * Wao :: Web Interface
+ * 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.ui.pages;
+
+import fr.ifremer.wao.WaoException;
+import fr.ifremer.wao.entity.ActivityCalendar;
+import fr.ifremer.wao.entity.ActivityMonth;
+import fr.ifremer.wao.entity.ActivityProfession;
+import fr.ifremer.wao.entity.ActivityZone;
+import fr.ifremer.wao.entity.Boat;
+import fr.ifremer.wao.entity.WaoUser;
+import fr.ifremer.wao.service.ServiceBoat;
+import fr.ifremer.wao.ui.base.WaoPage;
+import java.util.Collections;
+import java.util.List;
+import org.apache.commons.lang.StringUtils;
+import org.apache.tapestry5.annotations.IncludeStylesheet;
+import org.apache.tapestry5.annotations.InjectPage;
+import org.apache.tapestry5.annotations.Persist;
+import org.apache.tapestry5.annotations.Property;
+import org.apache.tapestry5.annotations.SessionState;
+import org.apache.tapestry5.ioc.annotations.Inject;
+import org.nuiton.util.DateUtils;
+import org.slf4j.Logger;
+
+/**
+ * ActivityCalendarPage
+ *
+ * Created: 14 déc. 2009
+ *
+ * @author fdesbois
+ * @version $Revision$
+ *
+ * Mise a jour: $Date$
+ * par : $Author$
+ */
+ at IncludeStylesheet("context:css/boats.css")
+public class BoatActivityCalendar implements WaoPage {
+
+ @Inject
+ private Logger log;
+
+ @Inject
+ private ServiceBoat serviceBoat;
+
+ @SessionState
+ private WaoUser user;
+
+ private ActivityCalendar activityCalendar;
+
+// @Property
+// private ActivityMonth activityMonth;
+
+ @Property
+ private int month;
+
+ @Property
+ private int professionIndex;
+
+ @Property
+ private int zoneIndex;
+
+ @Persist
+ private Boat boat;
+
+ void setupRender() {
+
+ }
+
+ @Override
+ public boolean isOnlyForAdmin() {
+ return false;
+ }
+
+ public void setBoat(Boat boat) {
+ this.boat = boat;
+ }
+
+ public Boat getBoat() {
+ return this.boat;
+ }
+
+ public List<Boat> getBoats() {
+ return Collections.singletonList(boat);
+ }
+
+ public ActivityCalendar getActivityCalendar() throws WaoException {
+ if (activityCalendar == null) {
+ if (log.isInfoEnabled()) {
+ log.info("BUSINESS REQUEST [getLastActivityCalendar]");
+ }
+ this.activityCalendar = serviceBoat.getLastActivityCalendar(user, getBoat());
+ }
+ return activityCalendar;
+ }
+
+ public ActivityMonth getActivityMonth() throws WaoException {
+ return getActivityCalendar().getActivityMonth(month);
+ }
+
+ public String getMonthName() {
+ String libelle = DateUtils.getMonthLibelle(month);
+ return StringUtils.capitalize(libelle);
+ }
+
+ public int getProfessionIndexMax() {
+ int result = 0;
+ for (ActivityMonth curr : activityCalendar.getActivityMonth()) {
+ int nbProfessions = curr.sizeActivityProfession();
+ if (nbProfessions > result) {
+ result = nbProfessions;
+ }
+ }
+ return result-1;
+ }
+
+ public boolean hasProfessions() {
+ return getProfessionIndexMax() != -1;
+ }
+
+ public ActivityProfession getActivityProfession() throws WaoException {
+ if (getActivityMonth() == null) {
+ return null;
+ }
+ if (professionIndex >= getActivityMonth().sizeActivityProfession()) {
+ return null;
+ }
+ return getActivityMonth().getActivityProfession().get(professionIndex);
+ }
+
+ public int getZoneIndexMax() throws WaoException {
+ int result = 0;
+ for (ActivityMonth activityMonth : activityCalendar.getActivityMonth()) {
+ month = activityMonth.getMonth();
+ ActivityProfession profession = getActivityProfession();
+ if (profession != null) {
+ int nbZones = profession.sizeActivityZone();
+ if (nbZones > result) {
+ result = nbZones;
+ }
+ }
+ }
+ return result-1;
+ }
+
+ /** Hack for pagelink to Boats page
+ *
+ * @return null
+ */
+ public String getNorow() {
+ return null;
+ }
+
+// public boolean hasZones() {
+// return getZoneIndexMax() != -1;
+// }
+
+ public ActivityZone getActivityZone() throws WaoException {
+ ActivityProfession profession = getActivityProfession();
+ if (profession == null) {
+ return null;
+ }
+ if (zoneIndex >= profession.sizeActivityZone()) {
+ return null;
+ }
+ return profession.getActivityZone().get(zoneIndex);
+ }
+
+ /*************************** RETURN LINK **********************************/
+
+ @InjectPage
+ private Boats boatsPage;
+
+ Object onActionFromReturnToBoats() {
+ boatsPage.setBoatSelectedImmatriculation(getBoat().getImmatriculation());
+ return boatsPage;
+ }
+}
Deleted: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Boats.java
===================================================================
--- trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/Boats.java 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Boats.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,827 +0,0 @@
-/*
- * *##%
- * SuiviObsmer :: Web Interface
- * 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.suiviobsmer.ui.pages;
-
-import fr.ifremer.suiviobsmer.SuiviObsmerContext;
-import fr.ifremer.suiviobsmer.SuiviObsmerException;
-import fr.ifremer.suiviobsmer.bean.BoatFilterImpl;
-import fr.ifremer.suiviobsmer.entity.Boat;
-import fr.ifremer.suiviobsmer.bean.BoatFilter;
-import fr.ifremer.suiviobsmer.bean.CompanyBoatInfos;
-import fr.ifremer.suiviobsmer.entity.BoatInfos;
-import fr.ifremer.suiviobsmer.entity.Company;
-import fr.ifremer.suiviobsmer.entity.Contact;
-import fr.ifremer.suiviobsmer.entity.ElligibleBoat;
-import fr.ifremer.suiviobsmer.entity.WaoUser;
-import fr.ifremer.suiviobsmer.entity.Profession;
-import fr.ifremer.suiviobsmer.entity.SampleRow;
-import fr.ifremer.suiviobsmer.services.ServiceBoat;
-import fr.ifremer.suiviobsmer.services.ServiceReferential;
-import fr.ifremer.suiviobsmer.services.ServiceSampling;
-import fr.ifremer.suiviobsmer.services.ServiceUser;
-import fr.ifremer.suiviobsmer.ui.base.AbstractFilteredPage;
-import fr.ifremer.suiviobsmer.ui.data.BusinessUtils;
-import fr.ifremer.suiviobsmer.ui.base.GenericSelectModel;
-import fr.ifremer.suiviobsmer.ui.base.SuiviObsmerPage;
-import fr.ifremer.suiviobsmer.ui.components.FeedBack;
-import fr.ifremer.suiviobsmer.ui.components.Layout;
-import fr.ifremer.suiviobsmer.ui.data.BoatDataSource;
-import fr.ifremer.suiviobsmer.ui.data.ExportStreamResponse;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.GregorianCalendar;
-import java.util.List;
-import java.util.zip.GZIPInputStream;
-import org.apache.commons.lang.BooleanUtils;
-import org.apache.commons.lang.StringUtils;
-import org.apache.tapestry5.Block;
-import org.apache.tapestry5.EventContext;
-import org.apache.tapestry5.PersistenceConstants;
-import org.apache.tapestry5.StreamResponse;
-import org.apache.tapestry5.annotations.IncludeStylesheet;
-import org.apache.tapestry5.annotations.InjectComponent;
-import org.apache.tapestry5.annotations.InjectPage;
-import org.apache.tapestry5.annotations.Log;
-import org.apache.tapestry5.annotations.Persist;
-import org.apache.tapestry5.annotations.Property;
-import org.apache.tapestry5.annotations.SessionState;
-import org.apache.tapestry5.corelib.components.Zone;
-import org.apache.tapestry5.ioc.annotations.Inject;
-import org.apache.tapestry5.ioc.services.PropertyAccess;
-import org.apache.tapestry5.services.Response;
-import org.apache.tapestry5.upload.services.UploadedFile;
-import org.slf4j.Logger;
-
-/**
- * Boats
- *
- * Created: 9 nov. 2009
- *
- * @author fdesbois
- * @version $Revision$
- *
- * Mise a jour: $Date$
- * par : $Author$
- */
- at IncludeStylesheet("context:css/boats.css")
-public class Boats extends AbstractFilteredPage implements SuiviObsmerPage {
-
- @Override
- public boolean isOnlyForAdmin() {
- return false;
- }
-
- @Inject
- private Logger log;
-
- @InjectComponent
- private Layout layout;
-
- @SessionState
- @Property
- private WaoUser user;
-
- @Inject
- private ServiceReferential serviceReferential;
-
- @Inject
- private ServiceSampling serviceSampling;
-
- @Inject
- private ServiceBoat serviceBoat;
-
- @Inject
- private PropertyAccess propertyAccess;
-
- @Property
- private String sampleRowContextId;
-
- /** Selected boat immatriculation for showing boatInfos */
- @Persist("flash")
- private Integer boatSelectedImmatriculation;
-
- public Integer getBoatSelectedImmatriculation() {
- return boatSelectedImmatriculation;
- }
-
- public void setBoatSelectedImmatriculation(Integer boatSelectedImmatriculation) {
- this.boatSelectedImmatriculation = boatSelectedImmatriculation;
- }
-
- @InjectComponent
- private FeedBack filterFeedback;
-
- void setupRender() throws SuiviObsmerException {
- sampleRow = null;
- getSampleRow();
- // Profession select reset
- professionSelectModel = null;
- getProfessionSelectModel();
-
- // Manage sampleRow from context
- if (isSampleRowExists()) {
- // Filters will be set and displayed
- getFilter().setSampleRow(sampleRow);
- filtersHidden = false;
- boats = null;
- filterFeedback.addInfo("Vous êtes en cours de sélection d'un navire pour la ligne du plan " + sampleRow.getCode());
- professionId = getSampleRow().getProfession().getTopiaId();
- }
-
- // Initialize filters using AbstractFilteredPage superclass
- initSelectFilters(false, false, false);
-
- companyBoatInfos = null;
- //boatSelectedImmatriculation = null;
- }
-
- void onActivate(EventContext ec) {
- sampleRowContextId = ec.get(String.class, 0);
-// boatSelectedImmatriculation = ec.get(Integer.class, 1);
- }
-
-// Object[] onPassivate() {
-// return new Object[] { sampleRowContextId, boatSelectedImmatriculation };
-// }
-
- String onPassivate() {
- return sampleRowContextId;
- }
-
- /**************************** Import Forms ********************************/
-
- /** Csv file for boats import */
- @Property
- private UploadedFile boatsCsvFile;
-
- @Log
- void onSuccessFromImportBoatsForm() {
- //importBoatsForm.clearErrors();
- try {
- int[] result = serviceBoat.importBoatCsv(boatsCsvFile.getStream());
- // Suppress persitant list of boats
- boats = null;
- layout.getFeedBack().addInfo(result[0] + " navires importés dont " + result[1] + " nouveaux");
- } catch (SuiviObsmerException eee) {
- layout.getFeedBack().addError(eee.getMessage());
- }
- }
-
- /** Csv file for activityCalendar import, can be a Gzip file */
- @Property
- private UploadedFile activityCalendarsCsvFile;
-
- private InputStream activityCalendarLogFile;
-
- private InputStream activityCalendarLogAccessFile;
-
- protected static final String GZIP_MIMETYPE = "application/x-gzip";
-
- InputStream getActivityCalendarLogFile() throws FileNotFoundException {
- if (activityCalendarLogFile == null) {
- if (log.isInfoEnabled()) {
- log.info("BUSINESS REQUEST [getActivityCalendarLogFile]");
- }
- activityCalendarLogFile = serviceBoat.getActivityCalendarLogFile();
- }
- return activityCalendarLogFile;
- }
-
- public boolean isLogFileExists() {
- try {
- getActivityCalendarLogFile();
- return true;
- } catch (FileNotFoundException eee) {
- if (log.isInfoEnabled()) {
- log.info("Aucun fichier de log existant pour les calendriers d'activité");
- }
- return false;
- }
- }
-
- InputStream getActivityCalendarLogAccessFile() throws FileNotFoundException {
- if (activityCalendarLogAccessFile == null) {
- if (log.isInfoEnabled()) {
- log.info("BUSINESS REQUEST [getActivityCalendarLogAccessFile]");
- }
- activityCalendarLogAccessFile =
- serviceBoat.getActivityCalendarLogAccessFile();
- }
- return activityCalendarLogAccessFile;
- }
-
- public boolean isLogAccessFileExists() {
- try {
- getActivityCalendarLogAccessFile();
- return true;
- } catch (FileNotFoundException eee) {
- if (log.isInfoEnabled()) {
- log.info("Aucun fichier de log existant pour les accès " +
- "utilisateurs aux calendriers d'activité");
- }
- return false;
- }
- }
-
- @Log
- void onSuccessFromImportActivityCalendarsForm() throws SuiviObsmerException, IOException {
- InputStream input = activityCalendarsCsvFile.getStream();
- if (log.isDebugEnabled()) {
- log.debug("Content type : " + activityCalendarsCsvFile.getContentType());
- }
- if (activityCalendarsCsvFile.getContentType().equals(GZIP_MIMETYPE)) {
- if (log.isDebugEnabled()) {
- log.debug("Gzip file");
- }
- input = new GZIPInputStream(input);
- }
- serviceBoat.importActivityCalendarCsv(input);
- companyBoatInfos = null;
- }
-
- public StreamResponse onActionFromShowActivityCalendarLogFile() {
- return new StreamResponse() {
-
- @Override
- public String getContentType() {
- return "text/plain;charset=utf-8";
- }
-
- @Override
- public InputStream getStream() throws IOException {
- return getActivityCalendarLogFile();
- }
-
- @Override
- public void prepareResponse(Response response) {
- }
- };
- }
-
- public StreamResponse onActionFromShowActivityCalendarLogAccessFile() {
- return new StreamResponse() {
-
- @Override
- public String getContentType() {
- return "text/plain;charset=utf-8";
- }
-
- @Override
- public InputStream getStream() throws IOException {
- return getActivityCalendarLogAccessFile();
- }
-
- @Override
- public void prepareResponse(Response response) {
- }
- };
- }
-
- /**************************** Filters Form *****************************************/
-
- /** Filters to apply on boats list */
- @Persist
- private BoatFilter boatFilter;
-
- /** Current sampleRow from context */
- @Persist
- private SampleRow sampleRow;
-
- /** Profession select */
- @Persist
- private GenericSelectModel<Profession> professionSelectModel;
-
- @Property
- private String professionId;
-
- /** Used to manage view of filters zone */
- @Persist
- private boolean filtersHidden;
-
- @InjectComponent
- private Zone filtersZone;
-
- /**
- * Filters to apply on boats list. Method used by AbstractFilteredPage superclass.
- *
- * @return the current BoatFilter to apply
- * @throws SuiviObsmerException
- * @see AbstractFilteredPage
- */
- @Override
- public BoatFilter getFilter() throws SuiviObsmerException {
- if (boatFilter == null) {
- if (log.isDebugEnabled()) {
- log.debug("Create filter");
- }
- boatFilter = new BoatFilterImpl();
- // Only rows which are not finished nearly one month
- boatFilter.setNbMonthFinishedFromToday(-1);
- }
- return boatFilter;
- }
-
- @Override
- protected boolean isAvailableDataForFiltersOnly() {
- return true;
- }
-
- /**
- * Retrieve sampleRow from business with id from url context. The sampleRowId from context is set by SamplingPlan page.
- * When the sampleRow is not null, the filters are disabled to optimize searching boats for this row.
- *
- * @return the sampleRow from business
- * @throws SuiviObsmerException
- */
- public SampleRow getSampleRow() throws SuiviObsmerException {
- if (sampleRow == null && !StringUtils.isEmpty(sampleRowContextId)) {
- if (log.isInfoEnabled()) {
- log.info("BUSINESS REQUEST [getSampleRow]");
- }
- sampleRow = serviceSampling.getSampleRow(sampleRowContextId);
- }
- return sampleRow;
- }
-
- public boolean isSampleRowExists() throws SuiviObsmerException {
- return getSampleRow() != null;
- }
-
- public GenericSelectModel<Profession> getProfessionSelectModel() throws SuiviObsmerException {
- if (professionSelectModel == null) {
- if (log.isInfoEnabled()) {
- log.info("BUSINESS REQUEST [getProfessions]");
- }
- List<Profession> professions = serviceReferential.getProfessions();
- professionSelectModel = new GenericSelectModel<Profession>(professions, Profession.class,
- "code", "topiaId", propertyAccess);
- }
- return professionSelectModel;
- }
-
- public boolean isFiltersHidden() {
- return filtersHidden;
- }
-
- public String getHiddenStyle() {
- return isFiltersHidden() ? "hidden" : "";
- }
-
- Block onActionFromShowFilters() {
- filtersHidden = false;
- return filtersZone.getBody();
- }
-
- Block onActionFromHideFilters() {
- filtersHidden = true;
- return filtersZone.getBody();
- }
-
- /**
- * EVENT_SELECTED :: reset submit button for filtersForm. Reset filters and sampleRow from context.
- */
- void onSelectedFromReset() {
- // Suppress persistant boat filter and sampleRowId in url context.
- boatFilter = null;
- sampleRowContextId = null;
- }
-
- /**
- * EVENT_SELECTED :: search sumit button for filtersForm. Get profession from selectModel to add it in filters.
- * Other filters are managed by AbstractFilteredPage superclass.
- *
- * @throws SuiviObsmerException for business errors
- * @see AbstractFilteredPage#onSelectedFromSearch()
- */
- @Override
- public void onSelectedFromSearch() throws SuiviObsmerException {
- super.onSelectedFromSearch();
- if (log.isDebugEnabled()) {
- log.debug("FILTER : facadeName=" + boatFilter.getFacadeName());
- log.debug("FILTER : sectorName=" + boatFilter.getSectorName());
- log.debug("FILTER : sampleRow=" + boatFilter.getSampleRow());
- log.debug("FILTER : profession=" + boatFilter.getProfession());
- log.debug("FILTER : boatName=" + boatFilter.getBoatName());
- log.debug("FILTER : boatImmatriculation=" + boatFilter.getBoatImmatriculation());
- log.debug("FILTER : boatDistrictCode=" + boatFilter.getBoatDistrictCode());
- log.debug("FILTER : company=" + boatFilter.getCompany());
- }
- Profession profession = getProfessionSelectModel().findObject(professionId);
- boatFilter.setProfession(profession);
- }
-
- /**
- * EVENT_SUCCESS :: for filtersForm. Reset persitant data to have new data using filters selected.
- *
- * @return the filtersZone if it's a refresh data for select, or the page otherwise
- * @throws SuiviObsmerException for business errors
- */
- Object onSuccessFromFiltersForm() throws SuiviObsmerException {
- if (isEdited()) {
- return filtersZone.getBody();
- }
- // Suppress persistant boats list to get new one with filter
- boats = null;
- // Suppress persistant immatriculation for boat selected
- boatSelectedImmatriculation = null;
- // Suppress persistant boat informations for boat selected
- companyBoatInfos = null;
- return this;
- }
-
- /**************************** Boats List *****************************************/
-
- /** DataSource containing the boats */
- @Persist
- private BoatDataSource boats;
-
- /** Current boat in the Grid */
- @Property
- private Boat boat;
-
- /** Used to change style a line on two */
- private boolean even = true;
-
- /** Used to refresh boats Grid */
- @InjectComponent
- private Zone boatsZone;
-
- /**
- * Get dataSource which contains current boats to show on the page. Depends on filters sets by user.
- * BoatDataSource uses serviceBoat to retrieve boats with filters.
- *
- * @return the BoatDataSource which contains the boats map
- * @throws SuiviObsmerException
- * @see BoatDataSource
- */
- public BoatDataSource getBoats() throws SuiviObsmerException {
- if (boats == null) {
- boats = new BoatDataSource(getFilter(), serviceBoat);
- }
- return boats;
- }
-
- /**
- * Initialized row CSS style depends on selection in the list. The style is also changed a line on two.
- *
- * @return the CSS style class to used for the current row in the Grid
- */
- public String getRowStyle() {
- String result = "";
- even = !even;
- if (boatSelectedImmatriculation != null &&
- boat.getImmatriculation() == boatSelectedImmatriculation) {
- result = "selected";
- } else if (!boat.getActive()) {
- result = "refused";
- } else {
- result = even ? "even" : "odd";
- }
- return result;
- }
-
- public DateFormat getDateFormat() {
- return new SimpleDateFormat("dd/MM/yyyy");
- }
-
- public boolean canCreateNewContactFromList() throws SuiviObsmerException {
- if (!user.getAdmin() && isSampleRowExists()) {
- return boat.canCreateContact(user.getCompany());
- }
- return false;
- }
-
- StreamResponse onActionFromExportShowBoats() {
- return new ExportStreamResponse("wao-navires") {
-
- @Override
- public InputStream getStream() throws IOException {
- InputStream result = null;
- try {
- if (log.isDebugEnabled()) {
- log.debug("Filter sampleRow : " + getFilter().getSampleRow());
- }
- result = serviceBoat.exportBoatCsv(getFilter());
- } catch (SuiviObsmerException eee) {
- throw new IOException(eee);
- }
- return result;
- }
- };
- }
-
- Block onActionFromShowBoatInfos(Integer boatImma) throws SuiviObsmerException {
- boatSelectedImmatriculation = boatImma;
- // Suppress persistant boat informations
- companyBoatInfos = null;
-
- if (log.isDebugEnabled()) {
- log.debug("Show infos for boat : " + boatImma);
- }
-
- if (user.getAdmin() && getCompany() != null) {
- companySelectedId = getCompany().getTopiaId();
- }
- return boatsZone.getBody();
- }
-
- /**************************** Boat selected Infos *************************/
-
- @Persist
- private CompanyBoatInfos companyBoatInfos;
-
- @InjectComponent
- private Zone boatInfosZone;
-
- @Inject
- private Block displayBoatInfos;
-
- @Inject
- private Block editBoatInfos;
-
- @Property
- private ElligibleBoat elligibleBoat;
-
- @Property
- private String boatInfosSampleRowId;
-
- private boolean boatInfosEditable;
-
- private Date boardingFromDate;
-
- private GenericSelectModel<Company> companies;
-
- @Inject
- private ServiceUser serviceUser;
-
- @Property
- @Persist(PersistenceConstants.FLASH)
- private String companySelectedId;
-
- private Company company;
-
- /*@Persist
- private SuiviObsmerPropertyChangeListener propertyChange;*/
-
- /** /////////////////////// GLOBAL TO THE BLOCK /////////////////////// **/
-
- public boolean isActivityCalendarImportRun() {
- return SuiviObsmerContext.isActivityCalendarImportRun();
- }
-
- public Block getActiveBoatInfosBlock() {
- if (boatInfosEditable) {
- return editBoatInfos;
- }
- return displayBoatInfos;
- }
-
- public CompanyBoatInfos getCompanyBoatInfos() throws SuiviObsmerException {
- if (companyBoatInfos == null && boatSelectedImmatriculation != null && getCompany() != null) {
- if (log.isInfoEnabled()) {
- log.info("BUSINESS REQUEST [getElligibleBoats]");
- }
- companyBoatInfos = serviceBoat.getCompanyBoatInfos(boatSelectedImmatriculation, getCompany());
- }
- return companyBoatInfos;
- }
-
- /**
- * Retrieve companies select model for admin user. Only active companies
- * will be used for this model.
- *
- * @return the GenericSelectModel<Company>
- * @throws SuiviObsmerException
- */
- public GenericSelectModel<Company> getCompanies() throws SuiviObsmerException {
- if (companies == null) {
- if (log.isDebugEnabled()) {
- log.debug("BUSINESS REQUEST [getCompanies]");
- }
- List<Company> results = serviceUser.getCompanies(true);
- companies = new GenericSelectModel<Company>(results, Company.class, "name","topiaId",propertyAccess);
- }
- return companies;
- }
-
- /**
- * Get the current company. The user one if it's not an admin or the
- * selected one otherwise.
- *
- * @return the current Company
- * @throws SuiviObsmerException
- */
- public Company getCompany() throws SuiviObsmerException {
- if (company == null) {
- if (StringUtils.isNotEmpty(companySelectedId)) {
- company = getCompanies().findObject(companySelectedId);
- } else if (!user.getAdmin()) {
- company = user.getCompany();
- }
- }
- return company;
- }
-
- /**
- * Used to get the selected boat.
- *
- * @return the selected boat from the grid
- * @throws SuiviObsmerException
- */
- public Boat getBoatSelected() throws SuiviObsmerException {
- if (log.isDebugEnabled()) {
- log.debug("selected imma : " + boatSelectedImmatriculation);
- log.debug("exist boat ? : " + getBoats().contains(boatSelectedImmatriculation));
- }
- return getBoats().get(boatSelectedImmatriculation);
- }
-
- /**
- * Date for calculate boardings done for the selected boat. All boardings (number of contacts) will be calculated from this date.
- * Initialized as 12 months from today, but can be set by user.
- *
- * @return the Date used to calculate boardings done on the selected boat
- */
- public Date getBoardingFromDate() {
- if (boardingFromDate == null) {
- Calendar calendar = new GregorianCalendar();
- calendar.add(Calendar.MONTH, -12);
- boardingFromDate = calendar.getTime();
- }
- return boardingFromDate;
- }
-
- /**
- * Used by Tapestry to set the boardingFromDate from calculateBoardings form.
- *
- * @param boardingFromDate used to calculate boardings done on the selected boat
- */
- public void setBoardingFromDate(Date boardingFromDate) {
- this.boardingFromDate = boardingFromDate;
- }
-
- public BoatInfos getBoatInfos() throws SuiviObsmerException {
- if (getCompanyBoatInfos() == null) {
- return null;
- }
- return getCompanyBoatInfos().getBoatInfos();
- }
-
- /**
- * Get CSS style class to apply on lastContact depends on its state.
- *
- * @return the CSS style to apply on contact block
- * @throws SuiviObsmerException
- * @see BusinessUtils#getContactStyle(Contact, boolean)
- */
- public String getlastContactStyle() throws SuiviObsmerException {
- Contact contact = getCompanyBoatInfos().getLastContact();
- return BusinessUtils.getContactStyle(contact, user.getAdmin());
- }
-
- /** /////////////////////// FOR EACH ELLIGIBLEBOAT ROW ///////////////// **/
-
- public String getElligibleRowInfos() {
- return BusinessUtils.getTooltipSampleRow(elligibleBoat.getSampleRow());
- }
-
- public boolean isElligibleBoatCompanyActiveFalse() {
- return BooleanUtils.isFalse(elligibleBoat.getCompanyActive());
- }
-
- public boolean canCreateNewContactFromElligibleBoat() throws SuiviObsmerException {
- if (!user.getAdmin() && !isElligibleBoatCompanyActiveFalse()) {
- Boat currentBoat = getBoatInfos().getBoat();
- return currentBoat.canCreateContact(user.getCompany());
- }
- return false;
- }
-
- public String getElligibleRowStyle() {
- boolean condition1 = elligibleBoat.getCompanyActive() == null && !elligibleBoat.getGlobalActive();
- return condition1 || isElligibleBoatCompanyActiveFalse() ? "line-through" : "";
- }
-
- /** /////////////////////// ACTIONS //////////////////////////////////// **/
-
- Block onSuccessFromCompanySelectForm() throws SuiviObsmerException {
- companyBoatInfos = null;
- getCompanyBoatInfos();
- return boatInfosZone.getBody();
- }
-
- Block onActionFromEditBoatInfos() throws SuiviObsmerException {
- boatInfosEditable = true;
- // WARNING :: Reset sampleRow select for edition mode, no limit for
- // showing sampleRows instead of filters
- getFilter().setNbMonthFinishedFromToday(null);
- resetSampleRowSelect();
- getFilter().setNbMonthFinishedFromToday(-1);
- return boatInfosZone.getBody();
- }
-
- Block onActionFromCancelEditBoatInfos() throws SuiviObsmerException {
- /*if (propertyChange.isChanged()) {
- if (log.isDebugEnabled()) {
- log.debug("Change property");
- }
- }*/
-
- // Set boatSelectedImmatriculation for boatInfos to reinitialize it (next getBoatInfos() call)
- //boatSelectedImmatriculation = getBoatInfos().getBoat().getImmatriculation();
- // Suppress boatInfos to get the one from serviceBoat (not updated yet)
- companyBoatInfos = null;
- return boatInfosZone.getBody();
- }
-
- void onSelectedFromAddBoatInfosSampleRow() throws SuiviObsmerException {
- // We stay in edition mode
- boatInfosEditable = true;
- if (StringUtils.isNotEmpty(boatInfosSampleRowId)) {
- SampleRow row = getSampleRowSelectModel().findObject(boatInfosSampleRowId);
- companyBoatInfos.setNewElligibleBoat(row);
- }
- }
-
- void onSelectedFromRemoveBoatInfosSampleRow(String sampleRowCode) throws SuiviObsmerException {
- boatInfosEditable = true;
- companyBoatInfos.removeElligibleBoat(sampleRowCode);
- }
-
- void onSelectedFromActiveBoatInfosSampleRow(String sampleRowCode) throws SuiviObsmerException {
- boatInfosEditable = true;
- companyBoatInfos.activeElligibleBoat(sampleRowCode);
- }
-
- Block onSuccessFromBoatInfosForm() throws SuiviObsmerException {
- if (!boatInfosEditable) {
- // Save data
- serviceBoat.createUpdateCompanyBoatInfos(companyBoatInfos);
- }
- return boatInfosZone.getBody();
- }
-
- Block onSuccessFromCalculateBoardings() throws SuiviObsmerException {
- return boatInfosZone.getBody();
- }
-
- /**************************** Create new contact **************************/
-
- @InjectPage
- private Contacts contacts;
-
- Object onActionFromAddNewContactFromBoat(int boatImmatriculation) throws SuiviObsmerException {
- // Get selected sampleRow
- sampleRow = getSampleRow();
- // Get boat from list
- boat = getBoats().get(boatImmatriculation);
- contacts.createNewContact(boat, sampleRow);
- return contacts;
- }
-
- Object onActionFromAddNewContactFromSampleRow(String sampleRowCode) throws SuiviObsmerException {
- // Get sampleRow from elligibleBoat list
- ElligibleBoat elligible = getCompanyBoatInfos().getElligibleBoat(sampleRowCode);
- sampleRow = elligible.getSampleRow();
- contacts.createNewContact(getBoatSelected(), sampleRow);
- return contacts;
- }
-
- /**************************** Go to last ActivityCalendar *****************/
-
- @InjectPage
- private BoatActivityCalendar calendarPage;
-
- public boolean hasActivityCalendar() throws SuiviObsmerException {
- return getBoatSelected().sizeActivityCalendar() != 0;
- }
-
- Object onActionFromShowLastActivityCalendar() throws SuiviObsmerException {
- calendarPage.setBoat(getBoatSelected());
- return calendarPage;
- }
-}
Copied: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Boats.java (from rev 354, trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/Boats.java)
===================================================================
--- trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Boats.java (rev 0)
+++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Boats.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -0,0 +1,835 @@
+/*
+ * *##%
+ * Wao :: Web Interface
+ * 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.ui.pages;
+
+import fr.ifremer.wao.WaoContext;
+import fr.ifremer.wao.WaoException;
+import fr.ifremer.wao.bean.BoatFilterImpl;
+import fr.ifremer.wao.entity.Boat;
+import fr.ifremer.wao.bean.BoatFilter;
+import fr.ifremer.wao.bean.CompanyBoatInfos;
+import fr.ifremer.wao.entity.BoatInfos;
+import fr.ifremer.wao.entity.Company;
+import fr.ifremer.wao.entity.Contact;
+import fr.ifremer.wao.entity.ElligibleBoat;
+import fr.ifremer.wao.entity.WaoUser;
+import fr.ifremer.wao.entity.Profession;
+import fr.ifremer.wao.entity.SampleRow;
+import fr.ifremer.wao.service.ServiceBoat;
+import fr.ifremer.wao.service.ServiceReferential;
+import fr.ifremer.wao.service.ServiceSampling;
+import fr.ifremer.wao.service.ServiceUser;
+import fr.ifremer.wao.ui.base.AbstractFilteredPage;
+import fr.ifremer.wao.ui.data.BusinessUtils;
+import fr.ifremer.wao.ui.base.GenericSelectModel;
+import fr.ifremer.wao.ui.base.WaoPage;
+import fr.ifremer.wao.ui.components.FeedBack;
+import fr.ifremer.wao.ui.components.Layout;
+import fr.ifremer.wao.ui.data.BoatDataSource;
+import fr.ifremer.wao.ui.data.ExportStreamResponse;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.GregorianCalendar;
+import java.util.List;
+import java.util.zip.GZIPInputStream;
+import org.apache.commons.lang.BooleanUtils;
+import org.apache.commons.lang.StringUtils;
+import org.apache.tapestry5.Block;
+import org.apache.tapestry5.EventContext;
+import org.apache.tapestry5.PersistenceConstants;
+import org.apache.tapestry5.StreamResponse;
+import org.apache.tapestry5.annotations.IncludeStylesheet;
+import org.apache.tapestry5.annotations.InjectComponent;
+import org.apache.tapestry5.annotations.InjectPage;
+import org.apache.tapestry5.annotations.Log;
+import org.apache.tapestry5.annotations.Persist;
+import org.apache.tapestry5.annotations.Property;
+import org.apache.tapestry5.annotations.SessionState;
+import org.apache.tapestry5.corelib.components.Zone;
+import org.apache.tapestry5.ioc.annotations.Inject;
+import org.apache.tapestry5.ioc.services.PropertyAccess;
+import org.apache.tapestry5.services.Response;
+import org.apache.tapestry5.upload.services.UploadedFile;
+import org.slf4j.Logger;
+
+/**
+ * Boats
+ *
+ * Created: 9 nov. 2009
+ *
+ * @author fdesbois
+ * @version $Revision$
+ *
+ * Mise a jour: $Date$
+ * par : $Author$
+ */
+ at IncludeStylesheet("context:css/boats.css")
+public class Boats extends AbstractFilteredPage implements WaoPage {
+
+ @Override
+ public boolean isOnlyForAdmin() {
+ return false;
+ }
+
+ @Inject
+ private Logger log;
+
+ @InjectComponent
+ private Layout layout;
+
+ @SessionState
+ @Property
+ private WaoUser user;
+
+ @Inject
+ private ServiceReferential serviceReferential;
+
+ @Inject
+ private ServiceSampling serviceSampling;
+
+ @Inject
+ private ServiceBoat serviceBoat;
+
+ @Inject
+ private PropertyAccess propertyAccess;
+
+ @Property
+ private String sampleRowContextId;
+
+ /** Selected boat immatriculation for showing boatInfos */
+ @Persist("flash")
+ private Integer boatSelectedImmatriculation;
+
+ public Integer getBoatSelectedImmatriculation() {
+ return boatSelectedImmatriculation;
+ }
+
+ public void setBoatSelectedImmatriculation(Integer boatSelectedImmatriculation) {
+ this.boatSelectedImmatriculation = boatSelectedImmatriculation;
+ }
+
+ @InjectComponent
+ private FeedBack filterFeedback;
+
+ void setupRender() throws WaoException {
+ sampleRow = null;
+ getSampleRow();
+ // Profession select reset
+ professionSelectModel = null;
+ getProfessionSelectModel();
+
+ // Manage sampleRow from context
+ if (isSampleRowExists()) {
+ // Filters will be set and displayed
+ getFilter().setSampleRow(sampleRow);
+ filtersHidden = false;
+ boats = null;
+ filterFeedback.addInfo("Vous êtes en cours de sélection d'un navire pour la ligne du plan " + sampleRow.getCode());
+ professionId = getSampleRow().getProfession().getTopiaId();
+ }
+
+ // Initialize filters using AbstractFilteredPage superclass
+ initSelectFilters(false, false, false);
+
+ companyBoatInfos = null;
+ //boatSelectedImmatriculation = null;
+ }
+
+ void onActivate(EventContext ec) {
+ sampleRowContextId = ec.get(String.class, 0);
+// boatSelectedImmatriculation = ec.get(Integer.class, 1);
+ }
+
+// Object[] onPassivate() {
+// return new Object[] { sampleRowContextId, boatSelectedImmatriculation };
+// }
+
+ String onPassivate() {
+ return sampleRowContextId;
+ }
+
+ /**************************** Import Forms ********************************/
+
+ /** Csv file for boats import */
+ @Property
+ private UploadedFile boatsCsvFile;
+
+ @Log
+ void onSuccessFromImportBoatsForm() {
+ //importBoatsForm.clearErrors();
+ try {
+ int[] result = serviceBoat.importBoatCsv(boatsCsvFile.getStream());
+ // Suppress persitant list of boats
+ boats = null;
+ layout.getFeedBack().addInfo(result[0] + " navires importés dont " + result[1] + " nouveaux");
+ } catch (WaoException eee) {
+ layout.getFeedBack().addError(eee.getMessage());
+ }
+ }
+
+ /** Csv file for activityCalendar import, can be a Gzip file */
+ @Property
+ private UploadedFile activityCalendarsCsvFile;
+
+ private InputStream activityCalendarLogFile;
+
+ private InputStream activityCalendarLogAccessFile;
+
+ protected static final String GZIP_MIMETYPE = "application/x-gzip";
+
+ InputStream getActivityCalendarLogFile() throws FileNotFoundException {
+ if (activityCalendarLogFile == null) {
+ if (log.isInfoEnabled()) {
+ log.info("BUSINESS REQUEST [getActivityCalendarLogFile]");
+ }
+ activityCalendarLogFile = serviceBoat.getActivityCalendarLogFile();
+ }
+ return activityCalendarLogFile;
+ }
+
+ public boolean isLogFileExists() {
+ try {
+ getActivityCalendarLogFile();
+ return true;
+ } catch (FileNotFoundException eee) {
+ if (log.isInfoEnabled()) {
+ log.info("Aucun fichier de log existant pour les calendriers d'activité");
+ }
+ return false;
+ }
+ }
+
+ InputStream getActivityCalendarLogAccessFile() throws FileNotFoundException {
+ if (activityCalendarLogAccessFile == null) {
+ if (log.isInfoEnabled()) {
+ log.info("BUSINESS REQUEST [getActivityCalendarLogAccessFile]");
+ }
+ activityCalendarLogAccessFile =
+ serviceBoat.getActivityCalendarLogAccessFile();
+ }
+ return activityCalendarLogAccessFile;
+ }
+
+ public boolean isLogAccessFileExists() {
+ try {
+ getActivityCalendarLogAccessFile();
+ return true;
+ } catch (FileNotFoundException eee) {
+ if (log.isInfoEnabled()) {
+ log.info("Aucun fichier de log existant pour les accès " +
+ "utilisateurs aux calendriers d'activité");
+ }
+ return false;
+ }
+ }
+
+ @Log
+ void onSuccessFromImportActivityCalendarsForm() throws WaoException, IOException {
+ InputStream input = activityCalendarsCsvFile.getStream();
+ if (log.isDebugEnabled()) {
+ log.debug("Content type : " + activityCalendarsCsvFile.getContentType());
+ }
+ if (activityCalendarsCsvFile.getContentType().equals(GZIP_MIMETYPE)) {
+ if (log.isDebugEnabled()) {
+ log.debug("Gzip file");
+ }
+ input = new GZIPInputStream(input);
+ }
+ serviceBoat.importActivityCalendarCsv(input);
+ companyBoatInfos = null;
+ }
+
+ public StreamResponse onActionFromShowActivityCalendarLogFile() {
+ return new StreamResponse() {
+
+ @Override
+ public String getContentType() {
+ return "text/plain;charset=utf-8";
+ }
+
+ @Override
+ public InputStream getStream() throws IOException {
+ return getActivityCalendarLogFile();
+ }
+
+ @Override
+ public void prepareResponse(Response response) {
+ }
+ };
+ }
+
+ public StreamResponse onActionFromShowActivityCalendarLogAccessFile() {
+ return new StreamResponse() {
+
+ @Override
+ public String getContentType() {
+ return "text/plain;charset=utf-8";
+ }
+
+ @Override
+ public InputStream getStream() throws IOException {
+ return getActivityCalendarLogAccessFile();
+ }
+
+ @Override
+ public void prepareResponse(Response response) {
+ }
+ };
+ }
+
+ /**************************** Filters Form *****************************************/
+
+ /** Filters to apply on boats list */
+ @Persist
+ private BoatFilter boatFilter;
+
+ /** Current sampleRow from context */
+ @Persist
+ private SampleRow sampleRow;
+
+ /** Profession select */
+ @Persist
+ private GenericSelectModel<Profession> professionSelectModel;
+
+ @Property
+ private String professionId;
+
+ /** Used to manage view of filters zone */
+ @Persist
+ private boolean filtersHidden;
+
+ @InjectComponent
+ private Zone filtersZone;
+
+ /**
+ * Filters to apply on boats list. Method used by AbstractFilteredPage superclass.
+ *
+ * @return the current BoatFilter to apply
+ * @throws WaoException
+ * @see AbstractFilteredPage
+ */
+ @Override
+ public BoatFilter getFilter() throws WaoException {
+ if (boatFilter == null) {
+ if (log.isDebugEnabled()) {
+ log.debug("Create filter");
+ }
+ boatFilter = new BoatFilterImpl();
+ // Only rows which are not finished nearly one month
+ boatFilter.setNbMonthFinishedFromToday(-1);
+ }
+ return boatFilter;
+ }
+
+ @Override
+ protected boolean isAvailableDataForFiltersOnly() {
+ return true;
+ }
+
+ /**
+ * Retrieve sampleRow from business with id from url context. The sampleRowId from context is set by SamplingPlan page.
+ * When the sampleRow is not null, the filters are disabled to optimize searching boats for this row.
+ *
+ * @return the sampleRow from business
+ * @throws WaoException
+ */
+ public SampleRow getSampleRow() throws WaoException {
+ if (sampleRow == null && !StringUtils.isEmpty(sampleRowContextId)) {
+ if (log.isInfoEnabled()) {
+ log.info("BUSINESS REQUEST [getSampleRow]");
+ }
+ sampleRow = serviceSampling.getSampleRow(sampleRowContextId);
+ }
+ return sampleRow;
+ }
+
+ public boolean isSampleRowExists() throws WaoException {
+ return getSampleRow() != null;
+ }
+
+ public GenericSelectModel<Profession> getProfessionSelectModel() throws WaoException {
+ if (professionSelectModel == null) {
+ if (log.isInfoEnabled()) {
+ log.info("BUSINESS REQUEST [getProfessions]");
+ }
+ List<Profession> professions = serviceReferential.getProfessions();
+ professionSelectModel = new GenericSelectModel<Profession>(professions, Profession.class,
+ "code", "topiaId", propertyAccess);
+ }
+ return professionSelectModel;
+ }
+
+ public boolean isFiltersHidden() {
+ return filtersHidden;
+ }
+
+ public String getHiddenStyle() {
+ return isFiltersHidden() ? "hidden" : "";
+ }
+
+ Block onActionFromShowFilters() {
+ filtersHidden = false;
+ return filtersZone.getBody();
+ }
+
+ Block onActionFromHideFilters() {
+ filtersHidden = true;
+ return filtersZone.getBody();
+ }
+
+ /**
+ * EVENT_SELECTED :: reset submit button for filtersForm. Reset filters and sampleRow from context.
+ */
+ void onSelectedFromReset() {
+ // Suppress persistant boat filter and sampleRowId in url context.
+ boatFilter = null;
+ sampleRowContextId = null;
+ }
+
+ /**
+ * EVENT_SELECTED :: search sumit button for filtersForm. Get profession from selectModel to add it in filters.
+ * Other filters are managed by AbstractFilteredPage superclass.
+ *
+ * @throws WaoException for business errors
+ * @see AbstractFilteredPage#onSelectedFromSearch()
+ */
+ @Override
+ public void onSelectedFromSearch() throws WaoException {
+ super.onSelectedFromSearch();
+ if (log.isDebugEnabled()) {
+ log.debug("FILTER : facadeName=" + boatFilter.getFacadeName());
+ log.debug("FILTER : sectorName=" + boatFilter.getSectorName());
+ log.debug("FILTER : sampleRow=" + boatFilter.getSampleRow());
+ log.debug("FILTER : profession=" + boatFilter.getProfession());
+ log.debug("FILTER : boatName=" + boatFilter.getBoatName());
+ log.debug("FILTER : boatImmatriculation=" + boatFilter.getBoatImmatriculation());
+ log.debug("FILTER : boatDistrictCode=" + boatFilter.getBoatDistrictCode());
+ log.debug("FILTER : company=" + boatFilter.getCompany());
+ }
+ Profession profession = getProfessionSelectModel().findObject(professionId);
+ boatFilter.setProfession(profession);
+ }
+
+ /**
+ * EVENT_SUCCESS :: for filtersForm. Reset persitant data to have new data using filters selected.
+ *
+ * @return the filtersZone if it's a refresh data for select, or the page otherwise
+ * @throws WaoException for business errors
+ */
+ Object onSuccessFromFiltersForm() throws WaoException {
+ if (isEdited()) {
+ return filtersZone.getBody();
+ }
+ // Suppress persistant boats list to get new one with filter
+ boats = null;
+ // Suppress persistant immatriculation for boat selected
+ boatSelectedImmatriculation = null;
+ // Suppress persistant boat informations for boat selected
+ companyBoatInfos = null;
+ return this;
+ }
+
+ /**************************** Boats List *****************************************/
+
+ /** DataSource containing the boats */
+ @Persist
+ private BoatDataSource boats;
+
+ /** Current boat in the Grid */
+ @Property
+ private Boat boat;
+
+ /** Used to change style a line on two */
+ private boolean even = true;
+
+ /** Used to refresh boats Grid */
+ @InjectComponent
+ private Zone boatsZone;
+
+ /**
+ * Get dataSource which contains current boats to show on the page. Depends on filters sets by user.
+ * BoatDataSource uses serviceBoat to retrieve boats with filters.
+ *
+ * @return the BoatDataSource which contains the boats map
+ * @throws WaoException
+ * @see BoatDataSource
+ */
+ public BoatDataSource getBoats() throws WaoException {
+ if (boats == null) {
+ boats = new BoatDataSource(getFilter(), serviceBoat);
+ }
+ return boats;
+ }
+
+ /**
+ * Initialized row CSS style depends on selection in the list. The style is also changed a line on two.
+ *
+ * @return the CSS style class to used for the current row in the Grid
+ */
+ public String getRowStyle() {
+ String result = "";
+ even = !even;
+ if (boatSelectedImmatriculation != null &&
+ boat.getImmatriculation() == boatSelectedImmatriculation) {
+ result = "selected";
+ } else if (!boat.getActive()) {
+ result = "refused";
+ } else {
+ result = even ? "even" : "odd";
+ }
+ return result;
+ }
+
+ public DateFormat getDateFormat() {
+ return new SimpleDateFormat("dd/MM/yyyy");
+ }
+
+ public boolean canCreateNewContactFromList() throws WaoException {
+ if (!user.getAdmin() && isSampleRowExists()) {
+ return boat.canCreateContact(user.getCompany());
+ }
+ return false;
+ }
+
+ StreamResponse onActionFromExportShowBoats() {
+ return new ExportStreamResponse("wao-navires") {
+
+ @Override
+ public InputStream getStream() throws IOException {
+ InputStream result = null;
+ try {
+ if (log.isDebugEnabled()) {
+ log.debug("Filter sampleRow : " + getFilter().getSampleRow());
+ }
+ result = serviceBoat.exportBoatCsv(getFilter());
+ } catch (WaoException eee) {
+ throw new IOException(eee);
+ }
+ return result;
+ }
+ };
+ }
+
+ Block onActionFromShowBoatInfos(Integer boatImma) throws WaoException {
+ boatSelectedImmatriculation = boatImma;
+ // Suppress persistant boat informations
+ companyBoatInfos = null;
+
+ if (log.isDebugEnabled()) {
+ log.debug("Show infos for boat : " + boatImma);
+ }
+
+ if (user.getAdmin() && getCompany() != null) {
+ companySelectedId = getCompany().getTopiaId();
+ }
+ return boatsZone.getBody();
+ }
+
+ /**************************** Boat selected Infos *************************/
+
+ @Persist
+ private CompanyBoatInfos companyBoatInfos;
+
+ @InjectComponent
+ private Zone boatInfosZone;
+
+ @Inject
+ private Block displayBoatInfos;
+
+ @Inject
+ private Block editBoatInfos;
+
+ @Property
+ private ElligibleBoat elligibleBoat;
+
+ @Property
+ private String boatInfosSampleRowId;
+
+ private boolean boatInfosEditable;
+
+ private Date boardingFromDate;
+
+ private GenericSelectModel<Company> companies;
+
+ @Inject
+ private ServiceUser serviceUser;
+
+ @Property
+ @Persist(PersistenceConstants.FLASH)
+ private String companySelectedId;
+
+ private Company company;
+
+ /*@Persist
+ private WaoPropertyChangeListener propertyChange;*/
+
+ /** /////////////////////// GLOBAL TO THE BLOCK /////////////////////// **/
+
+ public boolean isActivityCalendarImportRun() {
+ return WaoContext.isActivityCalendarImportRun();
+ }
+
+ public Block getActiveBoatInfosBlock() {
+ if (boatInfosEditable) {
+ return editBoatInfos;
+ }
+ return displayBoatInfos;
+ }
+
+ public CompanyBoatInfos getCompanyBoatInfos() throws WaoException {
+ if (companyBoatInfos == null && boatSelectedImmatriculation != null && getCompany() != null) {
+ if (log.isInfoEnabled()) {
+ log.info("BUSINESS REQUEST [getElligibleBoats]");
+ }
+ companyBoatInfos = serviceBoat.getCompanyBoatInfos(boatSelectedImmatriculation, getCompany());
+ }
+ return companyBoatInfos;
+ }
+
+ /**
+ * Retrieve companies select model for admin user. Only active companies
+ * will be used for this model.
+ *
+ * @return the GenericSelectModel<Company>
+ * @throws WaoException
+ */
+ public GenericSelectModel<Company> getCompanies() throws WaoException {
+ if (companies == null) {
+ if (log.isDebugEnabled()) {
+ log.debug("BUSINESS REQUEST [getCompanies]");
+ }
+ List<Company> results = serviceUser.getCompanies(true);
+ companies = new GenericSelectModel<Company>(results, Company.class, "name","topiaId",propertyAccess);
+ }
+ return companies;
+ }
+
+ /**
+ * Get the current company. The user one if it's not an admin or the
+ * selected one otherwise.
+ *
+ * @return the current Company
+ * @throws WaoException
+ */
+ public Company getCompany() throws WaoException {
+ if (company == null) {
+ if (StringUtils.isNotEmpty(companySelectedId)) {
+ company = getCompanies().findObject(companySelectedId);
+ } else if (!user.getAdmin()) {
+ company = user.getCompany();
+ }
+ }
+ return company;
+ }
+
+ /**
+ * Used to get the selected boat.
+ *
+ * @return the selected boat from the grid
+ * @throws WaoException
+ */
+ public Boat getBoatSelected() throws WaoException {
+ if (log.isDebugEnabled()) {
+ log.debug("selected imma : " + boatSelectedImmatriculation);
+ log.debug("exist boat ? : " + getBoats().contains(boatSelectedImmatriculation));
+ }
+ return getBoats().get(boatSelectedImmatriculation);
+ }
+
+ /**
+ * Date for calculate boardings done for the selected boat. All boardings (number of contacts) will be calculated from this date.
+ * Initialized as 12 months from today, but can be set by user.
+ *
+ * @return the Date used to calculate boardings done on the selected boat
+ */
+ public Date getBoardingFromDate() {
+ if (boardingFromDate == null) {
+ Calendar calendar = new GregorianCalendar();
+ calendar.add(Calendar.MONTH, -12);
+ boardingFromDate = calendar.getTime();
+ }
+ return boardingFromDate;
+ }
+
+ /**
+ * Used by Tapestry to set the boardingFromDate from calculateBoardings form.
+ *
+ * @param boardingFromDate used to calculate boardings done on the selected boat
+ */
+ public void setBoardingFromDate(Date boardingFromDate) {
+ this.boardingFromDate = boardingFromDate;
+ }
+
+ public BoatInfos getBoatInfos() throws WaoException {
+ if (getCompanyBoatInfos() == null) {
+ return null;
+ }
+ return getCompanyBoatInfos().getBoatInfos();
+ }
+
+ /**
+ * Get CSS style class to apply on lastContact depends on its state.
+ *
+ * @return the CSS style to apply on contact block
+ * @throws WaoException
+ * @see BusinessUtils#getContactStyle(Contact, boolean)
+ */
+ public String getlastContactStyle() throws WaoException {
+ Contact contact = getCompanyBoatInfos().getLastContact();
+ return BusinessUtils.getContactStyle(contact, user.getAdmin());
+ }
+
+ /** /////////////////////// FOR EACH ELLIGIBLEBOAT ROW ///////////////// **/
+
+ public String getElligibleRowInfos() {
+ return BusinessUtils.getTooltipSampleRow(elligibleBoat.getSampleRow());
+ }
+
+ public boolean isElligibleBoatCompanyActiveFalse() {
+ return BooleanUtils.isFalse(elligibleBoat.getCompanyActive());
+ }
+
+ public boolean canCreateNewContactFromElligibleBoat() throws WaoException {
+ if (!user.getAdmin() && !isElligibleBoatCompanyActiveFalse()) {
+ Boat currentBoat = getBoatInfos().getBoat();
+ return currentBoat.canCreateContact(user.getCompany());
+ }
+ return false;
+ }
+
+ public String getElligibleRowStyle() {
+ boolean condition1 = elligibleBoat.getCompanyActive() == null && !elligibleBoat.getGlobalActive();
+ return condition1 || isElligibleBoatCompanyActiveFalse() ? "line-through" : "";
+ }
+
+ /** /////////////////////// ACTIONS //////////////////////////////////// **/
+
+ void onSuccess() throws WaoException {
+ if (getBoatInfos() != null) {
+ boatSelectedImmatriculation = getBoatInfos().getBoat().getImmatriculation();
+ }
+ }
+
+ Block onSuccessFromCompanySelectForm() throws WaoException {
+ companyBoatInfos = null;
+ getCompanyBoatInfos();
+ return boatInfosZone.getBody();
+ }
+
+ Block onActionFromEditBoatInfos() throws WaoException {
+ boatInfosEditable = true;
+ // WARNING :: Reset sampleRow select for edition mode, no limit for
+ // showing sampleRows instead of filters
+ getFilter().setNbMonthFinishedFromToday(null);
+ resetSampleRowSelect();
+ getFilter().setNbMonthFinishedFromToday(-1);
+ return boatInfosZone.getBody();
+ }
+
+ Block onActionFromCancelEditBoatInfos() throws WaoException {
+ /*if (propertyChange.isChanged()) {
+ if (log.isDebugEnabled()) {
+ log.debug("Change property");
+ }
+ }*/
+
+ // Set boatSelectedImmatriculation for boatInfos to reinitialize it (next getBoatInfos() call)
+ boatSelectedImmatriculation = getBoatInfos().getBoat().getImmatriculation();
+ // Suppress boatInfos to get the one from serviceBoat (not updated yet)
+ companyBoatInfos = null;
+ return boatInfosZone.getBody();
+ }
+
+ void onSelectedFromAddBoatInfosSampleRow() throws WaoException {
+ // We stay in edition mode
+ boatInfosEditable = true;
+ if (StringUtils.isNotEmpty(boatInfosSampleRowId)) {
+ SampleRow row = getSampleRowSelectModel().findObject(boatInfosSampleRowId);
+ companyBoatInfos.setNewElligibleBoat(row);
+ }
+ }
+
+ void onSelectedFromRemoveBoatInfosSampleRow(String sampleRowCode) throws WaoException {
+ boatInfosEditable = true;
+ companyBoatInfos.removeElligibleBoat(sampleRowCode);
+ }
+
+ void onSelectedFromActiveBoatInfosSampleRow(String sampleRowCode) throws WaoException {
+ boatInfosEditable = true;
+ companyBoatInfos.activeElligibleBoat(sampleRowCode);
+ }
+
+ Block onSuccessFromBoatInfosForm() throws WaoException {
+ if (!boatInfosEditable) {
+ // Save data
+ serviceBoat.createUpdateCompanyBoatInfos(companyBoatInfos);
+ }
+ //boatSelectedImmatriculation = getBoatInfos().getBoat().getImmatriculation();
+ return boatInfosZone.getBody();
+ }
+
+ Block onSuccessFromCalculateBoardings() throws WaoException {
+ //boatSelectedImmatriculation = getBoatInfos().getBoat().getImmatriculation();
+ return boatInfosZone.getBody();
+ }
+
+ /**************************** Create new contact **************************/
+
+ @InjectPage
+ private Contacts contacts;
+
+ Object onActionFromAddNewContactFromBoat(int boatImmatriculation) throws WaoException {
+ // Get selected sampleRow
+ sampleRow = getSampleRow();
+ // Get boat from list
+ boat = getBoats().get(boatImmatriculation);
+ contacts.createNewContact(boat, sampleRow);
+ return contacts;
+ }
+
+ Object onActionFromAddNewContactFromSampleRow(String sampleRowCode) throws WaoException {
+ // Get sampleRow from elligibleBoat list
+ ElligibleBoat elligible = getCompanyBoatInfos().getElligibleBoat(sampleRowCode);
+ sampleRow = elligible.getSampleRow();
+ contacts.createNewContact(getBoatSelected(), sampleRow);
+ return contacts;
+ }
+
+ /**************************** Go to last ActivityCalendar *****************/
+
+ @InjectPage
+ private BoatActivityCalendar calendarPage;
+
+ public boolean hasActivityCalendar() throws WaoException {
+ return getBoatSelected().sizeActivityCalendar() != 0;
+ }
+
+ Object onActionFromShowLastActivityCalendar() throws WaoException {
+ calendarPage.setBoat(getBoatSelected());
+ return calendarPage;
+ }
+}
Deleted: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Contacts.java
===================================================================
--- trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/Contacts.java 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Contacts.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,638 +0,0 @@
-/*
- * *##%
- * SuiviObsmer :: Web Interface
- * 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.suiviobsmer.ui.pages;
-
-import fr.ifremer.suiviobsmer.SuiviObsmerBusinessException;
-import fr.ifremer.suiviobsmer.SuiviObsmerContext;
-import fr.ifremer.suiviobsmer.SuiviObsmerException;
-import fr.ifremer.suiviobsmer.bean.BoatFilter;
-import fr.ifremer.suiviobsmer.bean.ContactFilter;
-import fr.ifremer.suiviobsmer.bean.ContactFilterImpl;
-import fr.ifremer.suiviobsmer.bean.ContactState;
-import fr.ifremer.suiviobsmer.bean.ImportResults;
-import fr.ifremer.suiviobsmer.entity.Boat;
-import fr.ifremer.suiviobsmer.entity.Contact;
-import fr.ifremer.suiviobsmer.entity.SampleRow;
-import fr.ifremer.suiviobsmer.entity.WaoUser;
-import fr.ifremer.suiviobsmer.services.ServiceBoat;
-import fr.ifremer.suiviobsmer.services.ServiceContact;
-import fr.ifremer.suiviobsmer.services.ServiceSampling;
-import fr.ifremer.suiviobsmer.ui.base.AbstractFilteredPage;
-import fr.ifremer.suiviobsmer.ui.data.ContactDataSource;
-import fr.ifremer.suiviobsmer.ui.data.BusinessUtils;
-import fr.ifremer.suiviobsmer.ui.base.GenericSelectModel;
-import fr.ifremer.suiviobsmer.ui.base.SuiviObsmerPage;
-import fr.ifremer.suiviobsmer.ui.components.Layout;
-import fr.ifremer.suiviobsmer.ui.data.ExportStreamResponse;
-import fr.ifremer.suiviobsmer.ui.services.ContactModelFactory;
-import java.io.IOException;
-import java.io.InputStream;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.List;
-import org.apache.commons.lang.BooleanUtils;
-import org.apache.commons.lang.StringUtils;
-import org.apache.tapestry5.ComponentResources;
-import org.apache.tapestry5.Field;
-import org.apache.tapestry5.PersistenceConstants;
-import org.apache.tapestry5.StreamResponse;
-import org.apache.tapestry5.annotations.IncludeStylesheet;
-import org.apache.tapestry5.annotations.InjectComponent;
-import org.apache.tapestry5.annotations.Log;
-import org.apache.tapestry5.annotations.Persist;
-import org.apache.tapestry5.annotations.Property;
-import org.apache.tapestry5.annotations.SessionState;
-import org.apache.tapestry5.beaneditor.BeanModel;
-import org.apache.tapestry5.corelib.components.Form;
-import org.apache.tapestry5.corelib.components.Zone;
-import org.apache.tapestry5.ioc.annotations.Inject;
-import org.apache.tapestry5.ioc.services.PropertyAccess;
-import org.apache.tapestry5.services.BeanModelSource;
-import org.apache.tapestry5.upload.services.UploadedFile;
-import org.nuiton.util.DateUtils;
-import org.slf4j.Logger;
-
-/**
- * Contacts
- *
- * Created: 9 nov. 2009
- *
- * @author fdesbois
- * @version $Revision$
- *
- * Mise a jour: $Date$
- * par : $Author$
- */
- at IncludeStylesheet("context:css/contacts.css")
-public class Contacts extends AbstractFilteredPage implements SuiviObsmerPage {
-
- @Override
- public boolean isOnlyForAdmin() {
- return false;
- }
-
- @Inject
- private Logger log;
-
- @InjectComponent
- private Layout layout;
-
- @SessionState
- @Property
- private WaoUser user;
-
- @Inject
- private ServiceContact serviceContact;
-
- @Inject
- private ServiceSampling serviceSampling;
-
- @Inject
- private ServiceBoat serviceBoat;
-
-// @Persist(PersistenceConstants.FLASH)
-// private String contactEditedId;
-
- @Log
- void setupRender() throws SuiviObsmerException {
-// if (contactEdited == null) {
- if (log.isDebugEnabled()) {
- log.debug("RESET DATA");
- }
- initSelectFilters(true, true, false);
- contacts = null;
- getContacts();
-// }
- contactsForm.clearErrors();
- }
-
- /**************************** CONTACT FILTERS *****************************/
-
- @Persist
- private ContactFilter contactFilter;
-
- @InjectComponent
- private Zone filtersZone;
-
- @InjectComponent
- private Zone importExportZone;
-
- private boolean reset;
-
- @Property
- private ContactState stateFilter;
-
- public ContactFilter getContactFilter() throws SuiviObsmerException {
- if (contactFilter == null) {
- if (log.isDebugEnabled()) {
- log.debug("Init contactFilter");
- }
- contactFilter = new ContactFilterImpl();
- // Initialized to 12 months before the current day
- Date fromDate = DateUtils.createDateAfterToday(0, -3, 0);
- contactFilter.setFromDate(fromDate);
- }
- return contactFilter;
- }
-
- public boolean isFiltersVisible() {
- boolean companyFiltered = contactFilter.getCompany() != null && user.getAdmin();
- return (contactFilter.isFiltered() || companyFiltered) && StringUtils.isEmpty(contactFilter.getBoatName()); /*&& !getDefaultFromDate().equals(contactFilter.getFromDate());*/
- }
-
- @Override
- protected BoatFilter getFilter() throws SuiviObsmerException {
- return getContactFilter();
- }
-
- @Override
- protected boolean isAvailableDataForFiltersOnly() {
- return true;
- }
-
- Object onActionFromShowFilters() {
- //contactFilter = null;
- return filtersZone.getBody();
- }
-
- Object onActionFromShowImportExport() {
- return importExportZone.getBody();
- }
-
- void onSelectedFromReset() {
- reset = true;
- }
-
- @Log
- Object onSuccessFromFiltersForm() throws SuiviObsmerException {
- if (isEdited()) {
- return filtersZone.getBody();
- }
- if (reset) {
- contactFilter = null;
- }
-// else {
-// filtersVisible = true;
-// }
- return this;
- }
-
- /**************************** CONTACT IMPORT/EXPORT ***********************/
-
- @Property
- private UploadedFile contactsCsvFile;
-
- @Log
- void onSuccessFromImportContacts() throws SuiviObsmerException {
- //importBoatsForm.clearErrors();
- try {
- ImportResults result = serviceContact.importContactCsv(user, contactsCsvFile.getStream());
- // Suppress persitant list of contacts
- contacts = null;
- layout.getFeedBack().addInfo(result.getNbRowsImported() + " contacts importés, " +
- result.getNbRowsRefused() + " refusés.");
- for (String error : result.getErrors()) {
- layout.getFeedBack().addInfo(error);
- }
- } catch (SuiviObsmerBusinessException eee) {
- layout.getFeedBack().addError(eee.getMessage());
- }
- //return importBoatsForm.getHasErrors() ? importBoatsForm : this;
- }
-
- StreamResponse onActionFromExportShowContacts() {
- return new ExportStreamResponse("wao-contacts") {
-
- @Override
- public InputStream getStream() throws IOException {
- InputStream result = null;
- try {
- result = serviceContact.exportContactCsv(getContactFilter());
- } catch (SuiviObsmerException eee) {
- throw new IOException(eee);
- }
- return result;
- }
- };
- }
-
- /**************************** CONTACT LIST ********************************/
-
- @Inject
- private BeanModelSource beanModelSource;
-
- @Inject
- private ComponentResources resources;
-
- @Inject
- private ContactModelFactory contactModelFactory;
-
- @Persist
- private ContactDataSource contacts;
-// private Map<String, Contact> contacts;
-
- @Property
- private Contact contact;
-
- private BeanModel<Contact> contactModel;
-
- @Inject
- private PropertyAccess propertyAccess;
-
- private GenericSelectModel<WaoUser> userSelectModel;
-
- @Property
- @Persist(PersistenceConstants.FLASH)
- private String contactUserId;
-
- private ContactState contactState;
-
- private boolean even = true;
-
- public ContactDataSource getContacts() throws SuiviObsmerException {
- if (contacts == null) {
- if (log.isInfoEnabled()) {
- log.info("Create DataSource");
- }
- contacts = new ContactDataSource(getContactFilter(), serviceContact);
- }
- return contacts;
- }
-
-// public Map<String, Contact> getContacts() throws SuiviObsmerException {
-// if (contacts == null) {
-// if (log.isInfoEnabled()) {
-// log.info("BUSINESS REQUEST [getContactsByFilter]");
-// }
-// contacts = serviceContact.getContactsByFilter(getContactFilter());
-// }
-// return contacts;
-// }
-
- public BeanModel<Contact> getContactModel() {
- if (contactModel == null) {
- contactModel = user.getAdmin() ?
- contactModelFactory.buildAdminContactModel(beanModelSource, resources) :
- contactModelFactory.buildContactModel(beanModelSource, resources);
- }
- return contactModel;
- }
-
- public ContactState getContactState() {
- if (contactState == null) {
- // initialization
- this.contactState = ContactState.createContactStateEnum(contactEdited.getState());
- }
- return this.contactState;
- }
-
- public GenericSelectModel<WaoUser> getUserSelectModel() {
- if (userSelectModel == null) {
- List<WaoUser> users = user.getCompany().getWaoUser();
- if (log.isDebugEnabled()) {
- log.debug("Nb users : " + users.size());
- }
- userSelectModel = new GenericSelectModel<WaoUser>(users, WaoUser.class, "fullName", "id", propertyAccess);
- }
- return userSelectModel;
- }
-
- public void setContactState(ContactState contactState) {
- this.contactState = contactState;
- }
-
- public String getCommentDisplayed() {
- if (contact.getComment() != null && contact.getComment().length() > 20) {
- return contact.getComment().substring(0, 20) + "...";
- }
- return contact.getComment();
- }
-
- public String getCommentTooltip() {
- return contact.getComment().replaceAll("\n", "<br />").replaceAll("\r", "");
- }
-
- public String getSampleRowDescription() {
- return BusinessUtils.getTooltipSampleRow(contact.getSampleRow());
- }
-
- public String getBoatDescription() {
- return BusinessUtils.getTooltipBoat(contact.getBoat());
- }
-
- public String getTooltipExportFrom() throws SuiviObsmerException {
- if (getContactFilter().getFromDate() != null) {
- return "depuis le " + getDateFormat().format(getContactFilter().getFromDate());
- }
- return "";
- }
-
- public String getGridClass() {
- return user.getAdmin() ? "admin" : "user";
- }
-
- public String getRowClass() {
- String result = BusinessUtils.getContactStyle(contact, user.getAdmin());
- if (contact.getTopiaId().equals(contactSelectedId)) {
- result = "selected";
- }
- return result;
- }
-
- public DateFormat getDateFormat() {
- return new SimpleDateFormat("dd/MM/yyyy");
- }
-
- public boolean isEditionMode() {
- //return contact.getTopiaId().equals(contactEditedId);
- return contactEdited != null && contact.equals(contactEdited);
- }
-
- public boolean isEmpty(Boolean validation) {
- return validation == null;
- }
-
- /**************************** CONTACT ROW ACTION **************************/
-
- /**
- * Flag to know if it's only edition (=true) or save action (=false)
- */
- private boolean edited;
-
- private boolean deleted;
-
- @Persist
- @Property
- private Contact contactEdited;
-
- @Persist
- private String oldComment;
-
- public void prepareContactEdited(String contactId) throws SuiviObsmerException {
- if (contactEdited == null) {
- contactEdited = getContacts().get(contactId);
- }
- //contact = contactEdited;
- }
-
- public boolean hasActions() {
- return !user.getAdmin() && contact.getValidationCompany() == null;
- }
-
- public boolean canValidate() {
- // Can't validate during edition of the contact row
- if (isEditionMode()) {
- return false;
- }
- ContactState state = ContactState.createContactStateEnum(contact.getState());
- boolean boardingDone = state.equals(ContactState.BOARDING_DONE) && contact.getDataInputDate() != null;
- if (!user.getAdmin()) {
- return contact.getValidationCompany() == null && (state.isUnfinishedState() || boardingDone);
- }
- return contact.getValidationProgram() == null && BooleanUtils.isTrue(contact.getValidationCompany());
- }
-
- public boolean canUnvalidate() {
- if (!user.getAdmin()) {
- return contact.getValidationCompany() != null &&
- contact.getValidationProgram() == null;
- }
- return contact.getValidationProgram() != null;
- }
-
- void onSelectedFromAcceptContact(String contactId) throws SuiviObsmerException {
- //contact = getContacts().get(contactId);
- prepareContactEdited(contactId);
- if (user.getAdmin()) {
- contactEdited.setValidationProgram(Boolean.TRUE);
- } else {
- // For company accepted, addRealTideTime
- contactEdited.getSampleRow().addRealTideTime(contactEdited);
- contactEdited.setValidationCompany(Boolean.TRUE);
- }
- }
-
- void onSelectedFromRefuseContact(String contactId) throws SuiviObsmerException {
- //contact = getContacts().get(contactId);
- prepareContactEdited(contactId);
- if (user.getAdmin()) {
- // For program refused, removeRealTideTime
- contactEdited.getSampleRow().removeRealTideTime(contactEdited);
- contactEdited.setValidationProgram(Boolean.FALSE);
- } else {
- contactEdited.setValidationCompany(Boolean.FALSE);
- }
- }
-
- void onSelectedFromUnvalidateContact(String contactId) throws SuiviObsmerException {
- //contact = getContacts().get(contactId);
- prepareContactEdited(contactId);
- if (user.getAdmin()) {
- // For program unvalidate from previous refused validation, addRealTideTime
- if (BooleanUtils.isFalse(contactEdited.getValidationProgram())) {
- contactEdited.getSampleRow().addRealTideTime(contactEdited);
- }
- contactEdited.setValidationProgram(null);
- } else {
- // For company unvalidate from previous accepted validation,
- // removeRealTideTime
- if (BooleanUtils.isTrue(contactEdited.getValidationCompany())) {
- contactEdited.getSampleRow().removeRealTideTime(contactEdited);
- }
- contactEdited.setValidationCompany(null);
- }
- }
-
- void onSelectedFromEditContact(String contactId) throws SuiviObsmerException {
- //contact = getContacts().get(contactId);
- prepareContactEdited(contactId);
- contactUserId = contactEdited.getObserver().getTopiaId();
- //contactEditedId = contactId;
- contactSelectedId = contactId;
- oldComment = contactEdited.getComment();
- edited = true;
- }
-
- void onSelectedFromDeleteContact(String contactId) throws SuiviObsmerException {
- //contact = getContacts().get(contactId);
- prepareContactEdited(contactId);
- deleted = true;
- }
-
- void onSelectedFromSaveContact(String contactId) throws SuiviObsmerException {
- //contact = getContacts().get(contactId);
- prepareContactEdited(contactId);
- contactEdited.setState(contactState.toString());
- WaoUser contactUser = getUserSelectModel().findObject(contactUserId);
- contactEdited.setObserver(contactUser);
-
- if (log.isDebugEnabled()) {
- log.debug("Comment : " + contactEdited.getComment());
- }
- }
-
- void onSelectedFromCancelEditContact() throws SuiviObsmerException {
- contactEdited = null;
- edited = true;
- }
-
-// @Log
-// void onSelectedFromSaveComment(String contactId) throws SuiviObsmerException {
-// contact = getContacts().get(contactId);
-// if (log.isInfoEnabled()) {
-// log.info("Comment : " + contact.getComment());
-// }
-// contactEdited = true;
-// }
-
- /**************************** CONTACT SAVE ********************************/
-
- @Persist(PersistenceConstants.FLASH)
- private String contactSelectedId;
-
- @InjectComponent
- private Form contactsForm;
-
- @InjectComponent
- private Zone gridZone;
-
- @InjectComponent
- private Field beginDate;
-
- @InjectComponent
- private Field endDate;
-
- @InjectComponent
- private Field nbObservants;
-
- @InjectComponent
- private Field comment;
-
- @InjectComponent
- private Field inputDate;
-
- @Log
- void onValidateFormFromContactsForm() {
- contactsForm.clearErrors();
- // Validation for saving contact depends on contactState (only edition
- // form)
- if (!edited && contactState != null) {
- if (log.isInfoEnabled()) {
- log.info("For state : " + contactState);
- }
-
- Date begin = contactEdited.getTideBeginDate();
- Date end = contactEdited.getTideEndDate();
- Date input = contactEdited.getDataInputDate();
- SampleRow row = contactEdited.getSampleRow();
- //DateFormat dateFormat = new SimpleDateFormat("MM/yyyy");
-
- if (begin != null && !row.isValid(begin)) {
- contactsForm.recordError(beginDate,
- "La date de début de la marée doit correspondre à un mois valide (non vide) de la ligne " + row.getCode());
- }
-
- if (begin != null && end != null && end.before(begin)) {
- contactsForm.recordError(endDate, "La date de fin de la marée ne peut pas être antérieure à celle de début");
- }
-
- Date current = SuiviObsmerContext.getCurrentDate();
-
- if (end != null && end.after(current)) {
- contactsForm.recordError(endDate, "La date de fin de la marée ne peut pas être postérieure à la date du jour");
- }
-
- if (end != null && input != null && end.after(input)) {
- contactsForm.recordError(inputDate, "La date de saisie des données ne peut pas être antérieure à la date de fin de la marée");
- }
-
- if (input != null && input.after(current)) {
- contactsForm.recordError(inputDate, "La date de saisie des données ne peut pas être postérieure à la date du jour");
- }
-
- // Non abouti, Refus ou Refus Définitif
- if (contactState.isUnfinishedState()) {
- String newComment = contactEdited.getComment();
- if (StringUtils.isNotEmpty(newComment) && !newComment.equals(oldComment)) {
- // RAZ des champs
- contactEdited.setTideBeginDate(null);
- contactEdited.setTideEndDate(null);
- contactEdited.setNbObservants(0);
- contactEdited.setMammalsCapture(false);
- contactEdited.setMammalsObservation(false);
- contactEdited.setDataInputDate(null);
- } else {
- contactsForm.recordError(comment, "Vous devez ajouter un commentaire pour l'état '" + contactState + "'");
- }
- // Embarquement Réalisé
- } else if (contactState.equals(ContactState.BOARDING_DONE)) {
- if (begin == null) {
- contactsForm.recordError(beginDate, "La date de début de marée est obligatoire pour l'état '" + contactState + "'");
- }
- if (end == null) {
- contactsForm.recordError(endDate, "La date de fin de marée est obligatoire pour l'état '" + contactState + "'");
- }
- if (contactEdited.getNbObservants() == 0) {
- contactsForm.recordError(nbObservants, "Il ne peut y avoir aucun observateur pour l'état '" + contactState + "'");
- }
- }
- }
- }
-
- @Log
- Object onSuccessFromContactsForm() {
- if (!edited) {
- try {
- if (log.isDebugEnabled()) {
- log.debug("Contact save : " + contactEdited);
- }
- serviceContact.saveContact(contactEdited, deleted);
- contactSelectedId = contactEdited.getTopiaId();
- oldComment = null;
- contactEdited = null;
- } catch (SuiviObsmerException eee) {
- layout.getFeedBack().addError(eee.getMessage());
- }
- }
- return this;
- }
-
- @Log
- Object onFailureFromContactsForm() {
- if (log.isDebugEnabled()) {
- log.debug("Contact can't be saved with errors");
- }
- // The contact is not saved, the contact must be editable to show form
- // and correct errors
- edited = true;
- //contactEditedId = contact.getTopiaId();
- return contactsForm;
- //return gridZone;
- }
-
- public void createNewContact(Boat boat, SampleRow sampleRow) throws SuiviObsmerException {
- contact = serviceContact.getNewContact(user, sampleRow, boat);
- serviceContact.saveContact(contact, Boolean.FALSE);
- contactSelectedId = contact.getTopiaId();
- }
-}
Copied: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Contacts.java (from rev 354, trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/Contacts.java)
===================================================================
--- trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Contacts.java (rev 0)
+++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Contacts.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -0,0 +1,638 @@
+/*
+ * *##%
+ * Wao :: Web Interface
+ * 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.ui.pages;
+
+import fr.ifremer.wao.WaoBusinessException;
+import fr.ifremer.wao.WaoContext;
+import fr.ifremer.wao.WaoException;
+import fr.ifremer.wao.bean.BoatFilter;
+import fr.ifremer.wao.bean.ContactFilter;
+import fr.ifremer.wao.bean.ContactFilterImpl;
+import fr.ifremer.wao.bean.ContactState;
+import fr.ifremer.wao.bean.ImportResults;
+import fr.ifremer.wao.entity.Boat;
+import fr.ifremer.wao.entity.Contact;
+import fr.ifremer.wao.entity.SampleRow;
+import fr.ifremer.wao.entity.WaoUser;
+import fr.ifremer.wao.service.ServiceBoat;
+import fr.ifremer.wao.service.ServiceContact;
+import fr.ifremer.wao.service.ServiceSampling;
+import fr.ifremer.wao.ui.base.AbstractFilteredPage;
+import fr.ifremer.wao.ui.data.ContactDataSource;
+import fr.ifremer.wao.ui.data.BusinessUtils;
+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.ExportStreamResponse;
+import fr.ifremer.wao.ui.services.ContactModelFactory;
+import java.io.IOException;
+import java.io.InputStream;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.List;
+import org.apache.commons.lang.BooleanUtils;
+import org.apache.commons.lang.StringUtils;
+import org.apache.tapestry5.ComponentResources;
+import org.apache.tapestry5.Field;
+import org.apache.tapestry5.PersistenceConstants;
+import org.apache.tapestry5.StreamResponse;
+import org.apache.tapestry5.annotations.IncludeStylesheet;
+import org.apache.tapestry5.annotations.InjectComponent;
+import org.apache.tapestry5.annotations.Log;
+import org.apache.tapestry5.annotations.Persist;
+import org.apache.tapestry5.annotations.Property;
+import org.apache.tapestry5.annotations.SessionState;
+import org.apache.tapestry5.beaneditor.BeanModel;
+import org.apache.tapestry5.corelib.components.Form;
+import org.apache.tapestry5.corelib.components.Zone;
+import org.apache.tapestry5.ioc.annotations.Inject;
+import org.apache.tapestry5.ioc.services.PropertyAccess;
+import org.apache.tapestry5.services.BeanModelSource;
+import org.apache.tapestry5.upload.services.UploadedFile;
+import org.nuiton.util.DateUtils;
+import org.slf4j.Logger;
+
+/**
+ * Contacts
+ *
+ * Created: 9 nov. 2009
+ *
+ * @author fdesbois
+ * @version $Revision$
+ *
+ * Mise a jour: $Date$
+ * par : $Author$
+ */
+ at IncludeStylesheet("context:css/contacts.css")
+public class Contacts extends AbstractFilteredPage implements WaoPage {
+
+ @Override
+ public boolean isOnlyForAdmin() {
+ return false;
+ }
+
+ @Inject
+ private Logger log;
+
+ @InjectComponent
+ private Layout layout;
+
+ @SessionState
+ @Property
+ private WaoUser user;
+
+ @Inject
+ private ServiceContact serviceContact;
+
+ @Inject
+ private ServiceSampling serviceSampling;
+
+ @Inject
+ private ServiceBoat serviceBoat;
+
+// @Persist(PersistenceConstants.FLASH)
+// private String contactEditedId;
+
+ @Log
+ void setupRender() throws WaoException {
+// if (contactEdited == null) {
+ if (log.isDebugEnabled()) {
+ log.debug("RESET DATA");
+ }
+ initSelectFilters(true, true, false);
+ contacts = null;
+ getContacts();
+// }
+ contactsForm.clearErrors();
+ }
+
+ /**************************** CONTACT FILTERS *****************************/
+
+ @Persist
+ private ContactFilter contactFilter;
+
+ @InjectComponent
+ private Zone filtersZone;
+
+ @InjectComponent
+ private Zone importExportZone;
+
+ private boolean reset;
+
+ @Property
+ private ContactState stateFilter;
+
+ public ContactFilter getContactFilter() throws WaoException {
+ if (contactFilter == null) {
+ if (log.isDebugEnabled()) {
+ log.debug("Init contactFilter");
+ }
+ contactFilter = new ContactFilterImpl();
+ // Initialized to 12 months before the current day
+ Date fromDate = DateUtils.createDateAfterToday(0, -3, 0);
+ contactFilter.setFromDate(fromDate);
+ }
+ return contactFilter;
+ }
+
+ public boolean isFiltersVisible() {
+ boolean companyFiltered = contactFilter.getCompany() != null && user.getAdmin();
+ return (contactFilter.isFiltered() || companyFiltered) && StringUtils.isEmpty(contactFilter.getBoatName()); /*&& !getDefaultFromDate().equals(contactFilter.getFromDate());*/
+ }
+
+ @Override
+ protected BoatFilter getFilter() throws WaoException {
+ return getContactFilter();
+ }
+
+ @Override
+ protected boolean isAvailableDataForFiltersOnly() {
+ return true;
+ }
+
+ Object onActionFromShowFilters() {
+ //contactFilter = null;
+ return filtersZone.getBody();
+ }
+
+ Object onActionFromShowImportExport() {
+ return importExportZone.getBody();
+ }
+
+ void onSelectedFromReset() {
+ reset = true;
+ }
+
+ @Log
+ Object onSuccessFromFiltersForm() throws WaoException {
+ if (isEdited()) {
+ return filtersZone.getBody();
+ }
+ if (reset) {
+ contactFilter = null;
+ }
+// else {
+// filtersVisible = true;
+// }
+ return this;
+ }
+
+ /**************************** CONTACT IMPORT/EXPORT ***********************/
+
+ @Property
+ private UploadedFile contactsCsvFile;
+
+ @Log
+ void onSuccessFromImportContacts() throws WaoException {
+ //importBoatsForm.clearErrors();
+ try {
+ ImportResults result = serviceContact.importContactCsv(user, contactsCsvFile.getStream());
+ // Suppress persitant list of contacts
+ contacts = null;
+ layout.getFeedBack().addInfo(result.getNbRowsImported() + " contacts importés, " +
+ result.getNbRowsRefused() + " refusés.");
+ for (String error : result.getErrors()) {
+ layout.getFeedBack().addInfo(error);
+ }
+ } catch (WaoBusinessException eee) {
+ layout.getFeedBack().addError(eee.getMessage());
+ }
+ //return importBoatsForm.getHasErrors() ? importBoatsForm : this;
+ }
+
+ StreamResponse onActionFromExportShowContacts() {
+ return new ExportStreamResponse("wao-contacts") {
+
+ @Override
+ public InputStream getStream() throws IOException {
+ InputStream result = null;
+ try {
+ result = serviceContact.exportContactCsv(getContactFilter());
+ } catch (WaoException eee) {
+ throw new IOException(eee);
+ }
+ return result;
+ }
+ };
+ }
+
+ /**************************** CONTACT LIST ********************************/
+
+ @Inject
+ private BeanModelSource beanModelSource;
+
+ @Inject
+ private ComponentResources resources;
+
+ @Inject
+ private ContactModelFactory contactModelFactory;
+
+ @Persist
+ private ContactDataSource contacts;
+// private Map<String, Contact> contacts;
+
+ @Property
+ private Contact contact;
+
+ private BeanModel<Contact> contactModel;
+
+ @Inject
+ private PropertyAccess propertyAccess;
+
+ private GenericSelectModel<WaoUser> userSelectModel;
+
+ @Property
+ @Persist(PersistenceConstants.FLASH)
+ private String contactUserId;
+
+ private ContactState contactState;
+
+ private boolean even = true;
+
+ public ContactDataSource getContacts() throws WaoException {
+ if (contacts == null) {
+ if (log.isInfoEnabled()) {
+ log.info("Create DataSource");
+ }
+ contacts = new ContactDataSource(getContactFilter(), serviceContact);
+ }
+ return contacts;
+ }
+
+// public Map<String, Contact> getContacts() throws WaoException {
+// if (contacts == null) {
+// if (log.isInfoEnabled()) {
+// log.info("BUSINESS REQUEST [getContactsByFilter]");
+// }
+// contacts = serviceContact.getContactsByFilter(getContactFilter());
+// }
+// return contacts;
+// }
+
+ public BeanModel<Contact> getContactModel() {
+ if (contactModel == null) {
+ contactModel = user.getAdmin() ?
+ contactModelFactory.buildAdminContactModel(beanModelSource, resources) :
+ contactModelFactory.buildContactModel(beanModelSource, resources);
+ }
+ return contactModel;
+ }
+
+ public ContactState getContactState() {
+ if (contactState == null) {
+ // initialization
+ this.contactState = ContactState.createContactStateEnum(contactEdited.getState());
+ }
+ return this.contactState;
+ }
+
+ public GenericSelectModel<WaoUser> getUserSelectModel() {
+ if (userSelectModel == null) {
+ List<WaoUser> users = user.getCompany().getWaoUser();
+ if (log.isDebugEnabled()) {
+ log.debug("Nb users : " + users.size());
+ }
+ userSelectModel = new GenericSelectModel<WaoUser>(users, WaoUser.class, "fullName", "id", propertyAccess);
+ }
+ return userSelectModel;
+ }
+
+ public void setContactState(ContactState contactState) {
+ this.contactState = contactState;
+ }
+
+ public String getCommentDisplayed() {
+ if (contact.getComment() != null && contact.getComment().length() > 20) {
+ return contact.getComment().substring(0, 20) + "...";
+ }
+ return contact.getComment();
+ }
+
+ public String getCommentTooltip() {
+ return contact.getComment().replaceAll("\n", "<br />").replaceAll("\r", "");
+ }
+
+ public String getSampleRowDescription() {
+ return BusinessUtils.getTooltipSampleRow(contact.getSampleRow());
+ }
+
+ public String getBoatDescription() {
+ return BusinessUtils.getTooltipBoat(contact.getBoat());
+ }
+
+ public String getTooltipExportFrom() throws WaoException {
+ if (getContactFilter().getFromDate() != null) {
+ return "depuis le " + getDateFormat().format(getContactFilter().getFromDate());
+ }
+ return "";
+ }
+
+ public String getGridClass() {
+ return user.getAdmin() ? "admin" : "user";
+ }
+
+ public String getRowClass() {
+ String result = BusinessUtils.getContactStyle(contact, user.getAdmin());
+ if (contact.getTopiaId().equals(contactSelectedId)) {
+ result = "selected";
+ }
+ return result;
+ }
+
+ public DateFormat getDateFormat() {
+ return new SimpleDateFormat("dd/MM/yyyy");
+ }
+
+ public boolean isEditionMode() {
+ //return contact.getTopiaId().equals(contactEditedId);
+ return contactEdited != null && contact.equals(contactEdited);
+ }
+
+ public boolean isEmpty(Boolean validation) {
+ return validation == null;
+ }
+
+ /**************************** CONTACT ROW ACTION **************************/
+
+ /**
+ * Flag to know if it's only edition (=true) or save action (=false)
+ */
+ private boolean edited;
+
+ private boolean deleted;
+
+ @Persist
+ @Property
+ private Contact contactEdited;
+
+ @Persist
+ private String oldComment;
+
+ public void prepareContactEdited(String contactId) throws WaoException {
+ if (contactEdited == null) {
+ contactEdited = getContacts().get(contactId);
+ }
+ //contact = contactEdited;
+ }
+
+ public boolean hasActions() {
+ return !user.getAdmin() && contact.getValidationCompany() == null;
+ }
+
+ public boolean canValidate() {
+ // Can't validate during edition of the contact row
+ if (isEditionMode()) {
+ return false;
+ }
+ ContactState state = ContactState.createContactStateEnum(contact.getState());
+ boolean boardingDone = state.equals(ContactState.BOARDING_DONE) && contact.getDataInputDate() != null;
+ if (!user.getAdmin()) {
+ return contact.getValidationCompany() == null && (state.isUnfinishedState() || boardingDone);
+ }
+ return contact.getValidationProgram() == null && BooleanUtils.isTrue(contact.getValidationCompany());
+ }
+
+ public boolean canUnvalidate() {
+ if (!user.getAdmin()) {
+ return contact.getValidationCompany() != null &&
+ contact.getValidationProgram() == null;
+ }
+ return contact.getValidationProgram() != null;
+ }
+
+ void onSelectedFromAcceptContact(String contactId) throws WaoException {
+ //contact = getContacts().get(contactId);
+ prepareContactEdited(contactId);
+ if (user.getAdmin()) {
+ contactEdited.setValidationProgram(Boolean.TRUE);
+ } else {
+ // For company accepted, addRealTideTime
+ contactEdited.getSampleRow().addRealTideTime(contactEdited);
+ contactEdited.setValidationCompany(Boolean.TRUE);
+ }
+ }
+
+ void onSelectedFromRefuseContact(String contactId) throws WaoException {
+ //contact = getContacts().get(contactId);
+ prepareContactEdited(contactId);
+ if (user.getAdmin()) {
+ // For program refused, removeRealTideTime
+ contactEdited.getSampleRow().removeRealTideTime(contactEdited);
+ contactEdited.setValidationProgram(Boolean.FALSE);
+ } else {
+ contactEdited.setValidationCompany(Boolean.FALSE);
+ }
+ }
+
+ void onSelectedFromUnvalidateContact(String contactId) throws WaoException {
+ //contact = getContacts().get(contactId);
+ prepareContactEdited(contactId);
+ if (user.getAdmin()) {
+ // For program unvalidate from previous refused validation, addRealTideTime
+ if (BooleanUtils.isFalse(contactEdited.getValidationProgram())) {
+ contactEdited.getSampleRow().addRealTideTime(contactEdited);
+ }
+ contactEdited.setValidationProgram(null);
+ } else {
+ // For company unvalidate from previous accepted validation,
+ // removeRealTideTime
+ if (BooleanUtils.isTrue(contactEdited.getValidationCompany())) {
+ contactEdited.getSampleRow().removeRealTideTime(contactEdited);
+ }
+ contactEdited.setValidationCompany(null);
+ }
+ }
+
+ void onSelectedFromEditContact(String contactId) throws WaoException {
+ //contact = getContacts().get(contactId);
+ prepareContactEdited(contactId);
+ contactUserId = contactEdited.getObserver().getTopiaId();
+ //contactEditedId = contactId;
+ contactSelectedId = contactId;
+ oldComment = contactEdited.getComment();
+ edited = true;
+ }
+
+ void onSelectedFromDeleteContact(String contactId) throws WaoException {
+ //contact = getContacts().get(contactId);
+ prepareContactEdited(contactId);
+ deleted = true;
+ }
+
+ void onSelectedFromSaveContact(String contactId) throws WaoException {
+ //contact = getContacts().get(contactId);
+ prepareContactEdited(contactId);
+ contactEdited.setState(contactState.toString());
+ WaoUser contactUser = getUserSelectModel().findObject(contactUserId);
+ contactEdited.setObserver(contactUser);
+
+ if (log.isDebugEnabled()) {
+ log.debug("Comment : " + contactEdited.getComment());
+ }
+ }
+
+ void onSelectedFromCancelEditContact() throws WaoException {
+ contactEdited = null;
+ edited = true;
+ }
+
+// @Log
+// void onSelectedFromSaveComment(String contactId) throws WaoException {
+// contact = getContacts().get(contactId);
+// if (log.isInfoEnabled()) {
+// log.info("Comment : " + contact.getComment());
+// }
+// contactEdited = true;
+// }
+
+ /**************************** CONTACT SAVE ********************************/
+
+ @Persist(PersistenceConstants.FLASH)
+ private String contactSelectedId;
+
+ @InjectComponent
+ private Form contactsForm;
+
+ @InjectComponent
+ private Zone gridZone;
+
+ @InjectComponent
+ private Field beginDate;
+
+ @InjectComponent
+ private Field endDate;
+
+ @InjectComponent
+ private Field nbObservants;
+
+ @InjectComponent
+ private Field comment;
+
+ @InjectComponent
+ private Field inputDate;
+
+ @Log
+ void onValidateFormFromContactsForm() {
+ contactsForm.clearErrors();
+ // Validation for saving contact depends on contactState (only edition
+ // form)
+ if (!edited && contactState != null) {
+ if (log.isInfoEnabled()) {
+ log.info("For state : " + contactState);
+ }
+
+ Date begin = contactEdited.getTideBeginDate();
+ Date end = contactEdited.getTideEndDate();
+ Date input = contactEdited.getDataInputDate();
+ SampleRow row = contactEdited.getSampleRow();
+ //DateFormat dateFormat = new SimpleDateFormat("MM/yyyy");
+
+ if (begin != null && !row.isValid(begin)) {
+ contactsForm.recordError(beginDate,
+ "La date de début de la marée doit correspondre à un mois valide (non vide) de la ligne " + row.getCode());
+ }
+
+ if (begin != null && end != null && end.before(begin)) {
+ contactsForm.recordError(endDate, "La date de fin de la marée ne peut pas être antérieure à celle de début");
+ }
+
+ Date current = WaoContext.getCurrentDate();
+
+ if (end != null && end.after(current)) {
+ contactsForm.recordError(endDate, "La date de fin de la marée ne peut pas être postérieure à la date du jour");
+ }
+
+ if (end != null && input != null && end.after(input)) {
+ contactsForm.recordError(inputDate, "La date de saisie des données ne peut pas être antérieure à la date de fin de la marée");
+ }
+
+ if (input != null && input.after(current)) {
+ contactsForm.recordError(inputDate, "La date de saisie des données ne peut pas être postérieure à la date du jour");
+ }
+
+ // Non abouti, Refus ou Refus Définitif
+ if (contactState.isUnfinishedState()) {
+ String newComment = contactEdited.getComment();
+ if (StringUtils.isNotEmpty(newComment) && !newComment.equals(oldComment)) {
+ // RAZ des champs
+ contactEdited.setTideBeginDate(null);
+ contactEdited.setTideEndDate(null);
+ contactEdited.setNbObservants(0);
+ contactEdited.setMammalsCapture(false);
+ contactEdited.setMammalsObservation(false);
+ contactEdited.setDataInputDate(null);
+ } else {
+ contactsForm.recordError(comment, "Vous devez ajouter un commentaire pour l'état '" + contactState + "'");
+ }
+ // Embarquement Réalisé
+ } else if (contactState.equals(ContactState.BOARDING_DONE)) {
+ if (begin == null) {
+ contactsForm.recordError(beginDate, "La date de début de marée est obligatoire pour l'état '" + contactState + "'");
+ }
+ if (end == null) {
+ contactsForm.recordError(endDate, "La date de fin de marée est obligatoire pour l'état '" + contactState + "'");
+ }
+ if (contactEdited.getNbObservants() == 0) {
+ contactsForm.recordError(nbObservants, "Il ne peut y avoir aucun observateur pour l'état '" + contactState + "'");
+ }
+ }
+ }
+ }
+
+ @Log
+ Object onSuccessFromContactsForm() {
+ if (!edited) {
+ try {
+ if (log.isDebugEnabled()) {
+ log.debug("Contact save : " + contactEdited);
+ }
+ serviceContact.saveContact(contactEdited, deleted);
+ contactSelectedId = contactEdited.getTopiaId();
+ oldComment = null;
+ contactEdited = null;
+ } catch (WaoException eee) {
+ layout.getFeedBack().addError(eee.getMessage());
+ }
+ }
+ return this;
+ }
+
+ @Log
+ Object onFailureFromContactsForm() {
+ if (log.isDebugEnabled()) {
+ log.debug("Contact can't be saved with errors");
+ }
+ // The contact is not saved, the contact must be editable to show form
+ // and correct errors
+ edited = true;
+ //contactEditedId = contact.getTopiaId();
+ return contactsForm;
+ //return gridZone;
+ }
+
+ public void createNewContact(Boat boat, SampleRow sampleRow) throws WaoException {
+ contact = serviceContact.getNewContact(user, sampleRow, boat);
+ serviceContact.saveContact(contact, Boolean.FALSE);
+ contactSelectedId = contact.getTopiaId();
+ }
+}
Deleted: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/ExceptionReport.java
===================================================================
--- trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/ExceptionReport.java 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/ExceptionReport.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,83 +0,0 @@
-/*
- * *##%
- * SuiviObsmer :: Web Interface
- * 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.suiviobsmer.ui.pages;
-
-import fr.ifremer.suiviobsmer.SuiviObsmerException;
-import fr.ifremer.suiviobsmer.ui.base.SuiviObsmerPage;
-import fr.ifremer.suiviobsmer.ui.components.Layout;
-import org.apache.tapestry5.annotations.InjectComponent;
-import org.apache.tapestry5.annotations.Property;
-import org.apache.tapestry5.ioc.annotations.Inject;
-import org.apache.tapestry5.services.ExceptionReporter;
-import org.slf4j.Logger;
-
-/**
- * ExceptionReport
- *
- * Created: 5 janv. 2010
- *
- * @author fdesbois
- * @version $Revision$
- *
- * Mise a jour: $Date$
- * par : $Author$
- */
-public class ExceptionReport implements ExceptionReporter, SuiviObsmerPage {
-
- @InjectComponent
- private Layout layout;
-
- @Inject
- private Logger log;
-
- @Property
- private Throwable exception;
-
- @Override
- public void reportException(Throwable eee) {
- this.exception = getSuiviObsmerException(eee);
- if (exception != null) {
- layout.getFeedBack().addError(exception.getMessage());
- this.exception = exception.getCause();
- } else {
- this.exception = eee;
- log.error("Unexpected exception", eee);
- }
- layout.getFeedBack().addError("Erreur : " + this.exception.getClass().getSimpleName() + " : " + this.exception.getMessage());
- }
-
- protected Throwable getSuiviObsmerException(Throwable eee) {
- if (eee == null) {
- return eee;
- }
- if (eee instanceof SuiviObsmerException) {
- return eee;
- }
- return getSuiviObsmerException(eee.getCause());
- }
-
- @Override
- public boolean isOnlyForAdmin() {
- return false;
- }
-
-}
Copied: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/ExceptionReport.java (from rev 354, trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/ExceptionReport.java)
===================================================================
--- trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/ExceptionReport.java (rev 0)
+++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/ExceptionReport.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -0,0 +1,83 @@
+/*
+ * *##%
+ * Wao :: Web Interface
+ * 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.ui.pages;
+
+import fr.ifremer.wao.WaoException;
+import fr.ifremer.wao.ui.base.WaoPage;
+import fr.ifremer.wao.ui.components.Layout;
+import org.apache.tapestry5.annotations.InjectComponent;
+import org.apache.tapestry5.annotations.Property;
+import org.apache.tapestry5.ioc.annotations.Inject;
+import org.apache.tapestry5.services.ExceptionReporter;
+import org.slf4j.Logger;
+
+/**
+ * ExceptionReport
+ *
+ * Created: 5 janv. 2010
+ *
+ * @author fdesbois
+ * @version $Revision$
+ *
+ * Mise a jour: $Date$
+ * par : $Author$
+ */
+public class ExceptionReport implements ExceptionReporter, WaoPage {
+
+ @InjectComponent
+ private Layout layout;
+
+ @Inject
+ private Logger log;
+
+ @Property
+ private Throwable exception;
+
+ @Override
+ public void reportException(Throwable eee) {
+ this.exception = getWaoException(eee);
+ if (exception != null) {
+ layout.getFeedBack().addError(exception.getMessage());
+ this.exception = exception.getCause();
+ } else {
+ this.exception = eee;
+ log.error("Unexpected exception", eee);
+ }
+ layout.getFeedBack().addError("Erreur : " + this.exception.getClass().getSimpleName() + " : " + this.exception.getMessage());
+ }
+
+ protected Throwable getWaoException(Throwable eee) {
+ if (eee == null) {
+ return eee;
+ }
+ if (eee instanceof WaoException) {
+ return eee;
+ }
+ return getWaoException(eee.getCause());
+ }
+
+ @Override
+ public boolean isOnlyForAdmin() {
+ return false;
+ }
+
+}
Deleted: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Index.java
===================================================================
--- trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/Index.java 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Index.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,170 +0,0 @@
-/*
- * *##%
- * SuiviObsmer :: Web Interface
- * 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.suiviobsmer.ui.pages;
-
-import fr.ifremer.suiviobsmer.SuiviObsmerException;
-import fr.ifremer.suiviobsmer.entity.News;
-import fr.ifremer.suiviobsmer.entity.NewsImpl;
-import fr.ifremer.suiviobsmer.entity.WaoUser;
-import fr.ifremer.suiviobsmer.services.ServiceNews;
-import fr.ifremer.suiviobsmer.ui.base.SuiviObsmerPage;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.List;
-import org.apache.tapestry5.Asset2;
-import org.apache.tapestry5.PersistenceConstants;
-import org.apache.tapestry5.annotations.IncludeStylesheet;
-import org.apache.tapestry5.annotations.Log;
-import org.apache.tapestry5.annotations.Path;
-import org.apache.tapestry5.annotations.Persist;
-import org.apache.tapestry5.annotations.Property;
-import org.apache.tapestry5.annotations.SessionState;
-import org.apache.tapestry5.ioc.annotations.Inject;
-import org.slf4j.Logger;
-
-/**
- * Index
- *
- * Created: 9 nov. 2009
- *
- * @author fdesbois
- * @version $Revision$
- *
- * Mise a jour: $Date$
- * par : $Author$
- */
- at IncludeStylesheet("context:css/news.css")
-public class Index implements SuiviObsmerPage {
-
- @Override
- public boolean isOnlyForAdmin() {
- return false;
- }
-
- @Inject
- private ServiceNews serviceNews;
-
- @Inject
- private Logger log;
-
- @SessionState
- @Property
- private WaoUser user;
-
- @Persist
- private List<News> newsList;
-
- @Property
- private News news;
-
- private DateFormat dateFormat;
-
- @Persist(PersistenceConstants.FLASH)
- private String editedId;
-
- @Property
- private int rowIndex;
-
- @Property
- @Inject
- @Path("context:js/FCKConf.js")
- private Asset2 fckconf;
-
-
- @Log
- void setupRender() throws SuiviObsmerException {
- if (editedId == null || !"NEW".equals(editedId)) {
- newsList = null;
- getNewsList();
- }
- }
-
-// void onActivate(EventContext ec) {
-// if (ec.getCount() > 0) {
-// this.editedId = ec.get(String.class, 0);
-// }
-// }
-//
-// String onPassivate() {
-// return editedId;
-// }
-
- public List<News> getNewsList() throws SuiviObsmerException {
- if (newsList == null) {
- newsList = serviceNews.getNews();
- }
- return newsList;
- }
-
- public boolean isEditionMode() {
- return isCreateMode() || news.getTopiaId().equals(editedId);
- }
-
- public boolean isCreateMode() {
- return news.getTopiaId() == null;
- }
-
- public DateFormat getDateFormat() {
- if (dateFormat == null) {
- dateFormat = new SimpleDateFormat("dd/MM/yyyy");
- }
- return dateFormat;
- }
-
- void onActionFromAddNews() throws SuiviObsmerException {
- news = new NewsImpl();
- // Create a new list with the new news in first position
- List<News> list = new ArrayList<News>();
- list.add(news);
- list.addAll(getNewsList());
- newsList = list;
- editedId = "NEW";
- }
-
- void onActionFromEditNews(int rowIndex) throws SuiviObsmerException {
- news = getNewsList().get(rowIndex);
- this.editedId = news.getTopiaId();
- }
-
- void onActionFromDeleteNews(int rowIndex) throws SuiviObsmerException {
- news = getNewsList().get(rowIndex);
- serviceNews.saveNews(news, true);
- //newsList = null;
- }
-
- void onActionFromCancelEdit() {
- }
-
- void onSelectedFromSaveNews(int rowIndex) throws SuiviObsmerException {
- news = getNewsList().get(rowIndex);
- }
-
- void onSuccessFromNewsForm() throws SuiviObsmerException {
- serviceNews.saveNews(news, false);
- //this.editedId = null;
- if (log.isDebugEnabled()) {
- log.debug(news.getContent());
- }
- }
-
-}
Copied: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Index.java (from rev 354, trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/Index.java)
===================================================================
--- trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Index.java (rev 0)
+++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Index.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -0,0 +1,170 @@
+/*
+ * *##%
+ * Wao :: Web Interface
+ * 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.ui.pages;
+
+import fr.ifremer.wao.WaoException;
+import fr.ifremer.wao.entity.News;
+import fr.ifremer.wao.entity.NewsImpl;
+import fr.ifremer.wao.entity.WaoUser;
+import fr.ifremer.wao.service.ServiceNews;
+import fr.ifremer.wao.ui.base.WaoPage;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.tapestry5.Asset2;
+import org.apache.tapestry5.PersistenceConstants;
+import org.apache.tapestry5.annotations.IncludeStylesheet;
+import org.apache.tapestry5.annotations.Log;
+import org.apache.tapestry5.annotations.Path;
+import org.apache.tapestry5.annotations.Persist;
+import org.apache.tapestry5.annotations.Property;
+import org.apache.tapestry5.annotations.SessionState;
+import org.apache.tapestry5.ioc.annotations.Inject;
+import org.slf4j.Logger;
+
+/**
+ * Index
+ *
+ * Created: 9 nov. 2009
+ *
+ * @author fdesbois
+ * @version $Revision$
+ *
+ * Mise a jour: $Date$
+ * par : $Author$
+ */
+ at IncludeStylesheet("context:css/news.css")
+public class Index implements WaoPage {
+
+ @Override
+ public boolean isOnlyForAdmin() {
+ return false;
+ }
+
+ @Inject
+ private ServiceNews serviceNews;
+
+ @Inject
+ private Logger log;
+
+ @SessionState
+ @Property
+ private WaoUser user;
+
+ @Persist
+ private List<News> newsList;
+
+ @Property
+ private News news;
+
+ private DateFormat dateFormat;
+
+ @Persist(PersistenceConstants.FLASH)
+ private String editedId;
+
+ @Property
+ private int rowIndex;
+
+ @Property
+ @Inject
+ @Path("context:js/FCKConf.js")
+ private Asset2 fckconf;
+
+
+ @Log
+ void setupRender() throws WaoException {
+ if (editedId == null || !"NEW".equals(editedId)) {
+ newsList = null;
+ getNewsList();
+ }
+ }
+
+// void onActivate(EventContext ec) {
+// if (ec.getCount() > 0) {
+// this.editedId = ec.get(String.class, 0);
+// }
+// }
+//
+// String onPassivate() {
+// return editedId;
+// }
+
+ public List<News> getNewsList() throws WaoException {
+ if (newsList == null) {
+ newsList = serviceNews.getNews();
+ }
+ return newsList;
+ }
+
+ public boolean isEditionMode() {
+ return isCreateMode() || news.getTopiaId().equals(editedId);
+ }
+
+ public boolean isCreateMode() {
+ return news.getTopiaId() == null;
+ }
+
+ public DateFormat getDateFormat() {
+ if (dateFormat == null) {
+ dateFormat = new SimpleDateFormat("dd/MM/yyyy");
+ }
+ return dateFormat;
+ }
+
+ void onActionFromAddNews() throws WaoException {
+ news = new NewsImpl();
+ // Create a new list with the new news in first position
+ List<News> list = new ArrayList<News>();
+ list.add(news);
+ list.addAll(getNewsList());
+ newsList = list;
+ editedId = "NEW";
+ }
+
+ void onActionFromEditNews(int rowIndex) throws WaoException {
+ news = getNewsList().get(rowIndex);
+ this.editedId = news.getTopiaId();
+ }
+
+ void onActionFromDeleteNews(int rowIndex) throws WaoException {
+ news = getNewsList().get(rowIndex);
+ serviceNews.saveNews(news, true);
+ //newsList = null;
+ }
+
+ void onActionFromCancelEdit() {
+ }
+
+ void onSelectedFromSaveNews(int rowIndex) throws WaoException {
+ news = getNewsList().get(rowIndex);
+ }
+
+ void onSuccessFromNewsForm() throws WaoException {
+ serviceNews.saveNews(news, false);
+ //this.editedId = null;
+ if (log.isDebugEnabled()) {
+ log.debug(news.getContent());
+ }
+ }
+
+}
Deleted: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/SampleRowForm.java
===================================================================
--- trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/SampleRowForm.java 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/SampleRowForm.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,693 +0,0 @@
-/*
- * *##%
- * SuiviObsmer :: Web Interface
- * 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.suiviobsmer.ui.pages;
-
-import fr.ifremer.suiviobsmer.SuiviObsmerBusinessException;
-import fr.ifremer.suiviobsmer.SuiviObsmerContext;
-import fr.ifremer.suiviobsmer.SuiviObsmerException;
-import fr.ifremer.suiviobsmer.entity.Boat;
-import fr.ifremer.suiviobsmer.entity.Company;
-import fr.ifremer.suiviobsmer.entity.FishingZone;
-import fr.ifremer.suiviobsmer.entity.Profession;
-import fr.ifremer.suiviobsmer.entity.ProfessionImpl;
-import fr.ifremer.suiviobsmer.entity.SampleMonth;
-import fr.ifremer.suiviobsmer.entity.SampleRow;
-import fr.ifremer.suiviobsmer.entity.SampleRowLog;
-import fr.ifremer.suiviobsmer.entity.SampleRowLogImpl;
-import fr.ifremer.suiviobsmer.entity.WaoUser;
-import fr.ifremer.suiviobsmer.services.ServiceBoat;
-import fr.ifremer.suiviobsmer.services.ServiceReferential;
-import fr.ifremer.suiviobsmer.services.ServiceSampling;
-import fr.ifremer.suiviobsmer.services.ServiceUser;
-import fr.ifremer.suiviobsmer.ui.base.GenericSelectModel;
-import fr.ifremer.suiviobsmer.ui.base.SuiviObsmerPage;
-import fr.ifremer.suiviobsmer.ui.data.SuiviObsmerPropertyChangeListener;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-import org.apache.commons.lang.StringUtils;
-import org.apache.tapestry5.ComponentResources;
-import org.apache.tapestry5.EventContext;
-import org.apache.tapestry5.Field;
-import org.apache.tapestry5.OptionModel;
-import org.apache.tapestry5.SelectModel;
-import org.apache.tapestry5.annotations.IncludeStylesheet;
-import org.apache.tapestry5.annotations.InjectComponent;
-import org.apache.tapestry5.annotations.Log;
-import org.apache.tapestry5.annotations.Persist;
-import org.apache.tapestry5.annotations.Property;
-import org.apache.tapestry5.annotations.SessionState;
-import org.apache.tapestry5.beaneditor.BeanModel;
-import org.apache.tapestry5.corelib.components.Form;
-import org.apache.tapestry5.internal.OptionModelImpl;
-import org.apache.tapestry5.internal.SelectModelImpl;
-import org.apache.tapestry5.ioc.annotations.Inject;
-import org.apache.tapestry5.ioc.services.PropertyAccess;
-import org.apache.tapestry5.services.BeanModelSource;
-import org.nuiton.util.PeriodDates;
-import org.slf4j.Logger;
-
-/**
- * SampleRowForm
- *
- * Created: 26 nov. 2009
- *
- * @author fdesbois
- * @version $Revision$
- *
- * Mise a jour: $Date$
- * par : $Author$
- */
- at IncludeStylesheet("context:css/sampling.css")
-public class SampleRowForm implements SuiviObsmerPage {
-
- @Override
- public boolean isOnlyForAdmin() {
- return true;
- }
-
- @Inject
- private Logger log;
-
- @Inject
- private ServiceSampling serviceSampling;
-
- @Inject
- private ServiceReferential serviceReferential;
-
- @Inject
- private ServiceUser serviceUser;
-
- @Inject
- private ServiceBoat serviceBoat;
-
- @SessionState
- @Property
- private WaoUser user;
-
- @Inject
- private PropertyAccess propertyAccess;
-
- private boolean edited;
-
- void onActivate(EventContext ec) {
- if (ec.getCount() > 0) {
- sampleRowId = ec.get(String.class, 0);
- }
- }
-
- String onPassivate() {
- return sampleRowId;
- }
-
- void setupRender() throws SuiviObsmerException {
- // Reset data
- sampleRow = null;
- getSampleRow();
- sampleMonths = null;
- getSampleMonths();
- sampleRowLog = null;
- getSampleRowLog();
-
- // Reset persist select
- professionSelectModel = null;
- getProfessionSelectModel();
- programSelectModel = null;
- getProgramSelectModel();
- fishingZoneSelectModel = null;
- getFishingZoneSelectModel();
- companySelectModel = null;
- getCompanySelectModel();
-
- professionId = null;
- sampleRowForm.clearErrors();
-
- if (!isCreateMode()) {
- programId = getSampleRow().getProgramName();
- } else {
- programId = null;
- }
-
- // initialize companyId if exist for companySelect
- Company company = getSampleRow().getCompany();
- if (company != null) {
- companyId = company.getTopiaId();
- }
-
- immatriculations = getSampleRow().getMainElligibleBoatsAsString();
- }
-
- /*************************** PROFESSION ***********************************/
-
- /** Select model which contains all professions **/
- @Persist
- private GenericSelectModel<Profession> professionSelectModel;
-
- /** The current selected professionId **/
- @Property
- private String professionId;
-
- /** Bean model source to create the BeanModel for profession **/
- @Inject
- private BeanModelSource beanModelSource;
-
- /** Component resources needed to create the BeanModel for profession **/
- @Inject
- private ComponentResources resources;
-
- /**
- * Get SelectModel for profession input Select. The select contains all existing professions.
- *
- * @return a GenericSelectModel<Profession>
- * @throws SuiviObsmerException
- */
- public GenericSelectModel<Profession> getProfessionSelectModel() throws SuiviObsmerException {
- if (professionSelectModel == null) {
- if (log.isInfoEnabled()) {
- log.info("BUSINESS REQUEST [getProfessions]");
- }
- List<Profession> professions = serviceReferential.getProfessions();
- professionSelectModel = new GenericSelectModel<Profession>(professions, Profession.class,
- "code", "topiaId", propertyAccess);
- }
- return professionSelectModel;
- }
-
- /**
- * Get the Profession model for BeanDisplay component.
- *
- * @return a BeanModel<Profession>
- */
- public BeanModel<Profession> getProfessionModel() {
- return beanModelSource.createDisplayModel(Profession.class, resources.getMessages());
- }
-
- /**
- * Action on submit : addNewProfession. Used to set a new profession from the selected one.
- *
- * @throws SuiviObsmerException
- */
- void onSelectedFromAddNewProfession() throws SuiviObsmerException {
- Profession profession = new ProfessionImpl();
- if (!StringUtils.isEmpty(professionId)) {
- Profession professionSelected = getProfessionSelectModel().findObject(professionId);
- if (log.isDebugEnabled()) {
- log.debug("Add new profession from : " + professionSelected);
- }
- profession = serviceSampling.getNewProfession(professionSelected);
- }
- getSampleRow().setProfession(profession);
- edited = true;
- }
-
- /*************************** FISHING ZONE *********************************/
-
- /** Select model for the FishingZone list **/
- @Persist
- private GenericSelectModel<FishingZone> fishingZoneSelectModel;
-
- /** Current fishingZone id selected **/
- @Property
- private String fishingZoneId;
-
- /** Current fishingZone for loop **/
- @Property
- private FishingZone fishingZone;
-
- /** Current index in the loop **/
- @Property
- private int indexFishingZone;
-
- /** Field fishingZone for validation : must have at least one fishingZone **/
- @InjectComponent
- private Field fishingZoneSelect;
-
- /**
- * Get the select model for FishingZone. The select contains all existing fishingZones.
- *
- * @return a GenericSelectModel<FishingZone>
- * @throws SuiviObsmerException
- */
- public GenericSelectModel<FishingZone> getFishingZoneSelectModel() throws SuiviObsmerException {
- if (fishingZoneSelectModel == null) {
- if (log.isInfoEnabled()) {
- log.info("BUSINESS REQUEST [getFishingZones]");
- }
- List<FishingZone> zones = serviceReferential.getFishingZones();
- fishingZoneSelectModel = new GenericSelectModel<FishingZone>(zones, FishingZone.class,
- "code", "topiaId", propertyAccess);
- }
- return fishingZoneSelectModel;
- }
-
- /**
- * Get the list of FishingZones from the SampleRow.
- *
- * @return a List of FishingZone linked with the SampleRow
- * @throws SuiviObsmerException
- */
- public List<FishingZone> getFishingZones() throws SuiviObsmerException {
- return getSampleRow().getFishingZone();
- }
-
- /**
- * Action on submit : addFishingZone. Used to add the selected fishingZone to the SampleRow.
- *
- * @throws SuiviObsmerException
- */
- void onSelectedFromAddFishingZone() throws SuiviObsmerException {
- fishingZone = getFishingZoneSelectModel().findObject(fishingZoneId);
- if (!getFishingZones().contains(fishingZone)) {
- if (log.isDebugEnabled()) {
- log.debug("Add new fishingZone");
- }
- getFishingZones().add(fishingZone);
- }
- edited = true;
- }
-
- /**
- * Action on submit : removeFishingZone. Used to remove the fishingZone from the SampleRow.
- *
- * @param index of the FishingZone in the list (from loop component)
- * @throws SuiviObsmerException
- */
- void onSelectedFromRemoveFishingZone(int index) throws SuiviObsmerException {
- if (log.isDebugEnabled()) {
- log.debug("Remove fishingZone at position : " + index);
- }
- getFishingZones().remove(index);
- edited = true;
- }
-
- /*************************** PROGRAM & MONTHS *****************************/
-
- @Persist
- private SelectModel programSelectModel;
-
- @Property
- private String programName;
-
- @Property
- private String programId;
-
-// @Property
-// private Date month;
-
- private PeriodDates period;
-
-// @Persist
-// private List<Date> months;
-
- @Persist
- private List<SampleMonth> sampleMonths;
-
- @Property
- private int monthIndex;
-
- @Property
- private SampleMonth sampleMonth;
-
- @InjectComponent
- private Field programPeriodBegin;
-
- @InjectComponent
- private Field programPeriodEnd;
-
- @InjectComponent
- private Field program;
-
- private boolean periodChanged;
-
- public SelectModel getProgramSelectModel() throws SuiviObsmerException {
- if (programSelectModel == null) {
- if (log.isInfoEnabled()) {
- log.info("BUSINESS REQUEST [getPrograms]");
- }
- List<OptionModel> options = new ArrayList<OptionModel>();
- for (String name : serviceSampling.getPrograms(null)) {
- options.add(new OptionModelImpl(name, name));
- }
- programSelectModel = new SelectModelImpl(null, options);
- }
- return programSelectModel;
- }
-
-// public List<Date> getMonths() throws SuiviObsmerException {
-// if (months == null) {
-// if (log.isDebugEnabled()) {
-// log.debug("Reset months list");
-// }
-// months = getPeriod().getMonths();
-// sampleMonths = null;
-// getSampleMonths();
-// }
-// return months;
-// }
-
-// public Program getProgram() throws SuiviObsmerException {
-// return getSampleRow().getProgram();
-// }
-
- public PeriodDates getPeriod() throws SuiviObsmerException {
- if (period == null) {
- Date begin = getSampleRow().getPeriodBegin();
- Date end = getSampleRow().getPeriodEnd();
- period = new PeriodDates(begin, end);
- }
- return period;
- }
-
- public List<SampleMonth> getSampleMonths() throws SuiviObsmerException {
- if (sampleMonths == null) {
- sampleMonths = new ArrayList<SampleMonth>();
- for (Date currMonth : getPeriod().getMonths()) {
- SampleMonth curr = getSampleRow().getSampleMonth(currMonth);
- if (curr != null) {
- sampleMonths.add(curr);
- // If an other period is set
- } else if (periodChanged) {
- if (curr == null) {
- curr = serviceSampling.getNewSampleMonth(currMonth, getSampleRow());
- }
- sampleMonths.add(curr);
- }
- }
- }
- return sampleMonths;
- }
-
- public DateFormat getDateFormat() {
- return new SimpleDateFormat("MM/yyyy");
- }
-
- public String getMonthStyle() {
- String style = " ";
-
- Date current = SuiviObsmerContext.getCurrentDate();
- if (sampleMonth.isCurrentMonth()) {
- style += "selected";
- } else if (current.after(sampleMonth.getPeriodDate())) {
- style += "even";
- }
- return style;
- }
-
- /**
- * Search a program from the list.
- * The program will be set from the one selected. If no selection, a new one will be set.
- * @throws SuiviObsmerException
- */
-// @Log
-// void onSelectedFromSearchProgram() throws SuiviObsmerException {
-// if (!StringUtils.isEmpty(programId)) {
-// programName = null;
-//// period = null;
-//// months = null;
-// getSampleRow().setProgramName(programId);
-//
-// // No period in this case ?!?
-// }
-// edited = true;
-// }
-
- /**
- * Refresh months from program period.
- * If the programName is not empty, a new program will be set.
- * The period dates will be saved in program (validation will be done in onSuccess).
- * @throws SuiviObsmerException
- */
- @Log
- void onSelectedFromRefreshMonths() throws SuiviObsmerException {
- getSampleRow().setPeriod(period);
- periodChanged = true;
- // Reset sampleMonths for new period
- sampleMonths = null;
- getSampleMonths();
- saveProgram();
- }
-
- protected void saveProgram() throws SuiviObsmerException {
- // Save programName
- if (StringUtils.isNotEmpty(programName)) {
- getSampleRow().setProgramName(programName);
- programId = null;
- } else if (StringUtils.isNotEmpty(programId)) {
- getSampleRow().setProgramName(programId);
- }
- if (log.isInfoEnabled()) {
- log.info("Program : " + getSampleRow().getProgramName());
- }
- }
-
- @Log
- void onSelectedFromDeleteMonth(int index) throws SuiviObsmerException {
- getSampleMonths().remove(index);
- edited = true;
- }
-
- /*************************** SAMPLE ROW ***********************************/
-
- private String sampleRowId;
-
- @Persist
- private SampleRow sampleRow;
-
- private BeanModel<SampleRow> sampleRowModel;
-
- @InjectComponent
- private Form sampleRowForm;
-
- @InjectComponent
- private Field updateComment;
-
- @Persist
- private SampleRowLog sampleRowLog;
-
- @Property
- private String immatriculations;
-
- @Property
- private String companyId;
-
- private List<Boat> boats;
-
- private GenericSelectModel<Company> companySelectModel;
-
- private boolean cancel;
-
- @Persist
- private SuiviObsmerPropertyChangeListener propertyChange;
-
- public SampleRow getSampleRow() throws SuiviObsmerException {
- if (sampleRow == null) {
- if (!StringUtils.isEmpty(sampleRowId)) {
- if (log.isInfoEnabled()) {
- log.info("BUSINESS REQUEST [getSampleRow]");
- }
- sampleRow = serviceSampling.getSampleRow(sampleRowId);
- propertyChange = new SuiviObsmerPropertyChangeListener();
- for (SampleMonth month : sampleRow.getSampleMonth()) {
- month.addPropertyChangeListener(SampleMonth.EXPECTED_TIDES_VALUE, propertyChange);
- }
- } else {
- sampleRow = serviceSampling.getNewSampleRow();
- }
- }
- return sampleRow;
- }
-
- public SampleRowLog getSampleRowLog() throws SuiviObsmerException {
- if (sampleRowLog == null) {
- sampleRowLog = new SampleRowLogImpl();
- sampleRowLog.setSampleRow(getSampleRow());
- sampleRowLog.setAdmin(user);
- }
- return sampleRowLog;
- }
-
- public BeanModel<SampleRow> getSampleRowModel() {
- if (sampleRowModel == null) {
- sampleRowModel = beanModelSource.createEditModel(SampleRow.class, resources.getMessages());
- sampleRowModel.add("company", null);
- sampleRowModel.add("boats", null);
- sampleRowModel.include("code", "company", "nbObservants", "averageTideTime", "boats", "comment");
- }
- return sampleRowModel;
- }
-
- public GenericSelectModel<Company> getCompanySelectModel() throws SuiviObsmerException {
- if (companySelectModel == null) {
- if (log.isInfoEnabled()) {
- log.info("BUSINESS REQUEST [getCompanies]");
- }
- List<Company> companies = serviceUser.getCompanies(true);
- companySelectModel = new GenericSelectModel<Company>(companies, Company.class,
- "name", "topiaId", propertyAccess);
- }
- return companySelectModel;
- }
-
- public boolean isCreateMode() throws SuiviObsmerException {
- return StringUtils.isEmpty(getSampleRow().getTopiaId());
- }
-
- void onSelectedFromCancelSave() {
- cancel = true;
- }
-
- void onSelectedFromSaveData() throws SuiviObsmerException {
- saveProgram();
- }
-
- @Log
- void onValidateFormFromSampleRowForm() throws SuiviObsmerException {
- sampleRowForm.clearErrors();
- try {
- // Only for save or periodChanged (refreshMonth)
- if (!cancel && !edited) {
- if (StringUtils.isEmpty(getSampleRow().getProgramName())) {
- sampleRowForm.recordError(program,
- "Vous devez choisir un programme existant ou en créer un nouveau");
- }
-
- Date periodBegin = getSampleRow().getPeriodBegin();
- Date periodEnd = getSampleRow().getPeriodEnd();
-
- // Validation for period dates
- if (periodBegin == null) {
- sampleRowForm.recordError(programPeriodBegin,
- "Vous ne pouvez pas rafraîchir les mois avec une date de début de programme vide");
- }
- if (periodEnd == null) {
- sampleRowForm.recordError(programPeriodEnd,
- "Vous ne pouvez pas rafraîchir les mois avec une date de fin de programme vide");
- }
-
- if (periodBegin != null && periodEnd != null) {
-
- SampleMonth firstMonth = getSampleMonths().get(0);
-
- if (firstMonth != null) {
- Date firstDate = firstMonth.getPeriodDate();
-
- if (periodBegin.after(firstDate) && firstMonth.getRealTidesValue() != 0) {
- sampleRowForm.recordError(programPeriodBegin,
- "Vous ne pouvez pas réduire la période du programme. " +
- "Il existe des enregistrements de marées réels.");
- }
- }
-
- for (SampleMonth month : getSampleMonths()) {
- if (log.isTraceEnabled()) {
- log.trace("month : " + month.formatMonth() + " _ " +
- propertyChange.hasChanged(month.getTopiaId()));
- }
-
- if (propertyChange.hasChanged(month.getTopiaId()) &&
- month.getExpectedTidesValue() < month.getRealTidesValue()) {
- sampleRowForm.recordError(
- "Il n'est pas possible de mettre moins de marées (" + month.getExpectedTidesValue() + ") " +
- "pour le mois " + getDateFormat().format(month.getPeriodDate()) +
- " qu'il y en a de réels (" + month.getRealTidesValue() + ")");
- }
- }
- }
-
- // Validate profession, fishingZone and boats (from immatriculations) if no programChanged
- if (!periodChanged) {
-
- if (!isCreateMode() && StringUtils.isEmpty(sampleRowLog.getComment())) {
- sampleRowForm.recordError(updateComment,
- "Un commentaire est obligatoire lors d'une modification de la ligne");
- }
-
- Profession profession = getSampleRow().getProfession();
- if (StringUtils.isEmpty(profession.getCodeDCF5())) {
- sampleRowForm.recordError(
- "Le métier doit obligatoirement avoir un Code DCF niveau 5");
- }
- int nbZones = getSampleRow().sizeFishingZone();
- if (nbZones == 0) {
- sampleRowForm.recordError(fishingZoneSelect,
- "Vous devez ajouter au moins une zone de pêche à la ligne");
- }
-
- boats = serviceBoat.getBoatsByImmatriculations(immatriculations);
- // Update sampleRowCode from program only if changed
- } else if (isCreateMode()) {
- String rowCode = serviceSampling.getNewSampleRowCode(periodBegin);
- getSampleRow().setCode(rowCode);
- }
- }
- } catch (SuiviObsmerBusinessException eee) {
- sampleRowForm.recordError(eee.getMessage());
- log.error("BUSINESS ERROR : " + eee.getType() + " depuis " + eee.getServiceName() +
- " : " + eee.getMessage());
- }
-
- if (log.isDebugEnabled()) {
- log.debug("SampleMonths : " + getSampleMonths());
- }
- }
-
- @Log
- Object onSuccessFromSampleRowForm() throws SuiviObsmerException {
- if (cancel) {
- return this;
- }
- if (!edited && !periodChanged) {
-
- // No company change possible when sampleRow has real tide time
- if (!getSampleRow().hasSampleMonthRealTideTime()) {
- // Save company
- Company company = getCompanySelectModel().findObject(companyId);
- getSampleRow().setCompany(company);
- }
-
- // Save sampleMonths
-
- if (log.isDebugEnabled()) {
- log.debug("SampleMonths : " + getSampleMonths());
- }
-
- getSampleRow().setSampleMonth(getSampleMonths());
-
- serviceSampling.createUpdateSampleRow(sampleRow, boats, getSampleRowLog());
-
- return SamplingPlan.class;
- } else {
- // Reinitialize professionId for select to avoid selection from existing Profession
- professionId = null;
- }
- return sampleRowForm;
- }
-
- @Log
- Object onFailureFromSampleRowForm() {
- return sampleRowForm;
- }
-
-
-}
Copied: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/SampleRowForm.java (from rev 354, trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/SampleRowForm.java)
===================================================================
--- trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/SampleRowForm.java (rev 0)
+++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/SampleRowForm.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -0,0 +1,693 @@
+/*
+ * *##%
+ * Wao :: Web Interface
+ * 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.ui.pages;
+
+import fr.ifremer.wao.WaoBusinessException;
+import fr.ifremer.wao.WaoContext;
+import fr.ifremer.wao.WaoException;
+import fr.ifremer.wao.entity.Boat;
+import fr.ifremer.wao.entity.Company;
+import fr.ifremer.wao.entity.FishingZone;
+import fr.ifremer.wao.entity.Profession;
+import fr.ifremer.wao.entity.ProfessionImpl;
+import fr.ifremer.wao.entity.SampleMonth;
+import fr.ifremer.wao.entity.SampleRow;
+import fr.ifremer.wao.entity.SampleRowLog;
+import fr.ifremer.wao.entity.SampleRowLogImpl;
+import fr.ifremer.wao.entity.WaoUser;
+import fr.ifremer.wao.service.ServiceBoat;
+import fr.ifremer.wao.service.ServiceReferential;
+import fr.ifremer.wao.service.ServiceSampling;
+import fr.ifremer.wao.service.ServiceUser;
+import fr.ifremer.wao.ui.base.GenericSelectModel;
+import fr.ifremer.wao.ui.base.WaoPage;
+import fr.ifremer.wao.ui.data.WaoPropertyChangeListener;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import org.apache.commons.lang.StringUtils;
+import org.apache.tapestry5.ComponentResources;
+import org.apache.tapestry5.EventContext;
+import org.apache.tapestry5.Field;
+import org.apache.tapestry5.OptionModel;
+import org.apache.tapestry5.SelectModel;
+import org.apache.tapestry5.annotations.IncludeStylesheet;
+import org.apache.tapestry5.annotations.InjectComponent;
+import org.apache.tapestry5.annotations.Log;
+import org.apache.tapestry5.annotations.Persist;
+import org.apache.tapestry5.annotations.Property;
+import org.apache.tapestry5.annotations.SessionState;
+import org.apache.tapestry5.beaneditor.BeanModel;
+import org.apache.tapestry5.corelib.components.Form;
+import org.apache.tapestry5.internal.OptionModelImpl;
+import org.apache.tapestry5.internal.SelectModelImpl;
+import org.apache.tapestry5.ioc.annotations.Inject;
+import org.apache.tapestry5.ioc.services.PropertyAccess;
+import org.apache.tapestry5.services.BeanModelSource;
+import org.nuiton.util.PeriodDates;
+import org.slf4j.Logger;
+
+/**
+ * SampleRowForm
+ *
+ * Created: 26 nov. 2009
+ *
+ * @author fdesbois
+ * @version $Revision$
+ *
+ * Mise a jour: $Date$
+ * par : $Author$
+ */
+ at IncludeStylesheet("context:css/sampling.css")
+public class SampleRowForm implements WaoPage {
+
+ @Override
+ public boolean isOnlyForAdmin() {
+ return true;
+ }
+
+ @Inject
+ private Logger log;
+
+ @Inject
+ private ServiceSampling serviceSampling;
+
+ @Inject
+ private ServiceReferential serviceReferential;
+
+ @Inject
+ private ServiceUser serviceUser;
+
+ @Inject
+ private ServiceBoat serviceBoat;
+
+ @SessionState
+ @Property
+ private WaoUser user;
+
+ @Inject
+ private PropertyAccess propertyAccess;
+
+ private boolean edited;
+
+ void onActivate(EventContext ec) {
+ if (ec.getCount() > 0) {
+ sampleRowId = ec.get(String.class, 0);
+ }
+ }
+
+ String onPassivate() {
+ return sampleRowId;
+ }
+
+ void setupRender() throws WaoException {
+ // Reset data
+ sampleRow = null;
+ getSampleRow();
+ sampleMonths = null;
+ getSampleMonths();
+ sampleRowLog = null;
+ getSampleRowLog();
+
+ // Reset persist select
+ professionSelectModel = null;
+ getProfessionSelectModel();
+ programSelectModel = null;
+ getProgramSelectModel();
+ fishingZoneSelectModel = null;
+ getFishingZoneSelectModel();
+ companySelectModel = null;
+ getCompanySelectModel();
+
+ professionId = null;
+ sampleRowForm.clearErrors();
+
+ if (!isCreateMode()) {
+ programId = getSampleRow().getProgramName();
+ } else {
+ programId = null;
+ }
+
+ // initialize companyId if exist for companySelect
+ Company company = getSampleRow().getCompany();
+ if (company != null) {
+ companyId = company.getTopiaId();
+ }
+
+ immatriculations = getSampleRow().getMainElligibleBoatsAsString();
+ }
+
+ /*************************** PROFESSION ***********************************/
+
+ /** Select model which contains all professions **/
+ @Persist
+ private GenericSelectModel<Profession> professionSelectModel;
+
+ /** The current selected professionId **/
+ @Property
+ private String professionId;
+
+ /** Bean model source to create the BeanModel for profession **/
+ @Inject
+ private BeanModelSource beanModelSource;
+
+ /** Component resources needed to create the BeanModel for profession **/
+ @Inject
+ private ComponentResources resources;
+
+ /**
+ * Get SelectModel for profession input Select. The select contains all existing professions.
+ *
+ * @return a GenericSelectModel<Profession>
+ * @throws WaoException
+ */
+ public GenericSelectModel<Profession> getProfessionSelectModel() throws WaoException {
+ if (professionSelectModel == null) {
+ if (log.isInfoEnabled()) {
+ log.info("BUSINESS REQUEST [getProfessions]");
+ }
+ List<Profession> professions = serviceReferential.getProfessions();
+ professionSelectModel = new GenericSelectModel<Profession>(professions, Profession.class,
+ "code", "topiaId", propertyAccess);
+ }
+ return professionSelectModel;
+ }
+
+ /**
+ * Get the Profession model for BeanDisplay component.
+ *
+ * @return a BeanModel<Profession>
+ */
+ public BeanModel<Profession> getProfessionModel() {
+ return beanModelSource.createDisplayModel(Profession.class, resources.getMessages());
+ }
+
+ /**
+ * Action on submit : addNewProfession. Used to set a new profession from the selected one.
+ *
+ * @throws WaoException
+ */
+ void onSelectedFromAddNewProfession() throws WaoException {
+ Profession profession = new ProfessionImpl();
+ if (!StringUtils.isEmpty(professionId)) {
+ Profession professionSelected = getProfessionSelectModel().findObject(professionId);
+ if (log.isDebugEnabled()) {
+ log.debug("Add new profession from : " + professionSelected);
+ }
+ profession = serviceSampling.getNewProfession(professionSelected);
+ }
+ getSampleRow().setProfession(profession);
+ edited = true;
+ }
+
+ /*************************** FISHING ZONE *********************************/
+
+ /** Select model for the FishingZone list **/
+ @Persist
+ private GenericSelectModel<FishingZone> fishingZoneSelectModel;
+
+ /** Current fishingZone id selected **/
+ @Property
+ private String fishingZoneId;
+
+ /** Current fishingZone for loop **/
+ @Property
+ private FishingZone fishingZone;
+
+ /** Current index in the loop **/
+ @Property
+ private int indexFishingZone;
+
+ /** Field fishingZone for validation : must have at least one fishingZone **/
+ @InjectComponent
+ private Field fishingZoneSelect;
+
+ /**
+ * Get the select model for FishingZone. The select contains all existing fishingZones.
+ *
+ * @return a GenericSelectModel<FishingZone>
+ * @throws WaoException
+ */
+ public GenericSelectModel<FishingZone> getFishingZoneSelectModel() throws WaoException {
+ if (fishingZoneSelectModel == null) {
+ if (log.isInfoEnabled()) {
+ log.info("BUSINESS REQUEST [getFishingZones]");
+ }
+ List<FishingZone> zones = serviceReferential.getFishingZones();
+ fishingZoneSelectModel = new GenericSelectModel<FishingZone>(zones, FishingZone.class,
+ "code", "topiaId", propertyAccess);
+ }
+ return fishingZoneSelectModel;
+ }
+
+ /**
+ * Get the list of FishingZones from the SampleRow.
+ *
+ * @return a List of FishingZone linked with the SampleRow
+ * @throws WaoException
+ */
+ public List<FishingZone> getFishingZones() throws WaoException {
+ return getSampleRow().getFishingZone();
+ }
+
+ /**
+ * Action on submit : addFishingZone. Used to add the selected fishingZone to the SampleRow.
+ *
+ * @throws WaoException
+ */
+ void onSelectedFromAddFishingZone() throws WaoException {
+ fishingZone = getFishingZoneSelectModel().findObject(fishingZoneId);
+ if (!getFishingZones().contains(fishingZone)) {
+ if (log.isDebugEnabled()) {
+ log.debug("Add new fishingZone");
+ }
+ getFishingZones().add(fishingZone);
+ }
+ edited = true;
+ }
+
+ /**
+ * Action on submit : removeFishingZone. Used to remove the fishingZone from the SampleRow.
+ *
+ * @param index of the FishingZone in the list (from loop component)
+ * @throws WaoException
+ */
+ void onSelectedFromRemoveFishingZone(int index) throws WaoException {
+ if (log.isDebugEnabled()) {
+ log.debug("Remove fishingZone at position : " + index);
+ }
+ getFishingZones().remove(index);
+ edited = true;
+ }
+
+ /*************************** PROGRAM & MONTHS *****************************/
+
+ @Persist
+ private SelectModel programSelectModel;
+
+ @Property
+ private String programName;
+
+ @Property
+ private String programId;
+
+// @Property
+// private Date month;
+
+ private PeriodDates period;
+
+// @Persist
+// private List<Date> months;
+
+ @Persist
+ private List<SampleMonth> sampleMonths;
+
+ @Property
+ private int monthIndex;
+
+ @Property
+ private SampleMonth sampleMonth;
+
+ @InjectComponent
+ private Field programPeriodBegin;
+
+ @InjectComponent
+ private Field programPeriodEnd;
+
+ @InjectComponent
+ private Field program;
+
+ private boolean periodChanged;
+
+ public SelectModel getProgramSelectModel() throws WaoException {
+ if (programSelectModel == null) {
+ if (log.isInfoEnabled()) {
+ log.info("BUSINESS REQUEST [getPrograms]");
+ }
+ List<OptionModel> options = new ArrayList<OptionModel>();
+ for (String name : serviceSampling.getPrograms(null)) {
+ options.add(new OptionModelImpl(name, name));
+ }
+ programSelectModel = new SelectModelImpl(null, options);
+ }
+ return programSelectModel;
+ }
+
+// public List<Date> getMonths() throws WaoException {
+// if (months == null) {
+// if (log.isDebugEnabled()) {
+// log.debug("Reset months list");
+// }
+// months = getPeriod().getMonths();
+// sampleMonths = null;
+// getSampleMonths();
+// }
+// return months;
+// }
+
+// public Program getProgram() throws WaoException {
+// return getSampleRow().getProgram();
+// }
+
+ public PeriodDates getPeriod() throws WaoException {
+ if (period == null) {
+ Date begin = getSampleRow().getPeriodBegin();
+ Date end = getSampleRow().getPeriodEnd();
+ period = new PeriodDates(begin, end);
+ }
+ return period;
+ }
+
+ public List<SampleMonth> getSampleMonths() throws WaoException {
+ if (sampleMonths == null) {
+ sampleMonths = new ArrayList<SampleMonth>();
+ for (Date currMonth : getPeriod().getMonths()) {
+ SampleMonth curr = getSampleRow().getSampleMonth(currMonth);
+ if (curr != null) {
+ sampleMonths.add(curr);
+ // If an other period is set
+ } else if (periodChanged) {
+ if (curr == null) {
+ curr = serviceSampling.getNewSampleMonth(currMonth, getSampleRow());
+ }
+ sampleMonths.add(curr);
+ }
+ }
+ }
+ return sampleMonths;
+ }
+
+ public DateFormat getDateFormat() {
+ return new SimpleDateFormat("MM/yyyy");
+ }
+
+ public String getMonthStyle() {
+ String style = " ";
+
+ Date current = WaoContext.getCurrentDate();
+ if (sampleMonth.isCurrentMonth()) {
+ style += "selected";
+ } else if (current.after(sampleMonth.getPeriodDate())) {
+ style += "even";
+ }
+ return style;
+ }
+
+ /**
+ * Search a program from the list.
+ * The program will be set from the one selected. If no selection, a new one will be set.
+ * @throws WaoException
+ */
+// @Log
+// void onSelectedFromSearchProgram() throws WaoException {
+// if (!StringUtils.isEmpty(programId)) {
+// programName = null;
+//// period = null;
+//// months = null;
+// getSampleRow().setProgramName(programId);
+//
+// // No period in this case ?!?
+// }
+// edited = true;
+// }
+
+ /**
+ * Refresh months from program period.
+ * If the programName is not empty, a new program will be set.
+ * The period dates will be saved in program (validation will be done in onSuccess).
+ * @throws WaoException
+ */
+ @Log
+ void onSelectedFromRefreshMonths() throws WaoException {
+ getSampleRow().setPeriod(period);
+ periodChanged = true;
+ // Reset sampleMonths for new period
+ sampleMonths = null;
+ getSampleMonths();
+ saveProgram();
+ }
+
+ protected void saveProgram() throws WaoException {
+ // Save programName
+ if (StringUtils.isNotEmpty(programName)) {
+ getSampleRow().setProgramName(programName);
+ programId = null;
+ } else if (StringUtils.isNotEmpty(programId)) {
+ getSampleRow().setProgramName(programId);
+ }
+ if (log.isInfoEnabled()) {
+ log.info("Program : " + getSampleRow().getProgramName());
+ }
+ }
+
+ @Log
+ void onSelectedFromDeleteMonth(int index) throws WaoException {
+ getSampleMonths().remove(index);
+ edited = true;
+ }
+
+ /*************************** SAMPLE ROW ***********************************/
+
+ private String sampleRowId;
+
+ @Persist
+ private SampleRow sampleRow;
+
+ private BeanModel<SampleRow> sampleRowModel;
+
+ @InjectComponent
+ private Form sampleRowForm;
+
+ @InjectComponent
+ private Field updateComment;
+
+ @Persist
+ private SampleRowLog sampleRowLog;
+
+ @Property
+ private String immatriculations;
+
+ @Property
+ private String companyId;
+
+ private List<Boat> boats;
+
+ private GenericSelectModel<Company> companySelectModel;
+
+ private boolean cancel;
+
+ @Persist
+ private WaoPropertyChangeListener propertyChange;
+
+ public SampleRow getSampleRow() throws WaoException {
+ if (sampleRow == null) {
+ if (!StringUtils.isEmpty(sampleRowId)) {
+ if (log.isInfoEnabled()) {
+ log.info("BUSINESS REQUEST [getSampleRow]");
+ }
+ sampleRow = serviceSampling.getSampleRow(sampleRowId);
+ propertyChange = new WaoPropertyChangeListener();
+ for (SampleMonth month : sampleRow.getSampleMonth()) {
+ month.addPropertyChangeListener(SampleMonth.EXPECTED_TIDES_VALUE, propertyChange);
+ }
+ } else {
+ sampleRow = serviceSampling.getNewSampleRow();
+ }
+ }
+ return sampleRow;
+ }
+
+ public SampleRowLog getSampleRowLog() throws WaoException {
+ if (sampleRowLog == null) {
+ sampleRowLog = new SampleRowLogImpl();
+ sampleRowLog.setSampleRow(getSampleRow());
+ sampleRowLog.setAdmin(user);
+ }
+ return sampleRowLog;
+ }
+
+ public BeanModel<SampleRow> getSampleRowModel() {
+ if (sampleRowModel == null) {
+ sampleRowModel = beanModelSource.createEditModel(SampleRow.class, resources.getMessages());
+ sampleRowModel.add("company", null);
+ sampleRowModel.add("boats", null);
+ sampleRowModel.include("code", "company", "nbObservants", "averageTideTime", "boats", "comment");
+ }
+ return sampleRowModel;
+ }
+
+ public GenericSelectModel<Company> getCompanySelectModel() throws WaoException {
+ if (companySelectModel == null) {
+ if (log.isInfoEnabled()) {
+ log.info("BUSINESS REQUEST [getCompanies]");
+ }
+ List<Company> companies = serviceUser.getCompanies(true);
+ companySelectModel = new GenericSelectModel<Company>(companies, Company.class,
+ "name", "topiaId", propertyAccess);
+ }
+ return companySelectModel;
+ }
+
+ public boolean isCreateMode() throws WaoException {
+ return StringUtils.isEmpty(getSampleRow().getTopiaId());
+ }
+
+ void onSelectedFromCancelSave() {
+ cancel = true;
+ }
+
+ void onSelectedFromSaveData() throws WaoException {
+ saveProgram();
+ }
+
+ @Log
+ void onValidateFormFromSampleRowForm() throws WaoException {
+ sampleRowForm.clearErrors();
+ try {
+ // Only for save or periodChanged (refreshMonth)
+ if (!cancel && !edited) {
+ if (StringUtils.isEmpty(getSampleRow().getProgramName())) {
+ sampleRowForm.recordError(program,
+ "Vous devez choisir un programme existant ou en créer un nouveau");
+ }
+
+ Date periodBegin = getSampleRow().getPeriodBegin();
+ Date periodEnd = getSampleRow().getPeriodEnd();
+
+ // Validation for period dates
+ if (periodBegin == null) {
+ sampleRowForm.recordError(programPeriodBegin,
+ "Vous ne pouvez pas rafraîchir les mois avec une date de début de programme vide");
+ }
+ if (periodEnd == null) {
+ sampleRowForm.recordError(programPeriodEnd,
+ "Vous ne pouvez pas rafraîchir les mois avec une date de fin de programme vide");
+ }
+
+ if (periodBegin != null && periodEnd != null) {
+
+ SampleMonth firstMonth = getSampleMonths().get(0);
+
+ if (firstMonth != null) {
+ Date firstDate = firstMonth.getPeriodDate();
+
+ if (periodBegin.after(firstDate) && firstMonth.getRealTidesValue() != 0) {
+ sampleRowForm.recordError(programPeriodBegin,
+ "Vous ne pouvez pas réduire la période du programme. " +
+ "Il existe des enregistrements de marées réels.");
+ }
+ }
+
+ for (SampleMonth month : getSampleMonths()) {
+ if (log.isTraceEnabled()) {
+ log.trace("month : " + month.formatMonth() + " _ " +
+ propertyChange.hasChanged(month.getTopiaId()));
+ }
+
+ if (propertyChange.hasChanged(month.getTopiaId()) &&
+ month.getExpectedTidesValue() < month.getRealTidesValue()) {
+ sampleRowForm.recordError(
+ "Il n'est pas possible de mettre moins de marées (" + month.getExpectedTidesValue() + ") " +
+ "pour le mois " + getDateFormat().format(month.getPeriodDate()) +
+ " qu'il y en a de réels (" + month.getRealTidesValue() + ")");
+ }
+ }
+ }
+
+ // Validate profession, fishingZone and boats (from immatriculations) if no programChanged
+ if (!periodChanged) {
+
+ if (!isCreateMode() && StringUtils.isEmpty(sampleRowLog.getComment())) {
+ sampleRowForm.recordError(updateComment,
+ "Un commentaire est obligatoire lors d'une modification de la ligne");
+ }
+
+ Profession profession = getSampleRow().getProfession();
+ if (StringUtils.isEmpty(profession.getCodeDCF5())) {
+ sampleRowForm.recordError(
+ "Le métier doit obligatoirement avoir un Code DCF niveau 5");
+ }
+ int nbZones = getSampleRow().sizeFishingZone();
+ if (nbZones == 0) {
+ sampleRowForm.recordError(fishingZoneSelect,
+ "Vous devez ajouter au moins une zone de pêche à la ligne");
+ }
+
+ boats = serviceBoat.getBoatsByImmatriculations(immatriculations);
+ // Update sampleRowCode from program only if changed
+ } else if (isCreateMode()) {
+ String rowCode = serviceSampling.getNewSampleRowCode(periodBegin);
+ getSampleRow().setCode(rowCode);
+ }
+ }
+ } catch (WaoBusinessException eee) {
+ sampleRowForm.recordError(eee.getMessage());
+ log.error("BUSINESS ERROR : " + eee.getType() + " depuis " + eee.getServiceName() +
+ " : " + eee.getMessage());
+ }
+
+ if (log.isDebugEnabled()) {
+ log.debug("SampleMonths : " + getSampleMonths());
+ }
+ }
+
+ @Log
+ Object onSuccessFromSampleRowForm() throws WaoException {
+ if (cancel) {
+ return this;
+ }
+ if (!edited && !periodChanged) {
+
+ // No company change possible when sampleRow has real tide time
+ if (!getSampleRow().hasSampleMonthRealTideTime()) {
+ // Save company
+ Company company = getCompanySelectModel().findObject(companyId);
+ getSampleRow().setCompany(company);
+ }
+
+ // Save sampleMonths
+
+ if (log.isDebugEnabled()) {
+ log.debug("SampleMonths : " + getSampleMonths());
+ }
+
+ getSampleRow().setSampleMonth(getSampleMonths());
+
+ serviceSampling.createUpdateSampleRow(sampleRow, boats, getSampleRowLog());
+
+ return SamplingPlan.class;
+ } else {
+ // Reinitialize professionId for select to avoid selection from existing Profession
+ professionId = null;
+ }
+ return sampleRowForm;
+ }
+
+ @Log
+ Object onFailureFromSampleRowForm() {
+ return sampleRowForm;
+ }
+
+
+}
Deleted: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/SampleRowHistoric.java
===================================================================
--- trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/SampleRowHistoric.java 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/SampleRowHistoric.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,108 +0,0 @@
-/*
- * *##%
- * SuiviObsmer :: Web Interface
- * 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.suiviobsmer.ui.pages;
-
-import fr.ifremer.suiviobsmer.SuiviObsmerException;
-import fr.ifremer.suiviobsmer.entity.SampleRow;
-import fr.ifremer.suiviobsmer.entity.SampleRowLog;
-import fr.ifremer.suiviobsmer.services.ServiceSampling;
-import fr.ifremer.suiviobsmer.ui.base.SuiviObsmerPage;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.Locale;
-import org.apache.tapestry5.annotations.IncludeStylesheet;
-import org.apache.tapestry5.annotations.Persist;
-import org.apache.tapestry5.annotations.Property;
-import org.apache.tapestry5.ioc.annotations.Inject;
-import org.slf4j.Logger;
-
-/**
- * SampleRowHistoric
- *
- * Created: 12 janv. 2010
- *
- * @author fdesbois
- * @version $Revision$
- *
- * Mise a jour: $Date$
- * par : $Author$
- */
- at IncludeStylesheet("context:css/sampling.css")
-public class SampleRowHistoric implements SuiviObsmerPage {
-
- @Override
- public boolean isOnlyForAdmin() {
- return true;
- }
-
- @Inject
- private Logger log;
-
- @Inject
- private ServiceSampling serviceSampling;
-
- private String sampleRowId;
-
- @Persist
- private SampleRow sampleRow;
-
- @Property
- private SampleRowLog sampleRowLog;
-
- void onActivate(String id) {
- sampleRowId = id;
- }
-
- String onPassivate() {
- return sampleRowId;
- }
-
- void setupRender() throws SuiviObsmerException {
- sampleRow = null;
- getSampleRow();
- }
-
- public SampleRow getSampleRow() throws SuiviObsmerException {
- if (sampleRow == null) {
- if (log.isInfoEnabled()) {
- log.info("BUSINESS REQUEST [getSampleRow]");
- }
- sampleRow = serviceSampling.getSampleRow(sampleRowId);
- }
- return sampleRow;
- }
-
- public DateFormat getDateFormat() {
- return new SimpleDateFormat("dd/MM/yyyy HH:mm:ss", Locale.FRENCH);
- }
-
- public String getContent() {
- String content = sampleRowLog.getLogText();
- if (content == null) {
- content = "Aucun changement enregistré.";
- } else {
- content = content.replaceAll("\\n", "<br />");
- }
- return content;
- }
-
-}
Copied: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/SampleRowHistoric.java (from rev 354, trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/SampleRowHistoric.java)
===================================================================
--- trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/SampleRowHistoric.java (rev 0)
+++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/SampleRowHistoric.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -0,0 +1,108 @@
+/*
+ * *##%
+ * Wao :: Web Interface
+ * 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.ui.pages;
+
+import fr.ifremer.wao.WaoException;
+import fr.ifremer.wao.entity.SampleRow;
+import fr.ifremer.wao.entity.SampleRowLog;
+import fr.ifremer.wao.service.ServiceSampling;
+import fr.ifremer.wao.ui.base.WaoPage;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Locale;
+import org.apache.tapestry5.annotations.IncludeStylesheet;
+import org.apache.tapestry5.annotations.Persist;
+import org.apache.tapestry5.annotations.Property;
+import org.apache.tapestry5.ioc.annotations.Inject;
+import org.slf4j.Logger;
+
+/**
+ * SampleRowHistoric
+ *
+ * Created: 12 janv. 2010
+ *
+ * @author fdesbois
+ * @version $Revision$
+ *
+ * Mise a jour: $Date$
+ * par : $Author$
+ */
+ at IncludeStylesheet("context:css/sampling.css")
+public class SampleRowHistoric implements WaoPage {
+
+ @Override
+ public boolean isOnlyForAdmin() {
+ return true;
+ }
+
+ @Inject
+ private Logger log;
+
+ @Inject
+ private ServiceSampling serviceSampling;
+
+ private String sampleRowId;
+
+ @Persist
+ private SampleRow sampleRow;
+
+ @Property
+ private SampleRowLog sampleRowLog;
+
+ void onActivate(String id) {
+ sampleRowId = id;
+ }
+
+ String onPassivate() {
+ return sampleRowId;
+ }
+
+ void setupRender() throws WaoException {
+ sampleRow = null;
+ getSampleRow();
+ }
+
+ public SampleRow getSampleRow() throws WaoException {
+ if (sampleRow == null) {
+ if (log.isInfoEnabled()) {
+ log.info("BUSINESS REQUEST [getSampleRow]");
+ }
+ sampleRow = serviceSampling.getSampleRow(sampleRowId);
+ }
+ return sampleRow;
+ }
+
+ public DateFormat getDateFormat() {
+ return new SimpleDateFormat("dd/MM/yyyy HH:mm:ss", Locale.FRENCH);
+ }
+
+ public String getContent() {
+ String content = sampleRowLog.getLogText();
+ if (content == null) {
+ content = "Aucun changement enregistré.";
+ } else {
+ content = content.replaceAll("\\n", "<br />");
+ }
+ return content;
+ }
+
+}
Deleted: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/SamplingPlan.java
===================================================================
--- trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/SamplingPlan.java 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/SamplingPlan.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,395 +0,0 @@
-/*
- * *##%
- * SuiviObsmer :: Web Interface
- * 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.suiviobsmer.ui.pages;
-
-
-import fr.ifremer.suiviobsmer.SuiviObsmerBusinessException;
-import fr.ifremer.suiviobsmer.SuiviObsmerException;
-import fr.ifremer.suiviobsmer.bean.FacadeRow;
-import fr.ifremer.suiviobsmer.bean.ImportResults;
-import fr.ifremer.suiviobsmer.entity.Company;
-import fr.ifremer.suiviobsmer.entity.FishingZone;
-import fr.ifremer.suiviobsmer.entity.SampleMonth;
-import fr.ifremer.suiviobsmer.entity.SampleRow;
-import fr.ifremer.suiviobsmer.entity.WaoUser;
-import fr.ifremer.suiviobsmer.services.ServiceSampling;
-import fr.ifremer.suiviobsmer.ui.base.SuiviObsmerPage;
-import fr.ifremer.suiviobsmer.ui.components.Layout;
-import fr.ifremer.suiviobsmer.ui.data.ExportStreamResponse;
-import java.io.IOException;
-import java.io.InputStream;
-import java.text.DateFormat;
-import java.text.NumberFormat;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.List;
-import org.apache.tapestry5.StreamResponse;
-import org.apache.tapestry5.annotations.IncludeStylesheet;
-import org.apache.tapestry5.annotations.InjectComponent;
-import org.apache.tapestry5.annotations.Log;
-import org.apache.tapestry5.annotations.Persist;
-import org.apache.tapestry5.annotations.Property;
-import org.apache.tapestry5.annotations.SessionState;
-import org.apache.tapestry5.ioc.annotations.Inject;
-import org.apache.tapestry5.upload.services.UploadedFile;
-import org.nuiton.util.PeriodDates;
-import org.slf4j.Logger;
-
-/**
- * SampingPlan
- *
- * Created: 9 nov. 2009
- *
- * @author fdesbois
- * @version $Revision$
- *
- * Mise a jour: $Date$
- * par : $Author$
- */
- at IncludeStylesheet("context:css/sampling.css")
-public class SamplingPlan implements SuiviObsmerPage {
-
- @Override
- public boolean isOnlyForAdmin() {
- return false;
- }
-
- @Inject
- private Logger log;
-
- @Inject
- private ServiceSampling serviceSampling;
-
- @InjectComponent
- private Layout layout;
-
- @SessionState
- @Property
- private WaoUser user;
-
- /**
- * Page initialization
- */
- void setupRender() {
- periodBegin = getPeriod().getFromDate();
- periodEnd = getPeriod().getThruDate();
- }
-
- /**
- * Get current user from Layout component
- * @return current user
- */
-// public User getUser() {
-// return layout.getCurrentUser();
-// }
-
- /**************************** IMPORT (ADMIN) *******************************/
-
- /**
- * Fichier CSV contenant un plan d'échantillonnage
- */
- @Property
- private UploadedFile samplingPlanCsvFile;
-
- @Log
- void onSuccessFromImportSamplingPlan() throws SuiviObsmerException {
- try {
- ImportResults result = serviceSampling.importSamplingPlanCsv(samplingPlanCsvFile.getStream());
- layout.getFeedBack().addInfo(result.getNbRowsImported() + " lignes du plan importés, " +
- result.getNbRowsRefused() + " refusés.");
- for (String error : result.getErrors()) {
- layout.getFeedBack().addInfo(error);
- }
- } catch (SuiviObsmerBusinessException eee) {
- layout.getFeedBack().addError(eee.getMessage());
- }
- }
-
- /**************************** EXPORT **************************************/
-
- StreamResponse onActionFromExportSamplingPlan() {
- return new ExportStreamResponse("wao-echantillonnage") {
-
- @Override
- public InputStream getStream() throws IOException {
- InputStream result = null;
- try {
- result = serviceSampling.exportSamplingPlanCsv(user, getPeriod());
- } catch (SuiviObsmerException eee) {
- throw new IOException(eee);
- }
- return result;
- }
- };
- }
-
- /**************************** PERIOD SELECTION *****************************/
-
- @Persist
- private PeriodDates period;
-
- @Property
- private Date periodBegin;
-
- @Property
- private Date periodEnd;
-
- public PeriodDates getPeriod() {
- if (period == null) {
- period = PeriodDates.createMonthsPeriodFromToday(11);
- }
- return period;
- }
-
- void onSuccessFromPeriodForm() {
- if (periodBegin != null && periodEnd != null) {
- period.setFromDate(periodBegin);
- period.setThruDate(periodEnd);
- }
- }
-
- /**************************** MAIN TABLE ***********************************/
-
- /** ------------------------- DATA -------------------------------------- **/
-
- /**
- * Main data for samplingPlan : List of SampleRow ordered by FishingZone.
- */
- private List<SampleRow> data;
-
- private List<Date> months;
-
- @Property
- private Date month;
-
- /**
- * Current SampleRow from loop
- */
- @Property
- private SampleRow row;
-
- @Property
- private String currentFacadeName;
-
- @Property
- private String currentSectorName;
-
- /**
- * Return List of SampleRow from suiviobsmer-business
- * @return List of SampleRow
- * @throws SuiviObsmerException
- */
- public List<SampleRow> getData() throws SuiviObsmerException {
- if (data == null) {
- if (log.isInfoEnabled()) {
- log.info("BUSINESS REQUEST [getSampleRowsOrderedByFishingZone]");
- }
- Company company = null;
- if (!user.getAdmin()) {
- company = user.getCompany();
- }
- FacadeRow facade = serviceSampling.getSampleRowsOrderedByFishingZone(getPeriod(), company);
- data = facade.getValues();
- }
- return data;
- }
-
- public List<Date> getMonths() {
- if (months == null) {
- months = getPeriod().getMonths();
- }
- return months;
- }
-
- public boolean isFacadeChanged() {
- if (!row.getFacade().equals(currentFacadeName)) {
- currentFacadeName = row.getFacade();
- return true;
- }
- return false;
- }
-
- public boolean isSectorChanged() {
- if (!row.getSectors().equals(currentSectorName)) {
- currentSectorName = row.getSectors();
- return true;
- }
- return false;
- }
-
- public String getCompanyName() {
- return row.getCompany() != null ? row.getCompany().getName() : "";
- }
-
- public boolean isCurrentMonth() {
- String currentStr = getDateFormat().format(new Date());
- String monthStr = getDateFormat().format(month);
- return currentStr.equals(monthStr);
- }
-
- public Integer getNbTidesExpected() {
- SampleMonth sampleMonth = row.getSampleMonth(month);
- if (sampleMonth != null) {
- return sampleMonth.getExpectedTidesValue();
- }
- return null;
- }
-
- public String getFishingZones() {
- String result = "";
- for (FishingZone zone : row.getFishingZone()) {
- result += zone.getDistrictCode() + ", ";
- }
- return result.substring(0, result.length()-2);
- }
-
- public Integer getNbTidesReal() {
- SampleMonth sampleMonth = row.getSampleMonth(month);
- if (sampleMonth != null) {
- return sampleMonth.getRealTidesValue();
- }
- return null;
- }
-
- public boolean hasNbTidesReal() {
- Date current = new Date();
- boolean validMonth = month.before(current) || isCurrentMonth();
- return validMonth && getNbTidesReal() != null;
- }
-
- public int getTotalTidesExpected() {
- int total = 0;
- for (Date currentMonth : getMonths()) {
- SampleMonth sampleMonth = row.getSampleMonth(currentMonth);
- if (sampleMonth != null) {
- total += sampleMonth.getExpectedTidesValue();
- }
- }
- return total;
- }
-
- public int getTotalTidesReal() {
- int total = 0;
- for (Date currentMonth : getMonths()) {
- SampleMonth sampleMonth = row.getSampleMonth(currentMonth);
- if (sampleMonth != null) {
- total += sampleMonth.getRealTidesValue();
- }
- }
- return total;
- }
-
- public String getTotalPercentage() {
- double result = 0;
- if (getTotalTidesExpected() > 0) {
- result = (double)getTotalTidesReal() / (double)getTotalTidesExpected();
- }
- return NumberFormat.getPercentInstance().format(result);
- }
-
- public NumberFormat getNumberFormat() {
- return NumberFormat.getNumberInstance();
- }
-
- /** ------------------------- HTML & STYLE ------------------------------ **/
-
- @Property
- private int rowIndex;
-
- public int getNbColumnsForProfession() {
- // code, program.name, fishingZone.districts, profession.code, profession.libelle
- int fixed = 5;
- if (user.getAdmin()) {
- // company, program.periodBegin, program.periodEnd, fishingZonesInfos
- // profession.meshSize, profession.size, profession.other, profession.species
- fixed += 8;
- }
- return fixed;
- }
-
- public int getNbColumnsForMonths() {
- return getMonths().size() + 1;
- }
-
- public int getNbColumnsForOther() {
- return 4;
- }
-
- public int getNbColumnsTotal() {
- return getNbColumnsForProfession() +
- getNbColumnsForMonths() + getNbColumnsForOther();
- }
-
- public String getMainClass() {
- return user.getAdmin() ? "admin" : "user";
- }
-
- public String getParityClass() {
- return rowIndex % 2 == 0 ? "even" : "odd";
- }
-
- public String getActionsClass() {
- return user.getAdmin() ? "width100" : "width30";
- }
-
- public String getRealTidesClass() {
- String result = "real-warning";
- if (getNbTidesReal() < getNbTidesExpected()) {
- result += "-inf";
- } else if (getNbTidesReal() > getNbTidesExpected()) {
- result += "-sup";
- }
- return result;
- }
-
- public String getMonthCurrentClass() {
- return isCurrentMonth() ? "selected" : "";
- }
-
- public DateFormat getDateFormat() {
- return new SimpleDateFormat("MM/yyyy");
- }
-
- /** ------------------------- ACTIONS ----------------------------------- **/
-
- /**
- * Used to filter period using dates from the program selected in table.
- * @param rowIndex index of the row in the table
- * @throws SuiviObsmerException for a data problem
- */
- void onActionFromFilterPeriodDates(int rowIndex) throws SuiviObsmerException {
- row = getData().get(rowIndex);
- period.setFromDate(row.getPeriodBegin());
- period.setThruDate(row.getPeriodEnd());
- }
-
- void onActionFromDeleteSampleRow(int rowIndex) throws SuiviObsmerException {
- row = getData().get(rowIndex);
- serviceSampling.deleteSampleRow(row);
- }
-
- public boolean canAccessBoats() {
- // Test if the row isFinished with a gap of 1 month (today - 1 month)
- return !row.isFinished(-1);
- }
-
-}
Copied: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/SamplingPlan.java (from rev 354, trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/SamplingPlan.java)
===================================================================
--- trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/SamplingPlan.java (rev 0)
+++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/SamplingPlan.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -0,0 +1,395 @@
+/*
+ * *##%
+ * Wao :: Web Interface
+ * 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.ui.pages;
+
+
+import fr.ifremer.wao.WaoBusinessException;
+import fr.ifremer.wao.WaoException;
+import fr.ifremer.wao.bean.FacadeRow;
+import fr.ifremer.wao.bean.ImportResults;
+import fr.ifremer.wao.entity.Company;
+import fr.ifremer.wao.entity.FishingZone;
+import fr.ifremer.wao.entity.SampleMonth;
+import fr.ifremer.wao.entity.SampleRow;
+import fr.ifremer.wao.entity.WaoUser;
+import fr.ifremer.wao.service.ServiceSampling;
+import fr.ifremer.wao.ui.base.WaoPage;
+import fr.ifremer.wao.ui.components.Layout;
+import fr.ifremer.wao.ui.data.ExportStreamResponse;
+import java.io.IOException;
+import java.io.InputStream;
+import java.text.DateFormat;
+import java.text.NumberFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.List;
+import org.apache.tapestry5.StreamResponse;
+import org.apache.tapestry5.annotations.IncludeStylesheet;
+import org.apache.tapestry5.annotations.InjectComponent;
+import org.apache.tapestry5.annotations.Log;
+import org.apache.tapestry5.annotations.Persist;
+import org.apache.tapestry5.annotations.Property;
+import org.apache.tapestry5.annotations.SessionState;
+import org.apache.tapestry5.ioc.annotations.Inject;
+import org.apache.tapestry5.upload.services.UploadedFile;
+import org.nuiton.util.PeriodDates;
+import org.slf4j.Logger;
+
+/**
+ * SampingPlan
+ *
+ * Created: 9 nov. 2009
+ *
+ * @author fdesbois
+ * @version $Revision$
+ *
+ * Mise a jour: $Date$
+ * par : $Author$
+ */
+ at IncludeStylesheet("context:css/sampling.css")
+public class SamplingPlan implements WaoPage {
+
+ @Override
+ public boolean isOnlyForAdmin() {
+ return false;
+ }
+
+ @Inject
+ private Logger log;
+
+ @Inject
+ private ServiceSampling serviceSampling;
+
+ @InjectComponent
+ private Layout layout;
+
+ @SessionState
+ @Property
+ private WaoUser user;
+
+ /**
+ * Page initialization
+ */
+ void setupRender() {
+ periodBegin = getPeriod().getFromDate();
+ periodEnd = getPeriod().getThruDate();
+ }
+
+ /**
+ * Get current user from Layout component
+ * @return current user
+ */
+// public User getUser() {
+// return layout.getCurrentUser();
+// }
+
+ /**************************** IMPORT (ADMIN) *******************************/
+
+ /**
+ * Fichier CSV contenant un plan d'échantillonnage
+ */
+ @Property
+ private UploadedFile samplingPlanCsvFile;
+
+ @Log
+ void onSuccessFromImportSamplingPlan() throws WaoException {
+ try {
+ ImportResults result = serviceSampling.importSamplingPlanCsv(samplingPlanCsvFile.getStream());
+ layout.getFeedBack().addInfo(result.getNbRowsImported() + " lignes du plan importés, " +
+ result.getNbRowsRefused() + " refusés.");
+ for (String error : result.getErrors()) {
+ layout.getFeedBack().addInfo(error);
+ }
+ } catch (WaoBusinessException eee) {
+ layout.getFeedBack().addError(eee.getMessage());
+ }
+ }
+
+ /**************************** EXPORT **************************************/
+
+ StreamResponse onActionFromExportSamplingPlan() {
+ return new ExportStreamResponse("wao-echantillonnage") {
+
+ @Override
+ public InputStream getStream() throws IOException {
+ InputStream result = null;
+ try {
+ result = serviceSampling.exportSamplingPlanCsv(user, getPeriod());
+ } catch (WaoException eee) {
+ throw new IOException(eee);
+ }
+ return result;
+ }
+ };
+ }
+
+ /**************************** PERIOD SELECTION *****************************/
+
+ @Persist
+ private PeriodDates period;
+
+ @Property
+ private Date periodBegin;
+
+ @Property
+ private Date periodEnd;
+
+ public PeriodDates getPeriod() {
+ if (period == null) {
+ period = PeriodDates.createMonthsPeriodFromToday(11);
+ }
+ return period;
+ }
+
+ void onSuccessFromPeriodForm() {
+ if (periodBegin != null && periodEnd != null) {
+ period.setFromDate(periodBegin);
+ period.setThruDate(periodEnd);
+ }
+ }
+
+ /**************************** MAIN TABLE ***********************************/
+
+ /** ------------------------- DATA -------------------------------------- **/
+
+ /**
+ * Main data for samplingPlan : List of SampleRow ordered by FishingZone.
+ */
+ private List<SampleRow> data;
+
+ private List<Date> months;
+
+ @Property
+ private Date month;
+
+ /**
+ * Current SampleRow from loop
+ */
+ @Property
+ private SampleRow row;
+
+ @Property
+ private String currentFacadeName;
+
+ @Property
+ private String currentSectorName;
+
+ /**
+ * Return List of SampleRow from suiviobsmer-business
+ * @return List of SampleRow
+ * @throws WaoException
+ */
+ public List<SampleRow> getData() throws WaoException {
+ if (data == null) {
+ if (log.isInfoEnabled()) {
+ log.info("BUSINESS REQUEST [getSampleRowsOrderedByFishingZone]");
+ }
+ Company company = null;
+ if (!user.getAdmin()) {
+ company = user.getCompany();
+ }
+ FacadeRow facade = serviceSampling.getSampleRowsOrderedByFishingZone(getPeriod(), company);
+ data = facade.getValues();
+ }
+ return data;
+ }
+
+ public List<Date> getMonths() {
+ if (months == null) {
+ months = getPeriod().getMonths();
+ }
+ return months;
+ }
+
+ public boolean isFacadeChanged() {
+ if (!row.getFacade().equals(currentFacadeName)) {
+ currentFacadeName = row.getFacade();
+ return true;
+ }
+ return false;
+ }
+
+ public boolean isSectorChanged() {
+ if (!row.getSectors().equals(currentSectorName)) {
+ currentSectorName = row.getSectors();
+ return true;
+ }
+ return false;
+ }
+
+ public String getCompanyName() {
+ return row.getCompany() != null ? row.getCompany().getName() : "";
+ }
+
+ public boolean isCurrentMonth() {
+ String currentStr = getDateFormat().format(new Date());
+ String monthStr = getDateFormat().format(month);
+ return currentStr.equals(monthStr);
+ }
+
+ public Integer getNbTidesExpected() {
+ SampleMonth sampleMonth = row.getSampleMonth(month);
+ if (sampleMonth != null) {
+ return sampleMonth.getExpectedTidesValue();
+ }
+ return null;
+ }
+
+ public String getFishingZones() {
+ String result = "";
+ for (FishingZone zone : row.getFishingZone()) {
+ result += zone.getDistrictCode() + ", ";
+ }
+ return result.substring(0, result.length()-2);
+ }
+
+ public Integer getNbTidesReal() {
+ SampleMonth sampleMonth = row.getSampleMonth(month);
+ if (sampleMonth != null) {
+ return sampleMonth.getRealTidesValue();
+ }
+ return null;
+ }
+
+ public boolean hasNbTidesReal() {
+ Date current = new Date();
+ boolean validMonth = month.before(current) || isCurrentMonth();
+ return validMonth && getNbTidesReal() != null;
+ }
+
+ public int getTotalTidesExpected() {
+ int total = 0;
+ for (Date currentMonth : getMonths()) {
+ SampleMonth sampleMonth = row.getSampleMonth(currentMonth);
+ if (sampleMonth != null) {
+ total += sampleMonth.getExpectedTidesValue();
+ }
+ }
+ return total;
+ }
+
+ public int getTotalTidesReal() {
+ int total = 0;
+ for (Date currentMonth : getMonths()) {
+ SampleMonth sampleMonth = row.getSampleMonth(currentMonth);
+ if (sampleMonth != null) {
+ total += sampleMonth.getRealTidesValue();
+ }
+ }
+ return total;
+ }
+
+ public String getTotalPercentage() {
+ double result = 0;
+ if (getTotalTidesExpected() > 0) {
+ result = (double)getTotalTidesReal() / (double)getTotalTidesExpected();
+ }
+ return NumberFormat.getPercentInstance().format(result);
+ }
+
+ public NumberFormat getNumberFormat() {
+ return NumberFormat.getNumberInstance();
+ }
+
+ /** ------------------------- HTML & STYLE ------------------------------ **/
+
+ @Property
+ private int rowIndex;
+
+ public int getNbColumnsForProfession() {
+ // code, program.name, fishingZone.districts, profession.code, profession.libelle
+ int fixed = 5;
+ if (user.getAdmin()) {
+ // company, program.periodBegin, program.periodEnd, fishingZonesInfos
+ // profession.meshSize, profession.size, profession.other, profession.species
+ fixed += 8;
+ }
+ return fixed;
+ }
+
+ public int getNbColumnsForMonths() {
+ return getMonths().size() + 1;
+ }
+
+ public int getNbColumnsForOther() {
+ return 4;
+ }
+
+ public int getNbColumnsTotal() {
+ return getNbColumnsForProfession() +
+ getNbColumnsForMonths() + getNbColumnsForOther();
+ }
+
+ public String getMainClass() {
+ return user.getAdmin() ? "admin" : "user";
+ }
+
+ public String getParityClass() {
+ return rowIndex % 2 == 0 ? "even" : "odd";
+ }
+
+ public String getActionsClass() {
+ return user.getAdmin() ? "width100" : "width30";
+ }
+
+ public String getRealTidesClass() {
+ String result = "real-warning";
+ if (getNbTidesReal() < getNbTidesExpected()) {
+ result += "-inf";
+ } else if (getNbTidesReal() > getNbTidesExpected()) {
+ result += "-sup";
+ }
+ return result;
+ }
+
+ public String getMonthCurrentClass() {
+ return isCurrentMonth() ? "selected" : "";
+ }
+
+ public DateFormat getDateFormat() {
+ return new SimpleDateFormat("MM/yyyy");
+ }
+
+ /** ------------------------- ACTIONS ----------------------------------- **/
+
+ /**
+ * Used to filter period using dates from the program selected in table.
+ * @param rowIndex index of the row in the table
+ * @throws WaoException for a data problem
+ */
+ void onActionFromFilterPeriodDates(int rowIndex) throws WaoException {
+ row = getData().get(rowIndex);
+ period.setFromDate(row.getPeriodBegin());
+ period.setThruDate(row.getPeriodEnd());
+ }
+
+ void onActionFromDeleteSampleRow(int rowIndex) throws WaoException {
+ row = getData().get(rowIndex);
+ serviceSampling.deleteSampleRow(row);
+ }
+
+ public boolean canAccessBoats() {
+ // Test if the row isFinished with a gap of 1 month (today - 1 month)
+ return !row.isFinished(-1);
+ }
+
+}
Deleted: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Synthesis.java
===================================================================
--- trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/Synthesis.java 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Synthesis.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,446 +0,0 @@
-/*
- * *##%
- * SuiviObsmer :: Web Interface
- * 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.suiviobsmer.ui.pages;
-
-import fr.ifremer.suiviobsmer.SuiviObsmerException;
-import fr.ifremer.suiviobsmer.bean.BoardingResult;
-import fr.ifremer.suiviobsmer.bean.BoatFilter;
-import fr.ifremer.suiviobsmer.bean.BoatFilterImpl;
-import fr.ifremer.suiviobsmer.bean.ContactState;
-import fr.ifremer.suiviobsmer.bean.ContactStateStatistics;
-import fr.ifremer.suiviobsmer.entity.Company;
-import fr.ifremer.suiviobsmer.entity.WaoUser;
-import fr.ifremer.suiviobsmer.services.ServiceSynthesis;
-import fr.ifremer.suiviobsmer.ui.base.AbstractFilteredPage;
-import fr.ifremer.suiviobsmer.ui.base.SuiviObsmerPage;
-import fr.ifremer.suiviobsmer.ui.data.BusinessUtils;
-import fr.ifremer.suiviobsmer.ui.data.ChartUtils;
-import fr.ifremer.suiviobsmer.ui.data.ChartUtils.ChartType;
-import fr.ifremer.suiviobsmer.ui.data.SynthesisId;
-import java.text.DateFormat;
-import java.text.NumberFormat;
-import java.text.SimpleDateFormat;
-import java.util.Collection;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.SortedMap;
-import org.apache.tapestry5.Block;
-import org.apache.tapestry5.ComponentResources;
-import org.apache.tapestry5.annotations.IncludeStylesheet;
-import org.apache.tapestry5.annotations.InjectComponent;
-import org.apache.tapestry5.annotations.Log;
-import org.apache.tapestry5.annotations.Persist;
-import org.apache.tapestry5.annotations.Property;
-import org.apache.tapestry5.annotations.SessionState;
-import org.apache.tapestry5.corelib.components.Zone;
-import org.apache.tapestry5.ioc.annotations.Inject;
-import org.jfree.chart.JFreeChart;
-import org.nuiton.util.DateUtils;
-import org.nuiton.util.PeriodDates;
-import org.slf4j.Logger;
-
-/**
- * Synthesis
- *
- * Created: 9 nov. 2009
- *
- * @author fdesbois
- * @version $Revision$
- *
- * Mise a jour: $Date$
- * par : $Author$
- */
- at IncludeStylesheet("context:css/synthesis.css")
-public class Synthesis extends AbstractFilteredPage implements SuiviObsmerPage {
-
- @Override
- public boolean isOnlyForAdmin() {
- return false;
- }
-
- @Inject
- private ServiceSynthesis serviceSynthesis;
-
- @Inject
- private Logger log;
-
- @SessionState
- @Property
- private WaoUser user;
-
- @Persist
- private SynthesisId activeSynthesis;
-
- @Inject
- private ComponentResources resources;
-
- @InjectComponent
- private Zone delegator;
-
- public Block getActiveBlock() throws SuiviObsmerException {
- if (activeSynthesis == null) {
- // Initialize default synthesis by Data Sampling
- activeSynthesis = SynthesisId.GRAPH_SAMPLING;
- }
- switch (activeSynthesis) {
- case GRAPH_SAMPLING : initSamplingBlock(); break;
- case GRAPH_BOARDING : initBoardingBlock();
- }
- return resources.getBlock(activeSynthesis.getBlockId());
- }
-
- public String getActionSynthesisId() {
- return SynthesisId.class.getName();
- }
-
- public String getActionChartType() {
- return ChartType.class.getName();
- }
-
- public NumberFormat getPercentFormat() {
- return NumberFormat.getPercentInstance();
- }
-
- public DateFormat getDateFormat() {
- return new SimpleDateFormat("dd/MM/yyyy");
- }
-
- public NumberFormat getNumberFormat() {
- NumberFormat result = NumberFormat.getNumberInstance();
- result.setMaximumFractionDigits(1);
- return result;
- }
-
- @Log
- Object onAction(String actionType, String actionValue) {
- // Delegator action (menu)
- if (actionType.equals(SynthesisId.class.getName())) {
- activeSynthesis = SynthesisId.valueOf(actionValue);
- return delegator.getBody();
- // Change chart type for dataSampling
- } else if (actionType.equals(ChartType.class.getName())) {
- dataSamplingChartType = ChartType.valueOf(actionValue);
- }
- return this;
- }
-
- /********************* DYNAMICAL GRAPH : DATASAMPLING *********************/
-
- @Persist
- private BoatFilter dataSamplingFilter;
-
- @InjectComponent
- private Zone filtersZone;
-
- @Persist
- private ChartType dataSamplingChartType;
-
- private boolean reset;
-
- private void initSamplingBlock() throws SuiviObsmerException {
- initSelectFilters(true, false, true);
- }
-
- @Override
- public BoatFilter getFilter() throws SuiviObsmerException {
- if (dataSamplingFilter == null) {
- dataSamplingFilter = new BoatFilterImpl();
- if (!user.getAdmin()) {
- dataSamplingFilter.setCompany(user.getCompany());
- }
- }
- return dataSamplingFilter;
- }
-
- public PeriodDates getPeriod() throws SuiviObsmerException {
- if (getFilter().getPeriod() == null) {
- PeriodDates period = PeriodDates.createMonthsPeriodFromToday(-12);
- if (log.isDebugEnabled()) {
- log.debug("Period : " + period);
- }
- getFilter().setPeriod(period);
- }
- return getFilter().getPeriod();
- }
-
- @Override
- protected boolean isAvailableDataForFiltersOnly() {
- return false;
- }
-
- public JFreeChart getDataSamplingChart() throws SuiviObsmerException {
- if (log.isInfoEnabled()) {
- log.info("BUSINESS REQUEST [getDataSampling]");
- }
- List<SortedMap<Date, Integer>> res = serviceSynthesis.getDataSampling(getFilter());
- Map<String, Map<?, Integer>> data = new HashMap<String, Map<?, Integer>>();
- data.put("Planifié", res.get(0));
- data.put("Réalisé", res.get(1));
- String title = BusinessUtils.getDataSamplingTitle(getFilter());
- return ChartUtils.createCategoryChart(title, "Nb marées", "Mois", getDataSamplingChartType(), data);
- }
-
- public ChartType getDataSamplingChartType() {
- // Default type is BAR
- if (dataSamplingChartType == null) {
- dataSamplingChartType = ChartType.BAR;
- }
- if (log.isDebugEnabled()) {
- log.debug("ChartType : " + dataSamplingChartType);
- }
- return dataSamplingChartType;
- }
-
- void onSelectedFromReset() {
- reset = true;
- }
-
- Object onSuccessFromFiltersForm() {
- if (isEdited()) {
- return filtersZone.getBody();
- }
- if (reset) {
- dataSamplingFilter = null;
- }
- return this;
- }
-
- /********************* STATIC GRAPH : BOARDINGBOAT ************************/
-
- private BoardingResult boardingResult;
-
- @Persist
- private Company companyForBoarding;
-
- @Property
- private String companyIdForBoarding;
-
- private void initBoardingBlock() throws SuiviObsmerException {
- resetCompanySelect();
- // Set the companyIdForBoarding is only necessary for an admin which
- // have access to a select with all active companies (from Filters :
- // getCompanySelectModel())
- if (companyForBoarding != null && user.getAdmin()) {
- companyIdForBoarding = companyForBoarding.getTopiaId();
- if (log.isDebugEnabled()) {
- log.debug("companyId init : " + companyIdForBoarding);
- }
- }
- }
-
- public JFreeChart getBoardingBoatsChart() throws SuiviObsmerException {
- Map<String, Map<?, Integer>> data =
- new HashMap<String, Map<?, Integer>>();
- data.put("Navires", getBoardingResult().getData());
-
- String title = "Sollicitations des navires depuis le " +
- getDateFormat().format(getFromDate());
-
- if (companyForBoarding != null) {
- title += "\nSociété " + companyForBoarding.getName();
- }
-
- return ChartUtils.createCategoryChart(title, "Nb navires",
- "Nb embarquements", ChartType.BAR, data);
- }
-
- public BoardingResult getBoardingResult() throws SuiviObsmerException {
- if (boardingResult == null) {
- if (log.isInfoEnabled()) {
- log.info("BUSINESS REQUEST [getBoardingBoats]");
- }
- boardingResult = serviceSynthesis.getBoardingBoats(
- getCompanyForBoarding(), getFromDate());
- }
- return boardingResult;
- }
-
- public Company getCompanyForBoarding() {
- // Initialize only for an observer user. For admin, the company can
- // be null to search boardings for all companies.
- if (companyForBoarding == null && !user.getAdmin()) {
- companyForBoarding = user.getCompany();
- }
- if (log.isDebugEnabled()) {
- log.debug("company : " + companyForBoarding);
- }
- return companyForBoarding;
- }
-
- public Date getFromDate() {
- return DateUtils.createDateAfterToday(0, -12, 0);
- }
-
- @Log
- void onSuccessFromFilterCompanyForBoarding() throws SuiviObsmerException {
- companyForBoarding = getCompanySelectModel().findObject(companyIdForBoarding);
- }
-
- /********************* INDICATOR : NONCOMPLIANCEBOARDING ******************/
-
- private Map<String, Double> nonComplianceBoarding;
-
- @Property
- private Map.Entry<String, Double> nonComplianceBoardingEntry;
-
- /**
- * Data for nonComplianceBoarding indicator. The key is the company
- * considered and the value is the indicator value. The map will contains
- * only one row, if the current user is an observer.
- *
- * @return a Map with companies and there values for nonComplianceBoarding
- * @throws SuiviObsmerException
- */
- public Map<String, Double> getNonComplianceBoarding()
- throws SuiviObsmerException {
- if (nonComplianceBoarding == null) {
- Company company = !user.getAdmin() ? user.getCompany() : null;
- nonComplianceBoarding =
- serviceSynthesis.getNonComplianceBoardingIndicator(company);
- }
- return nonComplianceBoarding;
- }
-
- /**
- * Return the value of nonComplianceBoarding indicator. Only useful for
- * observer user.
- *
- * @return the value of the indicator
- * @throws SuiviObsmerException
- */
- public Double getNonComplianceBoardingValue() throws SuiviObsmerException {
- return getNonComplianceBoarding().get(user.getCompany().getName());
- }
-
- /********************* INDICATOR : NONCOMPLIANCEBOARDING ******************/
-
- private Collection<ContactStateStatistics> contactStateStatistics;
-
- @Persist
- private PeriodDates periodForContactStates;
-
- @Property
- private ContactStateStatistics contactStateStats;
-
- @Property
- private ContactState contactState;
-
- /**
- * Get all existing contactStates.
- *
- * @return ContactState[]
- */
- public ContactState[] getContactStates() {
- return ContactState.values();
- }
-
- /**
- * Get all contactStateStatistics from serviceSynthesis. There will be
- * only one result if the current user is an observer.
- *
- * @return all contactStateStatistics depends on company and selected period
- * @throws SuiviObsmerException
- */
- public Collection<ContactStateStatistics> getContactStateStatistics()
- throws SuiviObsmerException {
- if (contactStateStatistics == null) {
- Company company = !user.getAdmin() ? user.getCompany() : null;
- contactStateStatistics =
- serviceSynthesis.getContactStateStatistics(company, getPeriodForContactStates());
- }
- return contactStateStatistics;
- }
-
- public PeriodDates getPeriodForContactStates() {
- if (periodForContactStates == null) {
- periodForContactStates = PeriodDates.createMonthsPeriodFromToday(-12);
- }
- return periodForContactStates;
- }
-
- /**
- * Get the value for current contactStateStats in table row (by company)
- * and current contactState in table column.
- *
- * @return the number of contact states for the current contactState
- */
- public int getNbContactStates() {
- return contactStateStats.getData().get(contactState);
- }
-
- /**
- * Get the percent value for the current contactStateStats in table row
- * (by company) and current contactState in table column.
- *
- * @return the percent value of contact states for the current contactState
- */
- public double getPercentContactStates() {
- if (log.isDebugEnabled()) {
- log.debug("nbContactStates : " + getNbContactStates());
- log.debug("total : " + contactStateStats.getTotal());
- }
- return (double)getNbContactStates() / (double)contactStateStats.getTotal();
- }
-
- /********************* INDICATOR : NONCOMPLIANCEBOARDING ******************/
-
- private Map<String, Double> allegroReactivity;
-
- @Persist
- private PeriodDates periodForAllegroReactivity;
-
- @Property
- private Map.Entry<String, Double> allegroReactivityEntry;
-
- public Map<String, Double> getAllegroReactivity()
- throws SuiviObsmerException {
- if (allegroReactivity == null) {
- Company company = !user.getAdmin() ? user.getCompany() : null;
- allegroReactivity =
- serviceSynthesis.getContactDataInputDateReactivity(company, getPeriodForAllegroReactivity());
- }
- return allegroReactivity;
- }
-
- public PeriodDates getPeriodForAllegroReactivity() {
- if (periodForAllegroReactivity == null) {
- periodForAllegroReactivity = PeriodDates.createMonthsPeriodFromToday(-3);
- }
- return periodForAllegroReactivity;
- }
-
- public Double getAllegroReactivityValue() throws SuiviObsmerException {
- return getAllegroReactivity().get(user.getCompany().getName());
- }
-
- public String getAllegroReactivityStyle() throws SuiviObsmerException {
- double value = user.getAdmin() ?
- allegroReactivityEntry.getValue() : getAllegroReactivityValue();
- if (value >= 15.) {
- return " warn";
- }
- return "";
- }
-
-}
Copied: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Synthesis.java (from rev 354, trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/Synthesis.java)
===================================================================
--- trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Synthesis.java (rev 0)
+++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Synthesis.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -0,0 +1,450 @@
+/*
+ * *##%
+ * Wao :: Web Interface
+ * 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.ui.pages;
+
+import fr.ifremer.wao.WaoException;
+import fr.ifremer.wao.bean.BoardingResult;
+import fr.ifremer.wao.bean.BoatFilter;
+import fr.ifremer.wao.bean.BoatFilterImpl;
+import fr.ifremer.wao.bean.ContactState;
+import fr.ifremer.wao.bean.ContactStateStatistics;
+import fr.ifremer.wao.bean.ContactAverageReactivity;
+import fr.ifremer.wao.entity.Company;
+import fr.ifremer.wao.entity.WaoUser;
+import fr.ifremer.wao.service.ServiceSynthesis;
+import fr.ifremer.wao.ui.base.AbstractFilteredPage;
+import fr.ifremer.wao.ui.base.WaoPage;
+import fr.ifremer.wao.ui.data.BusinessUtils;
+import fr.ifremer.wao.ui.data.ChartUtils;
+import fr.ifremer.wao.ui.data.ChartUtils.ChartType;
+import fr.ifremer.wao.ui.data.SynthesisId;
+import java.text.DateFormat;
+import java.text.NumberFormat;
+import java.text.SimpleDateFormat;
+import java.util.Collection;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.SortedMap;
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.tapestry5.Block;
+import org.apache.tapestry5.ComponentResources;
+import org.apache.tapestry5.annotations.IncludeStylesheet;
+import org.apache.tapestry5.annotations.InjectComponent;
+import org.apache.tapestry5.annotations.Log;
+import org.apache.tapestry5.annotations.Persist;
+import org.apache.tapestry5.annotations.Property;
+import org.apache.tapestry5.annotations.SessionState;
+import org.apache.tapestry5.corelib.components.Zone;
+import org.apache.tapestry5.ioc.annotations.Inject;
+import org.jfree.chart.JFreeChart;
+import org.nuiton.util.DateUtils;
+import org.nuiton.util.PeriodDates;
+import org.slf4j.Logger;
+
+/**
+ * Synthesis
+ *
+ * Created: 9 nov. 2009
+ *
+ * @author fdesbois
+ * @version $Revision$
+ *
+ * Mise a jour: $Date$
+ * par : $Author$
+ */
+ at IncludeStylesheet("context:css/synthesis.css")
+public class Synthesis extends AbstractFilteredPage implements WaoPage {
+
+ @Override
+ public boolean isOnlyForAdmin() {
+ return false;
+ }
+
+ @Inject
+ private ServiceSynthesis serviceSynthesis;
+
+ @Inject
+ private Logger log;
+
+ @SessionState
+ @Property
+ private WaoUser user;
+
+ @Persist
+ private SynthesisId activeSynthesis;
+
+ @Inject
+ private ComponentResources resources;
+
+ @InjectComponent
+ private Zone delegator;
+
+ public Block getActiveBlock() throws WaoException {
+ if (activeSynthesis == null) {
+ // Initialize default synthesis by Data Sampling
+ activeSynthesis = SynthesisId.GRAPH_SAMPLING;
+ }
+ switch (activeSynthesis) {
+ case GRAPH_SAMPLING : initSamplingBlock(); break;
+ case GRAPH_BOARDING : initBoardingBlock();
+ }
+ return resources.getBlock(activeSynthesis.getBlockId());
+ }
+
+ public String getActionSynthesisId() {
+ return SynthesisId.class.getName();
+ }
+
+ public String getActionChartType() {
+ return ChartType.class.getName();
+ }
+
+ public NumberFormat getPercentFormat() {
+ return NumberFormat.getPercentInstance();
+ }
+
+ public DateFormat getDateFormat() {
+ return new SimpleDateFormat("dd/MM/yyyy");
+ }
+
+ public NumberFormat getNumberFormat() {
+ NumberFormat result = NumberFormat.getNumberInstance();
+ result.setMaximumFractionDigits(1);
+ return result;
+ }
+
+ @Log
+ Object onAction(String actionType, String actionValue) {
+ // Delegator action (menu)
+ if (actionType.equals(SynthesisId.class.getName())) {
+ activeSynthesis = SynthesisId.valueOf(actionValue);
+ return delegator.getBody();
+ // Change chart type for dataSampling
+ } else if (actionType.equals(ChartType.class.getName())) {
+ dataSamplingChartType = ChartType.valueOf(actionValue);
+ }
+ return this;
+ }
+
+ /********************* DYNAMICAL GRAPH : DATASAMPLING *********************/
+
+ @Persist
+ private BoatFilter dataSamplingFilter;
+
+ @InjectComponent
+ private Zone filtersZone;
+
+ @Persist
+ private ChartType dataSamplingChartType;
+
+ private boolean reset;
+
+ private void initSamplingBlock() throws WaoException {
+ initSelectFilters(true, false, true);
+ }
+
+ @Override
+ public BoatFilter getFilter() throws WaoException {
+ if (dataSamplingFilter == null) {
+ dataSamplingFilter = new BoatFilterImpl();
+ if (!user.getAdmin()) {
+ dataSamplingFilter.setCompany(user.getCompany());
+ }
+ }
+ return dataSamplingFilter;
+ }
+
+ public PeriodDates getPeriod() throws WaoException {
+ if (getFilter().getPeriod() == null) {
+ PeriodDates period = PeriodDates.createMonthsPeriodFromToday(-12);
+ if (log.isDebugEnabled()) {
+ log.debug("Period : " + period);
+ }
+ getFilter().setPeriod(period);
+ }
+ return getFilter().getPeriod();
+ }
+
+ @Override
+ protected boolean isAvailableDataForFiltersOnly() {
+ return false;
+ }
+
+ public JFreeChart getDataSamplingChart() throws WaoException {
+ if (log.isInfoEnabled()) {
+ log.info("BUSINESS REQUEST [getDataSampling]");
+ }
+ List<SortedMap<Date, Integer>> res = serviceSynthesis.getDataSampling(getFilter());
+ Map<String, Map<?, Integer>> data = new HashMap<String, Map<?, Integer>>();
+ data.put("Planifié", res.get(0));
+ data.put("Réalisé", res.get(1));
+ String title = BusinessUtils.getDataSamplingTitle(getFilter());
+ return ChartUtils.createCategoryChart(title, "Nb marées", "Mois", getDataSamplingChartType(), data);
+ }
+
+ public ChartType getDataSamplingChartType() {
+ // Default type is BAR
+ if (dataSamplingChartType == null) {
+ dataSamplingChartType = ChartType.BAR;
+ }
+ if (log.isDebugEnabled()) {
+ log.debug("ChartType : " + dataSamplingChartType);
+ }
+ return dataSamplingChartType;
+ }
+
+ void onSelectedFromReset() {
+ reset = true;
+ }
+
+ Object onSuccessFromFiltersForm() {
+ if (isEdited()) {
+ return filtersZone.getBody();
+ }
+ if (reset) {
+ dataSamplingFilter = null;
+ }
+ return this;
+ }
+
+ /********************* STATIC GRAPH : BOARDINGBOAT ************************/
+
+ private BoardingResult boardingResult;
+
+ @Persist
+ private Company companyForBoarding;
+
+ @Property
+ private String companyIdForBoarding;
+
+ private void initBoardingBlock() throws WaoException {
+ resetCompanySelect();
+ // Set the companyIdForBoarding is only necessary for an admin which
+ // have access to a select with all active companies (from Filters :
+ // getCompanySelectModel())
+ if (companyForBoarding != null && user.getAdmin()) {
+ companyIdForBoarding = companyForBoarding.getTopiaId();
+ if (log.isDebugEnabled()) {
+ log.debug("companyId init : " + companyIdForBoarding);
+ }
+ }
+ }
+
+ public JFreeChart getBoardingBoatsChart() throws WaoException {
+ Map<String, Map<?, Integer>> data =
+ new HashMap<String, Map<?, Integer>>();
+ data.put("Navires", getBoardingResult().getData());
+
+ String title = "Sollicitations des navires depuis le " +
+ getDateFormat().format(getFromDate());
+
+ if (companyForBoarding != null) {
+ title += "\nSociété " + companyForBoarding.getName();
+ }
+
+ return ChartUtils.createCategoryChart(title, "Nb navires",
+ "Nb embarquements", ChartType.BAR, data);
+ }
+
+ public BoardingResult getBoardingResult() throws WaoException {
+ if (boardingResult == null) {
+ if (log.isInfoEnabled()) {
+ log.info("BUSINESS REQUEST [getBoardingBoats]");
+ }
+ boardingResult = serviceSynthesis.getBoardingBoats(
+ getCompanyForBoarding(), getFromDate());
+ }
+ return boardingResult;
+ }
+
+ public Company getCompanyForBoarding() {
+ // Initialize only for an observer user. For admin, the company can
+ // be null to search boardings for all companies.
+ if (companyForBoarding == null && !user.getAdmin()) {
+ companyForBoarding = user.getCompany();
+ }
+ if (log.isDebugEnabled()) {
+ log.debug("company : " + companyForBoarding);
+ }
+ return companyForBoarding;
+ }
+
+ public Date getFromDate() {
+ return DateUtils.createDateAfterToday(0, -12, 0);
+ }
+
+ @Log
+ void onSuccessFromFilterCompanyForBoarding() throws WaoException {
+ companyForBoarding = getCompanySelectModel().findObject(companyIdForBoarding);
+ }
+
+ /********************* INDICATOR : NONCOMPLIANCEBOARDING ******************/
+
+ private Map<String, Double> nonComplianceBoarding;
+
+ @Property
+ private Map.Entry<String, Double> nonComplianceBoardingEntry;
+
+ /**
+ * Data for nonComplianceBoarding indicator. The key is the company
+ * considered and the value is the indicator value. The map will contains
+ * only one row, if the current user is an observer.
+ *
+ * @return a Map with companies and there values for nonComplianceBoarding
+ * @throws WaoException
+ */
+ public Map<String, Double> getNonComplianceBoarding()
+ throws WaoException {
+ if (nonComplianceBoarding == null) {
+ Company company = !user.getAdmin() ? user.getCompany() : null;
+ nonComplianceBoarding =
+ serviceSynthesis.getNonComplianceBoardingIndicator(company);
+ }
+ return nonComplianceBoarding;
+ }
+
+ /**
+ * Return the value of nonComplianceBoarding indicator. Only useful for
+ * observer user.
+ *
+ * @return the value of the indicator
+ * @throws WaoException
+ */
+ public Double getNonComplianceBoardingValue() throws WaoException {
+ return getNonComplianceBoarding().get(user.getCompany().getName());
+ }
+
+ /********************* INDICATOR : NONCOMPLIANCEBOARDING ******************/
+
+ private Collection<ContactStateStatistics> contactStateStatistics;
+
+ @Persist
+ private PeriodDates periodForContactStates;
+
+ @Property
+ private ContactStateStatistics contactStateStats;
+
+ @Property
+ private ContactState contactState;
+
+ /**
+ * Get all existing contactStates.
+ *
+ * @return ContactState[]
+ */
+ public ContactState[] getContactStates() {
+ return ContactState.values();
+ }
+
+ /**
+ * Get all contactStateStatistics from serviceSynthesis. There will be
+ * only one result if the current user is an observer.
+ *
+ * @return all contactStateStatistics depends on company and selected period
+ * @throws WaoException
+ */
+ public Collection<ContactStateStatistics> getContactStateStatistics()
+ throws WaoException {
+ if (contactStateStatistics == null) {
+ Company company = !user.getAdmin() ? user.getCompany() : null;
+ contactStateStatistics =
+ serviceSynthesis.getContactStateStatistics(company, getPeriodForContactStates());
+ }
+ return contactStateStatistics;
+ }
+
+ public PeriodDates getPeriodForContactStates() {
+ if (periodForContactStates == null) {
+ periodForContactStates = PeriodDates.createMonthsPeriodFromToday(-12);
+ }
+ return periodForContactStates;
+ }
+
+ /**
+ * Get the value for current contactStateStats in table row (by company)
+ * and current contactState in table column.
+ *
+ * @return the number of contact states for the current contactState
+ */
+ public int getNbContactStates() {
+ return contactStateStats.getData().get(contactState);
+ }
+
+ /**
+ * Get the percent value for the current contactStateStats in table row
+ * (by company) and current contactState in table column.
+ *
+ * @return the percent value of contact states for the current contactState
+ */
+ public double getPercentContactStates() {
+ if (log.isDebugEnabled()) {
+ log.debug("nbContactStates : " + getNbContactStates());
+ log.debug("total : " + contactStateStats.getTotal());
+ }
+ return (double)getNbContactStates() / (double)contactStateStats.getTotal();
+ }
+
+ /********************* INDICATOR : NONCOMPLIANCEBOARDING ******************/
+
+ private Collection<ContactAverageReactivity> allegroReactivity;
+
+ @Persist
+ private PeriodDates periodForAllegroReactivity;
+
+ @Property
+ private ContactAverageReactivity allegroReactivityEntry;
+
+ public Collection<ContactAverageReactivity> getAllegroReactivity()
+ throws WaoException {
+ if (allegroReactivity == null) {
+ Company company = !user.getAdmin() ? user.getCompany() : null;
+ allegroReactivity =
+ serviceSynthesis.getContactDataInputDateReactivity(company, getPeriodForAllegroReactivity());
+ }
+ return allegroReactivity;
+ }
+
+ public PeriodDates getPeriodForAllegroReactivity() {
+ if (periodForAllegroReactivity == null) {
+ periodForAllegroReactivity = PeriodDates.createMonthsPeriodFromToday(-3);
+ }
+ return periodForAllegroReactivity;
+ }
+
+ public Double getAllegroReactivityValue() throws WaoException {
+ ContactAverageReactivity entry =
+ (ContactAverageReactivity) CollectionUtils.get(getAllegroReactivity(), 0);
+ return entry.getResult();
+ }
+
+ public String getAllegroReactivityStyle() throws WaoException {
+ double value = user.getAdmin() ?
+ allegroReactivityEntry.getResult() : getAllegroReactivityValue();
+ if (value >= 15.) {
+ return " warn";
+ }
+ return "";
+ }
+
+}
Deleted: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/UserProfile.java
===================================================================
--- trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/UserProfile.java 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/UserProfile.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,111 +0,0 @@
-/*
- * *##%
- * SuiviObsmer :: Web Interface
- * 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.suiviobsmer.ui.pages;
-
-import fr.ifremer.suiviobsmer.SuiviObsmerBusinessException;
-import fr.ifremer.suiviobsmer.SuiviObsmerException;
-import fr.ifremer.suiviobsmer.entity.WaoUser;
-import fr.ifremer.suiviobsmer.services.ServiceUser;
-import fr.ifremer.suiviobsmer.ui.base.SuiviObsmerPage;
-import fr.ifremer.suiviobsmer.ui.components.Layout;
-import org.apache.commons.lang.StringUtils;
-import org.apache.tapestry5.annotations.IncludeStylesheet;
-import org.apache.tapestry5.annotations.InjectComponent;
-import org.apache.tapestry5.annotations.Property;
-import org.apache.tapestry5.annotations.SessionState;
-import org.apache.tapestry5.corelib.components.BeanEditForm;
-import org.apache.tapestry5.ioc.annotations.Inject;
-import org.slf4j.Logger;
-
-/**
- * UserProfile
- *
- * Created: 10 nov. 2009
- *
- * @author fdesbois
- * @version $Revision$
- *
- * Mise a jour: $Date$
- * par : $Author$
- */
- at IncludeStylesheet("context:css/userProfile.css")
-public class UserProfile implements SuiviObsmerPage {
-
- @Override
- public boolean isOnlyForAdmin() {
- return false;
- }
-
- @Inject
- private Logger log;
-
- @Inject
- private ServiceUser serviceUser;
-
- @InjectComponent
- private Layout layout;
-
- @SessionState
- private WaoUser user;
-
- private WaoUser userEditable;
-
- @InjectComponent
- private BeanEditForm userForm;
-
- @Property
- private String password;
-
- @Property
- private String password2;
-
- public WaoUser getUserEditable() {
- if (userEditable == null) {
- userEditable = user;
- }
- return userEditable;
- }
-
- void onSuccessFromUserForm() throws SuiviObsmerException {
-
- if (password != null && !password.equals(password2)) {
- userForm.recordError("Les deux password ne sont pas identiques, vérifiez la saisie !");
- } else {
- try {
- if (!StringUtils.isEmpty(password)) {
- userEditable.setPassword(password);
- userEditable.setPasswordChanged(true);
- }
- serviceUser.createUpdateUser(userEditable, false);
- layout.getFeedBack().addInfo("Modifications enregistrées avec succès !");
- } catch (SuiviObsmerBusinessException eee) {
- userForm.recordError(eee.getMessage());
-// if (log.isErrorEnabled()) {
-// log.error("Error during user save", eee);
-// }
- }
- }
- }
-
-
-
-}
Copied: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/UserProfile.java (from rev 354, trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/UserProfile.java)
===================================================================
--- trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/UserProfile.java (rev 0)
+++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/UserProfile.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -0,0 +1,111 @@
+/*
+ * *##%
+ * Wao :: Web Interface
+ * 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.ui.pages;
+
+import fr.ifremer.wao.WaoBusinessException;
+import fr.ifremer.wao.WaoException;
+import fr.ifremer.wao.entity.WaoUser;
+import fr.ifremer.wao.service.ServiceUser;
+import fr.ifremer.wao.ui.base.WaoPage;
+import fr.ifremer.wao.ui.components.Layout;
+import org.apache.commons.lang.StringUtils;
+import org.apache.tapestry5.annotations.IncludeStylesheet;
+import org.apache.tapestry5.annotations.InjectComponent;
+import org.apache.tapestry5.annotations.Property;
+import org.apache.tapestry5.annotations.SessionState;
+import org.apache.tapestry5.corelib.components.BeanEditForm;
+import org.apache.tapestry5.ioc.annotations.Inject;
+import org.slf4j.Logger;
+
+/**
+ * UserProfile
+ *
+ * Created: 10 nov. 2009
+ *
+ * @author fdesbois
+ * @version $Revision$
+ *
+ * Mise a jour: $Date$
+ * par : $Author$
+ */
+ at IncludeStylesheet("context:css/userProfile.css")
+public class UserProfile implements WaoPage {
+
+ @Override
+ public boolean isOnlyForAdmin() {
+ return false;
+ }
+
+ @Inject
+ private Logger log;
+
+ @Inject
+ private ServiceUser serviceUser;
+
+ @InjectComponent
+ private Layout layout;
+
+ @SessionState
+ private WaoUser user;
+
+ private WaoUser userEditable;
+
+ @InjectComponent
+ private BeanEditForm userForm;
+
+ @Property
+ private String password;
+
+ @Property
+ private String password2;
+
+ public WaoUser getUserEditable() {
+ if (userEditable == null) {
+ userEditable = user;
+ }
+ return userEditable;
+ }
+
+ void onSuccessFromUserForm() throws WaoException {
+
+ if (password != null && !password.equals(password2)) {
+ userForm.recordError("Les deux password ne sont pas identiques, vérifiez la saisie !");
+ } else {
+ try {
+ if (!StringUtils.isEmpty(password)) {
+ userEditable.setPassword(password);
+ userEditable.setPasswordChanged(true);
+ }
+ serviceUser.createUpdateUser(userEditable, false);
+ layout.getFeedBack().addInfo("Modifications enregistrées avec succès !");
+ } catch (WaoBusinessException eee) {
+ userForm.recordError(eee.getMessage());
+// if (log.isErrorEnabled()) {
+// log.error("Error during user save", eee);
+// }
+ }
+ }
+ }
+
+
+
+}
Deleted: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/services/AppModule.java
===================================================================
--- trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/services/AppModule.java 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/services/AppModule.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,155 +0,0 @@
-/* *##%
- * SuiviObsmer :: Web Interface
- * 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.suiviobsmer.ui.services;
-
-import fr.ifremer.suiviobsmer.entity.WaoUser;
-import fr.ifremer.suiviobsmer.entity.WaoUserImpl;
-import fr.ifremer.suiviobsmer.services.*;
-
-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;
-
-/**
- * This module is automatically included as part of the Tapestry IoC Registry,
- * it's a good place to configure and extend Tapestry, or to place your own
- * service definitions.
- *
- * @version $Id: AppModule.java 2766 2009-08-27 16:29:23Z nrannou $
- */
-public class AppModule {
-
- public static void bind(ServiceBinder binder) {
- // binder.bind(MyServiceInterface.class, MyServiceImpl.class);
-
- // Make bind() calls on the binder object to define most IoC services.
- // 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(ServiceUser.class, ServiceUserImpl.class);
- binder.bind(ServiceSampling.class, ServiceSamplingImpl.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(SuiviObsmerModelDAOHelper.getContractClass(User.class),
-// SuiviObsmerModelDAOHelper.getImplementationClass(User.class));
- }
-
- public static void contributeApplicationDefaults(
- MappedConfiguration<String, String> configuration) {
- // Contributions to ApplicationDefaults will override any contributions to
- // FactoryDefaults (with the same key). Here we're restricting the supported
- // locales to just "en" (English). As you add localised message catalogs and other assets,
- // you can extend this list of locales (it's a comma separated series of locale names;
- // the first locale name is the default when there's no reasonable match).
-
- configuration.add(SymbolConstants.SUPPORTED_LOCALES, "fr,en");
-
- // The factory default is true but during the early stages of an application
- // overriding to false is a good idea. In addition, this is often overridden
- // on the command line as -Dtapestry.production-mode=false
- configuration.add(SymbolConstants.PRODUCTION_MODE, "false");
- }
-
- /**
- * This is a service definition, the service will be named "TimingFilter".
- * The interface, RequestFilter, is used within the RequestHandler service
- * pipeline, which is built from the RequestHandler service configuration.
- * Tapestry IoC is responsible for passing in an appropriate Logger
- * instance. Requests for static resources are handled at a higher level, so
- * this filter will only be invoked for Tapestry related requests.
- *
- * <p>
- * Service builder methods are useful when the implementation is inline as
- * an inner class (as here) or require some other kind of special
- * initialization. In most cases, use the static bind() method instead.
- *
- * <p>
- * If this method was named "build", then the service id would be taken from
- * 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.
- */
- /*public RequestFilter buildTimingFilter(final Logger log) {
- return new RequestFilter() {
- public boolean service(Request request, Response response,
- RequestHandler handler) throws IOException {
- long startTime = System.currentTimeMillis();
-
- try {
- // The responsibility of a filter is to invoke the corresponding method
- // in the handler. When you chain multiple filters together, each filter
- // received a handler that is a bridge to the next filter.
-
- return handler.service(request, response);
- } finally {
- long elapsed = System.currentTimeMillis() - startTime;
-
- log.info(String.format("Request time: %d ms", elapsed));
- }
- }
- };
- }*/
-
- /**
- * 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 buildSuiviObsmerShutdown(
- @InjectService("RegistryShutdownHub") RegistryShutdownHub hub) {
- RegistryShutdownListener listener = new SuiviObsmerManager();
- hub.addRegistryShutdownListener(listener);
- return listener;
- }
-
- public static void contributeRegistryStartup(OrderedConfiguration<Runnable> configuration) {
- configuration.add("SuiviObsmerStartup", new SuiviObsmerManager());
- }
-
- /**
- * 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>() {
- @Override
- public WaoUser create() {
- return new WaoUserImpl();
- }
- };
-
- configuration.add(WaoUser.class, new ApplicationStateContribution("session", creator));
- }
-
-}
Copied: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/services/AppModule.java (from rev 354, trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/services/AppModule.java)
===================================================================
--- trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/services/AppModule.java (rev 0)
+++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/services/AppModule.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -0,0 +1,155 @@
+/* *##%
+ * Wao :: Web Interface
+ * 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.ui.services;
+
+import fr.ifremer.wao.entity.WaoUser;
+import fr.ifremer.wao.entity.WaoUserImpl;
+import fr.ifremer.wao.service.*;
+
+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;
+
+/**
+ * This module is automatically included as part of the Tapestry IoC Registry,
+ * it's a good place to configure and extend Tapestry, or to place your own
+ * service definitions.
+ *
+ * @version $Id: AppModule.java 2766 2009-08-27 16:29:23Z nrannou $
+ */
+public class AppModule {
+
+ public static void bind(ServiceBinder binder) {
+ // binder.bind(MyServiceInterface.class, MyServiceImpl.class);
+
+ // Make bind() calls on the binder object to define most IoC services.
+ // 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(ServiceUser.class, ServiceUserImpl.class);
+ binder.bind(ServiceSampling.class, ServiceSamplingImpl.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));
+ }
+
+ public static void contributeApplicationDefaults(
+ MappedConfiguration<String, String> configuration) {
+ // Contributions to ApplicationDefaults will override any contributions to
+ // FactoryDefaults (with the same key). Here we're restricting the supported
+ // locales to just "en" (English). As you add localised message catalogs and other assets,
+ // you can extend this list of locales (it's a comma separated series of locale names;
+ // the first locale name is the default when there's no reasonable match).
+
+ configuration.add(SymbolConstants.SUPPORTED_LOCALES, "fr,en");
+
+ // The factory default is true but during the early stages of an application
+ // overriding to false is a good idea. In addition, this is often overridden
+ // on the command line as -Dtapestry.production-mode=false
+ configuration.add(SymbolConstants.PRODUCTION_MODE, "false");
+ }
+
+ /**
+ * This is a service definition, the service will be named "TimingFilter".
+ * The interface, RequestFilter, is used within the RequestHandler service
+ * pipeline, which is built from the RequestHandler service configuration.
+ * Tapestry IoC is responsible for passing in an appropriate Logger
+ * instance. Requests for static resources are handled at a higher level, so
+ * this filter will only be invoked for Tapestry related requests.
+ *
+ * <p>
+ * Service builder methods are useful when the implementation is inline as
+ * an inner class (as here) or require some other kind of special
+ * initialization. In most cases, use the static bind() method instead.
+ *
+ * <p>
+ * If this method was named "build", then the service id would be taken from
+ * 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.
+ */
+ /*public RequestFilter buildTimingFilter(final Logger log) {
+ return new RequestFilter() {
+ public boolean service(Request request, Response response,
+ RequestHandler handler) throws IOException {
+ long startTime = System.currentTimeMillis();
+
+ try {
+ // The responsibility of a filter is to invoke the corresponding method
+ // in the handler. When you chain multiple filters together, each filter
+ // received a handler that is a bridge to the next filter.
+
+ return handler.service(request, response);
+ } finally {
+ long elapsed = System.currentTimeMillis() - startTime;
+
+ log.info(String.format("Request time: %d ms", elapsed));
+ }
+ }
+ };
+ }*/
+
+ /**
+ * 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());
+ }
+
+ /**
+ * 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>() {
+ @Override
+ public WaoUser create() {
+ return new WaoUserImpl();
+ }
+ };
+
+ configuration.add(WaoUser.class, new ApplicationStateContribution("session", creator));
+ }
+
+}
Deleted: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/services/ContactModelFactory.java
===================================================================
--- trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/services/ContactModelFactory.java 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/services/ContactModelFactory.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,448 +0,0 @@
-/*
- * *##%
- * SuiviObsmer :: Web Interface
- * 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.suiviobsmer.ui.services;
-
-import fr.ifremer.suiviobsmer.entity.Contact;
-import fr.ifremer.suiviobsmer.entity.FishingZone;
-import fr.ifremer.suiviobsmer.entity.WaoUser;
-import java.lang.annotation.Annotation;
-import org.apache.tapestry5.ComponentResources;
-import org.apache.tapestry5.PropertyConduit;
-import org.apache.tapestry5.beaneditor.BeanModel;
-import org.apache.tapestry5.beaneditor.RelativePosition;
-import org.apache.tapestry5.services.BeanModelSource;
-import org.nuiton.topia.persistence.TopiaEntity;
-
-/**
- * ContactModelFactory
- *
- * Created: 18 nov. 2009
- *
- * @author fdesbois
- * @version $Revision$
- *
- * Mise a jour: $Date$
- * par : $Author$
- */
-public class ContactModelFactory {
-
- /**
- * @param beanModelSource used to construct BeanModel<Contact>
- * @param resources used to construct BeanModel<Contact>
- * @return BeanModel<Contact> with new params
- */
- public BeanModel<Contact> buildContactModel(BeanModelSource beanModelSource, ComponentResources resources) {
- BeanModel<Contact> contactModel = beanModelSource.createDisplayModel(Contact.class, resources.getMessages());
-
- // New properties for contactModel
- contactModel.add("createdBy", null);
-// contactModel.add(Contact.SAMPLE_ROW, getSampleRowPropertyConduit());
-// contactModel.add(Contact.BOAT, getBoatPropertyConduit());
- contactModel.add(Contact.SAMPLE_ROW, null);
- contactModel.add(Contact.BOAT, null);
- contactModel.add("mammals", null);
- contactModel.add("validation", null);
- contactModel.add("actions", null);
-
- contactModel.include(
- "createdBy",
- TopiaEntity.TOPIA_CREATE_DATE,
- Contact.SAMPLE_ROW,
- Contact.BOAT,
- Contact.STATE,
- Contact.TIDE_BEGIN_DATE,
- Contact.TIDE_END_DATE,
- Contact.NB_OBSERVANTS,
- "mammals",
- Contact.COMMENT,
- Contact.DATA_INPUT_DATE,
- "validation",
- "actions");
-
- contactModel.get(TopiaEntity.TOPIA_CREATE_DATE).sortable(false);
- contactModel.get(Contact.STATE).sortable(false);
- contactModel.get(Contact.TIDE_BEGIN_DATE).sortable(false);
- contactModel.get(Contact.TIDE_END_DATE).sortable(false);
- contactModel.get(Contact.NB_OBSERVANTS).sortable(false);
- contactModel.get(Contact.DATA_INPUT_DATE).sortable(false);
- contactModel.get(Contact.COMMENT).sortable(false);
-
- return contactModel;
- }
-
- public BeanModel<Contact> buildAdminContactModel(BeanModelSource beanModelSource, ComponentResources resources) {
- BeanModel<Contact> contactModel = buildContactModel(beanModelSource, resources);
- contactModel.exclude("createdBy");
- contactModel.add(RelativePosition.AFTER, TopiaEntity.TOPIA_CREATE_DATE, "observer", getUserPropertyConduit());
- contactModel.add(RelativePosition.AFTER, "observer", WaoUser.COMPANY, getCompanyPropertyConduit());
- contactModel.add(RelativePosition.AFTER, Contact.SAMPLE_ROW, "program", getProgramPropertyConduit());
- contactModel.add(RelativePosition.AFTER, "program", "professionCode", getProfessionCodePropertyConduit());
- contactModel.add(RelativePosition.AFTER, "professionCode", "professionLibelle", getProfessionLibellePropertyConduit());
- contactModel.add(RelativePosition.AFTER, "professionLibelle", "professionSpecies", getProfessionSpeciesPropertyConduit());
- contactModel.add(RelativePosition.AFTER, "professionSpecies", "fishingZoneFacade", getFishingZoneFacadePropertyConduit());
- contactModel.add(RelativePosition.AFTER, "fishingZoneFacade", "fishingZoneSector", getFishingZoneSectorPropertyConduit());
- contactModel.add(RelativePosition.AFTER, "fishingZoneSector", "fishingZoneDivision", getFishingZoneDivisionPropertyConduit());
- contactModel.add(RelativePosition.AFTER, Contact.BOAT, "boatImmatriculation", getBoatImmatriculationPropertyConduit());
- contactModel.add(RelativePosition.AFTER, "boatImmatriculation", "boatDistrictCode", getBoatDistrictCodePropertyConduit());
-
- contactModel.get("observer").sortable(false);
- contactModel.get(WaoUser.COMPANY).sortable(false);
- contactModel.get("program").sortable(false);
- contactModel.get("professionCode").sortable(false);
- contactModel.get("professionLibelle").sortable(false);
- contactModel.get("professionSpecies").sortable(false);
- contactModel.get("fishingZoneFacade").sortable(false);
- contactModel.get("fishingZoneSector").sortable(false);
- contactModel.get("fishingZoneDivision").sortable(false);
- contactModel.get("boatImmatriculation").sortable(false);
- contactModel.get("boatDistrictCode").sortable(false);
-
-// contactModel.add(RelativePosition.AFTER, TopiaEntity.TOPIA_CREATE_DATE, "observer", null);
-// contactModel.add(RelativePosition.AFTER, "observer", User.COMPANY, null);
-// contactModel.add(RelativePosition.AFTER, Contact.SAMPLE_ROW, "program", null);
-// contactModel.add(RelativePosition.AFTER, "program", "professionCode", null);
-// contactModel.add(RelativePosition.AFTER, "professionCode", "professionLibelle", null);
-// contactModel.add(RelativePosition.AFTER, "professionLibelle", "professionSpecies", null);
-// contactModel.add(RelativePosition.AFTER, "professionSpecies", "fishingZoneFacade", null);
-// contactModel.add(RelativePosition.AFTER, "fishingZoneFacade", "fishingZoneSector", null);
-// contactModel.add(RelativePosition.AFTER, "fishingZoneSector", "fishingZoneDivision", null);
-// contactModel.add(RelativePosition.AFTER, Contact.BOAT, "boatImmatriculation", null);
-// contactModel.add(RelativePosition.AFTER, "boatImmatriculation", "boatDistrictCode", null);
- return contactModel;
- }
-
- public PropertyConduit getUserPropertyConduit() {
- return new PropertyConduit() {
- @Override
- public Object get(Object arg0) {
- Contact contact = (Contact)arg0;
- return contact.getObserver().getFullName();
- }
-
- @Override
- public void set(Object arg0, Object arg1) {
- }
-
- @Override
- public Class getPropertyType() {
- return String.class;
- }
-
- @Override
- public <T extends Annotation> T getAnnotation(Class<T> arg0) {
- return null;
- }
- };
- }
-
- public PropertyConduit getCompanyPropertyConduit() {
- return new PropertyConduit() {
- @Override
- public Object get(Object arg0) {
- Contact contact = (Contact)arg0;
- return contact.getObserver().getCompany().getName();
- }
-
- @Override
- public void set(Object arg0, Object arg1) {
- }
-
- @Override
- public Class getPropertyType() {
- return String.class;
- }
-
- @Override
- public <T extends Annotation> T getAnnotation(Class<T> arg0) {
- return null;
- }
- };
- }
-
- public PropertyConduit getSampleRowPropertyConduit() {
- return new PropertyConduit() {
- @Override
- public Object get(Object arg0) {
- Contact contact = (Contact)arg0;
- return contact.getSampleRow().getCode();
- }
-
- @Override
- public void set(Object arg0, Object arg1) {
- }
-
- @Override
- public Class getPropertyType() {
- return String.class;
- }
-
- @Override
- public <T extends Annotation> T getAnnotation(Class<T> arg0) {
- return null;
- }
- };
- }
-
- public PropertyConduit getBoatPropertyConduit() {
- return new PropertyConduit() {
- @Override
- public Object get(Object arg0) {
- Contact contact = (Contact)arg0;
- return contact.getBoat().getName();
- }
-
- @Override
- public void set(Object arg0, Object arg1) {
- }
-
- @Override
- public Class getPropertyType() {
- return String.class;
- }
-
- @Override
- public <T extends Annotation> T getAnnotation(Class<T> arg0) {
- return null;
- }
- };
- }
-
- public PropertyConduit getProgramPropertyConduit() {
- return new PropertyConduit() {
- @Override
- public Object get(Object arg0) {
- Contact contact = (Contact)arg0;
- return contact.getSampleRow().getProgramName();
- }
-
- @Override
- public void set(Object arg0, Object arg1) {
- }
-
- @Override
- public Class getPropertyType() {
- return String.class;
- }
-
- @Override
- public <T extends Annotation> T getAnnotation(Class<T> arg0) {
- return null;
- }
- };
- }
-
- public PropertyConduit getProfessionCodePropertyConduit() {
- return new PropertyConduit() {
- @Override
- public Object get(Object arg0) {
- Contact contact = (Contact)arg0;
- return contact.getSampleRow().getProfession().getCode();
- }
-
- @Override
- public void set(Object arg0, Object arg1) {
- }
-
- @Override
- public Class getPropertyType() {
- return String.class;
- }
-
- @Override
- public <T extends Annotation> T getAnnotation(Class<T> arg0) {
- return null;
- }
- };
- }
-
- public PropertyConduit getProfessionLibellePropertyConduit() {
- return new PropertyConduit() {
- @Override
- public Object get(Object arg0) {
- Contact contact = (Contact)arg0;
- return contact.getSampleRow().getProfession().getLibelle();
- }
-
- @Override
- public void set(Object arg0, Object arg1) {
- }
-
- @Override
- public Class getPropertyType() {
- return String.class;
- }
-
- @Override
- public <T extends Annotation> T getAnnotation(Class<T> arg0) {
- return null;
- }
- };
- }
-
- public PropertyConduit getProfessionSpeciesPropertyConduit() {
- return new PropertyConduit() {
- @Override
- public Object get(Object arg0) {
- Contact contact = (Contact)arg0;
- return contact.getSampleRow().getProfession().getSpecies();
- }
-
- @Override
- public void set(Object arg0, Object arg1) {
- }
-
- @Override
- public Class getPropertyType() {
- return String.class;
- }
-
- @Override
- public <T extends Annotation> T getAnnotation(Class<T> arg0) {
- return null;
- }
- };
- }
-
- public PropertyConduit getFishingZoneFacadePropertyConduit() {
- return new PropertyConduit() {
- @Override
- public Object get(Object arg0) {
- Contact contact = (Contact)arg0;
- return contact.getSampleRow().getFacade();
- }
-
- @Override
- public void set(Object arg0, Object arg1) {
- }
-
- @Override
- public Class getPropertyType() {
- return String.class;
- }
-
- @Override
- public <T extends Annotation> T getAnnotation(Class<T> arg0) {
- return null;
- }
- };
- }
-
- public PropertyConduit getFishingZoneSectorPropertyConduit() {
- return new PropertyConduit() {
- @Override
- public Object get(Object arg0) {
- Contact contact = (Contact)arg0;
- return contact.getSampleRow().getSectors();
- }
-
- @Override
- public void set(Object arg0, Object arg1) {
- }
-
- @Override
- public Class getPropertyType() {
- return String.class;
- }
-
- @Override
- public <T extends Annotation> T getAnnotation(Class<T> arg0) {
- return null;
- }
- };
- }
-
- public PropertyConduit getFishingZoneDivisionPropertyConduit() {
- return new PropertyConduit() {
- @Override
- public Object get(Object arg0) {
- Contact contact = (Contact)arg0;
- String result = "";
- for (FishingZone zone : contact.getSampleRow().getFishingZone()) {
- result += zone.getDistrictCode() + " ";
- }
- return result;
- }
-
- @Override
- public void set(Object arg0, Object arg1) {
- }
-
- @Override
- public Class getPropertyType() {
- return String.class;
- }
-
- @Override
- public <T extends Annotation> T getAnnotation(Class<T> arg0) {
- return null;
- }
- };
- }
-
- public PropertyConduit getBoatImmatriculationPropertyConduit() {
- return new PropertyConduit() {
- @Override
- public Object get(Object arg0) {
- Contact contact = (Contact)arg0;
- return contact.getBoat().getImmatriculation();
- }
-
- @Override
- public void set(Object arg0, Object arg1) {
- }
-
- @Override
- public Class getPropertyType() {
- return String.class;
- }
-
- @Override
- public <T extends Annotation> T getAnnotation(Class<T> arg0) {
- return null;
- }
- };
- }
-
- public PropertyConduit getBoatDistrictCodePropertyConduit() {
- return new PropertyConduit() {
- @Override
- public Object get(Object arg0) {
- Contact contact = (Contact)arg0;
- return contact.getBoat().getDistrictCode();
- }
-
- @Override
- public void set(Object arg0, Object arg1) {
- }
-
- @Override
- public Class getPropertyType() {
- return String.class;
- }
-
- @Override
- public <T extends Annotation> T getAnnotation(Class<T> arg0) {
- return null;
- }
- };
- }
-}
Copied: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/services/ContactModelFactory.java (from rev 354, trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/services/ContactModelFactory.java)
===================================================================
--- trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/services/ContactModelFactory.java (rev 0)
+++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/services/ContactModelFactory.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -0,0 +1,448 @@
+/*
+ * *##%
+ * Wao :: Web Interface
+ * 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.ui.services;
+
+import fr.ifremer.wao.entity.Contact;
+import fr.ifremer.wao.entity.FishingZone;
+import fr.ifremer.wao.entity.WaoUser;
+import java.lang.annotation.Annotation;
+import org.apache.tapestry5.ComponentResources;
+import org.apache.tapestry5.PropertyConduit;
+import org.apache.tapestry5.beaneditor.BeanModel;
+import org.apache.tapestry5.beaneditor.RelativePosition;
+import org.apache.tapestry5.services.BeanModelSource;
+import org.nuiton.topia.persistence.TopiaEntity;
+
+/**
+ * ContactModelFactory
+ *
+ * Created: 18 nov. 2009
+ *
+ * @author fdesbois
+ * @version $Revision$
+ *
+ * Mise a jour: $Date$
+ * par : $Author$
+ */
+public class ContactModelFactory {
+
+ /**
+ * @param beanModelSource used to construct BeanModel<Contact>
+ * @param resources used to construct BeanModel<Contact>
+ * @return BeanModel<Contact> with new params
+ */
+ public BeanModel<Contact> buildContactModel(BeanModelSource beanModelSource, ComponentResources resources) {
+ BeanModel<Contact> contactModel = beanModelSource.createDisplayModel(Contact.class, resources.getMessages());
+
+ // New properties for contactModel
+ contactModel.add("createdBy", null);
+// contactModel.add(Contact.SAMPLE_ROW, getSampleRowPropertyConduit());
+// contactModel.add(Contact.BOAT, getBoatPropertyConduit());
+ contactModel.add(Contact.SAMPLE_ROW, null);
+ contactModel.add(Contact.BOAT, null);
+ contactModel.add("mammals", null);
+ contactModel.add("validation", null);
+ contactModel.add("actions", null);
+
+ contactModel.include(
+ "createdBy",
+ TopiaEntity.TOPIA_CREATE_DATE,
+ Contact.SAMPLE_ROW,
+ Contact.BOAT,
+ Contact.STATE,
+ Contact.TIDE_BEGIN_DATE,
+ Contact.TIDE_END_DATE,
+ Contact.NB_OBSERVANTS,
+ "mammals",
+ Contact.COMMENT,
+ Contact.DATA_INPUT_DATE,
+ "validation",
+ "actions");
+
+ contactModel.get(TopiaEntity.TOPIA_CREATE_DATE).sortable(false);
+ contactModel.get(Contact.STATE).sortable(false);
+ contactModel.get(Contact.TIDE_BEGIN_DATE).sortable(false);
+ contactModel.get(Contact.TIDE_END_DATE).sortable(false);
+ contactModel.get(Contact.NB_OBSERVANTS).sortable(false);
+ contactModel.get(Contact.DATA_INPUT_DATE).sortable(false);
+ contactModel.get(Contact.COMMENT).sortable(false);
+
+ return contactModel;
+ }
+
+ public BeanModel<Contact> buildAdminContactModel(BeanModelSource beanModelSource, ComponentResources resources) {
+ BeanModel<Contact> contactModel = buildContactModel(beanModelSource, resources);
+ contactModel.exclude("createdBy");
+ contactModel.add(RelativePosition.AFTER, TopiaEntity.TOPIA_CREATE_DATE, "observer", getUserPropertyConduit());
+ contactModel.add(RelativePosition.AFTER, "observer", WaoUser.COMPANY, getCompanyPropertyConduit());
+ contactModel.add(RelativePosition.AFTER, Contact.SAMPLE_ROW, "program", getProgramPropertyConduit());
+ contactModel.add(RelativePosition.AFTER, "program", "professionCode", getProfessionCodePropertyConduit());
+ contactModel.add(RelativePosition.AFTER, "professionCode", "professionLibelle", getProfessionLibellePropertyConduit());
+ contactModel.add(RelativePosition.AFTER, "professionLibelle", "professionSpecies", getProfessionSpeciesPropertyConduit());
+ contactModel.add(RelativePosition.AFTER, "professionSpecies", "fishingZoneFacade", getFishingZoneFacadePropertyConduit());
+ contactModel.add(RelativePosition.AFTER, "fishingZoneFacade", "fishingZoneSector", getFishingZoneSectorPropertyConduit());
+ contactModel.add(RelativePosition.AFTER, "fishingZoneSector", "fishingZoneDivision", getFishingZoneDivisionPropertyConduit());
+ contactModel.add(RelativePosition.AFTER, Contact.BOAT, "boatImmatriculation", getBoatImmatriculationPropertyConduit());
+ contactModel.add(RelativePosition.AFTER, "boatImmatriculation", "boatDistrictCode", getBoatDistrictCodePropertyConduit());
+
+ contactModel.get("observer").sortable(false);
+ contactModel.get(WaoUser.COMPANY).sortable(false);
+ contactModel.get("program").sortable(false);
+ contactModel.get("professionCode").sortable(false);
+ contactModel.get("professionLibelle").sortable(false);
+ contactModel.get("professionSpecies").sortable(false);
+ contactModel.get("fishingZoneFacade").sortable(false);
+ contactModel.get("fishingZoneSector").sortable(false);
+ contactModel.get("fishingZoneDivision").sortable(false);
+ contactModel.get("boatImmatriculation").sortable(false);
+ contactModel.get("boatDistrictCode").sortable(false);
+
+// contactModel.add(RelativePosition.AFTER, TopiaEntity.TOPIA_CREATE_DATE, "observer", null);
+// contactModel.add(RelativePosition.AFTER, "observer", User.COMPANY, null);
+// contactModel.add(RelativePosition.AFTER, Contact.SAMPLE_ROW, "program", null);
+// contactModel.add(RelativePosition.AFTER, "program", "professionCode", null);
+// contactModel.add(RelativePosition.AFTER, "professionCode", "professionLibelle", null);
+// contactModel.add(RelativePosition.AFTER, "professionLibelle", "professionSpecies", null);
+// contactModel.add(RelativePosition.AFTER, "professionSpecies", "fishingZoneFacade", null);
+// contactModel.add(RelativePosition.AFTER, "fishingZoneFacade", "fishingZoneSector", null);
+// contactModel.add(RelativePosition.AFTER, "fishingZoneSector", "fishingZoneDivision", null);
+// contactModel.add(RelativePosition.AFTER, Contact.BOAT, "boatImmatriculation", null);
+// contactModel.add(RelativePosition.AFTER, "boatImmatriculation", "boatDistrictCode", null);
+ return contactModel;
+ }
+
+ public PropertyConduit getUserPropertyConduit() {
+ return new PropertyConduit() {
+ @Override
+ public Object get(Object arg0) {
+ Contact contact = (Contact)arg0;
+ return contact.getObserver().getFullName();
+ }
+
+ @Override
+ public void set(Object arg0, Object arg1) {
+ }
+
+ @Override
+ public Class getPropertyType() {
+ return String.class;
+ }
+
+ @Override
+ public <T extends Annotation> T getAnnotation(Class<T> arg0) {
+ return null;
+ }
+ };
+ }
+
+ public PropertyConduit getCompanyPropertyConduit() {
+ return new PropertyConduit() {
+ @Override
+ public Object get(Object arg0) {
+ Contact contact = (Contact)arg0;
+ return contact.getObserver().getCompany().getName();
+ }
+
+ @Override
+ public void set(Object arg0, Object arg1) {
+ }
+
+ @Override
+ public Class getPropertyType() {
+ return String.class;
+ }
+
+ @Override
+ public <T extends Annotation> T getAnnotation(Class<T> arg0) {
+ return null;
+ }
+ };
+ }
+
+ public PropertyConduit getSampleRowPropertyConduit() {
+ return new PropertyConduit() {
+ @Override
+ public Object get(Object arg0) {
+ Contact contact = (Contact)arg0;
+ return contact.getSampleRow().getCode();
+ }
+
+ @Override
+ public void set(Object arg0, Object arg1) {
+ }
+
+ @Override
+ public Class getPropertyType() {
+ return String.class;
+ }
+
+ @Override
+ public <T extends Annotation> T getAnnotation(Class<T> arg0) {
+ return null;
+ }
+ };
+ }
+
+ public PropertyConduit getBoatPropertyConduit() {
+ return new PropertyConduit() {
+ @Override
+ public Object get(Object arg0) {
+ Contact contact = (Contact)arg0;
+ return contact.getBoat().getName();
+ }
+
+ @Override
+ public void set(Object arg0, Object arg1) {
+ }
+
+ @Override
+ public Class getPropertyType() {
+ return String.class;
+ }
+
+ @Override
+ public <T extends Annotation> T getAnnotation(Class<T> arg0) {
+ return null;
+ }
+ };
+ }
+
+ public PropertyConduit getProgramPropertyConduit() {
+ return new PropertyConduit() {
+ @Override
+ public Object get(Object arg0) {
+ Contact contact = (Contact)arg0;
+ return contact.getSampleRow().getProgramName();
+ }
+
+ @Override
+ public void set(Object arg0, Object arg1) {
+ }
+
+ @Override
+ public Class getPropertyType() {
+ return String.class;
+ }
+
+ @Override
+ public <T extends Annotation> T getAnnotation(Class<T> arg0) {
+ return null;
+ }
+ };
+ }
+
+ public PropertyConduit getProfessionCodePropertyConduit() {
+ return new PropertyConduit() {
+ @Override
+ public Object get(Object arg0) {
+ Contact contact = (Contact)arg0;
+ return contact.getSampleRow().getProfession().getCode();
+ }
+
+ @Override
+ public void set(Object arg0, Object arg1) {
+ }
+
+ @Override
+ public Class getPropertyType() {
+ return String.class;
+ }
+
+ @Override
+ public <T extends Annotation> T getAnnotation(Class<T> arg0) {
+ return null;
+ }
+ };
+ }
+
+ public PropertyConduit getProfessionLibellePropertyConduit() {
+ return new PropertyConduit() {
+ @Override
+ public Object get(Object arg0) {
+ Contact contact = (Contact)arg0;
+ return contact.getSampleRow().getProfession().getLibelle();
+ }
+
+ @Override
+ public void set(Object arg0, Object arg1) {
+ }
+
+ @Override
+ public Class getPropertyType() {
+ return String.class;
+ }
+
+ @Override
+ public <T extends Annotation> T getAnnotation(Class<T> arg0) {
+ return null;
+ }
+ };
+ }
+
+ public PropertyConduit getProfessionSpeciesPropertyConduit() {
+ return new PropertyConduit() {
+ @Override
+ public Object get(Object arg0) {
+ Contact contact = (Contact)arg0;
+ return contact.getSampleRow().getProfession().getSpecies();
+ }
+
+ @Override
+ public void set(Object arg0, Object arg1) {
+ }
+
+ @Override
+ public Class getPropertyType() {
+ return String.class;
+ }
+
+ @Override
+ public <T extends Annotation> T getAnnotation(Class<T> arg0) {
+ return null;
+ }
+ };
+ }
+
+ public PropertyConduit getFishingZoneFacadePropertyConduit() {
+ return new PropertyConduit() {
+ @Override
+ public Object get(Object arg0) {
+ Contact contact = (Contact)arg0;
+ return contact.getSampleRow().getFacade();
+ }
+
+ @Override
+ public void set(Object arg0, Object arg1) {
+ }
+
+ @Override
+ public Class getPropertyType() {
+ return String.class;
+ }
+
+ @Override
+ public <T extends Annotation> T getAnnotation(Class<T> arg0) {
+ return null;
+ }
+ };
+ }
+
+ public PropertyConduit getFishingZoneSectorPropertyConduit() {
+ return new PropertyConduit() {
+ @Override
+ public Object get(Object arg0) {
+ Contact contact = (Contact)arg0;
+ return contact.getSampleRow().getSectors();
+ }
+
+ @Override
+ public void set(Object arg0, Object arg1) {
+ }
+
+ @Override
+ public Class getPropertyType() {
+ return String.class;
+ }
+
+ @Override
+ public <T extends Annotation> T getAnnotation(Class<T> arg0) {
+ return null;
+ }
+ };
+ }
+
+ public PropertyConduit getFishingZoneDivisionPropertyConduit() {
+ return new PropertyConduit() {
+ @Override
+ public Object get(Object arg0) {
+ Contact contact = (Contact)arg0;
+ String result = "";
+ for (FishingZone zone : contact.getSampleRow().getFishingZone()) {
+ result += zone.getDistrictCode() + " ";
+ }
+ return result;
+ }
+
+ @Override
+ public void set(Object arg0, Object arg1) {
+ }
+
+ @Override
+ public Class getPropertyType() {
+ return String.class;
+ }
+
+ @Override
+ public <T extends Annotation> T getAnnotation(Class<T> arg0) {
+ return null;
+ }
+ };
+ }
+
+ public PropertyConduit getBoatImmatriculationPropertyConduit() {
+ return new PropertyConduit() {
+ @Override
+ public Object get(Object arg0) {
+ Contact contact = (Contact)arg0;
+ return contact.getBoat().getImmatriculation();
+ }
+
+ @Override
+ public void set(Object arg0, Object arg1) {
+ }
+
+ @Override
+ public Class getPropertyType() {
+ return String.class;
+ }
+
+ @Override
+ public <T extends Annotation> T getAnnotation(Class<T> arg0) {
+ return null;
+ }
+ };
+ }
+
+ public PropertyConduit getBoatDistrictCodePropertyConduit() {
+ return new PropertyConduit() {
+ @Override
+ public Object get(Object arg0) {
+ Contact contact = (Contact)arg0;
+ return contact.getBoat().getDistrictCode();
+ }
+
+ @Override
+ public void set(Object arg0, Object arg1) {
+ }
+
+ @Override
+ public Class getPropertyType() {
+ return String.class;
+ }
+
+ @Override
+ public <T extends Annotation> T getAnnotation(Class<T> arg0) {
+ return null;
+ }
+ };
+ }
+}
Deleted: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/services/SuiviObsmerManager.java
===================================================================
--- trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/services/SuiviObsmerManager.java 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/services/SuiviObsmerManager.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,79 +0,0 @@
-/*
- * *##%
- * SuiviObsmer :: Web Interface
- * 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.suiviobsmer.ui.services;
-
-import fr.ifremer.suiviobsmer.SuiviObsmerException;
-import fr.ifremer.suiviobsmer.SuiviObsmerRunner;
-import fr.ifremer.suiviobsmer.SuiviObsmerRunnerImpl;
-import org.apache.tapestry5.ioc.services.RegistryShutdownListener;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * SuiviObsmerManager
- *
- * Created: 24 nov. 2009
- *
- * @author fdesbois
- * @version $Revision$
- *
- * Mise a jour: $Date$
- * par : $Author$
- */
-public class SuiviObsmerManager implements Runnable, RegistryShutdownListener {
-
- private static final Logger log = LoggerFactory.getLogger(SuiviObsmerManager.class);
-
- private SuiviObsmerRunner runner;
-
- @Override
- public void run() {
- runner = new SuiviObsmerRunnerImpl();
- try {
- if (log.isInfoEnabled()) {
- log.info("Start SuiviObsmer");
- }
- runner.start();
- } catch (SuiviObsmerException eee) {
- if (log.isErrorEnabled()) {
- log.error("Error on start", eee);
- }
- }
- }
-
- @Override
- public void registryDidShutdown() {
- // No problem with reinstanciate the runner, all context is in SuiviObsmerContext which is static
- runner = new SuiviObsmerRunnerImpl();
- try {
- if (log.isInfoEnabled()) {
- log.info("Stop SuiviObsmer");
- }
- runner.stop();
- } catch (SuiviObsmerException eee) {
- if (log.isErrorEnabled()) {
- log.error("Error on stop", eee);
- }
- }
- }
-
-}
Copied: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/services/WaoManager.java (from rev 354, trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/services/WaoManager.java)
===================================================================
--- trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/services/WaoManager.java (rev 0)
+++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/services/WaoManager.java 2010-02-16 13:56:07 UTC (rev 355)
@@ -0,0 +1,79 @@
+/*
+ * *##%
+ * Wao :: Web Interface
+ * 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.ui.services;
+
+import fr.ifremer.wao.WaoException;
+import fr.ifremer.wao.WaoRunner;
+import fr.ifremer.wao.WaoRunnerImpl;
+import org.apache.tapestry5.ioc.services.RegistryShutdownListener;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * WaoManager
+ *
+ * Created: 24 nov. 2009
+ *
+ * @author fdesbois
+ * @version $Revision$
+ *
+ * Mise a jour: $Date$
+ * par : $Author$
+ */
+public class WaoManager implements Runnable, RegistryShutdownListener {
+
+ private static final Logger log = LoggerFactory.getLogger(WaoManager.class);
+
+ private WaoRunner runner;
+
+ @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);
+ }
+ }
+ }
+
+}
Deleted: trunk/wao-ui/src/main/resources/fr/ifremer/suiviobsmer/ui/components/Layout.tml
===================================================================
--- trunk/suiviobsmer-ui/src/main/resources/fr/ifremer/suiviobsmer/ui/components/Layout.tml 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-ui/src/main/resources/fr/ifremer/suiviobsmer/ui/components/Layout.tml 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,134 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd" xmlns:p="tapestry:parameter">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
- <title>WAO - Web Applicatif Obsmer : ${pageTitle}</title>
- <link rel="stylesheet" type="text/css" href="${asset:context:}/css/common.css" />
- <link rel="stylesheet" type="text/css" href="${asset:context:}/css/main.css" />
- <script type="text/javascript" src="${asset:context:}/js/wao.js"/>
- </head>
- <t:if t:test="currentUserExists">
- <body>
- <div id="so-session" class="clearfix">
- <div class="fleft">
- <a t:type="pagelink" t:page="index" title="Page d'accueil">
- <img src="${asset:context:}/img/logo-wao-48px.png" alt="WAO logo" title="Retourner sur la page d'accueil"/>
- </a>
- </div>
- <div class="fleft">
- <a href="mailto:obsmer at ifremer.fr" title="Contacter un responsable Obsmer">
- <img src="${asset:context:}/img/MiniLogo.jpg" alt="Obsmer logo"/>
- </a>
- </div>
- <div id="user-infos" class="fleft">
- Vous êtes <strong>${currentUser.fullName}</strong> de la société <strong>${currentUser.company.name}</strong>
- </div>
- <div id="user-actions" class="fright">
- <a t:type="pagelink" t:page="index" title="Page d'accueil">
- <img src="${asset:context:}/img/home.png" alt="Accueil" title="Page d'accueil" />
- </a>
- <a t:type="pagelink" t:page="userProfile" title="Gestion profil">
- <img src="${asset:context:}/img/user.png" alt="Preferences" title="Gestion profil"/>
- </a>
- <a t:type="actionlink" t:id="exit" title="Déconnexion">
- <img src="${asset:context:}/img/exit.png" alt="Exit" title="Déconnexion"/>
- </a>
- </div>
- </div>
- <ul class="clearfix" id="so-menu">
- <li class="link${adminClass} ${samplingSelected}" onclick="location.href='${contextPath}/samplingPlan'"
- title="Plan d'échantillonnage">
- Plan d'Echantillonnage
- </li>
- <li class="sep"> </li>
- <li class="link${adminClass} ${boatsSelected}" onclick="location.href='${contextPath}/boats'" title="Liste des navires">
- Navires
- </li>
- <li class="sep"> </li>
- <li class="link${adminClass} ${contactsSelected}" onclick="location.href='${contextPath}/contacts'" title="Liste des contacts">
- Contacts
- </li>
- <li class="sep"> </li>
- <li class="link${adminClass} ${synthesisSelected}" onclick="location.href='${contextPath}/synthesis'" title="Synthèses et indicateurs">
- Synthèse
- </li>
- <t:if t:test="currentUser.admin">
- <li class="sep"> </li>
- <li class="link${adminClass} ${adminSelected}" onclick="location.href='${contextPath}/administration'" title="Administration">
- Administration
- </li>
- </t:if>
- </ul>
-
- <div id="${contentId}">
- <t:feedback t:id="contentFeedback" />
- <t:if t:test="canShowPage()">
- <t:body />
- </t:if>
- </div>
- <div id="so-footer">
- <a href="http://suiviobsmer.labs.libre-entreprise.org/suiviobsmer/" title="Documentation de l'application" target="blank">
- WAO
- </a>
- <a href="http://suiviobsmer.labs.libre-entreprise.org/suiviobsmer/release-note.html" title="Modifications faites pour cette version" target="blank">
- ${version}
- </a> -
- <a href="mailto:obsmer at ifremer.fr" title="Contacter un responsable Obsmer" target="blank">
- Obsmer
- </a> -
- <a href="http://www.ifremer.fr/sih" title="Page d'accueil du SIH" target="blank">
- Ifremer SIH
- </a> -
- <a href="http://www.gnu.org/licenses/gpl.html" title="License GPL v3" target="blank">
- GPLv3
- </a> - Copyright 2009-2010
- <a href="http://www.ifremer.fr" title="Ifremer" target="blank">
- Ifremer</a>,
- <a href="http://www.codelutin.com" title="Code Lutin" target="blank">
- Code Lutin
- </a>
-<!-- -
- <a href="https://labs.libre-entreprise.org/tracker/?atid=692&group_id=154&func=browse" title="Bug Tracker">
- Bugs
- </a>-->
- </div>
- </body>
-
- <!-- Connexion -->
- <p:else>
- <body class="so-connexion">
- <div id="so-connexion-feedback">
- <t:feedback t:id="connexionFeedback" />
- <t:if t:test="hasConnexionErrors()">
- <form t:type="form" t:id="forgetPassword">
- <strong>Mot de passe oublié ?</strong>
- <t:label t:for="email" /> :
- <input t:type="textfield" t:id="email" value="email" />
- <input class="ico accept" t:type="submit" value="Go" title="Envoyez moi un nouveau mot de passe" />
- </form>
- </t:if>
- </div>
- <div class="clearfix" id="so-connexion-box">
- <form t:id="connexionForm" t:type="form">
- <div class="fleft clearfix" id="so-connexion-form">
- <p><t:label for="login" /> : </p>
- <p><input t:type="textfield" t:id="login" t:value="login" /></p>
- <p><t:label for="password" /> : </p>
- <p><input t:type="passwordfield" t:id="password" t:value="password" /></p>
- <div class="fright" id="so-connexion-form-buttons">
- <input class="ico accept" t:type="submit" value="Connexion" title="Connexion à l'application SuiviObsmer" />
- </div>
- </div>
- <div class="fright" id="so-connexion-logo">
- <img src="${asset:context:}/img/logo-wao-48px.png" alt="Logo Obsmer"/>
- </div>
- </form>
- </div>
-
- </body>
- <!--<div class="acenter">
- <img src="${asset:context:}/img/logo_WAO.png" alt="Logo WAO" title="WAO - Web Applicatif Obsmer"/>
- </div>-->
- </p:else>
- </t:if>
-</html>
Copied: trunk/wao-ui/src/main/resources/fr/ifremer/suiviobsmer/ui/components/Layout.tml (from rev 354, trunk/suiviobsmer-ui/src/main/resources/fr/ifremer/suiviobsmer/ui/components/Layout.tml)
===================================================================
--- trunk/wao-ui/src/main/resources/fr/ifremer/suiviobsmer/ui/components/Layout.tml (rev 0)
+++ trunk/wao-ui/src/main/resources/fr/ifremer/suiviobsmer/ui/components/Layout.tml 2010-02-16 13:56:07 UTC (rev 355)
@@ -0,0 +1,134 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd" xmlns:p="tapestry:parameter">
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
+ <title>WAO - Web Applicatif Obsmer : ${pageTitle}</title>
+ <link rel="stylesheet" type="text/css" href="${asset:context:}/css/common.css" />
+ <link rel="stylesheet" type="text/css" href="${asset:context:}/css/main.css" />
+ <script type="text/javascript" src="${asset:context:}/js/wao.js"/>
+ </head>
+ <t:if t:test="currentUserExists">
+ <body>
+ <div id="so-session" class="clearfix">
+ <div class="fleft">
+ <a t:type="pagelink" t:page="index" title="Page d'accueil">
+ <img src="${asset:context:}/img/logo-wao-48px.png" alt="WAO logo" title="Retourner sur la page d'accueil"/>
+ </a>
+ </div>
+ <div class="fleft">
+ <a href="mailto:obsmer at ifremer.fr" title="Contacter un responsable Obsmer">
+ <img src="${asset:context:}/img/MiniLogo.jpg" alt="Obsmer logo"/>
+ </a>
+ </div>
+ <div id="user-infos" class="fleft">
+ Vous êtes <strong>${currentUser.fullName}</strong> de la société <strong>${currentUser.company.name}</strong>
+ </div>
+ <div id="user-actions" class="fright">
+ <a t:type="pagelink" t:page="index" title="Page d'accueil">
+ <img src="${asset:context:}/img/home.png" alt="Accueil" title="Page d'accueil" />
+ </a>
+ <a t:type="pagelink" t:page="userProfile" title="Gestion profil">
+ <img src="${asset:context:}/img/user.png" alt="Preferences" title="Gestion profil"/>
+ </a>
+ <a t:type="actionlink" t:id="exit" title="Déconnexion">
+ <img src="${asset:context:}/img/exit.png" alt="Exit" title="Déconnexion"/>
+ </a>
+ </div>
+ </div>
+ <ul class="clearfix" id="so-menu">
+ <li class="link${adminClass} ${samplingSelected}" onclick="location.href='${contextPath}/samplingPlan'"
+ title="Plan d'échantillonnage">
+ Plan d'Echantillonnage
+ </li>
+ <li class="sep"> </li>
+ <li class="link${adminClass} ${boatsSelected}" onclick="location.href='${contextPath}/boats'" title="Liste des navires">
+ Navires
+ </li>
+ <li class="sep"> </li>
+ <li class="link${adminClass} ${contactsSelected}" onclick="location.href='${contextPath}/contacts'" title="Liste des contacts">
+ Contacts
+ </li>
+ <li class="sep"> </li>
+ <li class="link${adminClass} ${synthesisSelected}" onclick="location.href='${contextPath}/synthesis'" title="Synthèses et indicateurs">
+ Synthèse
+ </li>
+ <t:if t:test="currentUser.admin">
+ <li class="sep"> </li>
+ <li class="link${adminClass} ${adminSelected}" onclick="location.href='${contextPath}/administration'" title="Administration">
+ Administration
+ </li>
+ </t:if>
+ </ul>
+
+ <div id="${contentId}">
+ <t:feedback t:id="contentFeedback" />
+ <t:if t:test="canShowPage()">
+ <t:body />
+ </t:if>
+ </div>
+ <div id="so-footer">
+ <a href="http://suiviobsmer.labs.libre-entreprise.org/suiviobsmer/" title="Documentation de l'application" target="blank">
+ WAO
+ </a>
+ <a href="http://suiviobsmer.labs.libre-entreprise.org/suiviobsmer/release-note.html" title="Modifications faites pour cette version" target="blank">
+ ${version}
+ </a> -
+ <a href="mailto:obsmer at ifremer.fr" title="Contacter un responsable Obsmer" target="blank">
+ Obsmer
+ </a> -
+ <a href="http://www.ifremer.fr/sih" title="Page d'accueil du SIH" target="blank">
+ Ifremer SIH
+ </a> -
+ <a href="http://www.gnu.org/licenses/gpl.html" title="License GPL v3" target="blank">
+ GPLv3
+ </a> - Copyright 2009-2010
+ <a href="http://www.ifremer.fr" title="Ifremer" target="blank">
+ Ifremer</a>,
+ <a href="http://www.codelutin.com" title="Code Lutin" target="blank">
+ Code Lutin
+ </a>
+<!-- -
+ <a href="https://labs.libre-entreprise.org/tracker/?atid=692&group_id=154&func=browse" title="Bug Tracker">
+ Bugs
+ </a>-->
+ </div>
+ </body>
+
+ <!-- Connexion -->
+ <p:else>
+ <body class="so-connexion">
+ <div id="so-connexion-feedback">
+ <t:feedback t:id="connexionFeedback" />
+ <t:if t:test="hasConnexionErrors()">
+ <form t:type="form" t:id="forgetPassword">
+ <strong>Mot de passe oublié ?</strong>
+ <t:label t:for="email" /> :
+ <input t:type="textfield" t:id="email" value="email" />
+ <input class="ico accept" t:type="submit" value="Go" title="Envoyez moi un nouveau mot de passe" />
+ </form>
+ </t:if>
+ </div>
+ <div class="clearfix" id="so-connexion-box">
+ <form t:id="connexionForm" t:type="form">
+ <div class="fleft clearfix" id="so-connexion-form">
+ <p><t:label for="login" /> : </p>
+ <p><input t:type="textfield" t:id="login" t:value="login" /></p>
+ <p><t:label for="password" /> : </p>
+ <p><input t:type="passwordfield" t:id="password" t:value="password" /></p>
+ <div class="fright" id="so-connexion-form-buttons">
+ <input class="ico accept" t:type="submit" value="Connexion" title="Connexion à l'application Wao" />
+ </div>
+ </div>
+ <div class="fright" id="so-connexion-logo">
+ <img src="${asset:context:}/img/logo-wao-48px.png" alt="Logo Obsmer"/>
+ </div>
+ </form>
+ </div>
+
+ </body>
+ <!--<div class="acenter">
+ <img src="${asset:context:}/img/logo_WAO.png" alt="Logo WAO" title="WAO - Web Applicatif Obsmer"/>
+ </div>-->
+ </p:else>
+ </t:if>
+</html>
Deleted: trunk/wao-ui/src/main/resources/fr/ifremer/suiviobsmer/ui/pages/Synthesis.properties
===================================================================
--- trunk/suiviobsmer-ui/src/main/resources/fr/ifremer/suiviobsmer/ui/pages/Synthesis.properties 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-ui/src/main/resources/fr/ifremer/suiviobsmer/ui/pages/Synthesis.properties 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,18 +0,0 @@
-periodBegin-label: D\u00E9but
-periodEnd-label: Fin
-boatName-label: Nom
-boatImmatriculation-label: N\u00B0
-boatDistrictCode-label: Quartier
-facadeName-label: Fa\u00E7ade
-sectorName-label: Zone
-sampleRow-label: Code ligne
-company-label: Soci\u00E9t\u00E9
-programName-label: Programme
-
-companyForBoarding-label: Soci\u00E9t\u00E9
-
-periodBeginForContactStates-label: du
-periodEndForContactStates-label: au
-
-periodBeginForAllegroReactivity-label: du
-periodEndForAllegroReactivity-label: au
\ No newline at end of file
Copied: trunk/wao-ui/src/main/resources/fr/ifremer/suiviobsmer/ui/pages/Synthesis.properties (from rev 352, trunk/suiviobsmer-ui/src/main/resources/fr/ifremer/suiviobsmer/ui/pages/Synthesis.properties)
===================================================================
--- trunk/wao-ui/src/main/resources/fr/ifremer/suiviobsmer/ui/pages/Synthesis.properties (rev 0)
+++ trunk/wao-ui/src/main/resources/fr/ifremer/suiviobsmer/ui/pages/Synthesis.properties 2010-02-16 13:56:07 UTC (rev 355)
@@ -0,0 +1,26 @@
+periodBegin-label: D\u00E9but
+periodEnd-label: Fin
+boatName-label: Nom
+boatImmatriculation-label: N\u00B0
+boatDistrictCode-label: Quartier
+facadeName-label: Fa\u00E7ade
+sectorName-label: Zone
+sampleRow-label: Code ligne
+company-label: Soci\u00E9t\u00E9
+programName-label: Programme
+
+companyForBoarding-label: Soci\u00E9t\u00E9
+
+periodBeginForContactStates-label: du
+periodEndForContactStates-label: au
+
+periodBeginForAllegroReactivity-label: du
+periodEndForAllegroReactivity-label: au
+
+# Validation messages
+filtersForm-periodBegin-required-message: La date de d\u00E9but est obligatoire
+filtersForm-periodEnd-required-message: La date de fin est obligatoire
+filterPeriodForContactStates-periodBeginForContactStates-required-message: La date de d\u00E9but est obligatoire
+filterPeriodForContactStates-periodEndForContactStates-required-message: La date de fin est obligatoire
+#filterPeriodForAllegroReactivity-periodBeginForAllegroReactivity-required-message: La date de d\u00E9but est obligatoire
+#filterPeriodForAllegroReactivity-periodEndForAllegroReactivity-required-message: La date de fin est obligatoire
\ No newline at end of file
Deleted: trunk/wao-ui/src/main/resources/log4j.properties
===================================================================
--- trunk/suiviobsmer-ui/src/main/resources/log4j.properties 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-ui/src/main/resources/log4j.properties 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,25 +0,0 @@
-# Default to info level output; this is very handy if you eventually use Hibernate as well.
-log4j.rootCategory=WARN, console, globalfile
-
-log4j.appender.console=org.apache.log4j.ConsoleAppender
-log4j.appender.console.layout=org.apache.log4j.PatternLayout
-#log4j.appender.console.layout.ConversionPattern=%d [%p] %c{2} %m%n
-log4j.appender.console.layout.ConversionPattern=%d{HH:mm:ss} %5p (%F:%L) %m%n
-log4j.appender.console.Threshold=INFO
-
-log4j.appender.globalfile=org.apache.log4j.RollingFileAppender
-log4j.appender.globalfile.File=/var/log/wao/wao.log
-log4j.appender.globalfile.MaxFileSize=500KB
-log4j.appender.globalfile.Append=true
-log4j.appender.globalfile.MaxBackupIndex=10
-log4j.appender.globalfile.Threshold=TRACE
-log4j.appender.globalfile.layout=org.apache.log4j.PatternLayout
-log4j.appender.globalfile.layout.ConversionPattern=%d{yyyy/MM/dd hh:mm:ss} %5p (%F:%L) %m%n
-
-# For Tapestry
-log4j.logger.org.apache.tapestry5.services.TapestryModule.ComponentClassResolver=INFO
-log4j.logger.org.apache.tapestry5.TapestryFilter=INFO
-
-log4j.logger.fr.ifremer.suiviobsmer=DEBUG
-log4j.logger.org.nuiton.util=DEBUG
-log4j.logger.org.nuiton.topia=INFO
Copied: trunk/wao-ui/src/main/resources/log4j.properties (from rev 354, trunk/suiviobsmer-ui/src/main/resources/log4j.properties)
===================================================================
--- trunk/wao-ui/src/main/resources/log4j.properties (rev 0)
+++ trunk/wao-ui/src/main/resources/log4j.properties 2010-02-16 13:56:07 UTC (rev 355)
@@ -0,0 +1,25 @@
+# Default to info level output; this is very handy if you eventually use Hibernate as well.
+log4j.rootCategory=WARN, console, globalfile
+
+log4j.appender.console=org.apache.log4j.ConsoleAppender
+log4j.appender.console.layout=org.apache.log4j.PatternLayout
+#log4j.appender.console.layout.ConversionPattern=%d [%p] %c{2} %m%n
+log4j.appender.console.layout.ConversionPattern=%d{HH:mm:ss} %5p (%F:%L) %m%n
+log4j.appender.console.Threshold=INFO
+
+log4j.appender.globalfile=org.apache.log4j.RollingFileAppender
+log4j.appender.globalfile.File=/var/log/wao/wao.log
+log4j.appender.globalfile.MaxFileSize=500KB
+log4j.appender.globalfile.Append=true
+log4j.appender.globalfile.MaxBackupIndex=10
+log4j.appender.globalfile.Threshold=TRACE
+log4j.appender.globalfile.layout=org.apache.log4j.PatternLayout
+log4j.appender.globalfile.layout.ConversionPattern=%d{yyyy/MM/dd hh:mm:ss} %5p (%F:%L) %m%n
+
+# For Tapestry
+log4j.logger.org.apache.tapestry5.services.TapestryModule.ComponentClassResolver=INFO
+log4j.logger.org.apache.tapestry5.TapestryFilter=INFO
+
+log4j.logger.fr.ifremer.wao=DEBUG
+log4j.logger.org.nuiton.util=INFO
+log4j.logger.org.nuiton.topia=INFO
Deleted: trunk/wao-ui/src/main/webapp/Synthesis.tml
===================================================================
--- trunk/suiviobsmer-ui/src/main/webapp/Synthesis.tml 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-ui/src/main/webapp/Synthesis.tml 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,282 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<t:layout t:pageTitle="Synthèse et indicateurs" t:contentId="so-synthesis"
- xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd" xmlns:p="tapestry:parameter">
-
- <!-- MENU : delegator -->
- <div class="clearfix">
- <div class="fleft" id="so-synthesis-menu">
- <ul>
- <li>
- <a t:type="actionlink" t:context="[actionSynthesisId,'GRAPH_SAMPLING']" t:zone="so-synthesis-main">
- <img src="${asset:context:}/img/synthesis-graph-sampling.png" alt="Diagramme en bâtons"
- title="Graphique des données des marées (réalisé / planifié)" />
- </a>
- </li>
- <li>
- <a t:type="actionlink" t:context="[actionSynthesisId,'GRAPH_BOARDING']" t:zone="so-synthesis-main">
- <img src="${asset:context:}/img/synthesis-graph-boarding.png" alt="Diagramme en bâtons"
- title="Graphique des sollicitations des navires" />
- </a>
- </li>
- <li>
- <a t:type="actionlink" t:context="[actionSynthesisId,'IND_NON_COMPLIANCE_BOARDING']" t:zone="so-synthesis-main">
- <img src="${asset:context:}/img/synthesis-ind-non-compliance-boarding.png" alt="Indicateur"
- title="Indicateur de non respect du nombre d'observateurs embarqués" />
- </a>
- </li>
- <li>
- <a t:type="actionlink" t:context="[actionSynthesisId,'IND_CONTACT_STATE']" t:zone="so-synthesis-main">
- <img src="${asset:context:}/img/synthesis-ind-contact-states.png" alt="Indicateur"
- title="Indicateur sur les états des contacts" />
- </a>
- </li>
- <li>
- <a t:type="actionlink" t:context="[actionSynthesisId,'IND_ALLEGRO_REACTIVITY']" t:zone="so-synthesis-main">
- <img src="${asset:context:}/img/synthesis-ind-allegro-reactivity.png" alt="Indicateur"
- title="Indicateur de réactivité sur la saisie des données dans Allegro" />
- </a>
- </li>
- </ul>
- </div>
- <div t:type="zone" t:id="delegator" class="fleft" t:update="show" id="so-synthesis-main">
- <t:delegate t:to="activeBlock" />
- </div>
- </div>
-
- <!-- GRAPH1 : DATA_SAMPLING -->
- <t:block t:id="graph1">
- <div class="acenter" id="so-datasampling">
- <h2>Données des marées (réalisé / planifié)</h2>
- <fieldset>
- <legend>Filtres</legend>
- <div t:type="zone" t:id="filtersZone" class="so-filters-form" id="so-datasampling-filters">
- <!--<div t:type="zone" t:id="dataSamplingFiltersZone" t:update="show" id="so-datasampling-filters">-->
- <form t:type="form" t:id="filtersForm" t:zone="so-datasampling-filters">
- <t:errors />
- <div class="t-beaneditor">
- <div class="filterRow">
- <label>Période: </label>
- <t:label t:for="periodBegin" />:
- <input t:type="datefield" class="width70" t:id="periodBegin" t:value="period.fromDate" t:format="MM/yyyy"/>
- <t:label t:for="periodEnd" />:
- <input t:type="datefield" class="width70" t:id="periodEnd" t:value="period.thruDate" t:format="MM/yyyy" />
- </div>
- <div>
- <t:if t:test="user.admin">
- <t:label t:for="company" />:
- <input t:type="select" t:id="company" t:model="companySelectModel" value="companyId"/>
- <input t:type="submit" class="ico22px refresh" t:id="refreshByCompany" value="Refresh"
- title="Rafraîchir les filtres en fonction de la société sélectionnée"/>
- </t:if>
- <t:label t:for="programName" />:
- <select t:type="select" t:id="programName" t:model="programSelectModel" value="filter.programName" />
- <input t:type="submit" class="ico22px refresh" t:id="refreshByProgram" value="Refresh"
- title="Rafraîchir les secteurs de pêche et les métiers en fonction du programme sélectionné"/>
- </div>
- <div class="filterRow" t:type="zone" t:id="sampleRowZone" t:update="show">
- <t:label t:for="facadeName" />:
- <select t:type="select" t:id="facadeName" t:model="facadeSelectModel" value="filter.facadeName" />
- <input t:type="submit" class="ico22px refresh" t:id="refreshByFacade" value="Refresh"
- title="Rafraîchir les zones et les métiers en fonction de la façade sélectionnée"/>
- <t:label t:for="sectorName" />:
- <select t:type="select" t:id="sectorName" t:model="sectorSelectModel" value="filter.sectorName" />
- <input t:type="submit" class="ico22px refresh" t:id="refreshBySector" value="Refresh"
- title="Rafraîchir les métiers en fonction de la zone sélectionnée"/>
- <t:label t:for="sampleRow" />:
- <input t:type="select" t:id="sampleRow" t:model="sampleRowSelectModel" value="sampleRowId" />
- <!--<t:label t:for="program" />:
- <input t:type="select" t:id="program" t:model="programSelectModel" value="programId" />-->
- </div>
- <div class="t-beaneditor-row aright">
- <input t:type="submit" class="ico search-32px" t:id="search" value="Search" title="Création du graphique en fonction des filtres saisies"/>
- <input t:type="submit" class="ico undo" t:id="reset" value="Reset" title="Remettre les filtres par défaut" />
- </div>
- </div>
- </form>
- <!--</div>-->
- </div>
- </fieldset>
- <p class="so-chart-types">
- <a t:type="actionlink" t:context="[actionChartType,'BAR']">
- <img src="${asset:context:}/img/chart-bar.png" alt="Diagramme en bâtons" title="Diagramme en bâtons" />
- </a>
- <a t:type="actionlink" t:context="[actionChartType,'AREA']">
- <img src="${asset:context:}/img/chart-area.png" alt="Diagramme avec zones" title="Diagramme avec zones" />
- </a>
- <a t:type="actionlink" t:context="[actionChartType,'LINE']">
- <img src="${asset:context:}/img/chart-line.png" alt="Diagramme linéaire (courbe)" title="Diagramme linéaire (courbe)" />
- </a>
- </p>
- <!--<t:zone t:id="dataSamplingZone" id="so-datasampling-chart" t:update="show">-->
- <t:chart t:width="600" t:height="400" t:chart="dataSamplingChart" />
- <!--</t:zone>-->
- </div>
- </t:block>
- <!-- GRAPH2 : BOARDING_BOAT -->
- <t:block t:id="graph2">
- <div class="acenter">
- <h2>Sollicitations des navires</h2>
- <br />
- <p>Ces résultats ne concernent que les lignes du plan d'échantillonnage<br /> ayant une durée moyenne de marées inférieure ou égale à 48h</p>
- <br />
- <t:if t:test="user.admin">
- <form t:type="form" t:id="filterCompanyForBoarding">
- <t:label t:for="companyForBoarding" />:
- <input t:type="select" t:id="companyForBoarding" t:model="companySelectModel" value="companyIdForBoarding"/>
- <input t:type="submit" class="ico search-32px" t:id="searchForBoarding" value="Search"
- title="Création du graphique pour cette société"/>
- </form>
- </t:if>
- <t:chart t:width="600" t:height="400" t:chart="boardingBoatsChart" />
- <t:if t:test="boardingResult.maxBoardingBoat">
- <p>
- Navire le plus sollicité avec ${boardingResult.maxBoardingValue} embarquements :
- <strong>${boardingResult.maxBoardingBoat.name} (${boardingResult.maxBoardingBoat.immatriculation})</strong>
- </p>
- </t:if>
- </div>
- </t:block>
- <!-- IND1 : NON_COMPLIANCE_BOARDING -->
- <t:block t:id="ind1">
- <div class="ind-table acenter" id="so-noncomplianceboarding">
- <h2>Non respect du nombre d'observateurs embarqués</h2>
- <br />
- <t:if t:test="user.admin">
- <p>
- Ces résultats concernent l'ensemble des contrats en cours
- ayant des données réelles.
- </p>
- <table class="t-data-grid">
- <thead>
- <tr>
- <th class="company">Société</th>
- <th>Indicateur</th>
- </tr>
- </thead>
- <tbody>
- <tr t:type="loop" t:source="nonComplianceBoarding.entrySet()" t:value="nonComplianceBoardingEntry">
- <td class="company">${nonComplianceBoardingEntry.key}</td>
- <td class="number">
- <t:output t:value="nonComplianceBoardingEntry.value" t:format="percentFormat"/>
- </td>
- </tr>
- </tbody>
- </table>
- <p:else>
- <p>
- Ce résultat concerne l'ensemble des contrats en cours
- pour votre société ayant des données réelles.
- </p>
- <div class="indicator">
- <p class="number">
- <span t:type="output" t:value="nonComplianceBoardingValue" t:format="percentFormat">
- ${nonComplianceBoardingValue}
- </span>
- </p>
- </div>
- </p:else>
- </t:if>
- </div>
- </t:block>
- <!-- IND2 : CONTACT_STATE -->
- <t:block t:id="ind2">
- <div class="ind-table acenter" id="so-contactstate">
- <h2>Etats des contacts</h2>
- <br />
- <p>
- Ces résultats concernent l'ensemble des états des contacts<br /> excepté
- ceux qui ont été refusés par le programme.
- </p>
- <br />
- <p>
- <form t:type="form" t:id="filterPeriodForContactStates">
- <label>Période : </label>
- <t:label t:for="periodBeginForContactStates" />
- <input t:type="datefield" class="width70" t:id="periodBeginForContactStates" t:value="periodForContactStates.fromDate" t:format="MM/yyyy"/>
- <t:label t:for="periodEndForContactStates" />
- <input t:type="datefield" class="width70" t:id="periodEndForContactStates" t:value="periodForContactStates.thruDate" t:format="MM/yyyy" />
- <input t:type="submit" class="ico search-32px" t:id="searchForContactStates" value="Search"
- title="Rechercher les états des contacts sur cette période"/>
- </form>
- </p>
- <table class="t-data-grid">
- <thead>
- <tr>
- <t:if t:test="user.admin">
- <th class="company">Société</th>
- </t:if>
- <th t:type="loop" t:source="contactStates" t:value="contactState">
- ${contactState}
- </th>
- <th>Total</th>
- </tr>
- </thead>
- <tbody>
- <tr t:type="loop" t:source="contactStateStatistics" t:value="contactStateStats">
- <t:if t:test="user.admin">
- <td class="company">${contactStateStats.companyName}</td>
- </t:if>
- <td t:type="loop" t:source="contactStates" t:value="contactState"
- class="number-contactstate">
- <t:if t:test="nbContactStates">
- ${nbContactStates}
- (<span t:type="output" t:value="percentContactStates" t:format="percentFormat">${percentContactStates}</span>)
- <p:else>
- -
- </p:else>
- </t:if>
- </td>
- <td>${contactStateStats.total}</td>
- </tr>
- </tbody>
- </table>
- </div>
- </t:block>
- <!-- IND3 : ALLEGRO_REACTIVITY -->
- <t:block t:id="ind3">
- <div class="ind-table acenter" id="so-allegroreactivity">
- <h2>Réactivité de la saisie dans Allegro par rapport à la date de fin de la marée</h2>
- <br />
- <p>
- Ce résultat est une moyenne du nombre de jours entre la date de saisie dans Allegro et la date de fin de la marée des contacts.
- </p>
- <br />
- <p>
- <form t:type="form" t:id="filterPeriodForAllegroReactivity">
- <label>Période : </label>
- <t:label t:for="periodBeginForAllegroReactivity" />
- <input t:type="datefield" class="width70" t:id="periodBeginForAllegroReactivity" t:value="periodForAllegroReactivity.fromDate" t:format="MM/yyyy"/>
- <t:label t:for="periodEndForAllegroReactivity" />
- <input t:type="datefield" class="width70" t:id="periodEndForAllegroReactivity" t:value="periodForAllegroReactivity.thruDate" t:format="MM/yyyy" />
- <input t:type="submit" class="ico search-32px" t:id="searchForAllegroReactivity" value="Search"
- title="Calcul de la moyenne du nombre de jours entre la date de saisie dans Allegro et la date de fin de marée sur la période sélectionnée"/>
- </form>
- </p>
- <t:if t:test="user.admin">
- <table class="t-data-grid">
- <thead>
- <tr>
- <th class="company">Société</th>
- <th>Indicateur</th>
- </tr>
- </thead>
- <tbody>
- <tr t:type="loop" t:source="allegroReactivity.entrySet()" t:value="allegroReactivityEntry">
- <td class="company">${allegroReactivityEntry.key}</td>
- <td class="number${allegroReactivityStyle}">
- <t:output t:value="allegroReactivityEntry.value" t:format="numberFormat" />
- </td>
- </tr>
- </tbody>
- </table>
- <p:else>
- <div class="indicator">
- <p class="number${allegroReactivityStyle}">
- <t:output t:value="allegroReactivityValue" t:format="numberFormat" />
- </p>
- </div>
- </p:else>
- </t:if>
- </div>
- </t:block>
-</t:layout>
Copied: trunk/wao-ui/src/main/webapp/Synthesis.tml (from rev 352, trunk/suiviobsmer-ui/src/main/webapp/Synthesis.tml)
===================================================================
--- trunk/wao-ui/src/main/webapp/Synthesis.tml (rev 0)
+++ trunk/wao-ui/src/main/webapp/Synthesis.tml 2010-02-16 13:56:07 UTC (rev 355)
@@ -0,0 +1,282 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<t:layout t:pageTitle="Synthèse et indicateurs" t:contentId="so-synthesis"
+ xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd" xmlns:p="tapestry:parameter">
+
+ <!-- MENU : delegator -->
+ <div class="clearfix">
+ <div class="fleft" id="so-synthesis-menu">
+ <ul>
+ <li>
+ <a t:type="actionlink" t:context="[actionSynthesisId,'GRAPH_SAMPLING']" t:zone="so-synthesis-main">
+ <img src="${asset:context:}/img/synthesis-graph-sampling.png" alt="Diagramme en bâtons"
+ title="Graphique des données des marées (réalisé / planifié)" />
+ </a>
+ </li>
+ <li>
+ <a t:type="actionlink" t:context="[actionSynthesisId,'GRAPH_BOARDING']" t:zone="so-synthesis-main">
+ <img src="${asset:context:}/img/synthesis-graph-boarding.png" alt="Diagramme en bâtons"
+ title="Graphique des sollicitations des navires" />
+ </a>
+ </li>
+ <li>
+ <a t:type="actionlink" t:context="[actionSynthesisId,'IND_NON_COMPLIANCE_BOARDING']" t:zone="so-synthesis-main">
+ <img src="${asset:context:}/img/synthesis-ind-non-compliance-boarding.png" alt="Indicateur"
+ title="Indicateur de non respect du nombre d'observateurs embarqués" />
+ </a>
+ </li>
+ <li>
+ <a t:type="actionlink" t:context="[actionSynthesisId,'IND_CONTACT_STATE']" t:zone="so-synthesis-main">
+ <img src="${asset:context:}/img/synthesis-ind-contact-states.png" alt="Indicateur"
+ title="Indicateur sur les états des contacts" />
+ </a>
+ </li>
+ <li>
+ <a t:type="actionlink" t:context="[actionSynthesisId,'IND_ALLEGRO_REACTIVITY']" t:zone="so-synthesis-main">
+ <img src="${asset:context:}/img/synthesis-ind-allegro-reactivity.png" alt="Indicateur"
+ title="Indicateur de réactivité sur la saisie des données dans Allegro" />
+ </a>
+ </li>
+ </ul>
+ </div>
+ <div t:type="zone" t:id="delegator" class="fleft" t:update="show" id="so-synthesis-main">
+ <t:delegate t:to="activeBlock" />
+ </div>
+ </div>
+
+ <!-- GRAPH1 : DATA_SAMPLING -->
+ <t:block t:id="graph1">
+ <div class="acenter" id="so-datasampling">
+ <h2>Données des marées (réalisé / planifié)</h2>
+ <fieldset>
+ <legend>Filtres</legend>
+ <div t:type="zone" t:id="filtersZone" class="so-filters-form" id="so-datasampling-filters">
+ <!--<div t:type="zone" t:id="dataSamplingFiltersZone" t:update="show" id="so-datasampling-filters">-->
+ <form t:type="form" t:id="filtersForm" t:zone="so-datasampling-filters">
+ <t:errors />
+ <div class="t-beaneditor">
+ <div class="filterRow">
+ <label>Période: </label>
+ <t:label t:for="periodBegin" />:
+ <input t:type="datefield" class="width70" t:id="periodBegin" t:value="period.fromDate" t:format="MM/yyyy" t:validate="required"/>
+ <t:label t:for="periodEnd" />:
+ <input t:type="datefield" class="width70" t:id="periodEnd" t:value="period.thruDate" t:format="MM/yyyy" t:validate="required"/>
+ </div>
+ <div>
+ <t:if t:test="user.admin">
+ <t:label t:for="company" />:
+ <input t:type="select" t:id="company" t:model="companySelectModel" value="companyId"/>
+ <input t:type="submit" class="ico22px refresh" t:id="refreshByCompany" value="Refresh"
+ title="Rafraîchir les filtres en fonction de la société sélectionnée"/>
+ </t:if>
+ <t:label t:for="programName" />:
+ <select t:type="select" t:id="programName" t:model="programSelectModel" value="filter.programName" />
+ <input t:type="submit" class="ico22px refresh" t:id="refreshByProgram" value="Refresh"
+ title="Rafraîchir les secteurs de pêche et les métiers en fonction du programme sélectionné"/>
+ </div>
+ <div class="filterRow" t:type="zone" t:id="sampleRowZone" t:update="show">
+ <t:label t:for="facadeName" />:
+ <select t:type="select" t:id="facadeName" t:model="facadeSelectModel" value="filter.facadeName" />
+ <input t:type="submit" class="ico22px refresh" t:id="refreshByFacade" value="Refresh"
+ title="Rafraîchir les zones et les métiers en fonction de la façade sélectionnée"/>
+ <t:label t:for="sectorName" />:
+ <select t:type="select" t:id="sectorName" t:model="sectorSelectModel" value="filter.sectorName" />
+ <input t:type="submit" class="ico22px refresh" t:id="refreshBySector" value="Refresh"
+ title="Rafraîchir les métiers en fonction de la zone sélectionnée"/>
+ <t:label t:for="sampleRow" />:
+ <input t:type="select" t:id="sampleRow" t:model="sampleRowSelectModel" value="sampleRowId" />
+ <!--<t:label t:for="program" />:
+ <input t:type="select" t:id="program" t:model="programSelectModel" value="programId" />-->
+ </div>
+ <div class="t-beaneditor-row aright">
+ <input t:type="submit" class="ico search-32px" t:id="search" value="Search" title="Création du graphique en fonction des filtres saisies"/>
+ <input t:type="submit" class="ico undo" t:id="reset" value="Reset" title="Remettre les filtres par défaut" />
+ </div>
+ </div>
+ </form>
+ <!--</div>-->
+ </div>
+ </fieldset>
+ <p class="so-chart-types">
+ <a t:type="actionlink" t:context="[actionChartType,'BAR']">
+ <img src="${asset:context:}/img/chart-bar.png" alt="Diagramme en bâtons" title="Diagramme en bâtons" />
+ </a>
+ <a t:type="actionlink" t:context="[actionChartType,'AREA']">
+ <img src="${asset:context:}/img/chart-area.png" alt="Diagramme avec zones" title="Diagramme avec zones" />
+ </a>
+ <a t:type="actionlink" t:context="[actionChartType,'LINE']">
+ <img src="${asset:context:}/img/chart-line.png" alt="Diagramme linéaire (courbe)" title="Diagramme linéaire (courbe)" />
+ </a>
+ </p>
+ <!--<t:zone t:id="dataSamplingZone" id="so-datasampling-chart" t:update="show">-->
+ <t:chart t:width="600" t:height="400" t:chart="dataSamplingChart" />
+ <!--</t:zone>-->
+ </div>
+ </t:block>
+ <!-- GRAPH2 : BOARDING_BOAT -->
+ <t:block t:id="graph2">
+ <div class="acenter">
+ <h2>Sollicitations des navires</h2>
+ <br />
+ <p>Ces résultats ne concernent que les lignes du plan d'échantillonnage<br /> ayant une durée moyenne de marées inférieure ou égale à 48h</p>
+ <br />
+ <t:if t:test="user.admin">
+ <form t:type="form" t:id="filterCompanyForBoarding">
+ <t:label t:for="companyForBoarding" />:
+ <input t:type="select" t:id="companyForBoarding" t:model="companySelectModel" value="companyIdForBoarding"/>
+ <input t:type="submit" class="ico search-32px" t:id="searchForBoarding" value="Search"
+ title="Création du graphique pour cette société"/>
+ </form>
+ </t:if>
+ <t:chart t:width="600" t:height="400" t:chart="boardingBoatsChart" />
+ <t:if t:test="boardingResult.maxBoardingBoat">
+ <p>
+ Navire le plus sollicité avec ${boardingResult.maxBoardingValue} embarquements :
+ <strong>${boardingResult.maxBoardingBoat.name} (${boardingResult.maxBoardingBoat.immatriculation})</strong>
+ </p>
+ </t:if>
+ </div>
+ </t:block>
+ <!-- IND1 : NON_COMPLIANCE_BOARDING -->
+ <t:block t:id="ind1">
+ <div class="ind-table acenter" id="so-noncomplianceboarding">
+ <h2>Non respect du nombre d'observateurs embarqués</h2>
+ <br />
+ <t:if t:test="user.admin">
+ <p>
+ Ces résultats concernent l'ensemble des contrats en cours
+ ayant des données réelles (contacts validés).
+ </p>
+ <table class="t-data-grid">
+ <thead>
+ <tr>
+ <th class="company">Société</th>
+ <th>Indicateur</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr t:type="loop" t:source="nonComplianceBoarding.entrySet()" t:value="nonComplianceBoardingEntry">
+ <td class="company">${nonComplianceBoardingEntry.key}</td>
+ <td class="number">
+ <t:output t:value="nonComplianceBoardingEntry.value" t:format="percentFormat"/>
+ </td>
+ </tr>
+ </tbody>
+ </table>
+ <p:else>
+ <p>
+ Ce résultat concerne l'ensemble des contrats en cours
+ pour votre société ayant des données réelles (contacts validés).
+ </p>
+ <div class="indicator">
+ <p class="number">
+ <span t:type="output" t:value="nonComplianceBoardingValue" t:format="percentFormat">
+ ${nonComplianceBoardingValue}
+ </span>
+ </p>
+ </div>
+ </p:else>
+ </t:if>
+ </div>
+ </t:block>
+ <!-- IND2 : CONTACT_STATE -->
+ <t:block t:id="ind2">
+ <div class="ind-table acenter" id="so-contactstate">
+ <h2>Etats des contacts</h2>
+ <br />
+ <p>
+ Ces résultats concernent l'ensemble des états des contacts<br /> excepté
+ ceux qui ont été refusés par le programme.
+ </p>
+ <br />
+ <p>
+ <form t:type="form" t:id="filterPeriodForContactStates">
+ <label>Période : </label>
+ <t:label t:for="periodBeginForContactStates" />
+ <input t:type="datefield" class="width70" t:id="periodBeginForContactStates" t:value="periodForContactStates.fromDate" t:format="MM/yyyy" t:validate="required"/>
+ <t:label t:for="periodEndForContactStates" />
+ <input t:type="datefield" class="width70" t:id="periodEndForContactStates" t:value="periodForContactStates.thruDate" t:format="MM/yyyy" t:validate="required" />
+ <input t:type="submit" class="ico search-32px" t:id="searchForContactStates" value="Search"
+ title="Rechercher les états des contacts sur cette période"/>
+ </form>
+ </p>
+ <table class="t-data-grid">
+ <thead>
+ <tr>
+ <t:if t:test="user.admin">
+ <th class="company">Société</th>
+ </t:if>
+ <th t:type="loop" t:source="contactStates" t:value="contactState">
+ ${contactState}
+ </th>
+ <th>Total</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr t:type="loop" t:source="contactStateStatistics" t:value="contactStateStats">
+ <t:if t:test="user.admin">
+ <td class="company">${contactStateStats.companyName}</td>
+ </t:if>
+ <td t:type="loop" t:source="contactStates" t:value="contactState"
+ class="number-contactstate">
+ <t:if t:test="nbContactStates">
+ ${nbContactStates}
+ (<span t:type="output" t:value="percentContactStates" t:format="percentFormat">${percentContactStates}</span>)
+ <p:else>
+ -
+ </p:else>
+ </t:if>
+ </td>
+ <td>${contactStateStats.total}</td>
+ </tr>
+ </tbody>
+ </table>
+ </div>
+ </t:block>
+ <!-- IND3 : ALLEGRO_REACTIVITY -->
+ <t:block t:id="ind3">
+ <div class="ind-table acenter" id="so-allegroreactivity">
+ <h2>Réactivité de la saisie dans Allegro par rapport à la date de fin de la marée</h2>
+ <br />
+ <p>
+ Ce résultat est une moyenne du nombre de jours entre la date de saisie dans Allegro et la date de fin de la marée des contacts validés.
+ </p>
+ <br />
+ <p>
+ <form t:type="form" t:id="filterPeriodForAllegroReactivity">
+ <label>Période : </label>
+ <t:label t:for="periodBeginForAllegroReactivity" />
+ <input t:type="datefield" class="width70" t:id="periodBeginForAllegroReactivity" t:value="periodForAllegroReactivity.fromDate" />
+ <t:label t:for="periodEndForAllegroReactivity" />
+ <input t:type="datefield" class="width70" t:id="periodEndForAllegroReactivity" t:value="periodForAllegroReactivity.thruDate" />
+ <input t:type="submit" class="ico search-32px" t:id="searchForAllegroReactivity" value="Search"
+ title="Calcul de la moyenne du nombre de jours entre la date de saisie dans Allegro et la date de fin de marée sur la période sélectionnée"/>
+ </form>
+ </p>
+ <t:if t:test="user.admin">
+ <table class="t-data-grid">
+ <thead>
+ <tr>
+ <th class="company">Société</th>
+ <th>Indicateur</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr t:type="loop" t:source="allegroReactivity" t:value="allegroReactivityEntry">
+ <td class="company">${allegroReactivityEntry.companyName}</td>
+ <td class="number${allegroReactivityStyle}">
+ <t:output t:value="allegroReactivityEntry.result" t:format="numberFormat" />
+ </td>
+ </tr>
+ </tbody>
+ </table>
+ <p:else>
+ <div class="indicator">
+ <p class="number${allegroReactivityStyle}">
+ <t:output t:value="allegroReactivityValue" t:format="numberFormat" />
+ </p>
+ </div>
+ </p:else>
+ </t:if>
+ </div>
+ </t:block>
+</t:layout>
Deleted: trunk/wao-ui/src/main/webapp/WEB-INF/web.xml
===================================================================
--- trunk/suiviobsmer-ui/src/main/webapp/WEB-INF/web.xml 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-ui/src/main/webapp/WEB-INF/web.xml 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,46 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Copyright 2007 The Apache Software Foundation
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<!DOCTYPE web-app
- PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
- "http://java.sun.com/dtd/web-app_2_3.dtd">
-<web-app>
- <display-name>SuiviObsmer</display-name>
- <context-param>
- <!-- The only significant configuration for Tapestry 5, this informs Tapestry
-of where to look for pages, components and mixins. -->
- <param-name>tapestry.app-package</param-name>
- <param-value>fr.ifremer.suiviobsmer.ui</param-value>
- </context-param>
- <filter>
- <filter-name>app</filter-name>
- <filter-class>org.apache.tapestry5.TapestryFilter</filter-class>
- </filter>
- <!--filter>
- <filter-name>appExceptions</filter-name>
- <filter-class>org.chorem.pollen.ui.filters.PollenExceptionsFilter</filter-class>
- </filter>
- <filter-mapping>
- <filter-name>appExceptions</filter-name>
- <url-pattern>/*</url-pattern>
- </filter-mapping-->
- <filter-mapping>
- <filter-name>app</filter-name>
- <url-pattern>/*</url-pattern>
- </filter-mapping>
-</web-app>
-
Copied: trunk/wao-ui/src/main/webapp/WEB-INF/web.xml (from rev 354, trunk/suiviobsmer-ui/src/main/webapp/WEB-INF/web.xml)
===================================================================
--- trunk/wao-ui/src/main/webapp/WEB-INF/web.xml (rev 0)
+++ trunk/wao-ui/src/main/webapp/WEB-INF/web.xml 2010-02-16 13:56:07 UTC (rev 355)
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright 2007 The Apache Software Foundation
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!DOCTYPE web-app
+ PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
+ "http://java.sun.com/dtd/web-app_2_3.dtd">
+<web-app>
+ <display-name>Wao</display-name>
+ <context-param>
+ <!-- The only significant configuration for Tapestry 5, this informs Tapestry
+of where to look for pages, components and mixins. -->
+ <param-name>tapestry.app-package</param-name>
+ <param-value>fr.ifremer.wao.ui</param-value>
+ </context-param>
+ <filter>
+ <filter-name>app</filter-name>
+ <filter-class>org.apache.tapestry5.TapestryFilter</filter-class>
+ </filter>
+ <!--filter>
+ <filter-name>appExceptions</filter-name>
+ <filter-class>org.chorem.pollen.ui.filters.PollenExceptionsFilter</filter-class>
+ </filter>
+ <filter-mapping>
+ <filter-name>appExceptions</filter-name>
+ <url-pattern>/*</url-pattern>
+ </filter-mapping-->
+ <filter-mapping>
+ <filter-name>app</filter-name>
+ <url-pattern>/*</url-pattern>
+ </filter-mapping>
+</web-app>
+
Deleted: trunk/wao-ui/src/main/webapp/css/common.css
===================================================================
--- trunk/suiviobsmer-ui/src/main/webapp/css/common.css 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/wao-ui/src/main/webapp/css/common.css 2010-02-16 13:56:07 UTC (rev 355)
@@ -1,318 +0,0 @@
-/*
- Document : main
- Created on : 9 nov. 2009, 10:33:06
- Author : fdesbois
- Description:
- Common style cheets for SuiviObsmer
-*/
-
-* {
- margin: 0;
- padding: 0;
- font-family: Tahoma, Verdana, Arial, Helvetica, Courier New, Courier, mono;
-}
-
-.fleft {
- float: left;
-}
-
-.fright {
- float: right;
-}
-
-.clearfix {
- display:block;
-}
-
-.hidden {
- display: none;
-}
-
-.clearfix:after {
- content:".";
- display:block;
- height:0;
- clear:both;
- visibility:hidden;
-}
-
-.acenter {
- text-align: center;
-}
-
-.aright {
- text-align: right;
-}
-
-.line-through {
- text-decoration: line-through;
-}
-
-.width30 {
- width: 40px;
-}
-
-.width40 {
- width: 40px;
-}
-
-.width50 {
- width: 50px;
-}
-
-.width60 {
- width: 60px;
-}
-
-.width70 {
- width: 70px;
-}
-
-.width100 {
- width: 100px;
-}
-
-.width150 {
- width: 150px;
-}
-
-.width200 {
- width: 200px;
-}
-
-
-.width300 {
- width: 300px;
-}
-
-.mbottom10 {
- margin-bottom: 10px;
-}
-
-/* Lien sur une image */
-a.img {
- text-decoration:none;
- cursor: pointer;
-}
-
-input.ico {
- border: 0 none;
- font-size: 0;
- width: 32px;
- height: 32px;
- cursor: pointer;
- vertical-align: top;
-}
-
-input.ico22px {
- border: 0 none;
- font-size: 0;
- width: 22px;
- height: 22px;
- cursor: pointer;
- vertical-align: top;
-}
-
-input.ico16px {
- border: 0 none;
- font-size: 0;
- width: 16px;
- height: 16px;
- cursor: pointer;
- vertical-align: top;
-}
-
-input.save {
- background: url(../img/save.png) no-repeat center center;
-}
-
-input.save22px {
- background: url(../img/save-22px.png) no-repeat center center;
-}
-
-input.add {
- background: url(../img/add-32px.png) no-repeat center center;
-}
-
-input.suppr {
- background: url(../img/suppr-16px.png) no-repeat center center;
-}
-
-input.search-32px {
- background: url(../img/search-32px.png) no-repeat center center;
-}
-
-input.search {
- width: 22px;
- height: 22px;
- background: url(../img/search.png) no-repeat center center;
-}
-
-input.undo {
- background: url(../img/undo.png) no-repeat center center;
-}
-
-input.undo22px {
- background: url(../img/undo-22px.png) no-repeat center center;
-}
-
-input.add {
- width: 22px;
- height: 22px;
- background: url(../img/add.png) no-repeat center center;
-}
-
-input.edit {
- width: 22px;
- height: 22px;
- background: url(../img/edit.png) no-repeat center center;
-}
-
-input.delete {
- background: url(../img/delete2.png) no-repeat center center;
-}
-
-input.remove {
- width: 22px;
- height: 22px;
- background: url(../img/remove-22px.png) no-repeat center center;
-}
-
-input.refresh {
- width: 22px;
- height: 22px;
- background: url(../img/refresh-22px.png) no-repeat center center;
-}
-
-input.accept {
- background: url(../img/accept-22px.png) no-repeat center center;
-}
-
-input.refuse {
- background: url(../img/refuse-22px.png) no-repeat center center;
-}
-
-input.unvalidate {
- background: url(../img/help-22px.png) no-repeat center center;
-}
-
-/* Common for forms (userProfile and administration forms) */
-fieldset.user-form {
- width: 50%;
- margin-left: auto;
- margin-right: auto;
- padding: 10px;
- background-color: #DEE7EC;
-}
-
-
-fieldset.user-form div.t-beaneditor {
- background-color: transparent;
- padding: 0px;
- border: none;
-}
-
-fieldset.user-form div.t-beaneditor label,
-fieldset.user-form dl.t-beandisplay dt,
-fieldset.user-form div.t-beaneditor span {
- color: #007CC2;
- font-weight: bold;
- font-size: 0.8em;
-}
-
-fieldset#so-contacts-form div.t-beaneditor input.t-beaneditor-submit,
-fieldset.user-form div.t-beaneditor input.t-beaneditor-submit {
- border: 0 none;
- font-size: 0;
- width: 32px;
- height: 32px;
- cursor: pointer;
- background: url(../img/save.png) no-repeat center center;
- float: right;
-}
-
-h1 {
- font-size: 1.7em;
-}
-
-.even {
- background-color: #DEE7EC;
-}
-
-.odd {
-}
-
-div.t-data-grid-pager span.current {
- background-color: #19a28d;
-}
-
-table.t-data-grid thead th {
- background-color: #19a28d;
- text-align: left;
- padding: 3px;
-}
-
-.selected {
- background-color: yellow;
-}
-
-.refused {
- background-color: #ffaaaa;
-}
-
-.accepted {
- background-color: #8dff98;
-}
-
-.unfinished {
- background-color: #ffca86;
-}
-
-/** FILTERS COMPONENT **/
-div.so-filters {
- width: 60%;
- margin-left: auto;
- margin-right: auto;
-}
-
-div.so-filters fieldset {
- padding: 5px;
-}
-
-div.so-filters-form div.t-beaneditor {
- border: 0;
- background-color: transparent;
-}
-
-div#so-boats label,
-div.so-filters-form div.t-beaneditor label,
-div.so-filters-form div.t-beaneditor span {
- width: 120px;
- color: #007CC2;
- font-weight: bold;
- font-size: 0.8em;
-}
-
-div.t-autocomplete-menu ul {
- background-color: #19a28d;
-}
-
-
-/***** ZONE IMPORT *****/
-div.so-import {
- width: 60%;
- margin-left: auto;
- margin-right: auto;
- margin-bottom: 10px;
-}
-
-div.so-import fieldset {
- padding: 8px;
- text-align: center;
-}
-
-input.import {
- width: 22px;
- height: 22px;
- background: url(../img/file-import-22px.png) no-repeat center center;
-}
Copied: trunk/wao-ui/src/main/webapp/css/common.css (from rev 354, trunk/suiviobsmer-ui/src/main/webapp/css/common.css)
===================================================================
--- trunk/wao-ui/src/main/webapp/css/common.css (rev 0)
+++ trunk/wao-ui/src/main/webapp/css/common.css 2010-02-16 13:56:07 UTC (rev 355)
@@ -0,0 +1,318 @@
+/*
+ Document : main
+ Created on : 9 nov. 2009, 10:33:06
+ Author : fdesbois
+ Description:
+ Common style cheets for Wao
+*/
+
+* {
+ margin: 0;
+ padding: 0;
+ font-family: Tahoma, Verdana, Arial, Helvetica, Courier New, Courier, mono;
+}
+
+.fleft {
+ float: left;
+}
+
+.fright {
+ float: right;
+}
+
+.clearfix {
+ display:block;
+}
+
+.hidden {
+ display: none;
+}
+
+.clearfix:after {
+ content:".";
+ display:block;
+ height:0;
+ clear:both;
+ visibility:hidden;
+}
+
+.acenter {
+ text-align: center;
+}
+
+.aright {
+ text-align: right;
+}
+
+.line-through {
+ text-decoration: line-through;
+}
+
+.width30 {
+ width: 40px;
+}
+
+.width40 {
+ width: 40px;
+}
+
+.width50 {
+ width: 50px;
+}
+
+.width60 {
+ width: 60px;
+}
+
+.width70 {
+ width: 70px;
+}
+
+.width100 {
+ width: 100px;
+}
+
+.width150 {
+ width: 150px;
+}
+
+.width200 {
+ width: 200px;
+}
+
+
+.width300 {
+ width: 300px;
+}
+
+.mbottom10 {
+ margin-bottom: 10px;
+}
+
+/* Lien sur une image */
+a.img {
+ text-decoration:none;
+ cursor: pointer;
+}
+
+input.ico {
+ border: 0 none;
+ font-size: 0;
+ width: 32px;
+ height: 32px;
+ cursor: pointer;
+ vertical-align: top;
+}
+
+input.ico22px {
+ border: 0 none;
+ font-size: 0;
+ width: 22px;
+ height: 22px;
+ cursor: pointer;
+ vertical-align: top;
+}
+
+input.ico16px {
+ border: 0 none;
+ font-size: 0;
+ width: 16px;
+ height: 16px;
+ cursor: pointer;
+ vertical-align: top;
+}
+
+input.save {
+ background: url(../img/save.png) no-repeat center center;
+}
+
+input.save22px {
+ background: url(../img/save-22px.png) no-repeat center center;
+}
+
+input.add {
+ background: url(../img/add-32px.png) no-repeat center center;
+}
+
+input.suppr {
+ background: url(../img/suppr-16px.png) no-repeat center center;
+}
+
+input.search-32px {
+ background: url(../img/search-32px.png) no-repeat center center;
+}
+
+input.search {
+ width: 22px;
+ height: 22px;
+ background: url(../img/search.png) no-repeat center center;
+}
+
+input.undo {
+ background: url(../img/undo.png) no-repeat center center;
+}
+
+input.undo22px {
+ background: url(../img/undo-22px.png) no-repeat center center;
+}
+
+input.add {
+ width: 22px;
+ height: 22px;
+ background: url(../img/add.png) no-repeat center center;
+}
+
+input.edit {
+ width: 22px;
+ height: 22px;
+ background: url(../img/edit.png) no-repeat center center;
+}
+
+input.delete {
+ background: url(../img/delete2.png) no-repeat center center;
+}
+
+input.remove {
+ width: 22px;
+ height: 22px;
+ background: url(../img/remove-22px.png) no-repeat center center;
+}
+
+input.refresh {
+ width: 22px;
+ height: 22px;
+ background: url(../img/refresh-22px.png) no-repeat center center;
+}
+
+input.accept {
+ background: url(../img/accept-22px.png) no-repeat center center;
+}
+
+input.refuse {
+ background: url(../img/refuse-22px.png) no-repeat center center;
+}
+
+input.unvalidate {
+ background: url(../img/help-22px.png) no-repeat center center;
+}
+
+/* Common for forms (userProfile and administration forms) */
+fieldset.user-form {
+ width: 50%;
+ margin-left: auto;
+ margin-right: auto;
+ padding: 10px;
+ background-color: #DEE7EC;
+}
+
+
+fieldset.user-form div.t-beaneditor {
+ background-color: transparent;
+ padding: 0px;
+ border: none;
+}
+
+fieldset.user-form div.t-beaneditor label,
+fieldset.user-form dl.t-beandisplay dt,
+fieldset.user-form div.t-beaneditor span {
+ color: #007CC2;
+ font-weight: bold;
+ font-size: 0.8em;
+}
+
+fieldset#so-contacts-form div.t-beaneditor input.t-beaneditor-submit,
+fieldset.user-form div.t-beaneditor input.t-beaneditor-submit {
+ border: 0 none;
+ font-size: 0;
+ width: 32px;
+ height: 32px;
+ cursor: pointer;
+ background: url(../img/save.png) no-repeat center center;
+ float: right;
+}
+
+h1 {
+ font-size: 1.7em;
+}
+
+.even {
+ background-color: #DEE7EC;
+}
+
+.odd {
+}
+
+div.t-data-grid-pager span.current {
+ background-color: #19a28d;
+}
+
+table.t-data-grid thead th {
+ background-color: #19a28d;
+ text-align: left;
+ padding: 3px;
+}
+
+.selected {
+ background-color: yellow;
+}
+
+.refused {
+ background-color: #ffaaaa;
+}
+
+.accepted {
+ background-color: #8dff98;
+}
+
+.unfinished {
+ background-color: #ffca86;
+}
+
+/** FILTERS COMPONENT **/
+div.so-filters {
+ width: 60%;
+ margin-left: auto;
+ margin-right: auto;
+}
+
+div.so-filters fieldset {
+ padding: 5px;
+}
+
+div.so-filters-form div.t-beaneditor {
+ border: 0;
+ background-color: transparent;
+}
+
+div#so-boats label,
+div.so-filters-form div.t-beaneditor label,
+div.so-filters-form div.t-beaneditor span {
+ width: 120px;
+ color: #007CC2;
+ font-weight: bold;
+ font-size: 0.8em;
+}
+
+div.t-autocomplete-menu ul {
+ background-color: #19a28d;
+}
+
+
+/***** ZONE IMPORT *****/
+div.so-import {
+ width: 60%;
+ margin-left: auto;
+ margin-right: auto;
+ margin-bottom: 10px;
+}
+
+div.so-import fieldset {
+ padding: 8px;
+ text-align: center;
+}
+
+input.import {
+ width: 22px;
+ height: 22px;
+ background: url(../img/file-import-22px.png) no-repeat center center;
+}
1
0
16 Feb '10
Author: fdesbois
Date: 2010-02-16 12:00:05 +0000 (Tue, 16 Feb 2010)
New Revision: 354
Added:
trunk/suiviobsmer-business/src/main/filters/Wao.properties
trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/WaoBusinessException.java
trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/WaoContext.java
trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/WaoException.java
trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/WaoGlobal.java
trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/WaoMigrationCallBack.java
trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/WaoRunner.java
trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/WaoRunnerImpl.java
trunk/suiviobsmer-business/src/main/resources/oldmappings/WaoModel/
trunk/suiviobsmer-business/src/main/resources/oldmappings/WaoModel/0.4/
trunk/suiviobsmer-business/src/main/resources/oldmappings/WaoModel/0.4/fr/
trunk/suiviobsmer-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/
trunk/suiviobsmer-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/
trunk/suiviobsmer-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/
trunk/suiviobsmer-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/ActivityCalendarImpl.hbm.xml
trunk/suiviobsmer-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/ActivityMonthImpl.hbm.xml
trunk/suiviobsmer-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/ActivityProfessionImpl.hbm.xml
trunk/suiviobsmer-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/ActivityZoneImpl.hbm.xml
trunk/suiviobsmer-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/BoatImpl.hbm.xml
trunk/suiviobsmer-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/BoatInfosImpl.hbm.xml
trunk/suiviobsmer-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/CompanyImpl.hbm.xml
trunk/suiviobsmer-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/ContactImpl.hbm.xml
trunk/suiviobsmer-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/ElligibleBoatImpl.hbm.xml
trunk/suiviobsmer-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/FishingZoneImpl.hbm.xml
trunk/suiviobsmer-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/NewsImpl.hbm.xml
trunk/suiviobsmer-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/ProfessionImpl.hbm.xml
trunk/suiviobsmer-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/SampleMonthImpl.hbm.xml
trunk/suiviobsmer-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/SampleRowImpl.hbm.xml
trunk/suiviobsmer-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/SampleRowLogImpl.hbm.xml
trunk/suiviobsmer-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/ShipOwnerImpl.hbm.xml
trunk/suiviobsmer-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/WaoUserImpl.hbm.xml
trunk/suiviobsmer-business/src/main/xmi/wao.properties
trunk/suiviobsmer-business/src/main/xmi/wao.zargo
trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/WaoGlobalTest.java
trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/WaoRunnerTest.java
trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/WaoUtilsTest.java
trunk/suiviobsmer-business/src/test/resources/WaoTest.properties
trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/base/WaoPage.java
trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/data/WaoPropertyChangeListener.java
trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/services/WaoManager.java
Removed:
trunk/suiviobsmer-business/src/main/filters/SuiviObsmer.properties
trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/SuiviObsmerBusinessException.java
trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/SuiviObsmerContext.java
trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/SuiviObsmerException.java
trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/SuiviObsmerGlobal.java
trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/SuiviObsmerMigrationCallBack.java
trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/SuiviObsmerRunner.java
trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/SuiviObsmerRunnerImpl.java
trunk/suiviobsmer-business/src/main/xmi/suiviobsmer.properties
trunk/suiviobsmer-business/src/main/xmi/suiviobsmer.zargo
trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/SuiviObsmerGlobalTest.java
trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/SuiviObsmerRunnerTest.java
trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/SuiviObsmerUtilsTest.java
trunk/suiviobsmer-business/src/test/resources/TopiaContextSuiviObsmer.properties
trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/base/SuiviObsmerPage.java
trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/data/SuiviObsmerPropertyChangeListener.java
trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/services/SuiviObsmerManager.java
Modified:
trunk/pom.xml
trunk/src/site/rst/business-rules.rst
trunk/src/site/rst/installation.rst
trunk/suiviobsmer-business/README.txt
trunk/suiviobsmer-business/pom.xml
trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/MD5.java
trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/bean/BoatFilterImpl.java
trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/bean/CompanyBoatInfosImpl.java
trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/bean/ContactAverageReactivityImpl.java
trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/bean/ContactFilterImpl.java
trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/bean/ContactState.java
trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/bean/ContactStateStatisticsImpl.java
trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/bean/FacadeRowImpl.java
trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/bean/ImportResultsImpl.java
trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/bean/SamplingFilterImpl.java
trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/bean/UserFilterImpl.java
trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/ActivityCalendarImpl.java
trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/ActivityMonthImpl.java
trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/ActivityProfessionImpl.java
trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/BoatImpl.java
trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/BoatInfosImpl.java
trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/CompanyImpl.java
trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/ContactDAOImpl.java
trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/ContactImpl.java
trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/FishingZoneImpl.java
trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/ProfessionImpl.java
trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/SampleMonthImpl.java
trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/SampleRowImpl.java
trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/SampleRowLogImpl.java
trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/WaoUserImpl.java
trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/io/ExportHelper.java
trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/io/ImportHelper.java
trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/io/SamplingExport.java
trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/io/WaoCsvHeader.java
trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/mock/ServiceNewsMock.java
trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services/ActivityCalendarImport.java
trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services/ServiceBoatImpl.java
trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services/ServiceContactImpl.java
trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services/ServiceNewsImpl.java
trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services/ServiceReferentialImpl.java
trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services/ServiceSamplingImpl.java
trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services/ServiceSynthesisImpl.java
trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services/ServiceUserImpl.java
trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/ImportHelperTest.java
trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/entity/BoatImplTest.java
trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/entity/BoatInfosImplTest.java
trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/entity/SampleRowImplTest.java
trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/services/ActivityCalendarImportTest.java
trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/services/ServiceBoatImplTest.java
trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/services/ServiceReferentialImplTest.java
trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/services/ServiceSamplingImplTest.java
trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/services/ServiceSynthesisImplTest.java
trunk/suiviobsmer-ui/pom.xml
trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/base/AbstractFilteredPage.java
trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/base/GenericSelectModel.java
trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/components/BooleanImage.java
trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/components/Chart.java
trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/components/FeedBack.java
trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/components/Layout.java
trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/components/SubmitContext.java
trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/data/AbstractMappedGridDataSource.java
trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/data/BoatDataSource.java
trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/data/BusinessUtils.java
trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/data/ChartUtils.java
trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/data/ContactDataSource.java
trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/data/ExportStreamResponse.java
trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/data/SynthesisId.java
trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/mixins/Confirm.java
trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/mixins/PopupPageLink.java
trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/mixins/ZoneUpdater.java
trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/Administration.java
trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/BoatActivityCalendar.java
trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/Boats.java
trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/Contacts.java
trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/ExceptionReport.java
trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/Index.java
trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/SampleRowForm.java
trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/SampleRowHistoric.java
trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/SamplingPlan.java
trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/Synthesis.java
trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/UserProfile.java
trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/services/AppModule.java
trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/services/ContactModelFactory.java
trunk/suiviobsmer-ui/src/main/resources/fr/ifremer/suiviobsmer/ui/components/Layout.tml
trunk/suiviobsmer-ui/src/main/resources/log4j.properties
trunk/suiviobsmer-ui/src/main/webapp/WEB-INF/web.xml
trunk/suiviobsmer-ui/src/main/webapp/css/common.css
Log:
Big refactor, change SuiviObsmer name by Wao in poms and class names + add install doc
- Must change packages and modules names
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2010-02-16 10:56:02 UTC (rev 353)
+++ trunk/pom.xml 2010-02-16 12:00:05 UTC (rev 354)
@@ -14,8 +14,8 @@
</parent>
<groupId>fr.ifremer</groupId>
- <artifactId>suiviobsmer</artifactId>
- <version>1.0.0-SNAPSHOT</version>
+ <artifactId>wao</artifactId>
+ <version>1.0-SNAPSHOT</version>
<modules>
<module>suiviobsmer-ui</module>
@@ -144,13 +144,6 @@
<artifactId>winstone</artifactId>
<version>0.9.10-hudson-16</version>
</dependency>
-
- <!-- base postgres -->
- <!--dependency>
- <groupId>postgresql</groupId>
- <artifactId>postgresql</artifactId>
- <version>8.3-603.jdbc4</version>
- </dependency-->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
@@ -164,7 +157,7 @@
<!-- *** Project Information ************************************* -->
<!-- ************************************************************* -->
- <name>SuiviObsmer</name>
+ <name>Wao</name>
<description>Application pour le suivi d'embarquements sur des bateaux de pêches dans le cadre
d'observations scientifiques.</description>
<inceptionYear>2009</inceptionYear>
Modified: trunk/src/site/rst/business-rules.rst
===================================================================
--- trunk/src/site/rst/business-rules.rst 2010-02-16 10:56:02 UTC (rev 353)
+++ trunk/src/site/rst/business-rules.rst 2010-02-16 12:00:05 UTC (rev 354)
@@ -8,7 +8,7 @@
- Création :
- * (obligatoire) métier : toujours une nouvelle métier
+ * (obligatoire) métier : toujours un nouveau métier
* (obligatoire) zone de pêche : au moins une zone de pêche doit être ajouté à la ligne
* (obligatoire) programme : déjà existant ou nouveau programme
* (obligatoire) période : modifiable si cela ne pose pas de problème sur des données d'embarquements réels
Modified: trunk/src/site/rst/installation.rst
===================================================================
--- trunk/src/site/rst/installation.rst 2010-02-16 10:56:02 UTC (rev 353)
+++ trunk/src/site/rst/installation.rst 2010-02-16 12:00:05 UTC (rev 354)
@@ -18,12 +18,98 @@
Note
Il est fortement conseillé de modifier le mot de passe par défaut du super admin ! (dans le profile utilisateur)
+Fichier de configuration
+------------------------
+
+Il est nécessaire de créer un fichier de configuration pour décrire la
+connexion à la base et certains paramètres nécessaires à l'application.
+Ce fichier se nomme Wao.properties et peut être placé dans :
+
+- /etc/Wao.properties
+- $HOME/.Wao.properties
+
+Un fichier par défaut existe depuis le war de l'application avec les paramètres
+suivant ::
+
+ ## Default properties for H2 database
+ hibernate.hbm2ddl.auto=create
+ hibernate.show_sql=false
+ hibernate.dialect=org.hibernate.dialect.H2Dialect
+ hibernate.connection.username=sa
+ hibernate.connection.password=
+ hibernate.connection.driver_class=org.h2.Driver
+ ## Database location in user home
+ hibernate.connection.url=jdbc:h2:file:~/.local/wao/h2data
+
+ ## Logs for activityCalendar in user home
+ wao.log.activityCalendar.access=${user.home}/.local/wao/log/activity-access.log
+ wao.log.activityCalendar.import=${user.home}/.local/wao/log/activity.log
+
+ ## Config for sending Email
+ wao.email.host=smtp
+ wao.email.port=25
+ wao.email.from=admin at wao.org
+
+ ## Server path for link in mails (must be override)
+ wao.server.path=localhost:8080/wao
+
+ ## Version (not necessary to override it)
+ wao.version=1.0
+
+Par défaut la base de données utilise le SGBD H2 qui créera un fichier dans
+le dossier $HOME/.local/wao nommé **h2data.h2.db**. Il est possible d'utiliser
+une base de données postgresql en écrasant la configuration pour hibernate ::
+
+ # use postgresql
+ hibernate.hbm2ddl.auto=update
+ hibernate.show_sql=false
+ hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
+ hibernate.connection.username=dbuser
+ hibernate.connection.password=password
+ hibernate.connection.driver_class=org.postgresql.Driver
+ hibernate.connection.url=jdbc:postgresql:dbname
+
+Les chaînes dbuser, dbname et password devront être changées pour correspondre
+à la configuration de la base de données pour postgresql.
+
+Logs de l'application
+---------------------
+
+Un fichier de log nommé wao.log permettant de voir le comportement de
+l'application sera automatiquement créé dans le dossier /var/log/wao.
+Voici la configuration pour les logs de l'application ::
+
+ log4j.appender.globalfile=org.apache.log4j.RollingFileAppender
+ log4j.appender.globalfile.File=/var/log/wao/wao.log
+ log4j.appender.globalfile.MaxFileSize=500KB
+ log4j.appender.globalfile.Append=true
+ log4j.appender.globalfile.MaxBackupIndex=10
+ log4j.appender.globalfile.Threshold=TRACE
+ log4j.appender.globalfile.layout=org.apache.log4j.PatternLayout
+ log4j.appender.globalfile.layout.ConversionPattern=%d{yyyy/MM/dd hh:mm:ss} %5p (%F:%L) %m%n
+
+Il est possible de changer cette configuration en la modifiant dans un fichier
+log4j.properties placé au même niveau que le fichier war de l'application.
+
+Note
+ Le niveau de log par défaut est placé à DEBUG pour l'ensemble de l'application
+ (package : **log4j.logger.fr.ifremer.suiviobsmer=DEBUG**)
+
+
Références
----------
- `Tomcat`_
-- WarLauncher de `Nuiton-utils`_
+- `WarLauncher`_ de `Nuiton-utils`_
+- ApplicationConfig de `Nuiton-utils`_
+- `Log4j`_
.. _Tomcat: http://tomcat.apache.org/
-.. _Nuiton-utils: http://maven-site.nuiton.org/nuiton-utils/Warlauncher.html
\ No newline at end of file
+.. _WarLauncher: http://maven-site.nuiton.org/nuiton-utils/Warlauncher.html
+
+.. _Nuiton-utils: http://maven-site.nuiton.org/nuiton-utils
+
+.. _ApplicationConfig: http://maven-site.nuiton.org/nuiton-utils
+
+.. _Log4j: http://logging.apache.org/log4j/1.2/index.html
\ No newline at end of file
Modified: trunk/suiviobsmer-business/README.txt
===================================================================
--- trunk/suiviobsmer-business/README.txt 2010-02-16 10:56:02 UTC (rev 353)
+++ trunk/suiviobsmer-business/README.txt 2010-02-16 12:00:05 UTC (rev 354)
@@ -1 +1 @@
-Look at README.txt in SuiviObsmer-ui to launch the application
+Look at README.txt in Wao-ui to launch the application
Modified: trunk/suiviobsmer-business/pom.xml
===================================================================
--- trunk/suiviobsmer-business/pom.xml 2010-02-16 10:56:02 UTC (rev 353)
+++ trunk/suiviobsmer-business/pom.xml 2010-02-16 12:00:05 UTC (rev 354)
@@ -9,11 +9,11 @@
<parent>
<groupId>fr.ifremer</groupId>
- <artifactId>suiviobsmer</artifactId>
- <version>1.0.0-SNAPSHOT</version>
+ <artifactId>wao</artifactId>
+ <version>1.0-SNAPSHOT</version>
</parent>
- <groupId>fr.ifremer.suiviobsmer</groupId>
+ <groupId>fr.ifremer.wao</groupId>
<artifactId>suiviobsmer-business</artifactId>
@@ -30,10 +30,12 @@
<groupId>org.apache.commons</groupId>
<artifactId>commons-email</artifactId>
</dependency>
+ <!-- Utils -->
<dependency>
<groupId>org.nuiton</groupId>
<artifactId>nuiton-utils</artifactId>
</dependency>
+ <!-- Logging -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
@@ -46,15 +48,12 @@
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</dependency>
+ <!-- CSV lib -->
<dependency>
- <groupId>org.nuiton</groupId>
- <artifactId>nuiton-utils</artifactId>
- </dependency>
- <dependency>
<groupId>net.sourceforge.javacsv</groupId>
<artifactId>javacsv</artifactId>
</dependency>
- <!-- ToPIA -->
+ <!-- ToPIA -->
<dependency>
<groupId>org.nuiton.topia</groupId>
<artifactId>topia-persistence</artifactId>
@@ -63,8 +62,7 @@
<groupId>org.nuiton.topia</groupId>
<artifactId>topia-service-migration</artifactId>
</dependency>
-
- <!-- base h2 -->
+ <!-- SGBD -->
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
@@ -73,12 +71,7 @@
<groupId>postgresql</groupId>
<artifactId>postgresql</artifactId>
</dependency>
-
- <!-- base postgres -->
- <!--dependency>
- <groupId>postgresql</groupId>
- <artifactId>postgresql</artifactId>
- </dependency-->
+ <!-- Tests -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
@@ -89,8 +82,8 @@
<!-- *** Project Information ************************************* -->
<!-- ************************************************************* -->
- <name>SuiviObsmer :: Business</name>
- <description>Métier de l'application SuiviObsmer</description>
+ <name>Wao :: Business</name>
+ <description>Métier de l'application Wao</description>
<!-- ************************************************************* -->
<!-- *** Build Settings ****************************************** -->
@@ -104,13 +97,13 @@
<build>
<!-- FIXME les filtres ne fonctionnent pas ! -->
- <!-- Filter for resolving maven properties in SuiviObsmer.properties in resource folder -->
+ <!-- Filter for resolving maven properties in Wao.properties in resource folder -->
<resources>
<resource>
<directory>src/main/filters</directory>
<filtering>true</filtering>
<includes>
- <include>SuiviObsmer.properties</include>
+ <include>Wao.properties</include>
</includes>
</resource>
<resource>
@@ -151,7 +144,7 @@
<phase>generate-sources</phase>
<id>copy-version-files</id>
<configuration>
- <includes>**/suiviobsmer.objectmodel</includes>
+ <includes>**/wao.objectmodel</includes>
<copyVersionDir>${basedir}/src/main/resources/oldmappings/%MODELNAME%
</copyVersionDir>
<copyVersionFiles>**/*.hbm.xml</copyVersionFiles>
Deleted: trunk/suiviobsmer-business/src/main/filters/SuiviObsmer.properties
===================================================================
--- trunk/suiviobsmer-business/src/main/filters/SuiviObsmer.properties 2010-02-16 10:56:02 UTC (rev 353)
+++ trunk/suiviobsmer-business/src/main/filters/SuiviObsmer.properties 2010-02-16 12:00:05 UTC (rev 354)
@@ -1,20 +0,0 @@
-## Default properties for H2 database
-hibernate.hbm2ddl.auto=create
-hibernate.show_sql=false
-
-hibernate.dialect=org.hibernate.dialect.H2Dialect
-hibernate.connection.username=sa
-hibernate.connection.password=
-hibernate.connection.driver_class=org.h2.Driver
-hibernate.connection.url=jdbc:h2:file:~/.local/wao/h2data
-
-suiviobsmer.log.activityCalendar.access=${user.home}/.local/wao/log/activity-access.log
-suiviobsmer.log.activityCalendar.import=${user.home}/.local/wao/log/activity.log
-
-## Config for sending Email
-suiviobsmer.email.host=smtp.free.fr
-suiviobsmer.email.port=25
-suiviobsmer.email.from=admin at wao.org
-
-## Version
-suiviobsmer.version=1.0
\ No newline at end of file
Copied: trunk/suiviobsmer-business/src/main/filters/Wao.properties (from rev 350, trunk/suiviobsmer-business/src/main/filters/SuiviObsmer.properties)
===================================================================
--- trunk/suiviobsmer-business/src/main/filters/Wao.properties (rev 0)
+++ trunk/suiviobsmer-business/src/main/filters/Wao.properties 2010-02-16 12:00:05 UTC (rev 354)
@@ -0,0 +1,24 @@
+## Default properties for H2 database
+hibernate.hbm2ddl.auto=create
+hibernate.show_sql=false
+hibernate.dialect=org.hibernate.dialect.H2Dialect
+hibernate.connection.username=sa
+hibernate.connection.password=
+hibernate.connection.driver_class=org.h2.Driver
+## Database location in user home
+hibernate.connection.url=jdbc:h2:file:~/.local/wao/h2data
+
+## Logs for activityCalendar in user home
+wao.log.activityCalendar.access=${user.home}/.local/wao/log/activity-access.log
+wao.log.activityCalendar.import=${user.home}/.local/wao/log/activity.log
+
+## Config for sending Email
+wao.email.host=smtp
+wao.email.port=25
+wao.email.from=admin at wao.org
+
+## Server path for link in mails (must be override)
+wao.server.path=localhost:8080/wao
+
+## Version (not necessary to override it)
+wao.version=1.0
\ No newline at end of file
Modified: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/MD5.java
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/MD5.java 2010-02-16 10:56:02 UTC (rev 353)
+++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/MD5.java 2010-02-16 12:00:05 UTC (rev 354)
@@ -1,5 +1,5 @@
/* *##%
- * SuiviObsmer :: Business
+ * Wao :: Business
* Copyright (C) 2009 - 2010 Ifremer
*
* This program is free software: you can redistribute it and/or modify
Deleted: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/SuiviObsmerBusinessException.java
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/SuiviObsmerBusinessException.java 2010-02-16 10:56:02 UTC (rev 353)
+++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/SuiviObsmerBusinessException.java 2010-02-16 12:00:05 UTC (rev 354)
@@ -1,66 +0,0 @@
-/*
- * *##%
- * SuiviObsmer :: 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.suiviobsmer;
-
-/**
- * SuiviObsmerBusinessException
- *
- * Created: 22 déc. 2009
- *
- * @param <T>
- * @author fdesbois
- * @version $Revision$
- *
- * Mise a jour: $Date$
- * par : $Author$
- */
-public class SuiviObsmerBusinessException extends SuiviObsmerException {
-
- protected Type type;
-
- protected Class<?> serviceClass;
-
- public SuiviObsmerBusinessException(Type type, Class<?> serviceClass, String msg) {
- super(msg);
- this.type = type;
- this.serviceClass = serviceClass;
- }
-
- public SuiviObsmerBusinessException(Type type, Class<?> serviceClass, String msg, Throwable cause) {
- super(msg, cause);
- this.type = type;
- this.serviceClass = serviceClass;
- }
-
- public static enum Type {
- IMPORT_ERROR, NOT_EXISTS, ALREADY_EXISTS, SYNTAX, BAD_CONNECTION, ILLEGAL_CONNECTION;
- }
-
- public Type getType() {
- return this.type;
- }
-
- public String getServiceName() {
- return this.serviceClass.getSimpleName();
- }
-
-}
Deleted: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/SuiviObsmerContext.java
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/SuiviObsmerContext.java 2010-02-16 10:56:02 UTC (rev 353)
+++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/SuiviObsmerContext.java 2010-02-16 12:00:05 UTC (rev 354)
@@ -1,243 +0,0 @@
-/**
- * *##%
- * SuiviObsmer :: 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.suiviobsmer;
-
-
-import fr.ifremer.suiviobsmer.entity.ActivityCalendar;
-import java.io.IOException;
-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;
-
-/**
- * ContextUtilSuiviObsmer.java
- *
- * Created on 2009-11-23
- *
- * @author fdesbois
- * @version $Revision$
- *
- * Last update: $Date$
- * by : $Author$
- */
-public class SuiviObsmerContext {
-
- private static final Logger log = LoggerFactory.getLogger(SuiviObsmerContext.class);
-
- public static final String PROP_FILENAME_LOG_ACTIVITY_IMPORT =
- "suiviobsmer.log.activityCalendar.import";
- public static final String PROP_FILENAME_LOG_ACTIVITY_ACCESS =
- "suiviobsmer.log.activityCalendar.access";
- public static final String PROP_EMAIL_HOST = "suiviobsmer.email.host";
- public static final String PROP_EMAIL_PORT = "suiviobsmer.email.port";
- public static final String PROP_EMAIL_FROM = "suiviobsmer.email.from";
- public static final String PROP_VERSION = "suiviobsmer.version";
- public static final String PROP_SERVER = "suiviobsmer.server.path";
-
- private static SuiviObsmerRunner runner;
-
- private static boolean activityCalendarImport;
-
- private static org.apache.log4j.Logger activityCalendarAccessLogger;
-
- public static void setRunner(SuiviObsmerRunner 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 SuiviObsmerException {
- if (runner.getConfiguration() == null) {
- throw new SuiviObsmerException("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 SuiviObsmerException {
- if (log.isDebugEnabled()) {
- log.debug("An error occured",eee);
- }
- if (!(eee instanceof SuiviObsmerException)) {
- //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 SuiviObsmerException("Fatal topia error when close context", eeee);
- }
- //}
- if (eee instanceof SQLGrammarException && log.isErrorEnabled()) {
- log.error("SQL executed with error : " + ((SQLGrammarException)eee).getSQL());
- }
- throw new SuiviObsmerException(message,eee);
- } else {
- throw (SuiviObsmerException)eee;
- }
- }
-
- public static void closeTransaction(TopiaContext transaction) throws SuiviObsmerException {
- try {
- if (transaction != null) {
- transaction.closeContext();
- }
- } catch (TopiaException eee) {
- throw new SuiviObsmerException("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 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();
- }
-}
Deleted: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/SuiviObsmerException.java
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/SuiviObsmerException.java 2010-02-16 10:56:02 UTC (rev 353)
+++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/SuiviObsmerException.java 2010-02-16 12:00:05 UTC (rev 354)
@@ -1,44 +0,0 @@
-/*
- * *##%
- * SuiviObsmer :: 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.suiviobsmer;
-
-/**
- * SuiviObsmerException
- *
- * Created: 7 nov. 2009
- *
- * @author fdesbois
- * @version $Revision$
- *
- * Mise a jour: $Date$
- * par : $Author$
- */
-public class SuiviObsmerException extends Exception {
-
- public SuiviObsmerException(String msg) {
- super(msg);
- }
-
- public SuiviObsmerException(String msg, Throwable cause) {
- super(msg, cause);
- }
-}
Deleted: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/SuiviObsmerGlobal.java
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/SuiviObsmerGlobal.java 2010-02-16 10:56:02 UTC (rev 353)
+++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/SuiviObsmerGlobal.java 2010-02-16 12:00:05 UTC (rev 354)
@@ -1,98 +0,0 @@
-/*
- * *##%
- * SuiviObsmer :: 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.suiviobsmer;
-
-import fr.ifremer.suiviobsmer.entity.Company;
-import fr.ifremer.suiviobsmer.entity.CompanyDAO;
-import fr.ifremer.suiviobsmer.entity.WaoUser;
-import fr.ifremer.suiviobsmer.entity.WaoUserDAO;
-import org.nuiton.topia.TopiaContext;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * SuiviObsmerGlobal
- *
- * Created: 27 nov. 2009
- *
- * @author fdesbois
- * @version $Revision$
- *
- * Mise a jour: $Date$
- * par : $Author$
- */
-public class SuiviObsmerGlobal {
-
- private static final Logger log = LoggerFactory.getLogger(SuiviObsmerGlobal.class);
-
- /**
- * Create a default admin user if no user already exist.
- *
- * @throws SuiviObsmerException
- */
- static void createDefaultAdmin() throws SuiviObsmerException {
- TopiaContext transaction = null;
- try {
- transaction = SuiviObsmerContext.getTopiaRootContext().beginTransaction();
-
- WaoUserDAO dao = SuiviObsmerModelDAOHelper.getWaoUserDAO(transaction);
-
- long nbUsers = dao.size();
-
- if (log.isInfoEnabled()) {
- log.info("Nb existing users : " + nbUsers);
- }
-
- if (nbUsers == 0) {
-
- CompanyDAO companyDAO = SuiviObsmerModelDAOHelper.getCompanyDAO(transaction);
-
- if (log.isInfoEnabled()) {
- log.info("Create first admin : login=\"admin\" / password=\"password\"");
- }
-
- Company company = companyDAO.create(Company.ACTIVE, false, Company.NAME, "ADMIN");
-
- String password = SuiviObsmerContext.encodeString("password");
-
- WaoUser user = dao.create(
- WaoUser.ADMIN, true,
- WaoUser.ACTIVE, true,
- WaoUser.LOGIN, "admin",
- WaoUser.PASSWORD, password,
- WaoUser.FIRST_NAME, "Super",
- WaoUser.LAST_NAME, "Admin");
- company.addWaoUser(user);
- user.setCompany(company);
-
- transaction.commitTransaction();
- }
-
- //transaction.closeContext();
- } catch (Exception eee) {
- SuiviObsmerContext.serviceException(null, "Error during database initialization", eee);
- } finally {
- SuiviObsmerContext.closeTransaction(transaction);
- }
- }
-
-}
Deleted: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/SuiviObsmerMigrationCallBack.java
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/SuiviObsmerMigrationCallBack.java 2010-02-16 10:56:02 UTC (rev 353)
+++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/SuiviObsmerMigrationCallBack.java 2010-02-16 12:00:05 UTC (rev 354)
@@ -1,44 +0,0 @@
-package fr.ifremer.suiviobsmer;
-
-import fr.ifremer.suiviobsmer.entity.SampleRow;
-import fr.ifremer.suiviobsmer.entity.SampleRowDAO;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.nuiton.topia.TopiaException;
-import org.nuiton.topia.framework.TopiaContextImplementor;
-import org.nuiton.topia.migration.ManualMigrationCallback;
-import org.nuiton.util.Version;
-
-import java.util.List;
-
-public class SuiviObsmerMigrationCallBack extends ManualMigrationCallback {
-
- /**
- * Logger
- */
- private static final Log log = LogFactory.getLog(SuiviObsmerMigrationCallBack.class);
-
- public void migrateTo_0_4(TopiaContextImplementor tx,
- boolean showSql,
- boolean showProgression) throws TopiaException {
-
- if (log.isInfoEnabled()) {
- log.info("Migrate to version 0.4");
- }
-
- SampleRowDAO dao = SuiviObsmerModelDAOHelper.getSampleRowDAO(tx);
- for (SampleRow row : dao.findAll()) {
- String newCode = SuiviObsmerContext.prepareSampleRowCode(row.getCode());
- row.setCode(newCode);
- }
- }
-
-
- @Override
- public boolean askUser(Version dbVersion,
- Version applicationVersion,
- List<Version> versions) {
- // Always migrate the database
- return true;
- }
-}
\ No newline at end of file
Deleted: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/SuiviObsmerRunner.java
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/SuiviObsmerRunner.java 2010-02-16 10:56:02 UTC (rev 353)
+++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/SuiviObsmerRunner.java 2010-02-16 12:00:05 UTC (rev 354)
@@ -1,68 +0,0 @@
-/*
- * *##%
- * SuiviObsmer :: 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.suiviobsmer;
-
-import java.util.Date;
-import org.nuiton.util.ApplicationConfig;
-
-/**
- * SuiviObsmerRun
- *
- * Created: 24 nov. 2009
- *
- * @author fdesbois
- * @version $Revision$
- *
- * Mise a jour: $Date$
- * par : $Author$
- */
-public interface SuiviObsmerRunner {
-
- /**
- * Start the application.
- *
- * @throws SuiviObsmerException
- */
- void start() throws SuiviObsmerException;
-
- /**
- * Stop the application.
- *
- * @throws SuiviObsmerException
- */
- void stop() throws SuiviObsmerException;
-
- /**
- * Return the current date, depends on environment.
- *
- * @return the current Date
- */
- Date getCurrentDate();
-
- /**
- * Return the configuration depends on environment.
- *
- * @return the ApplicationConfig which contains the application properties
- */
- ApplicationConfig getConfiguration();
-
-}
Deleted: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/SuiviObsmerRunnerImpl.java
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/SuiviObsmerRunnerImpl.java 2010-02-16 10:56:02 UTC (rev 353)
+++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/SuiviObsmerRunnerImpl.java 2010-02-16 12:00:05 UTC (rev 354)
@@ -1,97 +0,0 @@
-/*
- * *##%
- * SuiviObsmer :: 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.suiviobsmer;
-
-import java.util.Date;
-import java.util.Locale;
-
-import org.nuiton.i18n.I18n;
-import org.nuiton.topia.TopiaException;
-import org.nuiton.topia.migration.ManualMigrationEngine;
-import org.nuiton.util.ApplicationConfig;
-
-/**
- * StartSuiviObsmer
- *
- * Created: 24 nov. 2009
- *
- * @author fdesbois
- * @version $Revision$
- *
- * Mise a jour: $Date$
- * par : $Author$
- */
-public class SuiviObsmerRunnerImpl implements SuiviObsmerRunner {
-
- private ApplicationConfig configuration;
-
- public SuiviObsmerRunnerImpl() {
- }
-
- @Override
- public void start() throws SuiviObsmerException {
- try {
- configuration = new ApplicationConfig();
- configuration.setConfigFileName("SuiviObsmer.properties");
- configuration.parse(new String[]{});
- configuration.setOption("topia.persistence.classes",
- SuiviObsmerModelDAOHelper.getImplementationClassesAsString());
-
- // migration configuration
- configuration.setOption(ManualMigrationEngine.MIGRATION_APPLICATION_VERSION, SuiviObsmerModelDAOHelper.getModelVersion());
- configuration.setOption(ManualMigrationEngine.MIGRATION_MAPPING_DIRECTORY, "oldmappings");
- configuration.setOption(ManualMigrationEngine.MIGRATION_MODEL_NAME, "SuiviObsmerModel");
- configuration.setOption("topia.service.migration", ManualMigrationEngine.class.getName());
- configuration.setOption(ManualMigrationEngine.MIGRATION_CALLBACK, SuiviObsmerMigrationCallBack.class.getName());
-
- configuration.printConfig();
-
- I18n.init(Locale.FRANCE);
- // Use the context to set the runner for default environment.
- SuiviObsmerContext.setRunner(this);
- // Create the default admin in database
- SuiviObsmerGlobal.createDefaultAdmin();
- } catch (Exception eee) {
- SuiviObsmerContext.serviceException(null, "Error during loadConfiguration from " +
- "'SuiviObsmer.properties' file", eee);
- }
- }
-
- @Override
- public void stop() throws SuiviObsmerException {
- try {
- SuiviObsmerContext.getTopiaRootContext().closeContext();
- } catch (TopiaException eee) {
- SuiviObsmerContext.serviceException(null, "Error when closing Topia root context", eee);
- }
- }
-
- @Override
- public Date getCurrentDate() {
- return new Date();
- }
-
- @Override
- public ApplicationConfig getConfiguration() {
- return configuration;
- }
-}
Copied: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/WaoBusinessException.java (from rev 350, trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/SuiviObsmerBusinessException.java)
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/WaoBusinessException.java (rev 0)
+++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/WaoBusinessException.java 2010-02-16 12:00:05 UTC (rev 354)
@@ -0,0 +1,66 @@
+/*
+ * *##%
+ * 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.suiviobsmer;
+
+/**
+ * WaoBusinessException
+ *
+ * Created: 22 déc. 2009
+ *
+ * @param <T>
+ * @author fdesbois
+ * @version $Revision$
+ *
+ * Mise a jour: $Date$
+ * par : $Author$
+ */
+public class WaoBusinessException extends WaoException {
+
+ protected Type type;
+
+ protected Class<?> serviceClass;
+
+ public WaoBusinessException(Type type, Class<?> serviceClass, String msg) {
+ super(msg);
+ this.type = type;
+ this.serviceClass = serviceClass;
+ }
+
+ public WaoBusinessException(Type type, Class<?> serviceClass, String msg, Throwable cause) {
+ super(msg, cause);
+ this.type = type;
+ this.serviceClass = serviceClass;
+ }
+
+ public static enum Type {
+ IMPORT_ERROR, NOT_EXISTS, ALREADY_EXISTS, SYNTAX, BAD_CONNECTION, ILLEGAL_CONNECTION;
+ }
+
+ public Type getType() {
+ return this.type;
+ }
+
+ public String getServiceName() {
+ return this.serviceClass.getSimpleName();
+ }
+
+}
Property changes on: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/WaoBusinessException.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL"
Added: svn:mergeinfo
+
Copied: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/WaoContext.java (from rev 350, trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/SuiviObsmerContext.java)
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/WaoContext.java (rev 0)
+++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/WaoContext.java 2010-02-16 12:00:05 UTC (rev 354)
@@ -0,0 +1,243 @@
+/**
+ * *##%
+ * 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.suiviobsmer;
+
+
+import fr.ifremer.suiviobsmer.entity.ActivityCalendar;
+import java.io.IOException;
+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 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();
+ }
+}
Copied: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/WaoException.java (from rev 350, trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/SuiviObsmerException.java)
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/WaoException.java (rev 0)
+++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/WaoException.java 2010-02-16 12:00:05 UTC (rev 354)
@@ -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.suiviobsmer;
+
+/**
+ * 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/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/WaoGlobal.java (from rev 350, trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/SuiviObsmerGlobal.java)
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/WaoGlobal.java (rev 0)
+++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/WaoGlobal.java 2010-02-16 12:00:05 UTC (rev 354)
@@ -0,0 +1,98 @@
+/*
+ * *##%
+ * 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.suiviobsmer;
+
+import fr.ifremer.suiviobsmer.entity.Company;
+import fr.ifremer.suiviobsmer.entity.CompanyDAO;
+import fr.ifremer.suiviobsmer.entity.WaoUser;
+import fr.ifremer.suiviobsmer.entity.WaoUserDAO;
+import org.nuiton.topia.TopiaContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * WaoGlobal
+ *
+ * Created: 27 nov. 2009
+ *
+ * @author fdesbois
+ * @version $Revision$
+ *
+ * Mise a jour: $Date$
+ * par : $Author$
+ */
+public class WaoGlobal {
+
+ private static final Logger log = LoggerFactory.getLogger(WaoGlobal.class);
+
+ /**
+ * Create a default admin user if no user already exist.
+ *
+ * @throws WaoException
+ */
+ static void createDefaultAdmin() throws WaoException {
+ TopiaContext transaction = null;
+ try {
+ transaction = WaoContext.getTopiaRootContext().beginTransaction();
+
+ WaoUserDAO dao = WaoModelDAOHelper.getWaoUserDAO(transaction);
+
+ long nbUsers = dao.size();
+
+ if (log.isInfoEnabled()) {
+ log.info("Nb existing users : " + nbUsers);
+ }
+
+ if (nbUsers == 0) {
+
+ CompanyDAO companyDAO = WaoModelDAOHelper.getCompanyDAO(transaction);
+
+ if (log.isInfoEnabled()) {
+ log.info("Create first admin : login=\"admin\" / password=\"password\"");
+ }
+
+ Company company = companyDAO.create(Company.ACTIVE, false, Company.NAME, "ADMIN");
+
+ String password = WaoContext.encodeString("password");
+
+ WaoUser user = dao.create(
+ WaoUser.ADMIN, true,
+ WaoUser.ACTIVE, true,
+ WaoUser.LOGIN, "admin",
+ WaoUser.PASSWORD, password,
+ WaoUser.FIRST_NAME, "Super",
+ WaoUser.LAST_NAME, "Admin");
+ company.addWaoUser(user);
+ user.setCompany(company);
+
+ transaction.commitTransaction();
+ }
+
+ //transaction.closeContext();
+ } catch (Exception eee) {
+ WaoContext.serviceException(null, "Error during database initialization", eee);
+ } finally {
+ WaoContext.closeTransaction(transaction);
+ }
+ }
+
+}
Property changes on: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/WaoGlobal.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Revision
Added: svn:mergeinfo
+
Copied: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/WaoMigrationCallBack.java (from rev 350, trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/SuiviObsmerMigrationCallBack.java)
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/WaoMigrationCallBack.java (rev 0)
+++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/WaoMigrationCallBack.java 2010-02-16 12:00:05 UTC (rev 354)
@@ -0,0 +1,64 @@
+/*
+ * *##%
+ * 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.suiviobsmer;
+
+import fr.ifremer.suiviobsmer.entity.SampleRow;
+import fr.ifremer.suiviobsmer.entity.SampleRowDAO;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.topia.TopiaException;
+import org.nuiton.topia.framework.TopiaContextImplementor;
+import org.nuiton.topia.migration.ManualMigrationCallback;
+import org.nuiton.util.Version;
+
+import java.util.List;
+
+public class WaoMigrationCallBack extends ManualMigrationCallback {
+
+ /**
+ * Logger
+ */
+ private static final Log log = LogFactory.getLog(WaoMigrationCallBack.class);
+
+ public void migrateTo_0_4(TopiaContextImplementor tx,
+ boolean showSql,
+ boolean showProgression) throws TopiaException {
+
+ if (log.isInfoEnabled()) {
+ log.info("Migrate to version 0.4");
+ }
+
+ SampleRowDAO dao = WaoModelDAOHelper.getSampleRowDAO(tx);
+ for (SampleRow row : dao.findAll()) {
+ String newCode = WaoContext.prepareSampleRowCode(row.getCode());
+ row.setCode(newCode);
+ }
+ }
+
+
+ @Override
+ public boolean askUser(Version dbVersion,
+ Version applicationVersion,
+ List<Version> versions) {
+ // Always migrate the database
+ return true;
+ }
+}
\ No newline at end of file
Property changes on: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/WaoMigrationCallBack.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: svn:mergeinfo
+
Copied: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/WaoRunner.java (from rev 350, trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/SuiviObsmerRunner.java)
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/WaoRunner.java (rev 0)
+++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/WaoRunner.java 2010-02-16 12:00:05 UTC (rev 354)
@@ -0,0 +1,68 @@
+/*
+ * *##%
+ * 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.suiviobsmer;
+
+import java.util.Date;
+import org.nuiton.util.ApplicationConfig;
+
+/**
+ * WaoRun
+ *
+ * Created: 24 nov. 2009
+ *
+ * @author fdesbois
+ * @version $Revision$
+ *
+ * Mise a jour: $Date$
+ * par : $Author$
+ */
+public interface WaoRunner {
+
+ /**
+ * Start the application.
+ *
+ * @throws WaoException
+ */
+ void start() throws WaoException;
+
+ /**
+ * Stop the application.
+ *
+ * @throws WaoException
+ */
+ void stop() throws WaoException;
+
+ /**
+ * Return the current date, depends on environment.
+ *
+ * @return the current Date
+ */
+ Date getCurrentDate();
+
+ /**
+ * Return the configuration depends on environment.
+ *
+ * @return the ApplicationConfig which contains the application properties
+ */
+ ApplicationConfig getConfiguration();
+
+}
Copied: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/WaoRunnerImpl.java (from rev 350, trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/SuiviObsmerRunnerImpl.java)
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/WaoRunnerImpl.java (rev 0)
+++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/WaoRunnerImpl.java 2010-02-16 12:00:05 UTC (rev 354)
@@ -0,0 +1,97 @@
+/*
+ * *##%
+ * 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.suiviobsmer;
+
+import java.util.Date;
+import java.util.Locale;
+
+import org.nuiton.i18n.I18n;
+import org.nuiton.topia.TopiaException;
+import org.nuiton.topia.migration.ManualMigrationEngine;
+import org.nuiton.util.ApplicationConfig;
+
+/**
+ * StartWao
+ *
+ * Created: 24 nov. 2009
+ *
+ * @author fdesbois
+ * @version $Revision$
+ *
+ * Mise a jour: $Date$
+ * par : $Author$
+ */
+public class WaoRunnerImpl implements WaoRunner {
+
+ private ApplicationConfig configuration;
+
+ public WaoRunnerImpl() {
+ }
+
+ @Override
+ public void start() throws WaoException {
+ try {
+ configuration = new ApplicationConfig();
+ configuration.setConfigFileName("Wao.properties");
+ configuration.parse(new String[]{});
+ configuration.setOption("topia.persistence.classes",
+ WaoModelDAOHelper.getImplementationClassesAsString());
+
+ // migration configuration
+ configuration.setOption(ManualMigrationEngine.MIGRATION_APPLICATION_VERSION, WaoModelDAOHelper.getModelVersion());
+ configuration.setOption(ManualMigrationEngine.MIGRATION_MAPPING_DIRECTORY, "oldmappings");
+ configuration.setOption(ManualMigrationEngine.MIGRATION_MODEL_NAME, "WaoModel");
+ configuration.setOption("topia.service.migration", ManualMigrationEngine.class.getName());
+ configuration.setOption(ManualMigrationEngine.MIGRATION_CALLBACK, WaoMigrationCallBack.class.getName());
+
+ configuration.printConfig();
+
+ I18n.init(Locale.FRANCE);
+ // Use the context to set the runner for default environment.
+ WaoContext.setRunner(this);
+ // Create the default admin in database
+ WaoGlobal.createDefaultAdmin();
+ } catch (Exception eee) {
+ WaoContext.serviceException(null, "Error during loadConfiguration from " +
+ "'Wao.properties' file", eee);
+ }
+ }
+
+ @Override
+ public void stop() throws WaoException {
+ try {
+ WaoContext.getTopiaRootContext().closeContext();
+ } catch (TopiaException eee) {
+ WaoContext.serviceException(null, "Error when closing Topia root context", eee);
+ }
+ }
+
+ @Override
+ public Date getCurrentDate() {
+ return new Date();
+ }
+
+ @Override
+ public ApplicationConfig getConfiguration() {
+ return configuration;
+ }
+}
Modified: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/bean/BoatFilterImpl.java
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/bean/BoatFilterImpl.java 2010-02-16 10:56:02 UTC (rev 353)
+++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/bean/BoatFilterImpl.java 2010-02-16 12:00:05 UTC (rev 354)
@@ -1,6 +1,6 @@
/*
* *##%
- * SuiviObsmer :: Business
+ * Wao :: Business
* Copyright (C) 2009 - 2010 Ifremer
*
* This program is free software: you can redistribute it and/or modify
Modified: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/bean/CompanyBoatInfosImpl.java
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/bean/CompanyBoatInfosImpl.java 2010-02-16 10:56:02 UTC (rev 353)
+++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/bean/CompanyBoatInfosImpl.java 2010-02-16 12:00:05 UTC (rev 354)
@@ -1,6 +1,6 @@
/*
* *##%
- * SuiviObsmer :: Business
+ * Wao :: Business
* Copyright (C) 2009 - 2010 Ifremer
*
* This program is free software: you can redistribute it and/or modify
Modified: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/bean/ContactAverageReactivityImpl.java
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/bean/ContactAverageReactivityImpl.java 2010-02-16 10:56:02 UTC (rev 353)
+++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/bean/ContactAverageReactivityImpl.java 2010-02-16 12:00:05 UTC (rev 354)
@@ -1,3 +1,23 @@
+/*
+ * *##%
+ * 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.suiviobsmer.bean;
Modified: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/bean/ContactFilterImpl.java
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/bean/ContactFilterImpl.java 2010-02-16 10:56:02 UTC (rev 353)
+++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/bean/ContactFilterImpl.java 2010-02-16 12:00:05 UTC (rev 354)
@@ -1,6 +1,6 @@
/*
* *##%
- * SuiviObsmer :: Business
+ * Wao :: Business
* Copyright (C) 2009 - 2010 Ifremer
*
* This program is free software: you can redistribute it and/or modify
Modified: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/bean/ContactState.java
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/bean/ContactState.java 2010-02-16 10:56:02 UTC (rev 353)
+++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/bean/ContactState.java 2010-02-16 12:00:05 UTC (rev 354)
@@ -1,6 +1,6 @@
/*
* *##%
- * SuiviObsmer :: Business
+ * Wao :: Business
* Copyright (C) 2009 - 2010 Ifremer
*
* This program is free software: you can redistribute it and/or modify
Modified: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/bean/ContactStateStatisticsImpl.java
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/bean/ContactStateStatisticsImpl.java 2010-02-16 10:56:02 UTC (rev 353)
+++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/bean/ContactStateStatisticsImpl.java 2010-02-16 12:00:05 UTC (rev 354)
@@ -1,3 +1,23 @@
+/*
+ * *##%
+ * 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.suiviobsmer.bean;
Modified: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/bean/FacadeRowImpl.java
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/bean/FacadeRowImpl.java 2010-02-16 10:56:02 UTC (rev 353)
+++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/bean/FacadeRowImpl.java 2010-02-16 12:00:05 UTC (rev 354)
@@ -1,3 +1,23 @@
+/*
+ * *##%
+ * 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.suiviobsmer.bean;
Modified: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/bean/ImportResultsImpl.java
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/bean/ImportResultsImpl.java 2010-02-16 10:56:02 UTC (rev 353)
+++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/bean/ImportResultsImpl.java 2010-02-16 12:00:05 UTC (rev 354)
@@ -1,6 +1,6 @@
/*
* *##%
- * SuiviObsmer :: Business
+ * Wao :: Business
* Copyright (C) 2009 - 2010 Ifremer
*
* This program is free software: you can redistribute it and/or modify
Modified: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/bean/SamplingFilterImpl.java
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/bean/SamplingFilterImpl.java 2010-02-16 10:56:02 UTC (rev 353)
+++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/bean/SamplingFilterImpl.java 2010-02-16 12:00:05 UTC (rev 354)
@@ -1,6 +1,6 @@
/*
* *##%
- * SuiviObsmer :: Business
+ * Wao :: Business
* Copyright (C) 2009 - 2010 Ifremer
*
* This program is free software: you can redistribute it and/or modify
@@ -21,7 +21,7 @@
package fr.ifremer.suiviobsmer.bean;
-import fr.ifremer.suiviobsmer.SuiviObsmerContext;
+import fr.ifremer.suiviobsmer.WaoContext;
import fr.ifremer.suiviobsmer.entity.FishingZone;
import fr.ifremer.suiviobsmer.entity.SampleRow;
import java.util.Calendar;
@@ -93,9 +93,9 @@
if (getNbMonthFinishedFromToday() != null) {
// Only rows which are not finished will be kept
- // Date current = SuiviObsmerContext.getCurrentDate();
+ // Date current = WaoContext.getCurrentDate();
Calendar calendar = new GregorianCalendar();
- calendar.setTime(SuiviObsmerContext.getCurrentDate());
+ calendar.setTime(WaoContext.getCurrentDate());
calendar.add(Calendar.MONTH, getNbMonthFinishedFromToday());
query.add(main + "." + SampleRow.PERIOD_END, Op.GE, calendar.getTime());
}
Modified: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/bean/UserFilterImpl.java
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/bean/UserFilterImpl.java 2010-02-16 10:56:02 UTC (rev 353)
+++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/bean/UserFilterImpl.java 2010-02-16 12:00:05 UTC (rev 354)
@@ -1,3 +1,23 @@
+/*
+ * *##%
+ * 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.suiviobsmer.bean;
Modified: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/ActivityCalendarImpl.java
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/ActivityCalendarImpl.java 2010-02-16 10:56:02 UTC (rev 353)
+++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/ActivityCalendarImpl.java 2010-02-16 12:00:05 UTC (rev 354)
@@ -1,6 +1,6 @@
/*
* *##%
- * SuiviObsmer :: Business
+ * Wao :: Business
* Copyright (C) 2009 - 2010 Ifremer
*
* This program is free software: you can redistribute it and/or modify
Modified: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/ActivityMonthImpl.java
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/ActivityMonthImpl.java 2010-02-16 10:56:02 UTC (rev 353)
+++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/ActivityMonthImpl.java 2010-02-16 12:00:05 UTC (rev 354)
@@ -1,6 +1,6 @@
/*
* *##%
- * SuiviObsmer :: Business
+ * Wao :: Business
* Copyright (C) 2009 - 2010 Ifremer
*
* This program is free software: you can redistribute it and/or modify
Modified: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/ActivityProfessionImpl.java
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/ActivityProfessionImpl.java 2010-02-16 10:56:02 UTC (rev 353)
+++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/ActivityProfessionImpl.java 2010-02-16 12:00:05 UTC (rev 354)
@@ -1,6 +1,6 @@
/*
* *##%
- * SuiviObsmer :: Business
+ * Wao :: Business
* Copyright (C) 2009 - 2010 Ifremer
*
* This program is free software: you can redistribute it and/or modify
Modified: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/BoatImpl.java
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/BoatImpl.java 2010-02-16 10:56:02 UTC (rev 353)
+++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/BoatImpl.java 2010-02-16 12:00:05 UTC (rev 354)
@@ -1,6 +1,6 @@
/*
* *##%
- * SuiviObsmer :: Business
+ * Wao :: Business
* Copyright (C) 2009 - 2010 Ifremer
*
* This program is free software: you can redistribute it and/or modify
@@ -21,9 +21,9 @@
package fr.ifremer.suiviobsmer.entity;
-import fr.ifremer.suiviobsmer.SuiviObsmerException;
-import fr.ifremer.suiviobsmer.SuiviObsmerContext;
-import fr.ifremer.suiviobsmer.SuiviObsmerModelDAOHelper;
+import fr.ifremer.suiviobsmer.WaoException;
+import fr.ifremer.suiviobsmer.WaoContext;
+import fr.ifremer.suiviobsmer.WaoModelDAOHelper;
import fr.ifremer.suiviobsmer.bean.ContactState;
import java.io.Serializable;
import java.util.Date;
@@ -56,20 +56,20 @@
*
* @param company which is the creator of the contact
* @return true if the contact can be created, false otherwise
- * @throws SuiviObsmerException
+ * @throws WaoException
* @see fr.ifremer.suiviobsmer.bean.ContactState#isFinalState()
*/
@Override
- public boolean canCreateContact(Company company) throws SuiviObsmerException {
+ public boolean canCreateContact(Company company) throws WaoException {
boolean result = true;
if (!getActive()) {
result = false;
} else {
TopiaContext transaction = null;
try {
- transaction = SuiviObsmerContext.getTopiaRootContext().beginTransaction();
+ transaction = WaoContext.getTopiaRootContext().beginTransaction();
- ContactDAO dao = SuiviObsmerModelDAOHelper.getContactDAO(transaction);
+ ContactDAO dao = WaoModelDAOHelper.getContactDAO(transaction);
Contact contact = dao.findByQuery(dao.createQueryLastContactForBoat(this, company));
if (contact != null) {
@@ -79,12 +79,12 @@
//transaction.closeContext();
} catch (Exception eee) {
- SuiviObsmerContext.serviceException(transaction,
+ WaoContext.serviceException(transaction,
"Impossible de récupérer les informations privées du navire lié à la société " +
"'" + company.getName() + "'",
eee);
} finally {
- SuiviObsmerContext.closeTransaction(transaction);
+ WaoContext.closeTransaction(transaction);
}
}
return result;
@@ -96,29 +96,29 @@
*
* @param fromDate the date to start calcul
* @return a number of boarding done on the boat for all companies
- * @throws SuiviObsmerException
+ * @throws WaoException
* @see fr.ifremer.suiviobsmer.entity.ContactDAO#createQueryDoneContactsFromDate(Boat, Date)
*/
@Override
- public int getNbBoarding(Date fromDate) throws SuiviObsmerException {
+ public int getNbBoarding(Date fromDate) throws WaoException {
TopiaContext transaction = null;
int result = 0;
try {
- transaction = SuiviObsmerContext.getTopiaRootContext().beginTransaction();
+ transaction = WaoContext.getTopiaRootContext().beginTransaction();
- ContactDAO dao = SuiviObsmerModelDAOHelper.getContactDAO(transaction);
+ ContactDAO dao = WaoModelDAOHelper.getContactDAO(transaction);
TopiaQuery query = dao.createQueryDoneContactsFromDate(this, fromDate);
result = query.executeCount(transaction);
//transaction.closeContext();
} catch (Exception eee) {
- SuiviObsmerContext.serviceException(transaction,
+ WaoContext.serviceException(transaction,
"Impossible de récupérer le nombre d'embarquements réels depuis le " +
"'" + fromDate + "'",
eee);
} finally {
- SuiviObsmerContext.closeTransaction(transaction);
+ WaoContext.closeTransaction(transaction);
}
return result;
}
Modified: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/BoatInfosImpl.java
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/BoatInfosImpl.java 2010-02-16 10:56:02 UTC (rev 353)
+++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/BoatInfosImpl.java 2010-02-16 12:00:05 UTC (rev 354)
@@ -1,6 +1,6 @@
/*
* *##%
- * SuiviObsmer :: Business
+ * Wao :: Business
* Copyright (C) 2009 - 2010 Ifremer
*
* This program is free software: you can redistribute it and/or modify
@@ -21,9 +21,9 @@
package fr.ifremer.suiviobsmer.entity;
-import fr.ifremer.suiviobsmer.SuiviObsmerContext;
-import fr.ifremer.suiviobsmer.SuiviObsmerException;
-import fr.ifremer.suiviobsmer.SuiviObsmerModelDAOHelper;
+import fr.ifremer.suiviobsmer.WaoContext;
+import fr.ifremer.suiviobsmer.WaoException;
+import fr.ifremer.suiviobsmer.WaoModelDAOHelper;
import org.nuiton.topia.framework.TopiaQuery;
import java.io.Serializable;
import org.nuiton.topia.TopiaContext;
@@ -54,17 +54,17 @@
*
* @param fromDate the date to start calcul
* @return a number of boarding done on the boat for the current company
- * @throws SuiviObsmerException
+ * @throws WaoException
* @see fr.ifremer.suiviobsmer.entity.ContactDAO#createQueryDoneContactsFromDate(Boat, Date)
*/
@Override
- public int getNbBoardingForCompany(Date fromDate) throws SuiviObsmerException {
+ public int getNbBoardingForCompany(Date fromDate) throws WaoException {
TopiaContext transaction = null;
int result = 0;
try {
- transaction = SuiviObsmerContext.getTopiaRootContext().beginTransaction();
+ transaction = WaoContext.getTopiaRootContext().beginTransaction();
- ContactDAO dao = SuiviObsmerModelDAOHelper.getContactDAO(transaction);
+ ContactDAO dao = WaoModelDAOHelper.getContactDAO(transaction);
TopiaQuery query = dao.createQueryDoneContactsFromDate(getBoat(), fromDate);
query.add(Contact.OBSERVER + "." + WaoUser.COMPANY, getCompany());
@@ -73,12 +73,12 @@
//transaction.closeContext();
} catch (Exception eee) {
- SuiviObsmerContext.serviceException(transaction,
+ WaoContext.serviceException(transaction,
"Impossible de récupérer le nombre d'embarquements réels depuis le " +
"'" + fromDate + "' pour la société '" + getCompany().getName() + "'",
eee);
} finally {
- SuiviObsmerContext.closeTransaction(transaction);
+ WaoContext.closeTransaction(transaction);
}
return result;
}
Modified: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/CompanyImpl.java
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/CompanyImpl.java 2010-02-16 10:56:02 UTC (rev 353)
+++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/CompanyImpl.java 2010-02-16 12:00:05 UTC (rev 354)
@@ -1,6 +1,6 @@
/*
* *##%
- * SuiviObsmer :: Business
+ * Wao :: Business
* Copyright (C) 2009 - 2010 Ifremer
*
* This program is free software: you can redistribute it and/or modify
@@ -21,7 +21,7 @@
package fr.ifremer.suiviobsmer.entity;
-import fr.ifremer.suiviobsmer.SuiviObsmerContext;
+import fr.ifremer.suiviobsmer.WaoContext;
import java.io.Serializable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -46,10 +46,10 @@
/**
* Return a simplified id instead of using topiaId
* @return a simplified id
- * @see SuiviObsmerUtils#convertId(java.lang.String)
+ * @see WaoUtils#convertId(java.lang.String)
*/
@Override
public String getId() {
- return SuiviObsmerContext.convertId(getTopiaId());
+ return WaoContext.convertId(getTopiaId());
}
}
Modified: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/ContactDAOImpl.java
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/ContactDAOImpl.java 2010-02-16 10:56:02 UTC (rev 353)
+++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/ContactDAOImpl.java 2010-02-16 12:00:05 UTC (rev 354)
@@ -1,6 +1,6 @@
/*
* *##%
- * SuiviObsmer :: Business
+ * Wao :: Business
* Copyright (C) 2009 - 2010 Ifremer
*
* This program is free software: you can redistribute it and/or modify
Modified: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/ContactImpl.java
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/ContactImpl.java 2010-02-16 10:56:02 UTC (rev 353)
+++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/ContactImpl.java 2010-02-16 12:00:05 UTC (rev 354)
@@ -1,6 +1,6 @@
/*
* *##%
- * SuiviObsmer :: Business
+ * Wao :: Business
* Copyright (C) 2009 - 2010 Ifremer
*
* This program is free software: you can redistribute it and/or modify
Modified: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/FishingZoneImpl.java
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/FishingZoneImpl.java 2010-02-16 10:56:02 UTC (rev 353)
+++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/FishingZoneImpl.java 2010-02-16 12:00:05 UTC (rev 354)
@@ -1,6 +1,6 @@
/*
* *##%
- * SuiviObsmer :: Business
+ * Wao :: Business
* Copyright (C) 2009 - 2010 Ifremer
*
* This program is free software: you can redistribute it and/or modify
Modified: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/ProfessionImpl.java
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/ProfessionImpl.java 2010-02-16 10:56:02 UTC (rev 353)
+++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/ProfessionImpl.java 2010-02-16 12:00:05 UTC (rev 354)
@@ -1,6 +1,6 @@
/*
* *##%
- * SuiviObsmer :: Business
+ * Wao :: Business
* Copyright (C) 2009 - 2010 Ifremer
*
* This program is free software: you can redistribute it and/or modify
Modified: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/SampleMonthImpl.java
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/SampleMonthImpl.java 2010-02-16 10:56:02 UTC (rev 353)
+++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/SampleMonthImpl.java 2010-02-16 12:00:05 UTC (rev 354)
@@ -1,6 +1,6 @@
/*
* *##%
- * SuiviObsmer :: Business
+ * Wao :: Business
* Copyright (C) 2009 - 2010 Ifremer
*
* This program is free software: you can redistribute it and/or modify
@@ -21,9 +21,9 @@
package fr.ifremer.suiviobsmer.entity;
-import fr.ifremer.suiviobsmer.SuiviObsmerContext;
-import fr.ifremer.suiviobsmer.SuiviObsmerException;
-import fr.ifremer.suiviobsmer.SuiviObsmerModelDAOHelper;
+import fr.ifremer.suiviobsmer.WaoContext;
+import fr.ifremer.suiviobsmer.WaoException;
+import fr.ifremer.suiviobsmer.WaoModelDAOHelper;
import java.io.Serializable;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
@@ -56,15 +56,15 @@
* If nbDays is negative and superior to the current value,
* the real tides value will be set to 0.
* @param nbDays to add or remove (if negative)
- * @throws SuiviObsmerException for saving problem
+ * @throws WaoException for saving problem
*/
@Override
- public void addRealTideTime(int nbDays) throws SuiviObsmerException {
+ public void addRealTideTime(int nbDays) throws WaoException {
TopiaContext transaction = null;
try {
- transaction = SuiviObsmerContext.getTopiaRootContext().beginTransaction();
+ transaction = WaoContext.getTopiaRootContext().beginTransaction();
- SampleMonthDAO dao = SuiviObsmerModelDAOHelper.getSampleMonthDAO(transaction);
+ SampleMonthDAO dao = WaoModelDAOHelper.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) {
- SuiviObsmerContext.serviceException(transaction,
+ WaoContext.serviceException(transaction,
"Impossible d'enregistrer le nombre de marées réels pour le mois de " +
formatMonth() + " [ligne : " + this.getSampleRow().getCode() + "]", eee);
} finally {
- SuiviObsmerContext.closeTransaction(transaction);
+ WaoContext.closeTransaction(transaction);
}
}
@@ -97,7 +97,7 @@
@Override
public boolean isCurrentMonth() {
Calendar current = new GregorianCalendar();
- current.setTime(SuiviObsmerContext.getCurrentDate());
+ current.setTime(WaoContext.getCurrentDate());
Calendar calendar = new GregorianCalendar();
calendar.setTime(getPeriodDate());
Modified: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/SampleRowImpl.java
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/SampleRowImpl.java 2010-02-16 10:56:02 UTC (rev 353)
+++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/SampleRowImpl.java 2010-02-16 12:00:05 UTC (rev 354)
@@ -1,6 +1,6 @@
/*
* *##%
- * SuiviObsmer :: Business
+ * Wao :: Business
* Copyright (C) 2009 - 2010 Ifremer
*
* This program is free software: you can redistribute it and/or modify
@@ -21,8 +21,8 @@
package fr.ifremer.suiviobsmer.entity;
-import fr.ifremer.suiviobsmer.SuiviObsmerContext;
-import fr.ifremer.suiviobsmer.SuiviObsmerException;
+import fr.ifremer.suiviobsmer.WaoContext;
+import fr.ifremer.suiviobsmer.WaoException;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Calendar;
@@ -207,7 +207,7 @@
}
@Override
- public boolean addRealTideTime(Contact contact) throws SuiviObsmerException {
+ public boolean addRealTideTime(Contact contact) throws WaoException {
if (contact.getTideEndDate() == null || contact.getTideBeginDate() == null) {
return false;
}
@@ -224,7 +224,7 @@
}
@Override
- public void removeRealTideTime(Contact contact) throws SuiviObsmerException {
+ public void removeRealTideTime(Contact contact) throws WaoException {
if (contact.getTideEndDate() == null || contact.getTideBeginDate() == null) {
return;
}
@@ -245,14 +245,14 @@
@Override
public boolean isStarted() {
- Date current = SuiviObsmerContext.getCurrentDate();
+ Date current = WaoContext.getCurrentDate();
return current.after(getPeriodBegin()) || current.equals(getPeriodBegin());
}
@Override
public boolean isFinished(int nbMonths) {
Calendar calendar = new GregorianCalendar();
- calendar.setTime(SuiviObsmerContext.getCurrentDate());
+ calendar.setTime(WaoContext.getCurrentDate());
calendar.add(Calendar.MONTH, nbMonths);
return calendar.getTime().after(getPeriodEnd());
}
Modified: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/SampleRowLogImpl.java
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/SampleRowLogImpl.java 2010-02-16 10:56:02 UTC (rev 353)
+++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/SampleRowLogImpl.java 2010-02-16 12:00:05 UTC (rev 354)
@@ -1,6 +1,6 @@
/*
* *##%
- * SuiviObsmer :: Business
+ * Wao :: Business
* Copyright (C) 2009 - 2010 Ifremer
*
* This program is free software: you can redistribute it and/or modify
Modified: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/WaoUserImpl.java
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/WaoUserImpl.java 2010-02-16 10:56:02 UTC (rev 353)
+++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/WaoUserImpl.java 2010-02-16 12:00:05 UTC (rev 354)
@@ -1,6 +1,6 @@
/*
* *##%
- * SuiviObsmer :: Business
+ * Wao :: Business
* Copyright (C) 2009 - 2010 Ifremer
*
* This program is free software: you can redistribute it and/or modify
@@ -21,7 +21,7 @@
package fr.ifremer.suiviobsmer.entity;
-import fr.ifremer.suiviobsmer.SuiviObsmerContext;
+import fr.ifremer.suiviobsmer.WaoContext;
import java.io.Serializable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -59,11 +59,11 @@
/**
* Return a simplified id instead of using topiaId
* @return a simplified id
- * @see SuiviObsmerUtils#convertId(java.lang.String)
+ * @see WaoUtils#convertId(java.lang.String)
*/
@Override
public String getId() {
- return SuiviObsmerContext.convertId(getTopiaId());
+ return WaoContext.convertId(getTopiaId());
}
@Override
Modified: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/io/ExportHelper.java
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/io/ExportHelper.java 2010-02-16 10:56:02 UTC (rev 353)
+++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/io/ExportHelper.java 2010-02-16 12:00:05 UTC (rev 354)
@@ -1,3 +1,23 @@
+/*
+ * *##%
+ * 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.suiviobsmer.io;
Modified: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/io/ImportHelper.java
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/io/ImportHelper.java 2010-02-16 10:56:02 UTC (rev 353)
+++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/io/ImportHelper.java 2010-02-16 12:00:05 UTC (rev 354)
@@ -1,6 +1,6 @@
/*
* *##%
- * SuiviObsmer :: Business
+ * Wao :: Business
* Copyright (C) 2009 - 2010 Ifremer
*
* This program is free software: you can redistribute it and/or modify
@@ -86,7 +86,7 @@
time.setTime(timeFormat.parse(code));
} else {
// Use current date with no time as a reference if no code is set
- time.setTime(SuiviObsmerContext.getCurrentDate());
+ time.setTime(WaoContext.getCurrentDate());
time.set(Calendar.HOUR_OF_DAY, 0);
time.set(Calendar.MINUTE, 0);
time.set(Calendar.SECOND, 0);
@@ -102,14 +102,14 @@
result.set(Calendar.SECOND, time.get(Calendar.SECOND));
result.set(Calendar.MILLISECOND, time.get(Calendar.MILLISECOND));
} else {
- result.setTime(SuiviObsmerContext.getCurrentDate());
+ result.setTime(WaoContext.getCurrentDate());
}
return result.getTime();
}
public static String readSampleRowCode(CsvReader reader) throws IOException {
String code = read(reader, SAMPLING.PLAN_CODE);
- return SuiviObsmerContext.prepareSampleRowCode(code);
+ return WaoContext.prepareSampleRowCode(code);
}
/**
Modified: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/io/SamplingExport.java
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/io/SamplingExport.java 2010-02-16 10:56:02 UTC (rev 353)
+++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/io/SamplingExport.java 2010-02-16 12:00:05 UTC (rev 354)
@@ -1,3 +1,23 @@
+/*
+ * *##%
+ * 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.suiviobsmer.io;
Modified: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/io/WaoCsvHeader.java
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/io/WaoCsvHeader.java 2010-02-16 10:56:02 UTC (rev 353)
+++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/io/WaoCsvHeader.java 2010-02-16 12:00:05 UTC (rev 354)
@@ -1,3 +1,23 @@
+/*
+ * *##%
+ * 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.suiviobsmer.io;
Modified: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/mock/ServiceNewsMock.java
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/mock/ServiceNewsMock.java 2010-02-16 10:56:02 UTC (rev 353)
+++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/mock/ServiceNewsMock.java 2010-02-16 12:00:05 UTC (rev 354)
@@ -1,6 +1,6 @@
/*
* *##%
- * SuiviObsmer :: Business
+ * Wao :: Business
* Copyright (C) 2009 - 2010 Ifremer
*
* This program is free software: you can redistribute it and/or modify
@@ -21,7 +21,7 @@
package fr.ifremer.suiviobsmer.mock;
-import fr.ifremer.suiviobsmer.SuiviObsmerException;
+import fr.ifremer.suiviobsmer.WaoException;
import fr.ifremer.suiviobsmer.entity.News;
import fr.ifremer.suiviobsmer.entity.NewsImpl;
import fr.ifremer.suiviobsmer.services.ServiceNews;
@@ -47,7 +47,7 @@
private static final Logger log = LoggerFactory.getLogger(ServiceNewsMock.class);
@Override
- public List<News> getNews() throws SuiviObsmerException {
+ public List<News> getNews() throws WaoException {
List<News> results = new ArrayList<News>();
Integer[] tab = new Integer[12];
@@ -106,7 +106,7 @@
}
@Override
- public void saveNews(News news, boolean delete) throws SuiviObsmerException {
+ public void saveNews(News news, boolean delete) throws WaoException {
throw new UnsupportedOperationException("Not supported yet.");
}
Modified: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services/ActivityCalendarImport.java
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services/ActivityCalendarImport.java 2010-02-16 10:56:02 UTC (rev 353)
+++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services/ActivityCalendarImport.java 2010-02-16 12:00:05 UTC (rev 354)
@@ -1,6 +1,6 @@
/*
* *##%
- * SuiviObsmer :: Business
+ * Wao :: Business
* Copyright (C) 2009 - 2010 Ifremer
*
* This program is free software: you can redistribute it and/or modify
@@ -123,8 +123,8 @@
public ActivityCalendarImport(InputStream input) throws IOException {
super();
this.input = input;
- String filename = SuiviObsmerContext.getProperty(
- SuiviObsmerContext.PROP_FILENAME_LOG_ACTIVITY_IMPORT);
+ String filename = WaoContext.getProperty(
+ WaoContext.PROP_FILENAME_LOG_ACTIVITY_IMPORT);
File file = new File(filename);
file.getParentFile().mkdirs();
if (file.exists()) {
@@ -137,10 +137,10 @@
@Override
public void run() {
TopiaContext transaction = null;
- SuiviObsmerContext.setActivityCalendarImport(true);
+ WaoContext.setActivityCalendarImport(true);
int currRow = 1;
try {
- transaction = SuiviObsmerContext.getTopiaRootContext().beginTransaction();
+ transaction = WaoContext.getTopiaRootContext().beginTransaction();
CsvReader reader = new CsvReader(input, Charset.forName("UTF-8"));
@@ -156,11 +156,11 @@
Map<ActivityCalendarKey, ActivityCalendar> availableCalendars = new HashMap<ActivityCalendarKey, ActivityCalendar>();
- BoatDAO boatDAO = SuiviObsmerModelDAOHelper.getBoatDAO(transaction);
- ActivityCalendarDAO calendarDAO = SuiviObsmerModelDAOHelper.getActivityCalendarDAO(transaction);
- ActivityMonthDAO monthDAO = SuiviObsmerModelDAOHelper.getActivityMonthDAO(transaction);
- ActivityProfessionDAO professionDAO = SuiviObsmerModelDAOHelper.getActivityProfessionDAO(transaction);
- ActivityZoneDAO zoneDAO = SuiviObsmerModelDAOHelper.getActivityZoneDAO(transaction);
+ 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);
while(reader.readRecord()) {
currRow++;
@@ -334,7 +334,7 @@
}
} finally {
IOUtils.closeQuietly(writer);
- SuiviObsmerContext.setActivityCalendarImport(false);
+ WaoContext.setActivityCalendarImport(false);
try {
transaction.closeContext();
} catch (TopiaException te) {
Modified: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services/ServiceBoatImpl.java
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services/ServiceBoatImpl.java 2010-02-16 10:56:02 UTC (rev 353)
+++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services/ServiceBoatImpl.java 2010-02-16 12:00:05 UTC (rev 354)
@@ -1,6 +1,6 @@
/*
* *##%
- * SuiviObsmer :: Business
+ * Wao :: Business
* Copyright (C) 2009 - 2010 Ifremer
*
* This program is free software: you can redistribute it and/or modify
@@ -23,11 +23,11 @@
import com.csvreader.CsvReader;
import com.csvreader.CsvWriter;
-import fr.ifremer.suiviobsmer.SuiviObsmerBusinessException;
-import fr.ifremer.suiviobsmer.SuiviObsmerBusinessException.Type;
-import fr.ifremer.suiviobsmer.SuiviObsmerContext;
-import fr.ifremer.suiviobsmer.SuiviObsmerException;
-import fr.ifremer.suiviobsmer.SuiviObsmerModelDAOHelper;
+import fr.ifremer.suiviobsmer.WaoBusinessException;
+import fr.ifremer.suiviobsmer.WaoBusinessException.Type;
+import fr.ifremer.suiviobsmer.WaoContext;
+import fr.ifremer.suiviobsmer.WaoException;
+import fr.ifremer.suiviobsmer.WaoModelDAOHelper;
import org.nuiton.topia.TopiaException;
import org.nuiton.topia.framework.TopiaQuery;
import org.nuiton.topia.framework.TopiaQuery.Op;
@@ -75,18 +75,18 @@
protected TopiaContext rootContext;
- public ServiceBoatImpl() throws SuiviObsmerException {
- rootContext = SuiviObsmerContext.getTopiaRootContext();
+ public ServiceBoatImpl() throws WaoException {
+ rootContext = WaoContext.getTopiaRootContext();
}
@Override
- public Map<Integer, Boat> getBoatsByFilter(BoatFilter filter) throws SuiviObsmerException {
+ public Map<Integer, Boat> getBoatsByFilter(BoatFilter filter) throws WaoException {
TopiaContext transaction = null;
Map<Integer, Boat> results = new HashMap<Integer, Boat>();
try {
transaction = rootContext.beginTransaction();
- BoatDAO dao = SuiviObsmerModelDAOHelper.getBoatDAO(transaction);
+ BoatDAO dao = WaoModelDAOHelper.getBoatDAO(transaction);
TopiaQuery query = dao.createQuery("B");
query = createQueryForBoatFilter(query, filter);
@@ -104,21 +104,21 @@
results = dao.findAllMappedByQuery(query, Boat.IMMATRICULATION, Integer.class);
} catch (Exception eee) {
- SuiviObsmerContext.serviceException(transaction, "Impossible de filtrer la liste des navires", eee);
+ WaoContext.serviceException(transaction, "Impossible de filtrer la liste des navires", eee);
} finally {
- SuiviObsmerContext.closeTransaction(transaction);
+ WaoContext.closeTransaction(transaction);
}
return results;
}
@Override
- public int getNbBoatsByFilter(BoatFilter filter) throws SuiviObsmerException {
+ public int getNbBoatsByFilter(BoatFilter filter) throws WaoException {
TopiaContext transaction = null;
int result = 0;
try {
transaction = rootContext.beginTransaction();
- BoatDAO dao = SuiviObsmerModelDAOHelper.getBoatDAO(transaction);
+ BoatDAO dao = WaoModelDAOHelper.getBoatDAO(transaction);
TopiaQuery query = dao.createQuery("B");
query = createQueryForBoatFilter(query, filter);
@@ -126,9 +126,9 @@
result = query.executeCount();
} catch (Exception eee) {
- SuiviObsmerContext.serviceException(transaction, "Impossible de filtrer la liste des navires", eee);
+ WaoContext.serviceException(transaction, "Impossible de filtrer la liste des navires", eee);
} finally {
- SuiviObsmerContext.closeTransaction(transaction);
+ WaoContext.closeTransaction(transaction);
}
return result;
}
@@ -176,7 +176,7 @@
*/
@Override
public CompanyBoatInfos getCompanyBoatInfos(int boatImmatriculation, Company company)
- throws SuiviObsmerException {
+ throws WaoException {
Map<String, ElligibleBoat> elligibleBoats = new HashMap<String, ElligibleBoat>();
CompanyBoatInfos result = new CompanyBoatInfosImpl();
@@ -188,11 +188,11 @@
try {
transaction = rootContext.beginTransaction();
- BoatDAO dao = SuiviObsmerModelDAOHelper.getBoatDAO(transaction);
+ BoatDAO dao = WaoModelDAOHelper.getBoatDAO(transaction);
Boat boat = dao.findByImmatriculation(boatImmatriculation);
- BoatInfosDAO boatInfosDAO = SuiviObsmerModelDAOHelper.getBoatInfosDAO(transaction);
+ BoatInfosDAO boatInfosDAO = WaoModelDAOHelper.getBoatInfosDAO(transaction);
BoatInfos boatInfos = boatInfosDAO.findByProperties(
BoatInfos.BOAT, boat, BoatInfos.COMPANY, company);
if (boatInfos == null) {
@@ -224,7 +224,7 @@
}
// Last contact
- ContactDAO contactDAO = SuiviObsmerModelDAOHelper.getContactDAO(transaction);
+ ContactDAO contactDAO = WaoModelDAOHelper.getContactDAO(transaction);
TopiaQuery query = contactDAO.createQueryLastContactForBoat(boat, company).
addLoad(Contact.SAMPLE_ROW, Contact.OBSERVER);
@@ -236,33 +236,33 @@
// transaction.closeContext();
} catch (Exception eee) {
- SuiviObsmerContext.serviceException(transaction,
+ WaoContext.serviceException(transaction,
"Impossible de récupérer les informations du navire " +
"immatriculé '" + boatImmatriculation + "'" +
" pour la société '" + company.getName() + "'", eee);
} finally {
- SuiviObsmerContext.closeTransaction(transaction);
+ WaoContext.closeTransaction(transaction);
}
return result;
}
@Override
public void createUpdateCompanyBoatInfos(CompanyBoatInfos companyBoatInfos)
- throws SuiviObsmerException {
+ throws WaoException {
TopiaContext transaction = null;
try {
transaction = rootContext.beginTransaction();
- BoatInfosDAO dao = SuiviObsmerModelDAOHelper.getBoatInfosDAO(transaction);
+ BoatInfosDAO dao = WaoModelDAOHelper.getBoatInfosDAO(transaction);
BoatInfos boatInfos = companyBoatInfos.getBoatInfos();
- SuiviObsmerContext.prepareTopiaId(BoatInfos.class, boatInfos);
+ WaoContext.prepareTopiaId(BoatInfos.class, boatInfos);
dao.update(boatInfos);
- ElligibleBoatDAO elligibleDAO = SuiviObsmerModelDAOHelper.getElligibleBoatDAO(transaction);
+ ElligibleBoatDAO elligibleDAO = WaoModelDAOHelper.getElligibleBoatDAO(transaction);
for (ElligibleBoat elligible : companyBoatInfos.getElligibleBoatsValues()) {
- SuiviObsmerContext.prepareTopiaId(ElligibleBoat.class, elligible);
+ WaoContext.prepareTopiaId(ElligibleBoat.class, elligible);
elligibleDAO.update(elligible);
}
@@ -276,16 +276,16 @@
} catch (Exception eee) {
Boat boat = companyBoatInfos.getBoatInfos().getBoat();
Company company = companyBoatInfos.getCompany();
- SuiviObsmerContext.serviceException(transaction,
+ 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 {
- SuiviObsmerContext.closeTransaction(transaction);
+ WaoContext.closeTransaction(transaction);
}
}
@Override
- public List<Boat> getBoatsByImmatriculations(String immatriculations) throws SuiviObsmerException {
+ public List<Boat> getBoatsByImmatriculations(String immatriculations) throws WaoException {
List<Boat> boats = new ArrayList<Boat>();
TopiaContext transaction = null;
if (StringUtils.isEmpty(immatriculations)) {
@@ -294,7 +294,7 @@
try {
transaction = rootContext.beginTransaction();
- BoatDAO dao = SuiviObsmerModelDAOHelper.getBoatDAO(transaction);
+ BoatDAO dao = WaoModelDAOHelper.getBoatDAO(transaction);
Pattern pattern = Pattern.compile("\\d{6}");
Matcher matcher = pattern.matcher(immatriculations);
@@ -303,7 +303,7 @@
int immatriculation = Integer.parseInt(res);
Boat boat = dao.findByImmatriculation(immatriculation);
if (boat == null) {
- throw new SuiviObsmerBusinessException(Type.NOT_EXISTS, ServiceBoat.class,
+ throw new WaoBusinessException(Type.NOT_EXISTS, ServiceBoat.class,
"Immatriculation " + immatriculation + " incorrect, ne référence aucun navire");
}
boats.add(boat);
@@ -311,36 +311,36 @@
//transaction.closeContext();
} catch (Exception eee) {
- SuiviObsmerContext.serviceException(transaction,
+ WaoContext.serviceException(transaction,
"La chaîne d'immatriculations est incorrect ! Chaque immatriculation doit posséder 6 chiffres", eee);
} finally {
- SuiviObsmerContext.closeTransaction(transaction);
+ WaoContext.closeTransaction(transaction);
}
return boats;
}
@Override
- public Boat getBoat(String boatId) throws SuiviObsmerException {
+ public Boat getBoat(String boatId) throws WaoException {
TopiaContext transaction = null;
Boat result = null;
try {
transaction = rootContext.beginTransaction();
- BoatDAO dao = SuiviObsmerModelDAOHelper.getBoatDAO(transaction);
+ BoatDAO dao = WaoModelDAOHelper.getBoatDAO(transaction);
result = dao.findByTopiaId(boatId);
//transaction.closeContext();
} catch (Exception eee) {
- SuiviObsmerContext.serviceException(transaction, "Impossible de charger le navire", eee);
+ WaoContext.serviceException(transaction, "Impossible de charger le navire", eee);
} finally {
- SuiviObsmerContext.closeTransaction(transaction);
+ WaoContext.closeTransaction(transaction);
}
return result;
}
@Override
- public List<String> getBoatNamesStartWith(String input) throws SuiviObsmerException {
+ public List<String> getBoatNamesStartWith(String input) throws WaoException {
TopiaContext transaction = null;
List<String> results = new ArrayList<String>();
try {
@@ -348,16 +348,16 @@
input = StringUtils.upperCase(input);
- BoatDAO dao = SuiviObsmerModelDAOHelper.getBoatDAO(transaction);
+ BoatDAO dao = WaoModelDAOHelper.getBoatDAO(transaction);
results = (List<String>)dao.createQuery().addDistinct().setSelect(Boat.NAME).add(Boat.NAME, Op.LIKE, input + "%").execute();
//transaction.closeContext();
} catch (Exception eee) {
- SuiviObsmerContext.serviceException(transaction,
+ WaoContext.serviceException(transaction,
"Impossible de récupérer les navires avec un nom commencant par '" + input + "'", eee);
} finally {
- SuiviObsmerContext.closeTransaction(transaction);
+ WaoContext.closeTransaction(transaction);
}
return results;
}
@@ -372,11 +372,11 @@
* @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 SuiviObsmerException
+ * @throws WaoException
* @see com.csvreader.CsvReader
*/
@Override
- public int[] importBoatCsv(InputStream input) throws SuiviObsmerException {
+ public int[] importBoatCsv(InputStream input) throws WaoException {
TopiaContext transaction = null;
int[] result = new int[]{0,0};
try {
@@ -388,8 +388,8 @@
long startTime = System.currentTimeMillis();
long tic;
- BoatDAO boatDAO = SuiviObsmerModelDAOHelper.getBoatDAO(transaction);
- ShipOwnerDAO shipOwnerDAO = SuiviObsmerModelDAOHelper.getShipOwnerDAO(transaction);
+ BoatDAO boatDAO = WaoModelDAOHelper.getBoatDAO(transaction);
+ ShipOwnerDAO shipOwnerDAO = WaoModelDAOHelper.getShipOwnerDAO(transaction);
Map<String, ShipOwner> availableShipOwners = new HashMap<String, ShipOwner>();
@@ -475,19 +475,19 @@
//transaction.closeContext();
} catch (Exception eee) {
- SuiviObsmerContext.serviceException(transaction,
+ 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 {
- SuiviObsmerContext.closeTransaction(transaction);
+ WaoContext.closeTransaction(transaction);
}
return result;
}
@Override
- public InputStream exportBoatCsv(BoatFilter filter) throws SuiviObsmerException {
+ public InputStream exportBoatCsv(BoatFilter filter) throws WaoException {
TopiaContext transaction = null;
InputStream result = null;
CsvWriter writer = null;
@@ -515,7 +515,7 @@
export.writeHeaders();
// Get boats from database filterd by filter in argument
- BoatDAO dao = SuiviObsmerModelDAOHelper.getBoatDAO(transaction);
+ BoatDAO dao = WaoModelDAOHelper.getBoatDAO(transaction);
TopiaQuery query = dao.createQuery("B");
query = createQueryForBoatFilter(query, filter);
@@ -561,38 +561,38 @@
//transaction.closeContext();
} catch (Exception eee) {
- SuiviObsmerContext.serviceException(transaction,
+ WaoContext.serviceException(transaction,
"Impossible d'exporter les navires sélectionnés", eee);
} finally {
if (writer != null) {
writer.close();
}
- SuiviObsmerContext.closeTransaction(transaction);
+ WaoContext.closeTransaction(transaction);
}
return result;
}
@Override
- public void importActivityCalendarCsv(InputStream input) throws SuiviObsmerException {
- if (!SuiviObsmerContext.isActivityCalendarImportRun()) {
+ public void importActivityCalendarCsv(InputStream input) throws WaoException {
+ if (!WaoContext.isActivityCalendarImportRun()) {
try {
ActivityCalendarImport calendarImport = new ActivityCalendarImport(input);
new Thread(calendarImport).start();
} catch (IOException eee) {
- SuiviObsmerContext.serviceException(null,
+ WaoContext.serviceException(null,
"Problème d'import du fichier CSV des calendriers d'activité", eee);
}
}
}
@Override
- public ActivityCalendar getLastActivityCalendar(WaoUser user, Boat boat) throws SuiviObsmerException {
+ public ActivityCalendar getLastActivityCalendar(WaoUser user, Boat boat) throws WaoException {
TopiaContext transaction = null;
ActivityCalendar result = null;
try {
transaction = rootContext.beginTransaction();
- ActivityCalendarDAO dao = SuiviObsmerModelDAOHelper.getActivityCalendarDAO(transaction);
+ ActivityCalendarDAO dao = WaoModelDAOHelper.getActivityCalendarDAO(transaction);
TopiaQuery query = dao.createQuery("A").
add("A." + ActivityCalendar.BOAT, boat);
@@ -620,7 +620,7 @@
// Log ActivityCalendar access only for non admin user
if (!user.getAdmin()) {
Company company = user.getCompany();
- SuiviObsmerContext.addActivityCalendarAccessLog(
+ WaoContext.addActivityCalendarAccessLog(
"Calendrier " + result.getYear() + " du navire " +
boat.getName() + " (" + boat.getImmatriculation() + ") vu " +
"par " + user.getFullName() + " de la société " +
@@ -629,27 +629,27 @@
//transaction.closeContext();
} catch (Exception eee) {
- SuiviObsmerContext.serviceException(transaction,
+ WaoContext.serviceException(transaction,
"Impossible de charger le dernier calendrier d'activité du navire " +
boat.getName() + " (" + boat.getImmatriculation() + ")", eee);
} finally {
- SuiviObsmerContext.closeTransaction(transaction);
+ WaoContext.closeTransaction(transaction);
}
return result;
}
@Override
public InputStream getActivityCalendarLogFile() throws FileNotFoundException {
- String filename = SuiviObsmerContext.getProperty(
- SuiviObsmerContext.PROP_FILENAME_LOG_ACTIVITY_IMPORT);
+ String filename = WaoContext.getProperty(
+ WaoContext.PROP_FILENAME_LOG_ACTIVITY_IMPORT);
File file = new File(filename);
return new FileInputStream(file);
}
@Override
public InputStream getActivityCalendarLogAccessFile() throws FileNotFoundException {
- String filename = SuiviObsmerContext.getProperty(
- SuiviObsmerContext.PROP_FILENAME_LOG_ACTIVITY_ACCESS);
+ String filename = WaoContext.getProperty(
+ WaoContext.PROP_FILENAME_LOG_ACTIVITY_ACCESS);
File file = new File(filename);
return new FileInputStream(file);
}
Modified: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services/ServiceContactImpl.java
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services/ServiceContactImpl.java 2010-02-16 10:56:02 UTC (rev 353)
+++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services/ServiceContactImpl.java 2010-02-16 12:00:05 UTC (rev 354)
@@ -1,6 +1,6 @@
/*
* *##%
- * SuiviObsmer :: Business
+ * Wao :: Business
* Copyright (C) 2009 - 2010 Ifremer
*
* This program is free software: you can redistribute it and/or modify
@@ -25,11 +25,11 @@
import com.csvreader.CsvWriter;
import fr.ifremer.suiviobsmer.io.ImportHelper;
import fr.ifremer.suiviobsmer.io.ImportHelper.*;
-import fr.ifremer.suiviobsmer.SuiviObsmerBusinessException;
-import fr.ifremer.suiviobsmer.SuiviObsmerBusinessException.Type;
-import fr.ifremer.suiviobsmer.SuiviObsmerException;
-import fr.ifremer.suiviobsmer.SuiviObsmerModelDAOHelper;
-import fr.ifremer.suiviobsmer.SuiviObsmerContext;
+import fr.ifremer.suiviobsmer.WaoBusinessException;
+import fr.ifremer.suiviobsmer.WaoBusinessException.Type;
+import fr.ifremer.suiviobsmer.WaoException;
+import fr.ifremer.suiviobsmer.WaoModelDAOHelper;
+import fr.ifremer.suiviobsmer.WaoContext;
import fr.ifremer.suiviobsmer.bean.ContactState;
import java.io.IOException;
import java.io.InputStream;
@@ -95,18 +95,18 @@
protected TopiaContext rootContext;
- public ServiceContactImpl() throws SuiviObsmerException {
- rootContext = SuiviObsmerContext.getTopiaRootContext();
+ public ServiceContactImpl() throws WaoException {
+ rootContext = WaoContext.getTopiaRootContext();
}
@Override
- public Map<String, Contact> getContacts(ContactFilter filter) throws SuiviObsmerException {
+ public Map<String, Contact> getContacts(ContactFilter filter) throws WaoException {
Map<String, Contact> results = new HashMap<String, Contact>();
TopiaContext transaction = null;
try {
transaction = rootContext.beginTransaction();
- ContactDAO dao = SuiviObsmerModelDAOHelper.getContactDAO(transaction);
+ ContactDAO dao = WaoModelDAOHelper.getContactDAO(transaction);
TopiaQuery query = dao.createQuery("C").addDistinct();
@@ -122,22 +122,22 @@
//transaction.closeContext();
} catch (Exception eee) {
- SuiviObsmerContext.serviceException(transaction,
+ WaoContext.serviceException(transaction,
"Impossible de filtrer la liste des contacts", eee);
} finally {
- SuiviObsmerContext.closeTransaction(transaction);
+ WaoContext.closeTransaction(transaction);
}
return results;
}
@Override
- public int getNbContacts(ContactFilter filter) throws SuiviObsmerException {
+ public int getNbContacts(ContactFilter filter) throws WaoException {
TopiaContext transaction = null;
int result = 0;
try {
transaction = rootContext.beginTransaction();
- ContactDAO dao = SuiviObsmerModelDAOHelper.getContactDAO(transaction);
+ ContactDAO dao = WaoModelDAOHelper.getContactDAO(transaction);
TopiaQuery query = dao.createQuery("C");
query = filter.prepareQueryForContact(query);
@@ -145,10 +145,10 @@
//transaction.closeContext();
} catch (Exception eee) {
- SuiviObsmerContext.serviceException(transaction,
+ WaoContext.serviceException(transaction,
"Impossible de compter le nombre de contacts filtrés", eee);
} finally {
- SuiviObsmerContext.closeTransaction(transaction);
+ WaoContext.closeTransaction(transaction);
}
return result;
}
@@ -164,18 +164,18 @@
}
@Override
- public void saveContact(Contact contact, boolean delete) throws SuiviObsmerException {
+ public void saveContact(Contact contact, boolean delete) throws WaoException {
TopiaContext transaction = null;
try {
transaction = rootContext.beginTransaction();
- ContactDAO dao = SuiviObsmerModelDAOHelper.getContactDAO(transaction);
+ ContactDAO dao = WaoModelDAOHelper.getContactDAO(transaction);
if (log.isDebugEnabled()) {
log.debug("Create date : " + contact.getTopiaCreateDate());
}
- SuiviObsmerContext.prepareTopiaId(Contact.class, contact);
+ WaoContext.prepareTopiaId(Contact.class, contact);
if (delete) {
dao.delete(contact);
} else {
@@ -185,16 +185,16 @@
transaction.commitTransaction();
//transaction.closeContext();
} catch (Exception eee) {
- SuiviObsmerContext.serviceException(transaction,
+ WaoContext.serviceException(transaction,
"Impossible de sauvegarder le contact", eee);
} finally {
- SuiviObsmerContext.closeTransaction(transaction);
+ WaoContext.closeTransaction(transaction);
}
}
@Override
public InputStream exportContactCsv(ContactFilter filter)
- throws SuiviObsmerException {
+ throws WaoException {
TopiaContext transaction = null;
InputStream result = null;
CsvWriter writer = null;
@@ -232,7 +232,7 @@
DateFormat dateFormat = CONTACT.getDateFormat();
// Get contacts from database
- ContactDAO dao = SuiviObsmerModelDAOHelper.getContactDAO(transaction);
+ ContactDAO dao = WaoModelDAOHelper.getContactDAO(transaction);
TopiaQuery query = dao.createQuery("C");
query.addOrderDesc("C." + TopiaEntity.TOPIA_CREATE_DATE);
@@ -317,19 +317,19 @@
//transaction.closeContext();
} catch (Exception eee) {
- SuiviObsmerContext.serviceException(transaction,
+ WaoContext.serviceException(transaction,
"Impossible d'exporter les contacts", eee);
} finally {
if (writer != null) {
writer.close();
}
- SuiviObsmerContext.closeTransaction(transaction);
+ WaoContext.closeTransaction(transaction);
}
return result;
}
@Override
- public ImportResults importContactCsv(WaoUser user, InputStream input) throws SuiviObsmerException {
+ public ImportResults importContactCsv(WaoUser user, InputStream input) throws WaoException {
TopiaContext transaction = null;
ImportResults result = new ImportResultsImpl();
int currRow = 1;
@@ -340,11 +340,11 @@
reader = new CsvReader(input, Charset.forName("UTF-8"));
reader.readHeaders();
- ContactDAO dao = SuiviObsmerModelDAOHelper.getContactDAO(transaction);
- WaoUserDAO userDAO = SuiviObsmerModelDAOHelper.getWaoUserDAO(transaction);
- CompanyDAO companyDAO = SuiviObsmerModelDAOHelper.getCompanyDAO(transaction);
- SampleRowDAO rowDAO = SuiviObsmerModelDAOHelper.getSampleRowDAO(transaction);
- BoatDAO boatDAO = SuiviObsmerModelDAOHelper.getBoatDAO(transaction);
+ 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);
long tic;
tic = System.currentTimeMillis();
@@ -357,7 +357,7 @@
ContactState contactState = ContactState.createContactStateEnum(state);
if (contactState == null) {
- throw new SuiviObsmerBusinessException(Type.IMPORT_ERROR, this.getClass(),
+ throw new WaoBusinessException(Type.IMPORT_ERROR, this.getClass(),
"Erreur ligne " + currRow + " : " +
"Etat du contact invalide '" + state + "', valeurs possibles : " +
ContactState.availableStates());
@@ -372,7 +372,7 @@
company = companyDAO.findContainsWaoUser(observer);
// For a user, check if the observer as the same company as the current user
} else if (!observer.getCompany().equals(company)) {
- throw new SuiviObsmerBusinessException(Type.IMPORT_ERROR, this.getClass(),
+ throw new WaoBusinessException(Type.IMPORT_ERROR, this.getClass(),
"Erreur ligne " + currRow + " : " +
"L'observateur avec pour login '" + observerId + "' n'appartient pas à votre société !");
}
@@ -389,7 +389,7 @@
if (boat != null) {
- ElligibleBoatDAO elligibleDAO = SuiviObsmerModelDAOHelper.getElligibleBoatDAO(transaction);
+ ElligibleBoatDAO elligibleDAO = WaoModelDAOHelper.getElligibleBoatDAO(transaction);
ElligibleBoat elligible = elligibleDAO.findByProperties(
ElligibleBoat.BOAT, boat, ElligibleBoat.SAMPLE_ROW, row);
@@ -514,7 +514,7 @@
//transaction.closeContext();
} catch (ParseException eee) {
- SuiviObsmerContext.serviceException(transaction,
+ WaoContext.serviceException(transaction,
"Erreur ligne " + currRow + " : " +
"Le format des dates est incorrect, il doit être de la forme : JJ/MM/AAAA", eee);
} catch (Exception eee) {
@@ -525,10 +525,10 @@
log.error("Reader error", ex);
}
}
- SuiviObsmerContext.serviceException(transaction,
+ WaoContext.serviceException(transaction,
"Impossible d'importer les contacts", eee);
} finally {
- SuiviObsmerContext.closeTransaction(transaction);
+ WaoContext.closeTransaction(transaction);
}
return result;
}
Modified: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services/ServiceNewsImpl.java
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services/ServiceNewsImpl.java 2010-02-16 10:56:02 UTC (rev 353)
+++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services/ServiceNewsImpl.java 2010-02-16 12:00:05 UTC (rev 354)
@@ -1,6 +1,6 @@
/*
* *##%
- * SuiviObsmer :: Business
+ * Wao :: Business
* Copyright (C) 2009 - 2010 Ifremer
*
* This program is free software: you can redistribute it and/or modify
@@ -21,9 +21,9 @@
package fr.ifremer.suiviobsmer.services;
-import fr.ifremer.suiviobsmer.SuiviObsmerContext;
-import fr.ifremer.suiviobsmer.SuiviObsmerException;
-import fr.ifremer.suiviobsmer.SuiviObsmerModelDAOHelper;
+import fr.ifremer.suiviobsmer.WaoContext;
+import fr.ifremer.suiviobsmer.WaoException;
+import fr.ifremer.suiviobsmer.WaoModelDAOHelper;
import fr.ifremer.suiviobsmer.entity.News;
import fr.ifremer.suiviobsmer.entity.NewsDAO;
import fr.ifremer.suiviobsmer.services.ServiceNews;
@@ -51,53 +51,53 @@
protected TopiaContext rootContext;
- public ServiceNewsImpl() throws SuiviObsmerException {
- rootContext = SuiviObsmerContext.getTopiaRootContext();
+ public ServiceNewsImpl() throws WaoException {
+ rootContext = WaoContext.getTopiaRootContext();
}
@Override
- public List<News> getNews() throws SuiviObsmerException {
+ public List<News> getNews() throws WaoException {
TopiaContext transaction = null;
List<News> results = new ArrayList<News>();
try {
transaction = rootContext.beginTransaction();
- NewsDAO dao = SuiviObsmerModelDAOHelper.getNewsDAO(transaction);
+ NewsDAO dao = WaoModelDAOHelper.getNewsDAO(transaction);
results = dao.findAllWithOrder(TopiaEntity.TOPIA_CREATE_DATE + " DESC");
//transaction.closeContext();
} catch (Exception eee) {
- SuiviObsmerContext.serviceException(transaction,
+ WaoContext.serviceException(transaction,
"Impossible de récupérer l'ensemble des news", eee);
} finally {
- SuiviObsmerContext.closeTransaction(transaction);
+ WaoContext.closeTransaction(transaction);
}
return results;
}
@Override
- public void saveNews(News news, boolean delete) throws SuiviObsmerException {
+ public void saveNews(News news, boolean delete) throws WaoException {
TopiaContext transaction = null;
try {
transaction = rootContext.beginTransaction();
- NewsDAO dao = SuiviObsmerModelDAOHelper.getNewsDAO(transaction);
+ NewsDAO dao = WaoModelDAOHelper.getNewsDAO(transaction);
if (delete) {
dao.delete(news);
} else {
- SuiviObsmerContext.prepareTopiaId(News.class, news);
+ WaoContext.prepareTopiaId(News.class, news);
dao.update(news);
}
transaction.commitTransaction();
//transaction.closeContext();
} catch (Exception eee) {
- SuiviObsmerContext.serviceException(transaction,
+ WaoContext.serviceException(transaction,
"Impossible de récupérer l'ensemble des news", eee);
} finally {
- SuiviObsmerContext.closeTransaction(transaction);
+ WaoContext.closeTransaction(transaction);
}
}
Modified: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services/ServiceReferentialImpl.java
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services/ServiceReferentialImpl.java 2010-02-16 10:56:02 UTC (rev 353)
+++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services/ServiceReferentialImpl.java 2010-02-16 12:00:05 UTC (rev 354)
@@ -1,6 +1,6 @@
/*
* *##%
- * SuiviObsmer :: Business
+ * Wao :: Business
* Copyright (C) 2009 - 2010 Ifremer
*
* This program is free software: you can redistribute it and/or modify
@@ -22,9 +22,9 @@
package fr.ifremer.suiviobsmer.services;
import com.csvreader.CsvReader;
-import fr.ifremer.suiviobsmer.SuiviObsmerException;
-import fr.ifremer.suiviobsmer.SuiviObsmerModelDAOHelper;
-import fr.ifremer.suiviobsmer.SuiviObsmerContext;
+import fr.ifremer.suiviobsmer.WaoException;
+import fr.ifremer.suiviobsmer.WaoModelDAOHelper;
+import fr.ifremer.suiviobsmer.WaoContext;
import fr.ifremer.suiviobsmer.bean.SamplingFilter;
import fr.ifremer.suiviobsmer.entity.FishingZone;
import fr.ifremer.suiviobsmer.entity.FishingZoneDAO;
@@ -62,18 +62,18 @@
protected TopiaContext rootContext;
- public ServiceReferentialImpl() throws SuiviObsmerException {
- rootContext = SuiviObsmerContext.getTopiaRootContext();
+ public ServiceReferentialImpl() throws WaoException {
+ rootContext = WaoContext.getTopiaRootContext();
}
@Override
- public List<String> getFacades(SamplingFilter filter) throws SuiviObsmerException {
+ public List<String> getFacades(SamplingFilter filter) throws WaoException {
TopiaContext transaction = null;
List<String> results = new ArrayList<String>();
try {
transaction = rootContext.beginTransaction();
- FishingZoneDAO dao = SuiviObsmerModelDAOHelper.getFishingZoneDAO(transaction);
+ FishingZoneDAO dao = WaoModelDAOHelper.getFishingZoneDAO(transaction);
TopiaQuery query = dao.createQuery("F");
query = prepareQueryForFishingZoneFilter(query, filter);
@@ -82,21 +82,21 @@
//transaction.closeContext();
} catch (Exception eee) {
- SuiviObsmerContext.serviceException(transaction, "Impossible de charger la liste des facades", eee);
+ WaoContext.serviceException(transaction, "Impossible de charger la liste des facades", eee);
} finally {
- SuiviObsmerContext.closeTransaction(transaction);
+ WaoContext.closeTransaction(transaction);
}
return results;
}
@Override
- public List<String> getSectors(SamplingFilter filter) throws SuiviObsmerException {
+ public List<String> getSectors(SamplingFilter filter) throws WaoException {
TopiaContext transaction = null;
List<String> results = new ArrayList<String>();
try {
transaction = rootContext.beginTransaction();
- FishingZoneDAO dao = SuiviObsmerModelDAOHelper.getFishingZoneDAO(transaction);
+ FishingZoneDAO dao = WaoModelDAOHelper.getFishingZoneDAO(transaction);
TopiaQuery query = dao.createQuery("F");
query = prepareQueryForFishingZoneFilter(query, filter);
@@ -109,9 +109,9 @@
//transaction.closeContext();
} catch (Exception eee) {
- SuiviObsmerContext.serviceException(transaction, "Impossible de charger la liste des secteurs de pêche", eee);
+ WaoContext.serviceException(transaction, "Impossible de charger la liste des secteurs de pêche", eee);
} finally {
- SuiviObsmerContext.closeTransaction(transaction);
+ WaoContext.closeTransaction(transaction);
}
return results;
}
@@ -134,49 +134,49 @@
}
@Override
- public List<Profession> getProfessions() throws SuiviObsmerException {
+ public List<Profession> getProfessions() throws WaoException {
TopiaContext transaction = null;
List<Profession> results = new ArrayList<Profession>();
try {
transaction = rootContext.beginTransaction();
- ProfessionDAO dao = SuiviObsmerModelDAOHelper.getProfessionDAO(transaction);
+ ProfessionDAO dao = WaoModelDAOHelper.getProfessionDAO(transaction);
results = dao.findAll();
//transaction.closeContext();
} catch (Exception eee) {
- SuiviObsmerContext.serviceException(transaction,
+ WaoContext.serviceException(transaction,
"Impossible de charger la liste des métiers", eee);
} finally {
- SuiviObsmerContext.closeTransaction(transaction);
+ WaoContext.closeTransaction(transaction);
}
return results;
}
@Override
- public List<FishingZone> getFishingZones() throws SuiviObsmerException {
+ public List<FishingZone> getFishingZones() throws WaoException {
TopiaContext transaction = null;
List<FishingZone> results = new ArrayList<FishingZone>();
try {
transaction = rootContext.beginTransaction();
- FishingZoneDAO dao = SuiviObsmerModelDAOHelper.getFishingZoneDAO(transaction);
+ FishingZoneDAO dao = WaoModelDAOHelper.getFishingZoneDAO(transaction);
results = dao.findAll();
//transaction.closeContext();
} catch (Exception eee) {
- SuiviObsmerContext.serviceException(transaction,
+ WaoContext.serviceException(transaction,
"Impossible de charger la liste des zones de pêche", eee);
} finally {
- SuiviObsmerContext.closeTransaction(transaction);
+ WaoContext.closeTransaction(transaction);
}
return results;
}
@Override
- public int importFishingZoneCsv(InputStream input) throws SuiviObsmerException {
+ public int importFishingZoneCsv(InputStream input) throws WaoException {
TopiaContext transaction = null;
int result = 0;
try {
@@ -185,7 +185,7 @@
CsvReader reader = new CsvReader(input, Charset.forName("UTF-8"));
reader.readHeaders();
- FishingZoneDAO dao = SuiviObsmerModelDAOHelper.getFishingZoneDAO(transaction);
+ FishingZoneDAO dao = WaoModelDAOHelper.getFishingZoneDAO(transaction);
while(reader.readRecord()) {
if (log.isTraceEnabled()) {
@@ -209,12 +209,12 @@
transaction.commitTransaction();
//transaction.closeContext();
} catch (Exception eee) {
- SuiviObsmerContext.serviceException(transaction,
+ 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 {
- SuiviObsmerContext.closeTransaction(transaction);
+ WaoContext.closeTransaction(transaction);
}
return result;
}
Modified: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services/ServiceSamplingImpl.java
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services/ServiceSamplingImpl.java 2010-02-16 10:56:02 UTC (rev 353)
+++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services/ServiceSamplingImpl.java 2010-02-16 12:00:05 UTC (rev 354)
@@ -1,6 +1,6 @@
/*
* *##%
- * SuiviObsmer :: Business
+ * Wao :: Business
* Copyright (C) 2009 - 2010 Ifremer
*
* This program is free software: you can redistribute it and/or modify
@@ -24,11 +24,11 @@
import com.csvreader.CsvReader;
import com.csvreader.CsvWriter;
import fr.ifremer.suiviobsmer.io.ImportHelper;
-import fr.ifremer.suiviobsmer.SuiviObsmerBusinessException;
-import fr.ifremer.suiviobsmer.SuiviObsmerBusinessException.Type;
-import fr.ifremer.suiviobsmer.SuiviObsmerException;
-import fr.ifremer.suiviobsmer.SuiviObsmerModelDAOHelper;
-import fr.ifremer.suiviobsmer.SuiviObsmerContext;
+import fr.ifremer.suiviobsmer.WaoBusinessException;
+import fr.ifremer.suiviobsmer.WaoBusinessException.Type;
+import fr.ifremer.suiviobsmer.WaoException;
+import fr.ifremer.suiviobsmer.WaoModelDAOHelper;
+import fr.ifremer.suiviobsmer.WaoContext;
import fr.ifremer.suiviobsmer.bean.FacadeRow;
import fr.ifremer.suiviobsmer.bean.FacadeRowImpl;
import fr.ifremer.suiviobsmer.bean.ImportResults;
@@ -87,21 +87,21 @@
protected TopiaContext rootContext;
- public ServiceSamplingImpl() throws SuiviObsmerException {
- rootContext = SuiviObsmerContext.getTopiaRootContext();
+ public ServiceSamplingImpl() throws WaoException {
+ rootContext = WaoContext.getTopiaRootContext();
}
@Override
- public void createUpdateSampleRow(SampleRow row, List<Boat> boats, SampleRowLog rowLog) throws SuiviObsmerException {
+ public void createUpdateSampleRow(SampleRow row, List<Boat> boats, SampleRowLog rowLog) throws WaoException {
TopiaContext transaction = null;
try {
transaction = rootContext.beginTransaction();
- SampleRowLogDAO logDAO = SuiviObsmerModelDAOHelper.getSampleRowLogDAO(transaction);
- SuiviObsmerContext.prepareTopiaId(SampleRowLog.class, rowLog);
+ SampleRowLogDAO logDAO = WaoModelDAOHelper.getSampleRowLogDAO(transaction);
+ WaoContext.prepareTopiaId(SampleRowLog.class, rowLog);
logDAO.update(rowLog);
- boolean newRow = SuiviObsmerContext.prepareTopiaId(SampleRow.class, row);
+ boolean newRow = WaoContext.prepareTopiaId(SampleRow.class, row);
if (log.isDebugEnabled()) {
log.debug("new sampleRow : " + newRow);
@@ -120,7 +120,7 @@
if (!newRow) {
// Prepare data for logging or deleting oldMonths
TopiaContext transaction2 = rootContext.beginTransaction();
- SampleRowDAO oldDAO = SuiviObsmerModelDAOHelper.getSampleRowDAO(transaction2);
+ SampleRowDAO oldDAO = WaoModelDAOHelper.getSampleRowDAO(transaction2);
oldRow = oldDAO.findByTopiaId(row.getTopiaId());
oldCompany = oldRow.getCompany();
oldProfession = oldRow.getProfession();
@@ -156,13 +156,13 @@
rowLog.addChangePeriod(oldPeriod, newPeriod, pattern);
// Save Profession
- ProfessionDAO professionDAO = SuiviObsmerModelDAOHelper.getProfessionDAO(transaction);
- SuiviObsmerContext.prepareTopiaId(Profession.class, row.getProfession());
+ ProfessionDAO professionDAO = WaoModelDAOHelper.getProfessionDAO(transaction);
+ WaoContext.prepareTopiaId(Profession.class, row.getProfession());
rowLog.addChangeProfession(oldProfession, row.getProfession());
professionDAO.update(row.getProfession());
// Save sampleMonth
- SampleMonthDAO monthDAO = SuiviObsmerModelDAOHelper.getSampleMonthDAO(transaction);
+ SampleMonthDAO monthDAO = WaoModelDAOHelper.getSampleMonthDAO(transaction);
// Delete oldMonths
List<SampleMonth> newMonths = row.getSampleMonth();
@@ -177,7 +177,7 @@
}
// Create or update months
for (SampleMonth month : newMonths) {
- boolean monthCreated = SuiviObsmerContext.prepareTopiaId(SampleMonth.class, month);
+ boolean monthCreated = WaoContext.prepareTopiaId(SampleMonth.class, month);
String date = dateFormat.format(month.getPeriodDate());
if (monthCreated) {
// log create month
@@ -196,7 +196,7 @@
// Remove no longer elligibleBoats
row.removeNoLongerElligibleBoats(boats);
// Save new elligibleBoats
- ElligibleBoatDAO dao = SuiviObsmerModelDAOHelper.getElligibleBoatDAO(transaction);
+ ElligibleBoatDAO dao = WaoModelDAOHelper.getElligibleBoatDAO(transaction);
for (Boat boat : boats) {
if (!row.hasElligibleBoat(boat)) {
ElligibleBoat elligibleBoat = dao.create();
@@ -230,7 +230,7 @@
}
// Save sampleRow : create or update
- SampleRowDAO rowDAO = SuiviObsmerModelDAOHelper.getSampleRowDAO(transaction);
+ SampleRowDAO rowDAO = WaoModelDAOHelper.getSampleRowDAO(transaction);
if (log.isDebugEnabled()) {
log.debug("update row : " + row);
}
@@ -244,17 +244,17 @@
transaction.commitTransaction();
//transaction.closeContext();
} catch (Exception eee) {
- SuiviObsmerContext.serviceException(transaction,
+ WaoContext.serviceException(transaction,
"Impossible de sauvegarder la ligne d'échantillon", eee);
} finally {
- SuiviObsmerContext.closeTransaction(transaction);
+ WaoContext.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 = SuiviObsmerModelDAOHelper.getFishingZoneDAO(transaction);
+ FishingZoneDAO fishingZoneDAO = WaoModelDAOHelper.getFishingZoneDAO(transaction);
FishingZone zoneFromDB = fishingZoneDAO.findByTopiaId(zoneId);
if (delete) {
zoneFromDB.removeSampleRow(row);
@@ -265,25 +265,25 @@
}
// @Override
-// public List<SampleRowLog> getSampleRowLogs(SampleRow sampleRow) throws SuiviObsmerException {
+// public List<SampleRowLog> getSampleRowLogs(SampleRow sampleRow) throws WaoException {
// TopiaContext transaction = null;
// List<SampleRowLog> results = new ArrayList<SampleRowLog>();
// try {
// transaction = rootContext.beginTransaction();
//
-// SampleRowLogDAO dao = SuiviObsmerModelDAOHelper.getSampleRowLogDAO(transaction);
+// SampleRowLogDAO dao = WaoModelDAOHelper.getSampleRowLogDAO(transaction);
// results = dao.createQuery().add(SampleRowLog.SAMPLE_ROW, sampleRow).addOrderDesc(TopiaEntity.TOPIA_CREATE_DATE).executeToEntityList();
//
// transaction.closeContext();
// } catch (Exception eee) {
-// SuiviObsmerContext.serviceException(transaction,
+// WaoContext.serviceException(transaction,
// "Impossible de récupérer l'historique de la ligne d'échantillonnage", eee);
// }
// return results;
// }
@Override
- public FacadeRow getSampleRowsOrderedByFishingZone(PeriodDates period, Company company) throws SuiviObsmerException {
+ public FacadeRow getSampleRowsOrderedByFishingZone(PeriodDates period, Company company) throws WaoException {
TopiaContext transaction = null;
FacadeRow result = new FacadeRowImpl();
try {
@@ -292,7 +292,7 @@
}
transaction = rootContext.beginTransaction();
- SampleRowDAO dao = SuiviObsmerModelDAOHelper.getSampleRowDAO(transaction);
+ SampleRowDAO dao = WaoModelDAOHelper.getSampleRowDAO(transaction);
TopiaQuery query = dao.createQuery("S").addDistinct().
addFrom(FishingZone.class.getName() + " F").
@@ -326,22 +326,22 @@
//transaction.closeContext();
} catch (Exception eee) {
- SuiviObsmerContext.serviceException(transaction,
+ WaoContext.serviceException(transaction,
"Impossible de récupérer la liste des lignes du plan d'échantillonnage", eee);
} finally {
- SuiviObsmerContext.closeTransaction(transaction);
+ WaoContext.closeTransaction(transaction);
}
return result;
}
@Override
- public List<String> getPrograms(Company company) throws SuiviObsmerException {
+ public List<String> getPrograms(Company company) throws WaoException {
TopiaContext transaction = null;
List<String> results = new ArrayList<String>();
try {
transaction = rootContext.beginTransaction();
- SampleRowDAO dao = SuiviObsmerModelDAOHelper.getSampleRowDAO(transaction);
+ SampleRowDAO dao = WaoModelDAOHelper.getSampleRowDAO(transaction);
TopiaQuery query = dao.createQuery();
if (company != null) {
@@ -352,22 +352,22 @@
//transaction.closeContext();
} catch (Exception eee) {
- SuiviObsmerContext.serviceException(transaction,
+ WaoContext.serviceException(transaction,
"Impossible de charger la liste des programmes", eee);
} finally {
- SuiviObsmerContext.closeTransaction(transaction);
+ WaoContext.closeTransaction(transaction);
}
return results;
}
@Override
- public List<SampleRow> getSampleRowsByFilter(SamplingFilter filter) throws SuiviObsmerException {
+ public List<SampleRow> getSampleRowsByFilter(SamplingFilter filter) throws WaoException {
TopiaContext transaction = null;
List<SampleRow> results = new ArrayList<SampleRow>();
try {
transaction = rootContext.beginTransaction();
- SampleRowDAO dao = SuiviObsmerModelDAOHelper.getSampleRowDAO(transaction);
+ SampleRowDAO dao = WaoModelDAOHelper.getSampleRowDAO(transaction);
TopiaQuery query = dao.createQuery("S").addDistinct().addOrder("S." + SampleRow.CODE);
@@ -379,7 +379,7 @@
// if (finished) {
// // Only rows which are not finished will be kept
-// Date current = SuiviObsmerContext.getCurrentDate();
+// Date current = WaoContext.getCurrentDate();
// query.add(SampleRow.PERIOD_END, Op.GE, current);
// }
@@ -391,43 +391,43 @@
//transaction.closeContext();
} catch (Exception eee) {
- SuiviObsmerContext.serviceException(transaction,
+ WaoContext.serviceException(transaction,
"Impossible de récupérer la liste des lignes du plan d'échantillonnage", eee);
} finally {
- SuiviObsmerContext.closeTransaction(transaction);
+ WaoContext.closeTransaction(transaction);
}
return results;
}
@Override
- public SampleRow getSampleRow(String sampleRowId) throws SuiviObsmerException {
+ public SampleRow getSampleRow(String sampleRowId) throws WaoException {
TopiaContext transaction = null;
SampleRow result = null;
try {
transaction = rootContext.beginTransaction();
- SampleRowDAO dao = SuiviObsmerModelDAOHelper.getSampleRowDAO(transaction);
+ SampleRowDAO dao = WaoModelDAOHelper.getSampleRowDAO(transaction);
result = dao.findByTopiaId(sampleRowId);
//transaction.closeContext();
} catch (Exception eee) {
- SuiviObsmerContext.serviceException(transaction,
+ WaoContext.serviceException(transaction,
"Impossible de charger la ligne d'échantillon ayant pour identifiant : " + sampleRowId,
eee);
} finally {
- SuiviObsmerContext.closeTransaction(transaction);
+ WaoContext.closeTransaction(transaction);
}
return result;
}
@Override
- public void deleteSampleRow(SampleRow sampleRow) throws SuiviObsmerException {
+ public void deleteSampleRow(SampleRow sampleRow) throws WaoException {
TopiaContext transaction = null;
try {
transaction = rootContext.beginTransaction();
- SampleRowDAO dao = SuiviObsmerModelDAOHelper.getSampleRowDAO(transaction);
+ SampleRowDAO dao = WaoModelDAOHelper.getSampleRowDAO(transaction);
SampleRow row = dao.findByTopiaId(sampleRow.getTopiaId());
@@ -436,16 +436,16 @@
transaction.commitTransaction();
//transaction.closeContext();
} catch (Exception eee) {
- SuiviObsmerContext.serviceException(transaction,
+ WaoContext.serviceException(transaction,
"Impossible de supprimer la ligne d'échantillon : " + sampleRow.getCode(),
eee);
} finally {
- SuiviObsmerContext.closeTransaction(transaction);
+ WaoContext.closeTransaction(transaction);
}
}
@Override
- public String getNewSampleRowCode(Date beginDate) throws SuiviObsmerException {
+ public String getNewSampleRowCode(Date beginDate) throws WaoException {
TopiaContext transaction = null;
String result = null;
if (beginDate == null) {
@@ -458,7 +458,7 @@
begin.setTime(beginDate);
int year = begin.get(Calendar.YEAR);
- SampleRowDAO dao = SuiviObsmerModelDAOHelper.getSampleRowDAO(transaction);
+ SampleRowDAO dao = WaoModelDAOHelper.getSampleRowDAO(transaction);
TopiaQuery query = dao.createQuery().add(SampleRow.CODE, Op.LIKE, year + "_%");
String maxCode = query.executeToString("MAX(" + SampleRow.CODE + ")");
@@ -477,11 +477,11 @@
//transaction.closeContext();
} catch (Exception eee) {
- SuiviObsmerContext.serviceException(transaction,
+ WaoContext.serviceException(transaction,
"Impossible de récupérer un nouveau code pour une ligne d'échantillonnage",
eee);
} finally {
- SuiviObsmerContext.closeTransaction(transaction);
+ WaoContext.closeTransaction(transaction);
}
return result;
}
@@ -522,7 +522,7 @@
}
@Override
- public InputStream exportSamplingPlanCsv(WaoUser user, PeriodDates period) throws SuiviObsmerException {
+ public InputStream exportSamplingPlanCsv(WaoUser user, PeriodDates period) throws WaoException {
TopiaContext transaction = null;
InputStream result = null;
CsvWriter writer = null;
@@ -549,7 +549,7 @@
// Get sampleRows from database filtered by company if needed
// (only for user) and period
- SampleRowDAO dao = SuiviObsmerModelDAOHelper.getSampleRowDAO(transaction);
+ SampleRowDAO dao = WaoModelDAOHelper.getSampleRowDAO(transaction);
TopiaQuery query = dao.createQuery("S");
if (!user.getAdmin()) {
@@ -642,7 +642,7 @@
} catch (Exception eee) {
DateFormat dateFormat = SAMPLING.getDateFormat();
- SuiviObsmerContext.serviceException(transaction,
+ WaoContext.serviceException(transaction,
"Impossible d'exporter le plan d'échantillonnage sur la période du " +
dateFormat.format(period.getFromDate()) + " au " +
dateFormat.format(period.getThruDate()), eee);
@@ -650,13 +650,13 @@
if (writer != null) {
writer.close();
}
- SuiviObsmerContext.closeTransaction(transaction);
+ WaoContext.closeTransaction(transaction);
}
return result;
}
@Override
- public ImportResults importSamplingPlanCsv(InputStream input) throws SuiviObsmerException {
+ public ImportResults importSamplingPlanCsv(InputStream input) throws WaoException {
TopiaContext transaction = null;
ImportResults result = new ImportResultsImpl();
//int[] result = new int[3];
@@ -668,7 +668,7 @@
CsvReader reader = new CsvReader(input, Charset.forName("UTF-8"));
reader.readHeaders();
- SampleRowDAO dao = SuiviObsmerModelDAOHelper.getSampleRowDAO(transaction);
+ SampleRowDAO dao = WaoModelDAOHelper.getSampleRowDAO(transaction);
//int nbImported = 0;
//int nbRefused = 0;
@@ -705,10 +705,10 @@
// Create link with company if set in file
if (!StringUtils.isEmpty(companyName)) {
- CompanyDAO companyDAO = SuiviObsmerModelDAOHelper.getCompanyDAO(transaction);
+ CompanyDAO companyDAO = WaoModelDAOHelper.getCompanyDAO(transaction);
Company company = companyDAO.findByName(companyName);
if (company == null) {
- throw new SuiviObsmerBusinessException(Type.IMPORT_ERROR, this.getClass(),
+ throw new WaoBusinessException(Type.IMPORT_ERROR, this.getClass(),
"Erreur à la ligne " + currRow + " [CODE = " + code + "] : " +
"La société portant le nom '" + companyName + "' n'existe pas dans l'application");
}
@@ -720,7 +720,7 @@
row.setProfession(profession);
// Import zones and set them to the row
- // throw SuiviObsmerException if FishingZone doesn't exist
+ // throw WaoException if FishingZone doesn't exist
importFishingZones(transaction, districts, currRow, row);
updateRow(transaction, row, reader);
@@ -733,19 +733,19 @@
//transaction.closeContext();
} catch (NumberFormatException eee) {
- SuiviObsmerContext.serviceException(transaction,
+ WaoContext.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) {
- SuiviObsmerContext.serviceException(transaction,
+ WaoContext.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) {
- SuiviObsmerContext.serviceException(transaction,
+ WaoContext.serviceException(transaction,
"Erreur à la ligne " + currRow + " [CODE = " + row.getCode() + "]",
eee);
} finally {
- SuiviObsmerContext.closeTransaction(transaction);
+ WaoContext.closeTransaction(transaction);
}
return result;
}
@@ -771,7 +771,7 @@
String libelle = reader.get(SAMPLING.METIER_LIBELLE.name()).trim();
String especes = reader.get(SAMPLING.METIER_ESPECES.name()).trim();
- ProfessionDAO dao = SuiviObsmerModelDAOHelper.getProfessionDAO(transaction);
+ ProfessionDAO dao = WaoModelDAOHelper.getProfessionDAO(transaction);
Map<String, Object> existParams = new HashMap<String, Object>();
existParams.put(Profession.CODE_DCF5, codeDCF5);
existParams.put(Profession.MESH_SIZE, maillage);
@@ -801,12 +801,12 @@
* @param currRow Row number in the line for the SampleRow
* @param row SampleRow linked with districts (from Csv file)
* @throws TopiaException for dao errors
- * @throws SuiviObsmerException if a FishingZone doesn't exist.
+ * @throws WaoException if a FishingZone doesn't exist.
*/
protected void importFishingZones(TopiaContext transaction, String districts, int currRow, SampleRow row)
- throws TopiaException, SuiviObsmerException {
+ throws TopiaException, WaoException {
- FishingZoneDAO dao = SuiviObsmerModelDAOHelper.getFishingZoneDAO(transaction);
+ FishingZoneDAO dao = WaoModelDAOHelper.getFishingZoneDAO(transaction);
List<String> districtList = new ArrayList<String>(Arrays.asList(districts.split(FISHING_ZONE.getDistrictCodeSeparator())));
@@ -817,7 +817,7 @@
for (String districtCode : districtList) {
FishingZone zone = dao.findByDistrictCode(districtCode.trim());
if (zone == null) {
- throw new SuiviObsmerBusinessException(Type.IMPORT_ERROR, this.getClass(),
+ throw new WaoBusinessException(Type.IMPORT_ERROR, this.getClass(),
"Erreur à la ligne " + currRow + " [CODE = " + row.getCode() + "] : " +
"Cette ligne est lié à une zone inexistante : " + districtCode);
}
@@ -875,7 +875,7 @@
Integer monthValue = StringUtils.isEmpty(reader.get(i)) ? null : Integer.parseInt(reader.get(i));
if (monthValue != null && DateUtils.between(monthDate, sampleRow.getPeriodBegin(), sampleRow.getPeriodEnd())) {
- SampleMonthDAO dao = SuiviObsmerModelDAOHelper.getSampleMonthDAO(transaction);
+ SampleMonthDAO dao = WaoModelDAOHelper.getSampleMonthDAO(transaction);
SampleMonth month = sampleRow.getSampleMonth(monthDate);
Modified: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services/ServiceSynthesisImpl.java
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services/ServiceSynthesisImpl.java 2010-02-16 10:56:02 UTC (rev 353)
+++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services/ServiceSynthesisImpl.java 2010-02-16 12:00:05 UTC (rev 354)
@@ -1,6 +1,6 @@
/*
* *##%
- * SuiviObsmer :: Business
+ * Wao :: Business
* Copyright (C) 2009 - 2010 Ifremer
*
* This program is free software: you can redistribute it and/or modify
@@ -21,9 +21,9 @@
package fr.ifremer.suiviobsmer.services;
-import fr.ifremer.suiviobsmer.SuiviObsmerContext;
-import fr.ifremer.suiviobsmer.SuiviObsmerException;
-import fr.ifremer.suiviobsmer.SuiviObsmerModelDAOHelper;
+import fr.ifremer.suiviobsmer.WaoContext;
+import fr.ifremer.suiviobsmer.WaoException;
+import fr.ifremer.suiviobsmer.WaoModelDAOHelper;
import fr.ifremer.suiviobsmer.bean.ContactAverageReactivityImpl;
import fr.ifremer.suiviobsmer.bean.ContactAverageReactivity;
import fr.ifremer.suiviobsmer.bean.BoardingResult;
@@ -76,12 +76,12 @@
protected TopiaContext rootContext;
- public ServiceSynthesisImpl() throws SuiviObsmerException {
- rootContext = SuiviObsmerContext.getTopiaRootContext();
+ public ServiceSynthesisImpl() throws WaoException {
+ rootContext = WaoContext.getTopiaRootContext();
}
@Override
- public List<SortedMap<Date, Integer>> getDataSampling(SamplingFilter filter) throws SuiviObsmerException {
+ public List<SortedMap<Date, Integer>> getDataSampling(SamplingFilter filter) throws WaoException {
TopiaContext transaction = null;
List<SortedMap<Date, Integer>> results = new ArrayList<SortedMap<Date, Integer>>();
try {
@@ -106,7 +106,7 @@
serie2.put(month, 0);
}
- SampleMonthDAO dao = SuiviObsmerModelDAOHelper.getSampleMonthDAO(transaction);
+ SampleMonthDAO dao = WaoModelDAOHelper.getSampleMonthDAO(transaction);
String periodDate = "M." + SampleMonth.PERIOD_DATE;
TopiaQuery query = dao.createQuery("M").
setSelect(periodDate).
@@ -138,10 +138,10 @@
//transaction.closeContext();
} catch (Exception eee) {
- SuiviObsmerContext.serviceException(transaction,
+ WaoContext.serviceException(transaction,
"Impossible de récupérer les données pour le graphique dynamique des efforts de marées", eee);
} finally {
- SuiviObsmerContext.closeTransaction(transaction);
+ WaoContext.closeTransaction(transaction);
}
return results;
}
@@ -158,11 +158,11 @@
* @return a BoardingResult which contains the number of boats for boardings
* from 1 to {@link MAX_BOARDINGS}, the boat with the max boarding and its
* value.
- * @throws SuiviObsmerException
+ * @throws WaoException
*/
@Override
public BoardingResult getBoardingBoats(Company company, Date fromDate)
- throws SuiviObsmerException {
+ throws WaoException {
TopiaContext transaction = null;
Map<String, Integer> map = new LinkedHashMap<String, Integer>();
BoardingResult result = new BoardingResultImpl();
@@ -182,7 +182,7 @@
map.put(maxBoardingsKey, 0);
ContactDAO dao =
- SuiviObsmerModelDAOHelper.getContactDAO(transaction);
+ WaoModelDAOHelper.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
@@ -240,17 +240,17 @@
//transaction.closeContext();
} catch (Exception eee) {
- SuiviObsmerContext.serviceException(transaction,
+ WaoContext.serviceException(transaction,
"Impossible de récupérer les données pour le graphique " +
"dynamique des efforts de marées", eee);
} finally {
- SuiviObsmerContext.closeTransaction(transaction);
+ WaoContext.closeTransaction(transaction);
}
return result;
}
@Override
- public Map<String, Double> getNonComplianceBoardingIndicator(Company company) throws SuiviObsmerException {
+ public Map<String, Double> getNonComplianceBoardingIndicator(Company company) throws WaoException {
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
@@ -258,7 +258,7 @@
try {
transaction = rootContext.beginTransaction();
- ContactDAO dao = SuiviObsmerModelDAOHelper.getContactDAO(transaction);
+ ContactDAO dao = WaoModelDAOHelper.getContactDAO(transaction);
// Only for done contacts with no constraint
TopiaQuery query =
@@ -270,7 +270,7 @@
String companyName = companyProp + "." + Company.NAME;
// Only for unfinished sampleRows
- Date current = SuiviObsmerContext.getCurrentDate();
+ Date current = WaoContext.getCurrentDate();
query.add(sampleRow + "." + SampleRow.PERIOD_END, Op.GE, current);
if (company != null) {
@@ -330,23 +330,23 @@
if (company != null) {
msgEnd = " pour la société " + company.getName();
}
- SuiviObsmerContext.serviceException(transaction,
+ WaoContext.serviceException(transaction,
"Impossible de récupérer l'indicateur de non respect du " +
"nombre d'observateurs embarqués" + msgEnd, eee);
} finally {
- SuiviObsmerContext.closeTransaction(transaction);
+ WaoContext.closeTransaction(transaction);
}
return results;
}
@Override
- public Collection<ContactStateStatistics> getContactStateStatistics(Company company, PeriodDates period) throws SuiviObsmerException {
+ public Collection<ContactStateStatistics> getContactStateStatistics(Company company, PeriodDates period) throws WaoException {
TopiaContext transaction = null;
Map<String, ContactStateStatistics> results = new HashMap<String, ContactStateStatistics>();
try {
transaction = rootContext.beginTransaction();
- ContactDAO dao = SuiviObsmerModelDAOHelper.getContactDAO(transaction);
+ ContactDAO dao = WaoModelDAOHelper.getContactDAO(transaction);
// Only for contacts not refused by the program
String contact = "C";
@@ -410,17 +410,17 @@
if (company != null) {
msgEnd = " pour la société " + company.getName();
}
- SuiviObsmerContext.serviceException(transaction,
+ WaoContext.serviceException(transaction,
"Impossible de récupérer les statistiques sur les états des " +
"contacts " + msgEnd, eee);
} finally {
- SuiviObsmerContext.closeTransaction(transaction);
+ WaoContext.closeTransaction(transaction);
}
return results.values();
}
@Override
- public Collection<ContactAverageReactivity> getContactDataInputDateReactivity(Company company, PeriodDates period) throws SuiviObsmerException {
+ public Collection<ContactAverageReactivity> getContactDataInputDateReactivity(Company company, PeriodDates period) throws WaoException {
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
@@ -429,7 +429,7 @@
try {
transaction = rootContext.beginTransaction();
- ContactDAO dao = SuiviObsmerModelDAOHelper.getContactDAO(transaction);
+ ContactDAO dao = WaoModelDAOHelper.getContactDAO(transaction);
// String contact = "C";
// TopiaQuery query = dao.createQuery(contact);
@@ -521,11 +521,11 @@
if (company != null) {
msgEnd = " pour la société " + company.getName();
}
- SuiviObsmerContext.serviceException(transaction,
+ WaoContext.serviceException(transaction,
"Impossible de récupérer l'indicateur de réactivité sur " +
"les dates de saisies dans Allegro" + msgEnd, eee);
} finally {
- SuiviObsmerContext.closeTransaction(transaction);
+ WaoContext.closeTransaction(transaction);
}
return results.values();
}
Modified: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services/ServiceUserImpl.java
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services/ServiceUserImpl.java 2010-02-16 10:56:02 UTC (rev 353)
+++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services/ServiceUserImpl.java 2010-02-16 12:00:05 UTC (rev 354)
@@ -1,6 +1,6 @@
/*
* *##%
- * SuiviObsmer :: Business
+ * Wao :: Business
* Copyright (C) 2009 - 2010 Ifremer
*
* This program is free software: you can redistribute it and/or modify
@@ -21,11 +21,11 @@
package fr.ifremer.suiviobsmer.services;
-import fr.ifremer.suiviobsmer.SuiviObsmerBusinessException;
-import fr.ifremer.suiviobsmer.SuiviObsmerBusinessException.Type;
-import fr.ifremer.suiviobsmer.SuiviObsmerException;
-import fr.ifremer.suiviobsmer.SuiviObsmerModelDAOHelper;
-import fr.ifremer.suiviobsmer.SuiviObsmerContext;
+import fr.ifremer.suiviobsmer.WaoBusinessException;
+import fr.ifremer.suiviobsmer.WaoBusinessException.Type;
+import fr.ifremer.suiviobsmer.WaoException;
+import fr.ifremer.suiviobsmer.WaoModelDAOHelper;
+import fr.ifremer.suiviobsmer.WaoContext;
import fr.ifremer.suiviobsmer.entity.Company;
import fr.ifremer.suiviobsmer.entity.CompanyDAO;
import fr.ifremer.suiviobsmer.entity.Contact;
@@ -58,63 +58,63 @@
protected TopiaContext rootContext;
- public ServiceUserImpl() throws SuiviObsmerException {
- rootContext = SuiviObsmerContext.getTopiaRootContext();
+ public ServiceUserImpl() throws WaoException {
+ rootContext = WaoContext.getTopiaRootContext();
}
@Override
- public WaoUser connect(String login, String password) throws SuiviObsmerException {
+ public WaoUser connect(String login, String password) throws WaoException {
TopiaContext transaction = null;
WaoUser user = null;
try {
transaction = rootContext.beginTransaction();
- WaoUserDAO dao = SuiviObsmerModelDAOHelper.getWaoUserDAO(transaction);
+ WaoUserDAO dao = WaoModelDAOHelper.getWaoUserDAO(transaction);
- String passwordEncoded = SuiviObsmerContext.encodeString(password);
+ String passwordEncoded = WaoContext.encodeString(password);
user = dao.findByProperties(WaoUser.LOGIN, login, WaoUser.PASSWORD, passwordEncoded);
if (user != null && user.getActive()) {
// load company entity
user.getCompany();
} else if (user != null && !user.getActive()) {
- throw new SuiviObsmerBusinessException(Type.ILLEGAL_CONNECTION, this.getClass(),
+ throw new WaoBusinessException(Type.ILLEGAL_CONNECTION, this.getClass(),
"Vous n'avez plus les droits nécessaires pour vous connecter. Veuillez contacter un administrateur.");
} else {
- throw new SuiviObsmerBusinessException(Type.BAD_CONNECTION, this.getClass(),
+ throw new WaoBusinessException(Type.BAD_CONNECTION, this.getClass(),
"Identifiant ou mot de passe incorrects, veuillez réessayer.");
}
//transaction.closeContext();
} catch (Exception eee) {
- SuiviObsmerContext.serviceException(transaction, "Une erreur est survenue lors de la demande de connexion", eee);
+ WaoContext.serviceException(transaction, "Une erreur est survenue lors de la demande de connexion", eee);
} finally {
- SuiviObsmerContext.closeTransaction(transaction);
+ WaoContext.closeTransaction(transaction);
}
return user;
}
@Override
- public void forgetPassword(String login) throws SuiviObsmerException {
+ public void forgetPassword(String login) throws WaoException {
TopiaContext transaction = null;
try {
if (!login.contains("@")) {
- throw new SuiviObsmerBusinessException(Type.SYNTAX, this.getClass(), "Votre identifiant n'est pas un email valide, " +
+ throw new WaoBusinessException(Type.SYNTAX, this.getClass(), "Votre identifiant n'est pas un email valide, " +
"veuillez contacter un administrateur pour qu'il puisse changer votre mot de passe.");
}
transaction = rootContext.beginTransaction();
- WaoUserDAO dao = SuiviObsmerModelDAOHelper.getWaoUserDAO(transaction);
+ WaoUserDAO dao = WaoModelDAOHelper.getWaoUserDAO(transaction);
WaoUser user = dao.findByLogin(login);
if (user == null) {
- throw new SuiviObsmerBusinessException(Type.NOT_EXISTS, this.getClass(),
+ throw new WaoBusinessException(Type.NOT_EXISTS, this.getClass(),
"L'email '" + login + "' n'est pas référencé dans l'application.");
}
- String password = SuiviObsmerContext.createRandomString(8);
- String passwordEncoded = SuiviObsmerContext.encodeString(password);
+ String password = WaoContext.createRandomString(8);
+ String passwordEncoded = WaoContext.encodeString(password);
user.setPassword(passwordEncoded);
String subject = "[WAO] Mot de passe oublié";
@@ -122,11 +122,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://" + SuiviObsmerContext.getProperty(SuiviObsmerContext.PROP_SERVER) + "\n\n" +
+ "\t\thttp://" + WaoContext.getProperty(WaoContext.PROP_SERVER) + "\n\n" +
"Cordialement,\n\n" +
"L'Equipe WAO";
- SuiviObsmerContext.sendEmail(user.getLogin(), subject, msg);
+ WaoContext.sendEmail(user.getLogin(), subject, msg);
if (log.isDebugEnabled()) {
log.debug("send email to : " + user.getLogin());
}
@@ -134,14 +134,14 @@
transaction.commitTransaction();
//transaction.closeContext();
} catch (Exception eee) {
- SuiviObsmerContext.serviceException(transaction, "Impossible de créer ou de mettre à jour l'utilisateur", eee);
+ WaoContext.serviceException(transaction, "Impossible de créer ou de mettre à jour l'utilisateur", eee);
} finally {
- SuiviObsmerContext.closeTransaction(transaction);
+ WaoContext.closeTransaction(transaction);
}
}
@Override
- public void createUpdateUser(WaoUser user, boolean generatePassword) throws SuiviObsmerException {
+ public void createUpdateUser(WaoUser user, boolean generatePassword) throws WaoException {
TopiaContext transaction = null;
try {
if (user == null) {
@@ -150,15 +150,15 @@
transaction = rootContext.beginTransaction();
- WaoUserDAO dao = SuiviObsmerModelDAOHelper.getWaoUserDAO(transaction);
+ WaoUserDAO dao = WaoModelDAOHelper.getWaoUserDAO(transaction);
- boolean newUser = SuiviObsmerContext.prepareTopiaId(WaoUser.class, user);
+ boolean newUser = WaoContext.prepareTopiaId(WaoUser.class, user);
// Check for a new user if login already exists
if (newUser) {
WaoUser existUser = dao.findByLogin(user.getLogin());
if (existUser != null) {
- throw new SuiviObsmerBusinessException(Type.ALREADY_EXISTS, this.getClass(),
+ throw new WaoBusinessException(Type.ALREADY_EXISTS, this.getClass(),
"Un utilisateur existe déjà avec ce login " + user.getLogin());
}
}
@@ -166,7 +166,7 @@
String password = user.getPassword();
if (generatePassword) {
- password = SuiviObsmerContext.createRandomString(8);
+ password = WaoContext.createRandomString(8);
user.setPasswordChanged(true);
// if (log.isDebugEnabled()) {
// log.debug("show generated password : " + password);
@@ -174,7 +174,7 @@
}
// For a password set manually by user or generated
if (user.isPasswordChanged()) {
- String passwordEncoded = SuiviObsmerContext.encodeString(password);
+ String passwordEncoded = WaoContext.encodeString(password);
user.setPassword(passwordEncoded);
}
@@ -191,7 +191,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://" + SuiviObsmerContext.getProperty(SuiviObsmerContext.PROP_SERVER) + "\n\n";
+ "\t\thttp://" + WaoContext.getProperty(WaoContext.PROP_SERVER) + "\n\n";
} else {
subject += "Modification de votre compte";
if (generatePassword) {
@@ -206,7 +206,7 @@
msg += "Cordialement,\n\n" +
"L'Equipe WAO";
- SuiviObsmerContext.sendEmail(user.getLogin(), subject, msg);
+ WaoContext.sendEmail(user.getLogin(), subject, msg);
// if (log.isDebugEnabled()) {
// log.debug("send email to : " + user.getLogin());
// }
@@ -215,14 +215,14 @@
transaction.commitTransaction();
//transaction.closeContext();
} catch (Exception eee) {
- SuiviObsmerContext.serviceException(transaction, "Impossible de créer ou de mettre à jour l'utilisateur", eee);
+ WaoContext.serviceException(transaction, "Impossible de créer ou de mettre à jour l'utilisateur", eee);
} finally {
- SuiviObsmerContext.closeTransaction(transaction);
+ WaoContext.closeTransaction(transaction);
}
}
@Override
- public void deleteUser(WaoUser user) throws SuiviObsmerException {
+ public void deleteUser(WaoUser user) throws WaoException {
TopiaContext transaction = null;
try {
transaction = rootContext.beginTransaction();
@@ -232,40 +232,40 @@
String msgEnd = "Vous pouvez cependant le désactiver pour qu'il ne puisse plus se connecter.";
if (user.getAdmin()) {
- SampleRowLogDAO logDAO = SuiviObsmerModelDAOHelper.getSampleRowLogDAO(transaction);
+ SampleRowLogDAO logDAO = WaoModelDAOHelper.getSampleRowLogDAO(transaction);
List<SampleRowLog> results = logDAO.findAllByAdmin(user);
if (!results.isEmpty()) {
- throw new SuiviObsmerBusinessException(Type.ALREADY_EXISTS, this.getClass(),
+ throw new WaoBusinessException(Type.ALREADY_EXISTS, this.getClass(),
msgBegin + " car il a participé à la modification du plan d'échantillonnage. " + msgEnd);
}
} else {
- ContactDAO contactDAO = SuiviObsmerModelDAOHelper.getContactDAO(transaction);
+ ContactDAO contactDAO = WaoModelDAOHelper.getContactDAO(transaction);
List<Contact> results = contactDAO.findAllByObserver(user);
if (!results.isEmpty()) {
- throw new SuiviObsmerBusinessException(Type.ALREADY_EXISTS, this.getClass(),
+ throw new WaoBusinessException(Type.ALREADY_EXISTS, this.getClass(),
msgBegin + " car il est lié à plusieurs contacts existants. " + msgEnd);
}
}
- WaoUserDAO dao = SuiviObsmerModelDAOHelper.getWaoUserDAO(transaction);
+ WaoUserDAO dao = WaoModelDAOHelper.getWaoUserDAO(transaction);
dao.delete(user);
transaction.commitTransaction();
//transaction.closeContext();
} catch (Exception eee) {
- SuiviObsmerContext.serviceException(transaction, "Impossible de créer ou de mettre à jour l'utilisateur", eee);
+ WaoContext.serviceException(transaction, "Impossible de créer ou de mettre à jour l'utilisateur", eee);
} finally {
- SuiviObsmerContext.closeTransaction(transaction);
+ WaoContext.closeTransaction(transaction);
}
}
@Override
- public void createUpdateCompany(Company company) throws SuiviObsmerException {
+ public void createUpdateCompany(Company company) throws WaoException {
TopiaContext transaction = null;
try {
if (company == null) {
@@ -274,28 +274,28 @@
transaction = rootContext.beginTransaction();
- CompanyDAO dao = SuiviObsmerModelDAOHelper.getCompanyDAO(transaction);
+ CompanyDAO dao = WaoModelDAOHelper.getCompanyDAO(transaction);
- SuiviObsmerContext.prepareTopiaId(Company.class, company);
+ WaoContext.prepareTopiaId(Company.class, company);
dao.update(company);
transaction.commitTransaction();
//transaction.closeContext();
} catch (Exception eee) {
- SuiviObsmerContext.serviceException(transaction, "Impossible de créer ou de mettre à jour la société", eee);
+ WaoContext.serviceException(transaction, "Impossible de créer ou de mettre à jour la société", eee);
} finally {
- SuiviObsmerContext.closeTransaction(transaction);
+ WaoContext.closeTransaction(transaction);
}
}
@Override
- public List<Company> getCompanies(boolean activeOnly) throws SuiviObsmerException {
+ public List<Company> getCompanies(boolean activeOnly) throws WaoException {
TopiaContext transaction = null;
List<Company> results = new ArrayList<Company>();
try {
transaction = rootContext.beginTransaction();
- CompanyDAO dao = SuiviObsmerModelDAOHelper.getCompanyDAO(transaction);
+ CompanyDAO dao = WaoModelDAOHelper.getCompanyDAO(transaction);
if (activeOnly) {
results = dao.findAllByActive(activeOnly);
@@ -305,21 +305,21 @@
//transaction.closeContext();
} catch (Exception eee) {
- SuiviObsmerContext.serviceException(transaction, "Impossible de récupérer la liste des sociétés", eee);
+ WaoContext.serviceException(transaction, "Impossible de récupérer la liste des sociétés", eee);
} finally {
- SuiviObsmerContext.closeTransaction(transaction);
+ WaoContext.closeTransaction(transaction);
}
return results;
}
@Override
- public List<WaoUser> getObservers(boolean activeOnly) throws SuiviObsmerException {
+ public List<WaoUser> getObservers(boolean activeOnly) throws WaoException {
TopiaContext transaction = null;
List<WaoUser> results = new ArrayList<WaoUser>();
try {
transaction = rootContext.beginTransaction();
- WaoUserDAO dao = SuiviObsmerModelDAOHelper.getWaoUserDAO(transaction);
+ WaoUserDAO dao = WaoModelDAOHelper.getWaoUserDAO(transaction);
TopiaQuery query = dao.createQuery().add(WaoUser.ADMIN, Boolean.FALSE);
if (activeOnly) {
@@ -330,9 +330,9 @@
//transaction.closeContext();
} catch (Exception eee) {
- SuiviObsmerContext.serviceException(transaction, "Impossible de récupérer la liste des observateurs", eee);
+ WaoContext.serviceException(transaction, "Impossible de récupérer la liste des observateurs", eee);
} finally {
- SuiviObsmerContext.closeTransaction(transaction);
+ WaoContext.closeTransaction(transaction);
}
return results;
}
Added: trunk/suiviobsmer-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/ActivityCalendarImpl.hbm.xml
===================================================================
--- trunk/suiviobsmer-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/ActivityCalendarImpl.hbm.xml (rev 0)
+++ trunk/suiviobsmer-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/ActivityCalendarImpl.hbm.xml 2010-02-16 12:00:05 UTC (rev 354)
@@ -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.suiviobsmer.entity">
+ <class name="fr.ifremer.suiviobsmer.entity.ActivityCalendarImpl" table="activityCalendar" node="fr.ifremer.suiviobsmer.entity.ActivityCalendarImpl" abstract="false" proxy="fr.ifremer.suiviobsmer.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.suiviobsmer.entity.ActivityMonthImpl" node="topiaId" embed-xml="false"/>
+ </bag>
+ <many-to-one name="boat" class="fr.ifremer.suiviobsmer.entity.BoatImpl" column="boat" node="boat/@topiaId" embed-xml="false"/>
+ </class>
+</hibernate-mapping>
Added: trunk/suiviobsmer-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/ActivityMonthImpl.hbm.xml
===================================================================
--- trunk/suiviobsmer-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/ActivityMonthImpl.hbm.xml (rev 0)
+++ trunk/suiviobsmer-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/ActivityMonthImpl.hbm.xml 2010-02-16 12:00:05 UTC (rev 354)
@@ -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.suiviobsmer.entity">
+ <class name="fr.ifremer.suiviobsmer.entity.ActivityMonthImpl" table="activityMonth" node="fr.ifremer.suiviobsmer.entity.ActivityMonthImpl" abstract="false" proxy="fr.ifremer.suiviobsmer.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.suiviobsmer.entity.ActivityProfessionImpl" node="topiaId" embed-xml="false"/>
+ </bag>
+ <many-to-one name="activityCalendar" class="fr.ifremer.suiviobsmer.entity.ActivityCalendarImpl" column="activityCalendar" node="activityCalendar/@topiaId" embed-xml="false"/>
+ </class>
+</hibernate-mapping>
Added: trunk/suiviobsmer-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/ActivityProfessionImpl.hbm.xml
===================================================================
--- trunk/suiviobsmer-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/ActivityProfessionImpl.hbm.xml (rev 0)
+++ trunk/suiviobsmer-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/ActivityProfessionImpl.hbm.xml 2010-02-16 12:00:05 UTC (rev 354)
@@ -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.suiviobsmer.entity">
+ <class name="fr.ifremer.suiviobsmer.entity.ActivityProfessionImpl" table="activityProfession" node="fr.ifremer.suiviobsmer.entity.ActivityProfessionImpl" abstract="false" proxy="fr.ifremer.suiviobsmer.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.suiviobsmer.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.suiviobsmer.entity.ActivityZoneImpl" node="topiaId" embed-xml="false"/>
+ </bag>
+ </class>
+</hibernate-mapping>
Added: trunk/suiviobsmer-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/ActivityZoneImpl.hbm.xml
===================================================================
--- trunk/suiviobsmer-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/ActivityZoneImpl.hbm.xml (rev 0)
+++ trunk/suiviobsmer-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/ActivityZoneImpl.hbm.xml 2010-02-16 12:00:05 UTC (rev 354)
@@ -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.suiviobsmer.entity">
+ <class name="fr.ifremer.suiviobsmer.entity.ActivityZoneImpl" table="activityZone" node="fr.ifremer.suiviobsmer.entity.ActivityZoneImpl" abstract="false" proxy="fr.ifremer.suiviobsmer.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.suiviobsmer.entity.ActivityProfessionImpl" column="activityProfession" node="activityProfession/@topiaId" embed-xml="false"/>
+ </class>
+</hibernate-mapping>
Added: trunk/suiviobsmer-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/BoatImpl.hbm.xml
===================================================================
--- trunk/suiviobsmer-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/BoatImpl.hbm.xml (rev 0)
+++ trunk/suiviobsmer-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/BoatImpl.hbm.xml 2010-02-16 12:00:05 UTC (rev 354)
@@ -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.suiviobsmer.entity">
+ <class name="fr.ifremer.suiviobsmer.entity.BoatImpl" table="boat" node="fr.ifremer.suiviobsmer.entity.BoatImpl" abstract="false" proxy="fr.ifremer.suiviobsmer.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.suiviobsmer.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.suiviobsmer.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.suiviobsmer.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.suiviobsmer.entity.ElligibleBoatImpl" node="topiaId" embed-xml="false"/>
+ </bag>
+ </class>
+</hibernate-mapping>
Added: trunk/suiviobsmer-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/BoatInfosImpl.hbm.xml
===================================================================
--- trunk/suiviobsmer-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/BoatInfosImpl.hbm.xml (rev 0)
+++ trunk/suiviobsmer-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/BoatInfosImpl.hbm.xml 2010-02-16 12:00:05 UTC (rev 354)
@@ -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.suiviobsmer.entity">
+ <class name="fr.ifremer.suiviobsmer.entity.BoatInfosImpl" table="boatInfos" node="fr.ifremer.suiviobsmer.entity.BoatInfosImpl" abstract="false" proxy="fr.ifremer.suiviobsmer.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.suiviobsmer.entity.CompanyImpl" column="company" node="company/@topiaId" embed-xml="false" />
+ <many-to-one name="boat" class="fr.ifremer.suiviobsmer.entity.BoatImpl" column="boat" node="boat/@topiaId" embed-xml="false" />
+ </class>
+</hibernate-mapping>
Added: trunk/suiviobsmer-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/CompanyImpl.hbm.xml
===================================================================
--- trunk/suiviobsmer-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/CompanyImpl.hbm.xml (rev 0)
+++ trunk/suiviobsmer-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/CompanyImpl.hbm.xml 2010-02-16 12:00:05 UTC (rev 354)
@@ -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.suiviobsmer.entity">
+ <class name="fr.ifremer.suiviobsmer.entity.CompanyImpl" table="company" node="fr.ifremer.suiviobsmer.entity.CompanyImpl" abstract="false" proxy="fr.ifremer.suiviobsmer.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="false" cascade="all,delete-orphan" node="waoUser" embed-xml="false">
+ <key column="company"/>
+ <one-to-many class="fr.ifremer.suiviobsmer.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.suiviobsmer.entity.BoatInfosImpl" node="topiaId" embed-xml="false"/>
+ </bag>
+ </class>
+</hibernate-mapping>
Added: trunk/suiviobsmer-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/ContactImpl.hbm.xml
===================================================================
--- trunk/suiviobsmer-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/ContactImpl.hbm.xml (rev 0)
+++ trunk/suiviobsmer-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/ContactImpl.hbm.xml 2010-02-16 12:00:05 UTC (rev 354)
@@ -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.suiviobsmer.entity">
+ <class name="fr.ifremer.suiviobsmer.entity.ContactImpl" table="contact" node="fr.ifremer.suiviobsmer.entity.ContactImpl" abstract="false" proxy="fr.ifremer.suiviobsmer.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="text" 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.suiviobsmer.entity.WaoUserImpl" column="observer" node="observer/@topiaId" embed-xml="false"/>
+ <many-to-one name="sampleRow" class="fr.ifremer.suiviobsmer.entity.SampleRowImpl" column="sampleRow" lazy="false" node="sampleRow/@topiaId" embed-xml="false"/>
+ <many-to-one name="boat" class="fr.ifremer.suiviobsmer.entity.BoatImpl" column="boat" lazy="false" node="boat/@topiaId" embed-xml="false"/>
+ </class>
+</hibernate-mapping>
Added: trunk/suiviobsmer-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/ElligibleBoatImpl.hbm.xml
===================================================================
--- trunk/suiviobsmer-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/ElligibleBoatImpl.hbm.xml (rev 0)
+++ trunk/suiviobsmer-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/ElligibleBoatImpl.hbm.xml 2010-02-16 12:00:05 UTC (rev 354)
@@ -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.suiviobsmer.entity">
+ <class name="fr.ifremer.suiviobsmer.entity.ElligibleBoatImpl" table="elligibleBoat" node="fr.ifremer.suiviobsmer.entity.ElligibleBoatImpl" abstract="false" proxy="fr.ifremer.suiviobsmer.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.suiviobsmer.entity.BoatImpl" column="boat" lazy="false" node="boat/@topiaId" embed-xml="false"/>
+ <many-to-one name="sampleRow" class="fr.ifremer.suiviobsmer.entity.SampleRowImpl" column="sampleRow" node="sampleRow/@topiaId" embed-xml="false"/>
+ </class>
+</hibernate-mapping>
Added: trunk/suiviobsmer-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/FishingZoneImpl.hbm.xml
===================================================================
--- trunk/suiviobsmer-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/FishingZoneImpl.hbm.xml (rev 0)
+++ trunk/suiviobsmer-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/FishingZoneImpl.hbm.xml 2010-02-16 12:00:05 UTC (rev 354)
@@ -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.suiviobsmer.entity">
+ <class name="fr.ifremer.suiviobsmer.entity.FishingZoneImpl" table="fishingZone" node="fr.ifremer.suiviobsmer.entity.FishingZoneImpl" abstract="false" proxy="fr.ifremer.suiviobsmer.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" lazy="true" node="sampleRow" embed-xml="true">
+ <key column="fishingZone"/>
+ <many-to-many class="fr.ifremer.suiviobsmer.entity.SampleRowImpl" column="sampleRow" order-by="code" node="topiaId"/>
+ </bag>
+ </class>
+</hibernate-mapping>
Added: trunk/suiviobsmer-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/NewsImpl.hbm.xml
===================================================================
--- trunk/suiviobsmer-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/NewsImpl.hbm.xml (rev 0)
+++ trunk/suiviobsmer-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/NewsImpl.hbm.xml 2010-02-16 12:00:05 UTC (rev 354)
@@ -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.suiviobsmer.entity">
+ <class name="fr.ifremer.suiviobsmer.entity.NewsImpl" table="news" node="fr.ifremer.suiviobsmer.entity.NewsImpl" abstract="false" proxy="fr.ifremer.suiviobsmer.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/suiviobsmer-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/ProfessionImpl.hbm.xml
===================================================================
--- trunk/suiviobsmer-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/ProfessionImpl.hbm.xml (rev 0)
+++ trunk/suiviobsmer-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/ProfessionImpl.hbm.xml 2010-02-16 12:00:05 UTC (rev 354)
@@ -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.suiviobsmer.entity">
+ <class name="fr.ifremer.suiviobsmer.entity.ProfessionImpl" table="profession" node="fr.ifremer.suiviobsmer.entity.ProfessionImpl" abstract="false" proxy="fr.ifremer.suiviobsmer.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/suiviobsmer-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/SampleMonthImpl.hbm.xml
===================================================================
--- trunk/suiviobsmer-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/SampleMonthImpl.hbm.xml (rev 0)
+++ trunk/suiviobsmer-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/SampleMonthImpl.hbm.xml 2010-02-16 12:00:05 UTC (rev 354)
@@ -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.suiviobsmer.entity">
+ <class name="fr.ifremer.suiviobsmer.entity.SampleMonthImpl" table="sampleMonth" node="fr.ifremer.suiviobsmer.entity.SampleMonthImpl" abstract="false" proxy="fr.ifremer.suiviobsmer.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.suiviobsmer.entity.SampleRowImpl" column="sampleRow" node="sampleRow/@topiaId" embed-xml="false"/>
+ </class>
+</hibernate-mapping>
Added: trunk/suiviobsmer-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/SampleRowImpl.hbm.xml
===================================================================
--- trunk/suiviobsmer-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/SampleRowImpl.hbm.xml (rev 0)
+++ trunk/suiviobsmer-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/SampleRowImpl.hbm.xml 2010-02-16 12:00:05 UTC (rev 354)
@@ -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.suiviobsmer.entity">
+ <class name="fr.ifremer.suiviobsmer.entity.SampleRowImpl" table="sampleRow" node="fr.ifremer.suiviobsmer.entity.SampleRowImpl" abstract="false" proxy="fr.ifremer.suiviobsmer.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.suiviobsmer.entity.ProfessionImpl" column="profession" lazy="false" node="profession/@topiaId" embed-xml="false"/>
+ <bag name="sampleMonth" inverse="true" order-by="periodDate" lazy="false" cascade="all,delete-orphan" node="sampleMonth" embed-xml="false">
+ <key column="sampleRow"/>
+ <one-to-many class="fr.ifremer.suiviobsmer.entity.SampleMonthImpl" node="topiaId" embed-xml="false"/>
+ </bag>
+ <many-to-one name="company" class="fr.ifremer.suiviobsmer.entity.CompanyImpl" column="company" lazy="false" node="company/@topiaId" embed-xml="false"/>
+ <bag name="sampleRowLog" inverse="true" order-by="topiaCreateDate desc" lazy="false" cascade="all,delete-orphan" node="sampleRowLog" embed-xml="false">
+ <key column="sampleRow"/>
+ <one-to-many class="fr.ifremer.suiviobsmer.entity.SampleRowLogImpl" node="topiaId" embed-xml="false"/>
+ </bag>
+ <bag name="elligibleBoat" inverse="true" order-by="companyActive" lazy="false" cascade="all,delete-orphan" node="elligibleBoat" embed-xml="false">
+ <key column="sampleRow"/>
+ <one-to-many class="fr.ifremer.suiviobsmer.entity.ElligibleBoatImpl" node="topiaId" embed-xml="false"/>
+ </bag>
+ <bag name="fishingZone" table="fishingzone_samplerow" inverse="true" lazy="false" node="fishingZone" embed-xml="true">
+ <key column="sampleRow"/>
+ <many-to-many class="fr.ifremer.suiviobsmer.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.suiviobsmer.entity.ContactImpl" node="topiaId" embed-xml="false"/>
+ </bag>
+ </class>
+</hibernate-mapping>
Added: trunk/suiviobsmer-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/SampleRowLogImpl.hbm.xml
===================================================================
--- trunk/suiviobsmer-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/SampleRowLogImpl.hbm.xml (rev 0)
+++ trunk/suiviobsmer-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/SampleRowLogImpl.hbm.xml 2010-02-16 12:00:05 UTC (rev 354)
@@ -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.suiviobsmer.entity">
+ <class name="fr.ifremer.suiviobsmer.entity.SampleRowLogImpl" table="sampleRowLog" node="fr.ifremer.suiviobsmer.entity.SampleRowLogImpl" abstract="false" proxy="fr.ifremer.suiviobsmer.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.suiviobsmer.entity.SampleRowImpl" column="sampleRow" node="sampleRow/@topiaId" embed-xml="false"/>
+ <many-to-one name="admin" class="fr.ifremer.suiviobsmer.entity.WaoUserImpl" column="admin" lazy="false" node="admin/@topiaId" embed-xml="false"/>
+ </class>
+</hibernate-mapping>
Added: trunk/suiviobsmer-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/ShipOwnerImpl.hbm.xml
===================================================================
--- trunk/suiviobsmer-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/ShipOwnerImpl.hbm.xml (rev 0)
+++ trunk/suiviobsmer-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/ShipOwnerImpl.hbm.xml 2010-02-16 12:00:05 UTC (rev 354)
@@ -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.suiviobsmer.entity">
+ <class name="fr.ifremer.suiviobsmer.entity.ShipOwnerImpl" table="shipOwner" node="fr.ifremer.suiviobsmer.entity.ShipOwnerImpl" abstract="false" proxy="fr.ifremer.suiviobsmer.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/suiviobsmer-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/WaoUserImpl.hbm.xml
===================================================================
--- trunk/suiviobsmer-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/WaoUserImpl.hbm.xml (rev 0)
+++ trunk/suiviobsmer-business/src/main/resources/oldmappings/WaoModel/0.4/fr/ifremer/suiviobsmer/entity/WaoUserImpl.hbm.xml 2010-02-16 12:00:05 UTC (rev 354)
@@ -0,0 +1,21 @@
+<?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.suiviobsmer.entity">
+ <class name="fr.ifremer.suiviobsmer.entity.WaoUserImpl" table="waoUser" node="fr.ifremer.suiviobsmer.entity.WaoUserImpl" abstract="false" proxy="fr.ifremer.suiviobsmer.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="admin" type="boolean" access="field" column="admin" node="admin"/>
+ <many-to-one name="company" class="fr.ifremer.suiviobsmer.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.suiviobsmer.entity.ContactImpl" node="topiaId" embed-xml="false"/>
+ </bag>
+ </class>
+</hibernate-mapping>
Deleted: trunk/suiviobsmer-business/src/main/xmi/suiviobsmer.properties
===================================================================
--- trunk/suiviobsmer-business/src/main/xmi/suiviobsmer.properties 2010-02-16 10:56:02 UTC (rev 353)
+++ trunk/suiviobsmer-business/src/main/xmi/suiviobsmer.properties 2010-02-16 12:00:05 UTC (rev 354)
@@ -1,32 +0,0 @@
-model.tagvalue.copyright=/* *##%\n Copyright (C) 2009 SuiviObsmer\n *##%*/
-model.tagvalue.java.lang.String=text
-fr.ifremer.suiviobsmer.entity.Company.attribute.waoUser.tagvalue.lazy=false
-
-fr.ifremer.suiviobsmer.entity.SampleRow.attribute.sampleMonth.tagvalue.lazy=false
-fr.ifremer.suiviobsmer.entity.SampleRow.attribute.sampleMonth.tagvalue.orderBy=periodDate
-fr.ifremer.suiviobsmer.entity.SampleRow.attribute.fishingZone.tagvalue.lazy=false
-fr.ifremer.suiviobsmer.entity.SampleRow.attribute.fishingZone.tagvalue.orderBy=facadeName,sectorName,districtCode
-fr.ifremer.suiviobsmer.entity.SampleRow.attribute.profession.tagvalue.lazy=false
-fr.ifremer.suiviobsmer.entity.SampleRow.attribute.company.tagvalue.lazy=false
-#fr.ifremer.suiviobsmer.entity.SampleRow.attribute.pogram.tagvalue.lazy=false
-fr.ifremer.suiviobsmer.entity.SampleRow.attribute.elligibleBoat.tagvalue.lazy=false
-fr.ifremer.suiviobsmer.entity.SampleRow.attribute.elligibleBoat.tagvalue.orderBy=companyActive
-fr.ifremer.suiviobsmer.entity.SampleRow.attribute.sampleRowLog.tagvalue.lazy=false
-fr.ifremer.suiviobsmer.entity.SampleRow.attribute.sampleRowLog.tagvalue.orderBy=topiaCreateDate desc
-fr.ifremer.suiviobsmer.entity.SampleRowLog.attribute.admin.tagvalue.lazy=false
-
-fr.ifremer.suiviobsmer.entity.FishingZone.attribute.sampleRow.tagvalue.orderBy=code
-
-fr.ifremer.suiviobsmer.entity.Boat.attribute.shipOwner.tagvalue.lazy=false
-fr.ifremer.suiviobsmer.entity.Boat.attribute.elligibleBoat.tagvalue.orderBy=companyActive
-
-fr.ifremer.suiviobsmer.entity.ElligibleBoat.attribute.boat.tagvalue.lazy=false
-
-fr.ifremer.suiviobsmer.entity.Contact.attribute.sampleRow.tagvalue.lazy=false
-fr.ifremer.suiviobsmer.entity.Contact.attribute.boat.tagvalue.lazy=false
-
-#fr.ifremer.suiviobsmer.entity.Boat.attribute.elligibleBoat.tagvalue.lazy=false
-#fr.ifremer.suiviobsmer.entity.ElligibleBoat.attribute.sampleRow.tagvalue.lazy=false
-#fr.ifremer.suiviobsmer.entity.ElligibleBoat.attribute.company.tagvalue.lazy=false
-#fr.ifremer.suiviobsmer.entity.SampleRow.attribute.program.tagvalue.lazy=false
-#fr.ifremer.suiviobsmer.entity.SampleRow.attribute.company.tagvalue.lazy=false
\ No newline at end of file
Deleted: trunk/suiviobsmer-business/src/main/xmi/suiviobsmer.zargo
===================================================================
(Binary files differ)
Copied: trunk/suiviobsmer-business/src/main/xmi/wao.properties (from rev 350, trunk/suiviobsmer-business/src/main/xmi/suiviobsmer.properties)
===================================================================
--- trunk/suiviobsmer-business/src/main/xmi/wao.properties (rev 0)
+++ trunk/suiviobsmer-business/src/main/xmi/wao.properties 2010-02-16 12:00:05 UTC (rev 354)
@@ -0,0 +1,32 @@
+model.tagvalue.copyright=/* *##%\n Copyright (C) 2009 Wao\n *##%*/
+model.tagvalue.java.lang.String=text
+fr.ifremer.suiviobsmer.entity.Company.attribute.waoUser.tagvalue.lazy=false
+
+fr.ifremer.suiviobsmer.entity.SampleRow.attribute.sampleMonth.tagvalue.lazy=false
+fr.ifremer.suiviobsmer.entity.SampleRow.attribute.sampleMonth.tagvalue.orderBy=periodDate
+fr.ifremer.suiviobsmer.entity.SampleRow.attribute.fishingZone.tagvalue.lazy=false
+fr.ifremer.suiviobsmer.entity.SampleRow.attribute.fishingZone.tagvalue.orderBy=facadeName,sectorName,districtCode
+fr.ifremer.suiviobsmer.entity.SampleRow.attribute.profession.tagvalue.lazy=false
+fr.ifremer.suiviobsmer.entity.SampleRow.attribute.company.tagvalue.lazy=false
+#fr.ifremer.suiviobsmer.entity.SampleRow.attribute.pogram.tagvalue.lazy=false
+fr.ifremer.suiviobsmer.entity.SampleRow.attribute.elligibleBoat.tagvalue.lazy=false
+fr.ifremer.suiviobsmer.entity.SampleRow.attribute.elligibleBoat.tagvalue.orderBy=companyActive
+fr.ifremer.suiviobsmer.entity.SampleRow.attribute.sampleRowLog.tagvalue.lazy=false
+fr.ifremer.suiviobsmer.entity.SampleRow.attribute.sampleRowLog.tagvalue.orderBy=topiaCreateDate desc
+fr.ifremer.suiviobsmer.entity.SampleRowLog.attribute.admin.tagvalue.lazy=false
+
+fr.ifremer.suiviobsmer.entity.FishingZone.attribute.sampleRow.tagvalue.orderBy=code
+
+fr.ifremer.suiviobsmer.entity.Boat.attribute.shipOwner.tagvalue.lazy=false
+fr.ifremer.suiviobsmer.entity.Boat.attribute.elligibleBoat.tagvalue.orderBy=companyActive
+
+fr.ifremer.suiviobsmer.entity.ElligibleBoat.attribute.boat.tagvalue.lazy=false
+
+fr.ifremer.suiviobsmer.entity.Contact.attribute.sampleRow.tagvalue.lazy=false
+fr.ifremer.suiviobsmer.entity.Contact.attribute.boat.tagvalue.lazy=false
+
+#fr.ifremer.suiviobsmer.entity.Boat.attribute.elligibleBoat.tagvalue.lazy=false
+#fr.ifremer.suiviobsmer.entity.ElligibleBoat.attribute.sampleRow.tagvalue.lazy=false
+#fr.ifremer.suiviobsmer.entity.ElligibleBoat.attribute.company.tagvalue.lazy=false
+#fr.ifremer.suiviobsmer.entity.SampleRow.attribute.program.tagvalue.lazy=false
+#fr.ifremer.suiviobsmer.entity.SampleRow.attribute.company.tagvalue.lazy=false
\ No newline at end of file
Copied: trunk/suiviobsmer-business/src/main/xmi/wao.zargo (from rev 351, trunk/suiviobsmer-business/src/main/xmi/suiviobsmer.zargo)
===================================================================
(Binary files differ)
Property changes on: trunk/suiviobsmer-business/src/main/xmi/wao.zargo
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: svn:mergeinfo
+
Modified: trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/ImportHelperTest.java
===================================================================
--- trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/ImportHelperTest.java 2010-02-16 10:56:02 UTC (rev 353)
+++ trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/ImportHelperTest.java 2010-02-16 12:00:05 UTC (rev 354)
@@ -1,6 +1,6 @@
/*
* *##%
- * SuiviObsmer :: Business
+ * Wao :: Business
* Copyright (C) 2009 - 2010 Ifremer
*
* This program is free software: you can redistribute it and/or modify
@@ -48,14 +48,14 @@
*/
public class ImportHelperTest {
- private static SuiviObsmerRunner runner;
+ private static WaoRunner runner;
private static final Logger log = LoggerFactory.getLogger(ImportHelperTest.class);
private CsvReader reader;
public ImportHelperTest() {
- runner = new SuiviObsmerRunnerTest();
+ runner = new WaoRunnerTest();
}
@BeforeClass
@@ -69,7 +69,7 @@
}
@Before
- public void setUp() throws SuiviObsmerException, IOException {
+ public void setUp() throws WaoException, IOException {
runner.start();
InputStream input = getClass().getResourceAsStream("/import/misc.csv");
@@ -78,7 +78,7 @@
}
@After
- public void tearDown() throws SuiviObsmerException {
+ public void tearDown() throws WaoException {
reader.close();
runner.stop();
@@ -122,7 +122,7 @@
@Test
public void testFormatContactCode() {
log.info("formatContactCode");
- Date createDate = SuiviObsmerContext.getCurrentDate();
+ Date createDate = WaoContext.getCurrentDate();
Calendar calendar = new GregorianCalendar(Locale.FRENCH);
calendar.setTime(createDate);
calendar.set(Calendar.HOUR_OF_DAY, 10);
@@ -142,7 +142,7 @@
public void testParseContactCreateDate() throws Exception {
System.out.println("parseContactCreateDate");
String code = "101250718";
- Date createDate = SuiviObsmerContext.getCurrentDate();
+ Date createDate = WaoContext.getCurrentDate();
Calendar calendar = new GregorianCalendar(Locale.FRENCH);
calendar.setTime(createDate);
calendar.set(Calendar.HOUR_OF_DAY, 10);
Deleted: trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/SuiviObsmerGlobalTest.java
===================================================================
--- trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/SuiviObsmerGlobalTest.java 2010-02-16 10:56:02 UTC (rev 353)
+++ trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/SuiviObsmerGlobalTest.java 2010-02-16 12:00:05 UTC (rev 354)
@@ -1,104 +0,0 @@
-/*
- * *##%
- * SuiviObsmer :: 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.suiviobsmer;
-
-import fr.ifremer.suiviobsmer.entity.Company;
-import fr.ifremer.suiviobsmer.entity.WaoUser;
-import fr.ifremer.suiviobsmer.services.ServiceUserImpl;
-import fr.ifremer.suiviobsmer.services.ServiceUser;
-import java.util.List;
-import static org.junit.Assert.*;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * SuiviObsmerGlobalTest
- *
- * Created: 27 nov. 2009
- *
- * @author fdesbois
- * @version $Revision$
- *
- * Mise a jour: $Date$
- * par : $Author$
- */
-public class SuiviObsmerGlobalTest {
-
- private static SuiviObsmerRunner runner;
-
- private static final Logger log = LoggerFactory.getLogger(SuiviObsmerGlobalTest.class);
-
- public SuiviObsmerGlobalTest() {
- runner = new SuiviObsmerRunnerTest();
- }
-
- @BeforeClass
- public static void setUpClass() throws Exception {
-
- }
-
- @AfterClass
- public static void tearDownClass() throws Exception {
-
- }
-
- @Before
- public void setUp() throws SuiviObsmerException {
- runner.start();
- }
-
- @After
- public void tearDown() throws SuiviObsmerException {
- runner.stop();
- }
-
- /**
- * Test of initApplication method, of class SuiviObsmerGlobal.
- */
- @Test
- public void testCreateDefaultAdmin() throws Exception {
- System.out.println("createDefaultAdmin");
-
- SuiviObsmerGlobal.createDefaultAdmin();
-
- ServiceUser serviceUser = new ServiceUserImpl();
-
- List<Company> companies = serviceUser.getCompanies(false);
- assertEquals(1, companies.size());
-
- Company company = companies.get(0);
- assertEquals("ADMIN", company.getName());
-
- List<WaoUser> users = company.getWaoUser();
- assertEquals(1, users.size());
-
- WaoUser user = users.get(0);
- assertEquals("admin", user.getLogin());
-
- }
-
-}
Deleted: trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/SuiviObsmerRunnerTest.java
===================================================================
--- trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/SuiviObsmerRunnerTest.java 2010-02-16 10:56:02 UTC (rev 353)
+++ trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/SuiviObsmerRunnerTest.java 2010-02-16 12:00:05 UTC (rev 354)
@@ -1,150 +0,0 @@
-/*
- * *##%
- * SuiviObsmer :: 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.suiviobsmer;
-
-import fr.ifremer.suiviobsmer.entity.Company;
-import fr.ifremer.suiviobsmer.entity.CompanyImpl;
-import fr.ifremer.suiviobsmer.entity.WaoUser;
-import fr.ifremer.suiviobsmer.entity.WaoUserImpl;
-import fr.ifremer.suiviobsmer.services.*;
-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;
-
-/**
- * ContextUtilObsmerTest
- *
- * Created: 23 nov. 2009
- *
- * @author fdesbois
- * @version $Revision$
- *
- * Mise a jour: $Date$
- * par : $Author$
- */
- at Ignore
-public class SuiviObsmerRunnerTest implements SuiviObsmerRunner {
-
- private static final Logger log = LoggerFactory.getLogger(SuiviObsmerRunnerTest.class);
-
- private ApplicationConfig _configuration;
-
- @Override
- public void start() throws SuiviObsmerException {
- if (log.isDebugEnabled()) {
- log.debug("TEST START : loadConfiguration");
- }
- try {
- Properties options = loadFileProperties("TopiaContextSuiviObsmer.properties");
- options.setProperty("topia.persistence.classes",
- SuiviObsmerModelDAOHelper.getImplementationClassesAsString());
-
- _configuration = new ApplicationConfig();
- _configuration.setOptions(options);
-
- SuiviObsmerContext.setRunner(this);
- } catch (Exception eee) {
- SuiviObsmerContext.serviceException(null, "Error during loadConfiguration from " +
- "'TopiaContextSuiviObsmer.properties' file", eee);
- }
- }
-
- @Override
- public void stop() throws SuiviObsmerException {
- if (log.isDebugEnabled()) {
- log.debug("TEST STOP : clearContext");
- }
- try {
- SuiviObsmerContext.getTopiaRootContext().clear(true);
- } catch (TopiaException eee) {
- SuiviObsmerContext.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 SuiviObsmerException {
- 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);
- }
-
-}
Deleted: trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/SuiviObsmerUtilsTest.java
===================================================================
--- trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/SuiviObsmerUtilsTest.java 2010-02-16 10:56:02 UTC (rev 353)
+++ trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/SuiviObsmerUtilsTest.java 2010-02-16 12:00:05 UTC (rev 354)
@@ -1,138 +0,0 @@
-/*
- * *##%
- * SuiviObsmer :: 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.suiviobsmer;
-
-import fr.ifremer.suiviobsmer.entity.Company;
-import fr.ifremer.suiviobsmer.entity.CompanyImpl;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import static org.junit.Assert.*;
-
-/**
- * SuiviObsmerUtilsTest
- *
- * Created: 27 nov. 2009
- *
- * @author fdesbois
- * @version $Revision$
- *
- * Mise a jour: $Date$
- * par : $Author$
- */
-public class SuiviObsmerUtilsTest {
-
- private static SuiviObsmerRunner runner;
-
- private static final Logger log = LoggerFactory.getLogger(SuiviObsmerUtilsTest.class);
-
- public SuiviObsmerUtilsTest() {
- runner = new SuiviObsmerRunnerTest();
- }
-
- @BeforeClass
- public static void setUpClass() throws Exception {
-
- }
-
- @AfterClass
- public static void tearDownClass() throws Exception {
-
- }
-
- @Before
- public void setUp() throws SuiviObsmerException {
- runner.start();
- }
-
- @After
- public void tearDown() throws SuiviObsmerException {
- runner.stop();
- }
-
- /**
- * Test of getTopiaRootContext method, of class SuiviObsmerUtils.
- */
- //@Test
- public void testGetTopiaRootContext() throws Exception {
- System.out.println("getTopiaRootContext");
- }
-
- /**
- * Test of loadConfiguration method, of class SuiviObsmerUtils.
- */
- //@Test
- public void testLoadConfiguration() throws Exception {
- System.out.println("loadConfiguration");
- }
-
- /**
- * Test of serviceException method, of class SuiviObsmerUtils.
- */
- //@Test
- public void testServiceException() throws Exception {
- System.out.println("serviceException");
- }
-
- /**
- * Test of createRandomString method, of class SuiviObsmerUtils.
- */
- //@Test
- public void testCreateRandomString() {
- System.out.println("createRandomString");
- }
-
- /**
- * Test of encodeString method, of class SuiviObsmerUtils.
- */
- //@Test
- public void testEncodeString() {
- System.out.println("encodeString");
- }
-
- /**
- * Test of convertId method, of class SuiviObsmerUtils.
- */
- //@Test
- public void testConvertId() {
- System.out.println("convertId");
- }
-
- /**
- * Test of prepareTopiaId method, of class SuiviObsmerUtils.
- */
- @Test
- public void testPrepareTopiaId() {
- log.info("prepareTopiaId");
-
- Company company = new CompanyImpl();
-
- SuiviObsmerContext.prepareTopiaId(Company.class, company);
- assertNotNull(company.getTopiaId());
- log.debug("topiaId for Company : " + company.getTopiaId());
- }
-
-}
Copied: trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/WaoGlobalTest.java (from rev 350, trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/SuiviObsmerGlobalTest.java)
===================================================================
--- trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/WaoGlobalTest.java (rev 0)
+++ trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/WaoGlobalTest.java 2010-02-16 12:00:05 UTC (rev 354)
@@ -0,0 +1,104 @@
+/*
+ * *##%
+ * 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.suiviobsmer;
+
+import fr.ifremer.suiviobsmer.entity.Company;
+import fr.ifremer.suiviobsmer.entity.WaoUser;
+import fr.ifremer.suiviobsmer.services.ServiceUserImpl;
+import fr.ifremer.suiviobsmer.services.ServiceUser;
+import java.util.List;
+import static org.junit.Assert.*;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * WaoGlobalTest
+ *
+ * Created: 27 nov. 2009
+ *
+ * @author fdesbois
+ * @version $Revision$
+ *
+ * Mise a jour: $Date$
+ * par : $Author$
+ */
+public class WaoGlobalTest {
+
+ private static WaoRunner runner;
+
+ private static final Logger log = LoggerFactory.getLogger(WaoGlobalTest.class);
+
+ public WaoGlobalTest() {
+ runner = new WaoRunnerTest();
+ }
+
+ @BeforeClass
+ public static void setUpClass() throws Exception {
+
+ }
+
+ @AfterClass
+ public static void tearDownClass() throws Exception {
+
+ }
+
+ @Before
+ public void setUp() throws WaoException {
+ runner.start();
+ }
+
+ @After
+ public void tearDown() throws WaoException {
+ runner.stop();
+ }
+
+ /**
+ * Test of initApplication method, of class WaoGlobal.
+ */
+ @Test
+ public void testCreateDefaultAdmin() throws Exception {
+ System.out.println("createDefaultAdmin");
+
+ WaoGlobal.createDefaultAdmin();
+
+ ServiceUser serviceUser = new ServiceUserImpl();
+
+ List<Company> companies = serviceUser.getCompanies(false);
+ assertEquals(1, companies.size());
+
+ Company company = companies.get(0);
+ assertEquals("ADMIN", company.getName());
+
+ List<WaoUser> users = company.getWaoUser();
+ assertEquals(1, users.size());
+
+ WaoUser user = users.get(0);
+ assertEquals("admin", user.getLogin());
+
+ }
+
+}
Property changes on: trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/WaoGlobalTest.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Revision
Added: svn:mergeinfo
+
Copied: trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/WaoRunnerTest.java (from rev 350, trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/SuiviObsmerRunnerTest.java)
===================================================================
--- trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/WaoRunnerTest.java (rev 0)
+++ trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/WaoRunnerTest.java 2010-02-16 12:00:05 UTC (rev 354)
@@ -0,0 +1,150 @@
+/*
+ * *##%
+ * 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.suiviobsmer;
+
+import fr.ifremer.suiviobsmer.entity.Company;
+import fr.ifremer.suiviobsmer.entity.CompanyImpl;
+import fr.ifremer.suiviobsmer.entity.WaoUser;
+import fr.ifremer.suiviobsmer.entity.WaoUserImpl;
+import fr.ifremer.suiviobsmer.services.*;
+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);
+ }
+
+}
Copied: trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/WaoUtilsTest.java (from rev 350, trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/SuiviObsmerUtilsTest.java)
===================================================================
--- trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/WaoUtilsTest.java (rev 0)
+++ trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/WaoUtilsTest.java 2010-02-16 12:00:05 UTC (rev 354)
@@ -0,0 +1,138 @@
+/*
+ * *##%
+ * 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.suiviobsmer;
+
+import fr.ifremer.suiviobsmer.entity.Company;
+import fr.ifremer.suiviobsmer.entity.CompanyImpl;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import static org.junit.Assert.*;
+
+/**
+ * WaoUtilsTest
+ *
+ * Created: 27 nov. 2009
+ *
+ * @author fdesbois
+ * @version $Revision$
+ *
+ * Mise a jour: $Date$
+ * par : $Author$
+ */
+public class WaoUtilsTest {
+
+ private static WaoRunner runner;
+
+ private static final Logger log = LoggerFactory.getLogger(WaoUtilsTest.class);
+
+ public WaoUtilsTest() {
+ runner = new WaoRunnerTest();
+ }
+
+ @BeforeClass
+ public static void setUpClass() throws Exception {
+
+ }
+
+ @AfterClass
+ public static void tearDownClass() throws Exception {
+
+ }
+
+ @Before
+ public void setUp() throws WaoException {
+ runner.start();
+ }
+
+ @After
+ public void tearDown() throws WaoException {
+ runner.stop();
+ }
+
+ /**
+ * Test of getTopiaRootContext method, of class WaoUtils.
+ */
+ //@Test
+ public void testGetTopiaRootContext() throws Exception {
+ System.out.println("getTopiaRootContext");
+ }
+
+ /**
+ * Test of loadConfiguration method, of class WaoUtils.
+ */
+ //@Test
+ public void testLoadConfiguration() throws Exception {
+ System.out.println("loadConfiguration");
+ }
+
+ /**
+ * Test of serviceException method, of class WaoUtils.
+ */
+ //@Test
+ public void testServiceException() throws Exception {
+ System.out.println("serviceException");
+ }
+
+ /**
+ * Test of createRandomString method, of class WaoUtils.
+ */
+ //@Test
+ public void testCreateRandomString() {
+ System.out.println("createRandomString");
+ }
+
+ /**
+ * Test of encodeString method, of class WaoUtils.
+ */
+ //@Test
+ public void testEncodeString() {
+ System.out.println("encodeString");
+ }
+
+ /**
+ * Test of convertId method, of class WaoUtils.
+ */
+ //@Test
+ public void testConvertId() {
+ System.out.println("convertId");
+ }
+
+ /**
+ * Test of prepareTopiaId method, of class WaoUtils.
+ */
+ @Test
+ public void testPrepareTopiaId() {
+ log.info("prepareTopiaId");
+
+ Company company = new CompanyImpl();
+
+ WaoContext.prepareTopiaId(Company.class, company);
+ assertNotNull(company.getTopiaId());
+ log.debug("topiaId for Company : " + company.getTopiaId());
+ }
+
+}
Property changes on: trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/WaoUtilsTest.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Revision
Added: svn:mergeinfo
+
Modified: trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/entity/BoatImplTest.java
===================================================================
--- trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/entity/BoatImplTest.java 2010-02-16 10:56:02 UTC (rev 353)
+++ trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/entity/BoatImplTest.java 2010-02-16 12:00:05 UTC (rev 354)
@@ -1,6 +1,6 @@
/*
* *##%
- * SuiviObsmer :: Business
+ * Wao :: Business
* Copyright (C) 2009 - 2010 Ifremer
*
* This program is free software: you can redistribute it and/or modify
@@ -21,11 +21,11 @@
package fr.ifremer.suiviobsmer.entity;
-import fr.ifremer.suiviobsmer.SuiviObsmerContext;
-import fr.ifremer.suiviobsmer.SuiviObsmerModelDAOHelper;
-import fr.ifremer.suiviobsmer.SuiviObsmerRunner;
+import fr.ifremer.suiviobsmer.WaoContext;
+import fr.ifremer.suiviobsmer.WaoModelDAOHelper;
+import fr.ifremer.suiviobsmer.WaoRunner;
import fr.ifremer.suiviobsmer.bean.ContactState;
-import fr.ifremer.suiviobsmer.SuiviObsmerRunnerTest;
+import fr.ifremer.suiviobsmer.WaoRunnerTest;
import fr.ifremer.suiviobsmer.services.ServiceBoatImpl;
import fr.ifremer.suiviobsmer.services.ServiceContactImpl;
import fr.ifremer.suiviobsmer.services.ServiceSamplingImpl;
@@ -61,7 +61,7 @@
*/
public class BoatImplTest {
- private static SuiviObsmerRunner runner;
+ private static WaoRunner runner;
private static final Logger log = LoggerFactory.getLogger(BoatImplTest.class);
@@ -70,7 +70,7 @@
@BeforeClass
public static void setUpClass() throws Exception {
- runner = new SuiviObsmerRunnerTest();
+ runner = new WaoRunnerTest();
}
@AfterClass
@@ -115,9 +115,9 @@
List<Boat> boats = serviceBoat.getBoatsByImmatriculations("174258");
Boat boat = boats.get(0);
- TopiaContext transaction = SuiviObsmerContext.getTopiaRootContext().beginTransaction();
+ TopiaContext transaction = WaoContext.getTopiaRootContext().beginTransaction();
- FishingZoneDAO zoneDAO = SuiviObsmerModelDAOHelper.getFishingZoneDAO(transaction);
+ FishingZoneDAO zoneDAO = WaoModelDAOHelper.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 +128,7 @@
input = getClass().getResourceAsStream("/import/echantillonnage.csv");
serviceSampling.importSamplingPlanCsv(input);
- SampleRowDAO rowDAO = SuiviObsmerModelDAOHelper.getSampleRowDAO(transaction);
+ SampleRowDAO rowDAO = WaoModelDAOHelper.getSampleRowDAO(transaction);
SampleRow row = rowDAO.findByCode("2010_0001");
row.getCompany();
row.getProfession();
@@ -191,13 +191,13 @@
List<Boat> boats = serviceBoat.getBoatsByImmatriculations("174258");
Boat boat = boats.get(0);
- TopiaContext transaction = SuiviObsmerContext.getTopiaRootContext().beginTransaction();
+ TopiaContext transaction = WaoContext.getTopiaRootContext().beginTransaction();
- CompanyDAO companyDAO = SuiviObsmerModelDAOHelper.getCompanyDAO(transaction);
+ CompanyDAO companyDAO = WaoModelDAOHelper.getCompanyDAO(transaction);
Company company = companyDAO.create(Company.NAME, "TARTANPION");
Company company2 = companyDAO.create(Company.NAME, "BIS");
- WaoUserDAO userDAO = SuiviObsmerModelDAOHelper.getWaoUserDAO(transaction);
+ WaoUserDAO userDAO = WaoModelDAOHelper.getWaoUserDAO(transaction);
WaoUser user = userDAO.create(WaoUser.FIRST_NAME,"Jean", WaoUser.LAST_NAME, "Michmuche",
WaoUser.COMPANY, company);
company.addWaoUser(user);
@@ -205,7 +205,7 @@
WaoUser.COMPANY, company2);
company2.addWaoUser(user2);
-// BoatInfosDAO boatInfosDAO = SuiviObsmerModelDAOHelper.getBoatInfosDAO(transaction);
+// BoatInfosDAO boatInfosDAO = WaoModelDAOHelper.getBoatInfosDAO(transaction);
// BoatInfos boatInfos = boatInfosDAO.create(BoatInfos.BOAT, boat, BoatInfos.COMPANY, company);
transaction.commitTransaction();
Modified: trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/entity/BoatInfosImplTest.java
===================================================================
--- trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/entity/BoatInfosImplTest.java 2010-02-16 10:56:02 UTC (rev 353)
+++ trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/entity/BoatInfosImplTest.java 2010-02-16 12:00:05 UTC (rev 354)
@@ -1,6 +1,6 @@
/*
* *##%
- * SuiviObsmer :: Business
+ * Wao :: Business
* Copyright (C) 2009 - 2010 Ifremer
*
* This program is free software: you can redistribute it and/or modify
@@ -21,8 +21,8 @@
package fr.ifremer.suiviobsmer.entity;
-import fr.ifremer.suiviobsmer.SuiviObsmerRunner;
-import fr.ifremer.suiviobsmer.SuiviObsmerRunnerTest;
+import fr.ifremer.suiviobsmer.WaoRunner;
+import fr.ifremer.suiviobsmer.WaoRunnerTest;
import fr.ifremer.suiviobsmer.services.ServiceBoatImpl;
import fr.ifremer.suiviobsmer.services.ServiceContactImpl;
import org.junit.After;
@@ -46,7 +46,7 @@
*/
public class BoatInfosImplTest {
- private static SuiviObsmerRunner runner;
+ private static WaoRunner runner;
private static final Logger log = LoggerFactory.getLogger(BoatInfosImplTest.class);
@@ -55,7 +55,7 @@
@BeforeClass
public static void setUpClass() throws Exception {
- runner = new SuiviObsmerRunnerTest();
+ runner = new WaoRunnerTest();
}
@AfterClass
Modified: trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/entity/SampleRowImplTest.java
===================================================================
--- trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/entity/SampleRowImplTest.java 2010-02-16 10:56:02 UTC (rev 353)
+++ trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/entity/SampleRowImplTest.java 2010-02-16 12:00:05 UTC (rev 354)
@@ -1,6 +1,6 @@
/*
* *##%
- * SuiviObsmer :: Business
+ * Wao :: Business
* Copyright (C) 2009 - 2010 Ifremer
*
* This program is free software: you can redistribute it and/or modify
@@ -21,11 +21,11 @@
package fr.ifremer.suiviobsmer.entity;
-import fr.ifremer.suiviobsmer.SuiviObsmerException;
-import fr.ifremer.suiviobsmer.SuiviObsmerModelDAOHelper;
-import fr.ifremer.suiviobsmer.SuiviObsmerRunner;
-import fr.ifremer.suiviobsmer.SuiviObsmerContext;
-import fr.ifremer.suiviobsmer.SuiviObsmerRunnerTest;
+import fr.ifremer.suiviobsmer.WaoException;
+import fr.ifremer.suiviobsmer.WaoModelDAOHelper;
+import fr.ifremer.suiviobsmer.WaoRunner;
+import fr.ifremer.suiviobsmer.WaoContext;
+import fr.ifremer.suiviobsmer.WaoRunnerTest;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
@@ -54,7 +54,7 @@
*/
public class SampleRowImplTest {
- private static SuiviObsmerRunner runner;
+ private static WaoRunner runner;
private static final Logger log = LoggerFactory.getLogger(SampleRowImplTest.class);
@@ -63,7 +63,7 @@
@BeforeClass
public static void setUpClass() throws Exception {
- runner = new SuiviObsmerRunnerTest();
+ runner = new WaoRunnerTest();
}
@AfterClass
@@ -80,15 +80,15 @@
runner.stop();
}
- private SampleRow prepareData() throws SuiviObsmerException, TopiaException {
- TopiaContext transaction = SuiviObsmerContext.getTopiaRootContext().beginTransaction();
+ private SampleRow prepareData() throws WaoException, TopiaException {
+ TopiaContext transaction = WaoContext.getTopiaRootContext().beginTransaction();
- SampleRowDAO dao = SuiviObsmerModelDAOHelper.getSampleRowDAO(transaction);
+ SampleRowDAO dao = WaoModelDAOHelper.getSampleRowDAO(transaction);
SampleRow row = dao.create();
row.setCode("2010_1");
- SampleMonthDAO monthDAO = SuiviObsmerModelDAOHelper.getSampleMonthDAO(transaction);
+ SampleMonthDAO monthDAO = WaoModelDAOHelper.getSampleMonthDAO(transaction);
SampleMonth month = monthDAO.create(SampleMonth.SAMPLE_ROW, row);
Calendar calendar = new GregorianCalendar(2009, 3, 1);
@@ -101,9 +101,9 @@
return myRow;
}
- private SampleRow getRowFromContext() throws SuiviObsmerException, TopiaException {
- TopiaContext transaction = SuiviObsmerContext.getTopiaRootContext().beginTransaction();
- SampleRowDAO dao = SuiviObsmerModelDAOHelper.getSampleRowDAO(transaction);
+ private SampleRow getRowFromContext() throws WaoException, TopiaException {
+ TopiaContext transaction = WaoContext.getTopiaRootContext().beginTransaction();
+ SampleRowDAO dao = WaoModelDAOHelper.getSampleRowDAO(transaction);
SampleRow resultRow = dao.findByCode("2010_1");
transaction.closeContext();
return resultRow;
Modified: trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/services/ActivityCalendarImportTest.java
===================================================================
--- trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/services/ActivityCalendarImportTest.java 2010-02-16 10:56:02 UTC (rev 353)
+++ trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/services/ActivityCalendarImportTest.java 2010-02-16 12:00:05 UTC (rev 354)
@@ -1,6 +1,6 @@
/*
* *##%
- * SuiviObsmer :: Business
+ * Wao :: Business
* Copyright (C) 2009 - 2010 Ifremer
*
* This program is free software: you can redistribute it and/or modify
@@ -21,10 +21,10 @@
package fr.ifremer.suiviobsmer.services;
-import fr.ifremer.suiviobsmer.SuiviObsmerContext;
-import fr.ifremer.suiviobsmer.SuiviObsmerException;
-import fr.ifremer.suiviobsmer.SuiviObsmerRunner;
-import fr.ifremer.suiviobsmer.SuiviObsmerRunnerTest;
+import fr.ifremer.suiviobsmer.WaoContext;
+import fr.ifremer.suiviobsmer.WaoException;
+import fr.ifremer.suiviobsmer.WaoRunner;
+import fr.ifremer.suiviobsmer.WaoRunnerTest;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
@@ -54,7 +54,7 @@
*/
public class ActivityCalendarImportTest {
- private static SuiviObsmerRunner runner;
+ private static WaoRunner runner;
private static final Logger log = LoggerFactory.getLogger(ActivityCalendarImportTest.class);
@@ -63,7 +63,7 @@
@BeforeClass
public static void setUpClass() throws Exception {
- runner = new SuiviObsmerRunnerTest();
+ runner = new WaoRunnerTest();
}
@AfterClass
@@ -71,12 +71,12 @@
}
@Before
- public void setUp() throws SuiviObsmerException {
+ public void setUp() throws WaoException {
runner.start();
}
@After
- public void tearDown() throws SuiviObsmerException {
+ public void tearDown() throws WaoException {
runner.stop();
}
@@ -84,7 +84,7 @@
* Test of run method, of class ActivityCalendarImport.
*/
@Test
- public void testRun() throws IOException, InterruptedException, SuiviObsmerException {
+ public void testRun() throws IOException, InterruptedException, WaoException {
log.info("run");
ServiceBoat serviceBoat = new ServiceBoatImpl();
@@ -100,8 +100,8 @@
t.start();
t.join();
- String filename = SuiviObsmerContext.getProperty(
- SuiviObsmerContext.PROP_FILENAME_LOG_ACTIVITY_IMPORT);
+ String filename = WaoContext.getProperty(
+ WaoContext.PROP_FILENAME_LOG_ACTIVITY_IMPORT);
File file = new File(filename);
Assert.assertTrue(file.exists());
Modified: trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/services/ServiceBoatImplTest.java
===================================================================
--- trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/services/ServiceBoatImplTest.java 2010-02-16 10:56:02 UTC (rev 353)
+++ trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/services/ServiceBoatImplTest.java 2010-02-16 12:00:05 UTC (rev 354)
@@ -1,6 +1,6 @@
/*
* *##%
- * SuiviObsmer :: Business
+ * Wao :: Business
* Copyright (C) 2009 - 2010 Ifremer
*
* This program is free software: you can redistribute it and/or modify
@@ -21,12 +21,12 @@
package fr.ifremer.suiviobsmer.services;
-import fr.ifremer.suiviobsmer.SuiviObsmerException;
-import fr.ifremer.suiviobsmer.SuiviObsmerModelDAOHelper;
-import fr.ifremer.suiviobsmer.SuiviObsmerRunner;
-import fr.ifremer.suiviobsmer.SuiviObsmerContext;
+import fr.ifremer.suiviobsmer.WaoException;
+import fr.ifremer.suiviobsmer.WaoModelDAOHelper;
+import fr.ifremer.suiviobsmer.WaoRunner;
+import fr.ifremer.suiviobsmer.WaoContext;
import fr.ifremer.suiviobsmer.bean.BoatFilterImpl;
-import fr.ifremer.suiviobsmer.SuiviObsmerRunnerTest;
+import fr.ifremer.suiviobsmer.WaoRunnerTest;
import fr.ifremer.suiviobsmer.bean.BoatFilter;
import fr.ifremer.suiviobsmer.bean.CompanyBoatInfos;
import fr.ifremer.suiviobsmer.bean.ContactState;
@@ -71,7 +71,7 @@
*/
public class ServiceBoatImplTest {
- private static SuiviObsmerRunner runner;
+ private static WaoRunner runner;
private static final Logger log = LoggerFactory.getLogger(ServiceBoatImplTest.class);
@@ -82,7 +82,7 @@
@BeforeClass
public static void setUpClass() throws Exception {
- runner = new SuiviObsmerRunnerTest();
+ runner = new WaoRunnerTest();
}
@AfterClass
@@ -204,15 +204,15 @@
}
private List<SampleRow> prepareSampleRows(Company company)
- throws SuiviObsmerException, TopiaException {
+ throws WaoException, TopiaException {
ServiceReferential serviceReferential = new ServiceReferentialImpl();
InputStream input = getClass().getResourceAsStream("/import/zonesPeche.csv");
serviceReferential.importFishingZoneCsv(input);
- TopiaContext transaction = SuiviObsmerContext.getTopiaRootContext().beginTransaction();
+ TopiaContext transaction = WaoContext.getTopiaRootContext().beginTransaction();
// Create a company
- CompanyDAO companyDAO = SuiviObsmerModelDAOHelper.getCompanyDAO(transaction);
- SuiviObsmerContext.prepareTopiaId(Company.class, company);
+ CompanyDAO companyDAO = WaoModelDAOHelper.getCompanyDAO(transaction);
+ WaoContext.prepareTopiaId(Company.class, company);
companyDAO.update(company);
companyDAO.create(Company.NAME, "BIS");
transaction.commitTransaction();
@@ -222,7 +222,7 @@
serviceSampling.importSamplingPlanCsv(input);
// Get two SampleRows : 2009_3 & 2010_4
- SampleRowDAO rowDAO = SuiviObsmerModelDAOHelper.getSampleRowDAO(transaction);
+ SampleRowDAO rowDAO = WaoModelDAOHelper.getSampleRowDAO(transaction);
SampleRow row1 = rowDAO.findByCode("2009_0003");
row1.getProfession();
SampleRow row2 = rowDAO.findByCode("2010_0004");
@@ -267,8 +267,8 @@
serviceUser.createUpdateUser(user, true);
List<SampleRow> rows = prepareSampleRows(company);
- TopiaContext transaction = SuiviObsmerContext.getTopiaRootContext().beginTransaction();
- SampleRowDAO rowDAO = SuiviObsmerModelDAOHelper.getSampleRowDAO(transaction);
+ TopiaContext transaction = WaoContext.getTopiaRootContext().beginTransaction();
+ SampleRowDAO rowDAO = WaoModelDAOHelper.getSampleRowDAO(transaction);
SampleRow row = rowDAO.findByCode("2010_0001");
row.getCompany();
row.getProfession();
@@ -355,14 +355,14 @@
log.info("getLastActivityCalendar");
/** PREPARE DATA **/
- TopiaContext transaction = SuiviObsmerContext.getTopiaRootContext().beginTransaction();
+ TopiaContext transaction = WaoContext.getTopiaRootContext().beginTransaction();
- BoatDAO boatDAO = SuiviObsmerModelDAOHelper.getBoatDAO(transaction);
+ BoatDAO boatDAO = WaoModelDAOHelper.getBoatDAO(transaction);
Boat boat = boatDAO.create(
Boat.NAME, "TESTBOAT",
Boat.IMMATRICULATION, 174592);
- ActivityCalendarDAO dao = SuiviObsmerModelDAOHelper.getActivityCalendarDAO(transaction);
+ ActivityCalendarDAO dao = WaoModelDAOHelper.getActivityCalendarDAO(transaction);
ActivityCalendar calendar1 = dao.create(
ActivityCalendar.BOAT, boat,
@@ -391,8 +391,8 @@
Assert.assertNotNull(result);
Assert.assertEquals(2009, result.getYear());
- String filename = SuiviObsmerContext.getProperty(
- SuiviObsmerContext.PROP_FILENAME_LOG_ACTIVITY_ACCESS);
+ String filename = WaoContext.getProperty(
+ WaoContext.PROP_FILENAME_LOG_ACTIVITY_ACCESS);
File file = new File(filename);
Assert.assertTrue(file.exists());
Modified: trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/services/ServiceReferentialImplTest.java
===================================================================
--- trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/services/ServiceReferentialImplTest.java 2010-02-16 10:56:02 UTC (rev 353)
+++ trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/services/ServiceReferentialImplTest.java 2010-02-16 12:00:05 UTC (rev 354)
@@ -1,6 +1,6 @@
/*
* *##%
- * SuiviObsmer :: Business
+ * Wao :: Business
* Copyright (C) 2009 - 2010 Ifremer
*
* This program is free software: you can redistribute it and/or modify
@@ -21,9 +21,9 @@
package fr.ifremer.suiviobsmer.services;
-import fr.ifremer.suiviobsmer.SuiviObsmerException;
-import fr.ifremer.suiviobsmer.SuiviObsmerRunner;
-import fr.ifremer.suiviobsmer.SuiviObsmerRunnerTest;
+import fr.ifremer.suiviobsmer.WaoException;
+import fr.ifremer.suiviobsmer.WaoRunner;
+import fr.ifremer.suiviobsmer.WaoRunnerTest;
import fr.ifremer.suiviobsmer.bean.SamplingFilter;
import fr.ifremer.suiviobsmer.bean.SamplingFilterImpl;
import fr.ifremer.suiviobsmer.entity.FishingZone;
@@ -44,7 +44,7 @@
*/
public class ServiceReferentialImplTest {
- private static SuiviObsmerRunner runner;
+ private static WaoRunner runner;
private static final Logger log = LoggerFactory.getLogger(ServiceReferentialImplTest.class);
@@ -55,7 +55,7 @@
@BeforeClass
public static void setUpClass() throws Exception {
- runner = new SuiviObsmerRunnerTest();
+ runner = new WaoRunnerTest();
}
@AfterClass
@@ -125,10 +125,10 @@
/**
* Test of getFishingZones method, of class ServiceReferentialImpl.
- * @throws SuiviObsmerException if error during import or getFishingZones
+ * @throws WaoException if error during import or getFishingZones
*/
@Test
- public void testGetFishingZones() throws SuiviObsmerException {
+ public void testGetFishingZones() throws WaoException {
log.info("getFishingZones");
InputStream input = getClass().getResourceAsStream("/import/zonesPeche.csv");
@@ -141,10 +141,10 @@
/**
* Test of importFishingZoneCsv method, of class ServiceReferentialImpl.
- * @throws SuiviObsmerException if import error
+ * @throws WaoException if import error
*/
@Test
- public void testImportFishingZoneCsv() throws SuiviObsmerException {
+ public void testImportFishingZoneCsv() throws WaoException {
log.info("importFishingZoneCsv");
InputStream input = getClass().getResourceAsStream("/import/zonesPeche.csv");
Modified: trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/services/ServiceSamplingImplTest.java
===================================================================
--- trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/services/ServiceSamplingImplTest.java 2010-02-16 10:56:02 UTC (rev 353)
+++ trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/services/ServiceSamplingImplTest.java 2010-02-16 12:00:05 UTC (rev 354)
@@ -1,6 +1,6 @@
/*
* *##%
- * SuiviObsmer :: Business
+ * Wao :: Business
* Copyright (C) 2009 - 2010 Ifremer
*
* This program is free software: you can redistribute it and/or modify
@@ -21,14 +21,14 @@
package fr.ifremer.suiviobsmer.services;
-import fr.ifremer.suiviobsmer.SuiviObsmerException;
-import fr.ifremer.suiviobsmer.SuiviObsmerModelDAOHelper;
-import fr.ifremer.suiviobsmer.SuiviObsmerRunner;
-import fr.ifremer.suiviobsmer.SuiviObsmerContext;
+import fr.ifremer.suiviobsmer.WaoException;
+import fr.ifremer.suiviobsmer.WaoModelDAOHelper;
+import fr.ifremer.suiviobsmer.WaoRunner;
+import fr.ifremer.suiviobsmer.WaoContext;
import fr.ifremer.suiviobsmer.bean.ImportResults;
import fr.ifremer.suiviobsmer.bean.SamplingFilter;
import fr.ifremer.suiviobsmer.bean.SamplingFilterImpl;
-import fr.ifremer.suiviobsmer.SuiviObsmerRunnerTest;
+import fr.ifremer.suiviobsmer.WaoRunnerTest;
import fr.ifremer.suiviobsmer.bean.FacadeRow;
import fr.ifremer.suiviobsmer.entity.Boat;
import fr.ifremer.suiviobsmer.entity.Company;
@@ -79,7 +79,7 @@
*/
public class ServiceSamplingImplTest {
- private static SuiviObsmerRunner runner;
+ private static WaoRunner runner;
private static final Logger log = LoggerFactory.getLogger(ServiceSamplingImplTest.class);
@@ -90,7 +90,7 @@
@BeforeClass
public static void setUpClass() throws Exception {
- runner = new SuiviObsmerRunnerTest();
+ runner = new WaoRunnerTest();
}
@AfterClass
@@ -113,7 +113,7 @@
log.info("createUpdateSampleRow");
/** PREPARE DATA **/
- TopiaContext transaction = SuiviObsmerContext.getTopiaRootContext().beginTransaction();
+ TopiaContext transaction = WaoContext.getTopiaRootContext().beginTransaction();
List<FishingZone> zones = prepareFishingZones(transaction);
@@ -187,7 +187,7 @@
/** PREPARE DATA **/
- TopiaContext transaction = SuiviObsmerContext.getTopiaRootContext().beginTransaction();
+ TopiaContext transaction = WaoContext.getTopiaRootContext().beginTransaction();
List<FishingZone> zones = prepareFishingZones(transaction);
@@ -201,7 +201,7 @@
Date dateEnd2 = DateUtils.createDate(1, 12, 2008);
PeriodDates period2 = new PeriodDates(dateBegin2, dateEnd2);
- SampleRowDAO dao = SuiviObsmerModelDAOHelper.getSampleRowDAO(transaction);
+ SampleRowDAO dao = WaoModelDAOHelper.getSampleRowDAO(transaction);
SampleRow row1 = dao.create();
row1.setCode("2010_0001");
@@ -291,9 +291,9 @@
}
- private List<FishingZone> prepareFishingZones(TopiaContext transaction) throws SuiviObsmerException, TopiaException {
+ private List<FishingZone> prepareFishingZones(TopiaContext transaction) throws WaoException, TopiaException {
- FishingZoneDAO fishingZoneDAO = SuiviObsmerModelDAOHelper.getFishingZoneDAO(transaction);
+ FishingZoneDAO fishingZoneDAO = WaoModelDAOHelper.getFishingZoneDAO(transaction);
FishingZone fishingZone1 = fishingZoneDAO.create();
fishingZone1.setFacadeName("Atlantique");
@@ -318,18 +318,18 @@
public void testGetSampleRowsForUser() throws Exception {
log.info("getSampleRowsForUser");
/** PREPARE DATA **/
- TopiaContext transaction = SuiviObsmerContext.getTopiaRootContext().beginTransaction();
+ TopiaContext transaction = WaoContext.getTopiaRootContext().beginTransaction();
- FishingZoneDAO zoneDAO = SuiviObsmerModelDAOHelper.getFishingZoneDAO(transaction);
+ FishingZoneDAO zoneDAO = WaoModelDAOHelper.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 = SuiviObsmerModelDAOHelper.getCompanyDAO(transaction);
+ CompanyDAO companyDAO = WaoModelDAOHelper.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 = SuiviObsmerModelDAOHelper.getSampleRowDAO(transaction);
+ SampleRowDAO sampleRowDAO = WaoModelDAOHelper.getSampleRowDAO(transaction);
SampleRow row = sampleRowDAO.create(
SampleRow.CODE,"2010_178",
SampleRow.COMPANY,company,
@@ -383,9 +383,9 @@
/** PREPARE DATA **/
- TopiaContext transaction = SuiviObsmerContext.getTopiaRootContext().beginTransaction();
+ TopiaContext transaction = WaoContext.getTopiaRootContext().beginTransaction();
- ProfessionDAO dao = SuiviObsmerModelDAOHelper.getProfessionDAO(transaction);
+ ProfessionDAO dao = WaoModelDAOHelper.getProfessionDAO(transaction);
Profession profession = dao.create(
Profession.CODE_DCF5, "OBR",
@@ -413,14 +413,14 @@
log.info("deleteSampleRow");
/** PREPARE DATA **/
- TopiaContext transaction = SuiviObsmerContext.getTopiaRootContext().beginTransaction();
+ TopiaContext transaction = WaoContext.getTopiaRootContext().beginTransaction();
- FishingZoneDAO zoneDAO = SuiviObsmerModelDAOHelper.getFishingZoneDAO(transaction);
+ FishingZoneDAO zoneDAO = WaoModelDAOHelper.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 = SuiviObsmerModelDAOHelper.getCompanyDAO(transaction);
+ CompanyDAO companyDAO = WaoModelDAOHelper.getCompanyDAO(transaction);
companyDAO.create(Company.NAME, "TARTANPION");
companyDAO.create(Company.NAME, "BIS");
transaction.commitTransaction();
@@ -429,7 +429,7 @@
InputStream input = getClass().getResourceAsStream("/import/echantillonnage.csv");
service.importSamplingPlanCsv(input);
- SampleRowDAO rowDAO = SuiviObsmerModelDAOHelper.getSampleRowDAO(transaction);
+ SampleRowDAO rowDAO = WaoModelDAOHelper.getSampleRowDAO(transaction);
SampleRow row = rowDAO.findByCode("2010_0001");
row.getProfession();
row.getCompany();
@@ -444,30 +444,30 @@
/** EXEC METHOD **/
service.deleteSampleRow(row);
- transaction = SuiviObsmerContext.getTopiaRootContext().beginTransaction();
- rowDAO = SuiviObsmerModelDAOHelper.getSampleRowDAO(transaction);
+ transaction = WaoContext.getTopiaRootContext().beginTransaction();
+ rowDAO = WaoModelDAOHelper.getSampleRowDAO(transaction);
row = rowDAO.findByCode("2010_0001");
assertNull(row);
- ElligibleBoatDAO elligibleDAO = SuiviObsmerModelDAOHelper.getElligibleBoatDAO(transaction);
+ ElligibleBoatDAO elligibleDAO = WaoModelDAOHelper.getElligibleBoatDAO(transaction);
List<ElligibleBoat> elligibles = elligibleDAO.findAll();
assertEquals(0, elligibles.size());
transaction.closeContext();
}
@Test
- public void testImportSamplingPlanCsv() throws SuiviObsmerException, TopiaException {
+ public void testImportSamplingPlanCsv() throws WaoException, TopiaException {
log.info("importSamplingPlanCsv");
/** PREPARE DATA **/
- TopiaContext transaction = SuiviObsmerContext.getTopiaRootContext().beginTransaction();
+ TopiaContext transaction = WaoContext.getTopiaRootContext().beginTransaction();
- FishingZoneDAO zoneDAO = SuiviObsmerModelDAOHelper.getFishingZoneDAO(transaction);
+ FishingZoneDAO zoneDAO = WaoModelDAOHelper.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 = SuiviObsmerModelDAOHelper.getCompanyDAO(transaction);
+ CompanyDAO companyDAO = WaoModelDAOHelper.getCompanyDAO(transaction);
companyDAO.create(Company.NAME, "TARTANPION");
companyDAO.create(Company.NAME, "BIS");
transaction.commitTransaction();
@@ -483,14 +483,14 @@
assertEquals(1, result.getNbRowsRefused());
/** CHECK VALUES **/
- transaction = SuiviObsmerContext.getTopiaRootContext().beginTransaction();
+ transaction = WaoContext.getTopiaRootContext().beginTransaction();
- ProfessionDAO professionDAO = SuiviObsmerModelDAOHelper.getProfessionDAO(transaction);
+ ProfessionDAO professionDAO = WaoModelDAOHelper.getProfessionDAO(transaction);
List<Profession> professions = professionDAO.findAll();
assertEquals(9, professions.size());
- SampleRowDAO rowDAO = SuiviObsmerModelDAOHelper.getSampleRowDAO(transaction);
+ SampleRowDAO rowDAO = WaoModelDAOHelper.getSampleRowDAO(transaction);
SampleRow row1 = rowDAO.findByCode("2010_0001");
assertNotNull(row1);
@@ -518,14 +518,14 @@
@Test
public void testGetPrograms() throws Exception {
/** PREPARE DATA **/
- TopiaContext transaction = SuiviObsmerContext.getTopiaRootContext().beginTransaction();
+ TopiaContext transaction = WaoContext.getTopiaRootContext().beginTransaction();
- FishingZoneDAO zoneDAO = SuiviObsmerModelDAOHelper.getFishingZoneDAO(transaction);
+ FishingZoneDAO zoneDAO = WaoModelDAOHelper.getFishingZoneDAO(transaction);
zoneDAO.create(FishingZone.DISTRICT_CODE, "IId");
zoneDAO.create(FishingZone.DISTRICT_CODE, "IV");
zoneDAO.create(FishingZone.DISTRICT_CODE, "I");
- CompanyDAO companyDAO = SuiviObsmerModelDAOHelper.getCompanyDAO(transaction);
+ CompanyDAO companyDAO = WaoModelDAOHelper.getCompanyDAO(transaction);
companyDAO.create(Company.NAME, "TARTANPION");
companyDAO.create(Company.NAME, "BIS");
transaction.commitTransaction();
@@ -545,14 +545,14 @@
log.info("getNewSampleRowCode");
/** PREPARE DATA **/
- TopiaContext transaction = SuiviObsmerContext.getTopiaRootContext().beginTransaction();
+ TopiaContext transaction = WaoContext.getTopiaRootContext().beginTransaction();
- FishingZoneDAO zoneDAO = SuiviObsmerModelDAOHelper.getFishingZoneDAO(transaction);
+ FishingZoneDAO zoneDAO = WaoModelDAOHelper.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 = SuiviObsmerModelDAOHelper.getCompanyDAO(transaction);
+ CompanyDAO companyDAO = WaoModelDAOHelper.getCompanyDAO(transaction);
companyDAO.create(Company.NAME, "TARTANPION");
companyDAO.create(Company.NAME, "BIS");
transaction.commitTransaction();
Modified: trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/services/ServiceSynthesisImplTest.java
===================================================================
--- trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/services/ServiceSynthesisImplTest.java 2010-02-16 10:56:02 UTC (rev 353)
+++ trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/services/ServiceSynthesisImplTest.java 2010-02-16 12:00:05 UTC (rev 354)
@@ -1,10 +1,30 @@
+/*
+ * *##%
+ * 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.suiviobsmer.services;
-import fr.ifremer.suiviobsmer.SuiviObsmerContext;
-import fr.ifremer.suiviobsmer.SuiviObsmerModelDAOHelper;
-import fr.ifremer.suiviobsmer.SuiviObsmerRunner;
-import fr.ifremer.suiviobsmer.SuiviObsmerRunnerTest;
+import fr.ifremer.suiviobsmer.WaoContext;
+import fr.ifremer.suiviobsmer.WaoModelDAOHelper;
+import fr.ifremer.suiviobsmer.WaoRunner;
+import fr.ifremer.suiviobsmer.WaoRunnerTest;
import fr.ifremer.suiviobsmer.bean.BoardingResult;
import fr.ifremer.suiviobsmer.bean.ContactAverageReactivity;
import fr.ifremer.suiviobsmer.bean.ContactState;
@@ -43,7 +63,7 @@
*/
public class ServiceSynthesisImplTest {
- private static SuiviObsmerRunner runner;
+ private static WaoRunner runner;
private static final Logger log = LoggerFactory.getLogger(ServiceSynthesisImplTest.class);
@@ -54,7 +74,7 @@
@BeforeClass
public static void setUpClass() throws Exception {
- runner = new SuiviObsmerRunnerTest();
+ runner = new WaoRunnerTest();
}
@AfterClass
@@ -96,13 +116,13 @@
List<Boat> boats2 = serviceBoat.getBoatsByImmatriculations("177474");
Boat boat2 = boats2.get(0);
- TopiaContext transaction = SuiviObsmerContext.getTopiaRootContext().beginTransaction();
+ TopiaContext transaction = WaoContext.getTopiaRootContext().beginTransaction();
- CompanyDAO companyDAO = SuiviObsmerModelDAOHelper.getCompanyDAO(transaction);
+ CompanyDAO companyDAO = WaoModelDAOHelper.getCompanyDAO(transaction);
Company company = companyDAO.create(Company.NAME, "TARTANPION");
Company company2 = companyDAO.create(Company.NAME, "BIS");
- WaoUserDAO userDAO = SuiviObsmerModelDAOHelper.getWaoUserDAO(transaction);
+ WaoUserDAO userDAO = WaoModelDAOHelper.getWaoUserDAO(transaction);
WaoUser user = userDAO.create(WaoUser.FIRST_NAME,"Jean", WaoUser.LAST_NAME, "Michmuche",
WaoUser.COMPANY, company);
company.addWaoUser(user);
@@ -120,7 +140,7 @@
ServiceSampling serviceSampling = new ServiceSamplingImpl();
serviceSampling.importSamplingPlanCsv(input);
- SampleRowDAO rowDAO = SuiviObsmerModelDAOHelper.getSampleRowDAO(transaction);
+ SampleRowDAO rowDAO = WaoModelDAOHelper.getSampleRowDAO(transaction);
SampleRow row = rowDAO.findByCode("2010_0001");
transaction.closeContext();
@@ -184,13 +204,13 @@
List<Boat> boats2 = serviceBoat.getBoatsByImmatriculations("177474");
Boat boat2 = boats2.get(0);
- TopiaContext transaction = SuiviObsmerContext.getTopiaRootContext().beginTransaction();
+ TopiaContext transaction = WaoContext.getTopiaRootContext().beginTransaction();
- CompanyDAO companyDAO = SuiviObsmerModelDAOHelper.getCompanyDAO(transaction);
+ CompanyDAO companyDAO = WaoModelDAOHelper.getCompanyDAO(transaction);
Company company = companyDAO.create(Company.NAME, "TARTANPION");
Company company2 = companyDAO.create(Company.NAME, "BIS");
- WaoUserDAO userDAO = SuiviObsmerModelDAOHelper.getWaoUserDAO(transaction);
+ WaoUserDAO userDAO = WaoModelDAOHelper.getWaoUserDAO(transaction);
WaoUser user = userDAO.create(WaoUser.FIRST_NAME,"Jean", WaoUser.LAST_NAME, "Michmuche",
WaoUser.COMPANY, company);
company.addWaoUser(user);
@@ -208,7 +228,7 @@
ServiceSampling serviceSampling = new ServiceSamplingImpl();
serviceSampling.importSamplingPlanCsv(input);
- SampleRowDAO rowDAO = SuiviObsmerModelDAOHelper.getSampleRowDAO(transaction);
+ SampleRowDAO rowDAO = WaoModelDAOHelper.getSampleRowDAO(transaction);
SampleRow row = rowDAO.findByCode("2010_0001");
SampleRow row2 = rowDAO.findByCode("2009_0006");
@@ -291,13 +311,13 @@
List<Boat> boats2 = serviceBoat.getBoatsByImmatriculations("177474");
Boat boat2 = boats2.get(0);
- TopiaContext transaction = SuiviObsmerContext.getTopiaRootContext().beginTransaction();
+ TopiaContext transaction = WaoContext.getTopiaRootContext().beginTransaction();
- CompanyDAO companyDAO = SuiviObsmerModelDAOHelper.getCompanyDAO(transaction);
+ CompanyDAO companyDAO = WaoModelDAOHelper.getCompanyDAO(transaction);
Company company = companyDAO.create(Company.NAME, "TARTANPION");
Company company2 = companyDAO.create(Company.NAME, "BIS");
- WaoUserDAO userDAO = SuiviObsmerModelDAOHelper.getWaoUserDAO(transaction);
+ WaoUserDAO userDAO = WaoModelDAOHelper.getWaoUserDAO(transaction);
WaoUser user = userDAO.create(WaoUser.FIRST_NAME,"Jean", WaoUser.LAST_NAME, "Michmuche",
WaoUser.COMPANY, company);
company.addWaoUser(user);
@@ -315,7 +335,7 @@
ServiceSampling serviceSampling = new ServiceSamplingImpl();
serviceSampling.importSamplingPlanCsv(input);
- SampleRowDAO rowDAO = SuiviObsmerModelDAOHelper.getSampleRowDAO(transaction);
+ SampleRowDAO rowDAO = WaoModelDAOHelper.getSampleRowDAO(transaction);
SampleRow row = rowDAO.findByCode("2010_0001");
transaction.closeContext();
@@ -434,13 +454,13 @@
List<Boat> boats2 = serviceBoat.getBoatsByImmatriculations("177474");
Boat boat2 = boats2.get(0);
- TopiaContext transaction = SuiviObsmerContext.getTopiaRootContext().beginTransaction();
+ TopiaContext transaction = WaoContext.getTopiaRootContext().beginTransaction();
- CompanyDAO companyDAO = SuiviObsmerModelDAOHelper.getCompanyDAO(transaction);
+ CompanyDAO companyDAO = WaoModelDAOHelper.getCompanyDAO(transaction);
Company company = companyDAO.create(Company.NAME, "TARTANPION");
Company company2 = companyDAO.create(Company.NAME, "BIS");
- WaoUserDAO userDAO = SuiviObsmerModelDAOHelper.getWaoUserDAO(transaction);
+ WaoUserDAO userDAO = WaoModelDAOHelper.getWaoUserDAO(transaction);
WaoUser user = userDAO.create(WaoUser.FIRST_NAME,"Jean", WaoUser.LAST_NAME, "Michmuche",
WaoUser.COMPANY, company);
company.addWaoUser(user);
@@ -458,7 +478,7 @@
ServiceSampling serviceSampling = new ServiceSamplingImpl();
serviceSampling.importSamplingPlanCsv(input);
- SampleRowDAO rowDAO = SuiviObsmerModelDAOHelper.getSampleRowDAO(transaction);
+ SampleRowDAO rowDAO = WaoModelDAOHelper.getSampleRowDAO(transaction);
SampleRow row = rowDAO.findByCode("2010_0001");
SampleRow row2 = rowDAO.findByCode("2009_0006");
Deleted: trunk/suiviobsmer-business/src/test/resources/TopiaContextSuiviObsmer.properties
===================================================================
--- trunk/suiviobsmer-business/src/test/resources/TopiaContextSuiviObsmer.properties 2010-02-16 10:56:02 UTC (rev 353)
+++ trunk/suiviobsmer-business/src/test/resources/TopiaContextSuiviObsmer.properties 2010-02-16 12:00:05 UTC (rev 354)
@@ -1,12 +0,0 @@
-# Propri\u00C3\u00A9t\u00C3\u00A9s par d\u00C3\u00A9faut pour une base de donn\u00C3\u00A9es de type H2
-hibernate.hbm2ddl.auto=update
-hibernate.show_sql=false
-
-hibernate.dialect=org.hibernate.dialect.H2Dialect
-hibernate.connection.username=sa
-hibernate.connection.password=
-hibernate.connection.driver_class=org.h2.Driver
-hibernate.connection.url=jdbc:h2:file:target/db/h2data
-
-suiviobsmer.log.activityCalendar.import=target/log/activity.log
-suiviobsmer.log.activityCalendar.access=target/log/activity-access.log
\ No newline at end of file
Copied: trunk/suiviobsmer-business/src/test/resources/WaoTest.properties (from rev 350, trunk/suiviobsmer-business/src/test/resources/TopiaContextSuiviObsmer.properties)
===================================================================
--- trunk/suiviobsmer-business/src/test/resources/WaoTest.properties (rev 0)
+++ trunk/suiviobsmer-business/src/test/resources/WaoTest.properties 2010-02-16 12:00:05 UTC (rev 354)
@@ -0,0 +1,11 @@
+hibernate.hbm2ddl.auto=update
+hibernate.show_sql=false
+
+hibernate.dialect=org.hibernate.dialect.H2Dialect
+hibernate.connection.username=sa
+hibernate.connection.password=
+hibernate.connection.driver_class=org.h2.Driver
+hibernate.connection.url=jdbc:h2:file:target/db/h2data
+
+wao.log.activityCalendar.import=target/log/activity.log
+wao.log.activityCalendar.access=target/log/activity-access.log
\ No newline at end of file
Property changes on: trunk/suiviobsmer-business/src/test/resources/WaoTest.properties
___________________________________________________________________
Added: svn:mergeinfo
+
Modified: trunk/suiviobsmer-ui/pom.xml
===================================================================
--- trunk/suiviobsmer-ui/pom.xml 2010-02-16 10:56:02 UTC (rev 353)
+++ trunk/suiviobsmer-ui/pom.xml 2010-02-16 12:00:05 UTC (rev 354)
@@ -9,17 +9,18 @@
<parent>
<groupId>fr.ifremer</groupId>
- <artifactId>suiviobsmer</artifactId>
- <version>1.0.0-SNAPSHOT</version>
+ <artifactId>wao</artifactId>
+ <version>1.0-SNAPSHOT</version>
</parent>
- <groupId>fr.ifremer.suiviobsmer</groupId>
+ <groupId>fr.ifremer.wao</groupId>
<artifactId>suiviobsmer-ui</artifactId>
<dependencies>
+ <!-- Wao business : services and entities -->
<dependency>
- <groupId>fr.ifremer.suiviobsmer</groupId>
+ <groupId>fr.ifremer.wao</groupId>
<artifactId>suiviobsmer-business</artifactId>
<version>${project.version}</version>
</dependency>
@@ -27,10 +28,12 @@
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
</dependency>
+ <!-- Utils -->
<dependency>
<groupId>org.nuiton</groupId>
<artifactId>nuiton-utils</artifactId>
</dependency>
+ <!-- Tapestry framework + components -->
<dependency>
<groupId>org.apache.tapestry</groupId>
<artifactId>tapestry-core</artifactId>
@@ -47,14 +50,17 @@
<groupId>com.orientimport</groupId>
<artifactId>t5-easy-fckeditor</artifactId>
</dependency>
+ <!-- Graph library for synthesis -->
<dependency>
<groupId>jfree</groupId>
<artifactId>jfreechart</artifactId>
</dependency>
+ <!-- Tests -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
+ <!-- Logging -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
@@ -63,6 +69,7 @@
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</dependency>
+ <!-- Embedded war lib for Nuiton-utils WarLauncher -->
<dependency>
<groupId>org.jvnet.hudson.winstone</groupId>
<artifactId>winstone</artifactId>
@@ -75,8 +82,8 @@
<!-- *** Project Information ************************************* -->
<!-- ************************************************************* -->
- <name>SuiviObsmer :: Web Interface</name>
- <description>Interface utilisateur du SuiviObsmer</description>
+ <name>Wao :: Web Interface</name>
+ <description>Interface utilisateur du Wao</description>
<!-- ************************************************************* -->
<!-- *** Build Settings ****************************************** -->
@@ -89,7 +96,7 @@
<!-- ************************************************************* -->
<build>
<!-- call result war : suiviobsmer-xxx.war -->
- <finalName>wao-${project.version}</finalName>
+ <!--<finalName>wao-${project.version}</finalName>-->
<!-- Add main class into war to make it executable -->
<plugins>
@@ -123,6 +130,7 @@
<repositories>
+ <!-- Repository for fckeditor component needed for News page -->
<repository>
<id>m2-release-repository.orientimport.kenai.com</id>
<name>Orient Import Oy Maven Release Repository</name>
Modified: trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/base/AbstractFilteredPage.java
===================================================================
--- trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/base/AbstractFilteredPage.java 2010-02-16 10:56:02 UTC (rev 353)
+++ trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/base/AbstractFilteredPage.java 2010-02-16 12:00:05 UTC (rev 354)
@@ -1,6 +1,6 @@
/*
* *##%
- * SuiviObsmer :: Web Interface
+ * Wao :: Web Interface
* Copyright (C) 2009 - 2010 Ifremer
*
* This program is free software: you can redistribute it and/or modify
@@ -21,7 +21,7 @@
package fr.ifremer.suiviobsmer.ui.base;
-import fr.ifremer.suiviobsmer.SuiviObsmerException;
+import fr.ifremer.suiviobsmer.WaoException;
import fr.ifremer.suiviobsmer.bean.BoatFilter;
import fr.ifremer.suiviobsmer.entity.Company;
import fr.ifremer.suiviobsmer.entity.SampleRow;
@@ -141,9 +141,9 @@
*
* @param companySelect if true, company select will be initialized
* @param observerSelect if true, observer select will be initialized
- * @throws SuiviObsmerException
+ * @throws WaoException
*/
- protected void initSelectFilters(boolean companySelect, boolean observerSelect, boolean programSelect) throws SuiviObsmerException {
+ protected void initSelectFilters(boolean companySelect, boolean observerSelect, boolean programSelect) throws WaoException {
this.observerSelect = observerSelect;
this.programSelect = programSelect;
@@ -185,22 +185,22 @@
resetSampleRowSelect();
}
- protected void resetCompanySelect() throws SuiviObsmerException {
+ protected void resetCompanySelect() throws WaoException {
companySelectModel = null;
getCompanySelectModel();
}
- protected void resetFacadeSelect() throws SuiviObsmerException {
+ protected void resetFacadeSelect() throws WaoException {
facadeSelectModel = null;
getFacadeSelectModel();
}
- protected void resetSectorSelect() throws SuiviObsmerException {
+ protected void resetSectorSelect() throws WaoException {
sectorSelectModel = null;
getSectorSelectModel();
}
- protected void resetSampleRowSelect() throws SuiviObsmerException {
+ protected void resetSampleRowSelect() throws WaoException {
sampleRowSelectModel = null;
getSampleRowSelectModel();
}
@@ -210,9 +210,9 @@
* filter.
*
* @return the SelectModel for facade names
- * @throws SuiviObsmerException
+ * @throws WaoException
*/
- public SelectModel getFacadeSelectModel() throws SuiviObsmerException {
+ public SelectModel getFacadeSelectModel() throws WaoException {
if (facadeSelectModel == null) {
if (log.isInfoEnabled()) {
log.info("BUSINESS REQUEST [getFacades]");
@@ -231,9 +231,9 @@
* company set in filter.
*
* @return the SelectModel for sector names
- * @throws SuiviObsmerException
+ * @throws WaoException
*/
- public SelectModel getSectorSelectModel() throws SuiviObsmerException {
+ public SelectModel getSectorSelectModel() throws WaoException {
if (sectorSelectModel == null) {
if (log.isInfoEnabled()) {
log.info("BUSINESS REQUEST [getSectors]");
@@ -253,9 +253,9 @@
* only one element in the select.
*
* @return the GenericSelectModel<SampleRow> for sampleRows
- * @throws SuiviObsmerException
+ * @throws WaoException
*/
- public GenericSelectModel<SampleRow> getSampleRowSelectModel() throws SuiviObsmerException {
+ public GenericSelectModel<SampleRow> getSampleRowSelectModel() throws WaoException {
if (sampleRowSelectModel == null) {
if (log.isInfoEnabled()) {
log.info("BUSINESS REQUEST [getSampleRowsByFilter]");
@@ -279,9 +279,9 @@
* companies. This select model is only used by admin users.
*
* @return the GenericSelectModel<Company> for companies
- * @throws SuiviObsmerException
+ * @throws WaoException
*/
- public GenericSelectModel<Company> getCompanySelectModel() throws SuiviObsmerException {
+ public GenericSelectModel<Company> getCompanySelectModel() throws WaoException {
if (companySelectModel == null) {
if (log.isDebugEnabled()) {
log.debug("BUSINESS REQUEST [getCompanies]");
@@ -299,9 +299,9 @@
* companies.
*
* @return the GenericSelectModel<WaoUser> for observers
- * @throws SuiviObsmerException
+ * @throws WaoException
*/
- public GenericSelectModel<WaoUser> getObserverSelectModel() throws SuiviObsmerException {
+ public GenericSelectModel<WaoUser> getObserverSelectModel() throws WaoException {
if (observerSelectModel == null) {
List<WaoUser> observers = new ArrayList<WaoUser>();
if (getFilter().getCompany() != null) {
@@ -323,9 +323,9 @@
* filter.
*
* @return the SelectModel for program names
- * @throws SuiviObsmerException
+ * @throws WaoException
*/
- public SelectModel getProgramSelectModel() throws SuiviObsmerException {
+ public SelectModel getProgramSelectModel() throws WaoException {
if (programSelectModel == null) {
if (log.isInfoEnabled()) {
log.info("BUSINESS REQUEST [getPrograms]");
@@ -339,7 +339,7 @@
return programSelectModel;
}
- protected abstract BoatFilter getFilter() throws SuiviObsmerException;
+ protected abstract BoatFilter getFilter() throws WaoException;
/**
* Used to show only active company and observers.
@@ -348,7 +348,7 @@
*/
protected abstract boolean isAvailableDataForFiltersOnly();
- public String[] onProvideCompletionsFromBoatName(String input) throws SuiviObsmerException {
+ public String[] onProvideCompletionsFromBoatName(String input) throws WaoException {
if (log.isInfoEnabled()) {
log.info("BUSINESS REQUEST [getBoatNamesStartWith]");
}
@@ -360,9 +360,9 @@
* Called when search submit button is pressed. This method is useful to
* refresh all filters data from selects.
*
- * @throws SuiviObsmerException
+ * @throws WaoException
*/
- public void onSelectedFromSearch() throws SuiviObsmerException {
+ public void onSelectedFromSearch() throws WaoException {
if (log.isDebugEnabled()) {
log.debug("REFRESH FILTERS DATA");
}
@@ -389,10 +389,10 @@
* This method set the state to edited, you can use
* {@link AbstractFilteredPage#isEdited() } method to test it.
*
- * @throws SuiviObsmerException
+ * @throws WaoException
* @see AbstractFilteredPage#onSelectedFromRefreshByProgram()
*/
- public void onSelectedFromRefreshByCompany() throws SuiviObsmerException {
+ public void onSelectedFromRefreshByCompany() throws WaoException {
// Reset programs (the behavior is needed even if programSelect is false)
getFilter().setProgramName(null);
onSelectedFromRefreshByProgram();
@@ -415,10 +415,10 @@
* This method set the state to edited, you can use
* {@link AbstractFilteredPage#isEdited() } method to test it.
*
- * @throws SuiviObsmerException
+ * @throws WaoException
* @see AbstractFilteredPage#onSelectedFromRefreshByFacade()
*/
- public void onSelectedFromRefreshByProgram() throws SuiviObsmerException {
+ public void onSelectedFromRefreshByProgram() throws WaoException {
// Reset facades
getFilter().setFacadeName(null);
onSelectedFromRefreshByFacade();
@@ -431,10 +431,10 @@
* This method set the state to edited, you can use
* {@link AbstractFilteredPage#isEdited() } method to test it.
*
- * @throws SuiviObsmerException
+ * @throws WaoException
* @see AbstractFilteredPage#onSelectedFromRefreshBySector()
*/
- public void onSelectedFromRefreshByFacade() throws SuiviObsmerException {
+ public void onSelectedFromRefreshByFacade() throws WaoException {
// Reset sectors
getFilter().setSectorName(null);
onSelectedFromRefreshBySector();
@@ -447,10 +447,10 @@
* This method set the state to edited, you can use
* {@link AbstractFilteredPage#isEdited() } method to test it.
*
- * @throws SuiviObsmerException
+ * @throws WaoException
* @see AbstractFilteredPage#onSelectedFromSearch()
*/
- public void onSelectedFromRefreshBySector() throws SuiviObsmerException {
+ public void onSelectedFromRefreshBySector() throws WaoException {
// Update selected data
onSelectedFromSearch();
// Reset sampleRows;
Modified: trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/base/GenericSelectModel.java
===================================================================
--- trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/base/GenericSelectModel.java 2010-02-16 10:56:02 UTC (rev 353)
+++ trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/base/GenericSelectModel.java 2010-02-16 12:00:05 UTC (rev 354)
@@ -1,6 +1,6 @@
/**
* *##%
- * SuiviObsmer :: Web Interface
+ * Wao :: Web Interface
* Copyright (C) 2009 - 2010 Ifremer
*
* This program is free software: you can redistribute it and/or modify
Deleted: trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/base/SuiviObsmerPage.java
===================================================================
--- trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/base/SuiviObsmerPage.java 2010-02-16 10:56:02 UTC (rev 353)
+++ trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/base/SuiviObsmerPage.java 2010-02-16 12:00:05 UTC (rev 354)
@@ -1,39 +0,0 @@
-/*
- * *##%
- * SuiviObsmer :: Web Interface
- * 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.suiviobsmer.ui.base;
-
-/**
- * SuiviObsmerPage
- *
- * Created: 3 déc. 2009
- *
- * @author fdesbois
- * @version $Revision$
- *
- * Mise a jour: $Date$
- * par : $Author$
- */
-public interface SuiviObsmerPage {
-
- boolean isOnlyForAdmin();
-
-}
Copied: trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/base/WaoPage.java (from rev 350, trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/base/SuiviObsmerPage.java)
===================================================================
--- trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/base/WaoPage.java (rev 0)
+++ trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/base/WaoPage.java 2010-02-16 12:00:05 UTC (rev 354)
@@ -0,0 +1,39 @@
+/*
+ * *##%
+ * Wao :: Web Interface
+ * 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.suiviobsmer.ui.base;
+
+/**
+ * WaoPage
+ *
+ * Created: 3 déc. 2009
+ *
+ * @author fdesbois
+ * @version $Revision$
+ *
+ * Mise a jour: $Date$
+ * par : $Author$
+ */
+public interface WaoPage {
+
+ boolean isOnlyForAdmin();
+
+}
Property changes on: trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/base/WaoPage.java
___________________________________________________________________
Added: svn:mergeinfo
+
Modified: trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/components/BooleanImage.java
===================================================================
--- trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/components/BooleanImage.java 2010-02-16 10:56:02 UTC (rev 353)
+++ trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/components/BooleanImage.java 2010-02-16 12:00:05 UTC (rev 354)
@@ -1,6 +1,6 @@
/*
* *##%
- * SuiviObsmer :: Web Interface
+ * Wao :: Web Interface
* Copyright (C) 2009 - 2010 Ifremer
*
* This program is free software: you can redistribute it and/or modify
Modified: trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/components/Chart.java
===================================================================
--- trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/components/Chart.java 2010-02-16 10:56:02 UTC (rev 353)
+++ trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/components/Chart.java 2010-02-16 12:00:05 UTC (rev 354)
@@ -1,5 +1,5 @@
/* *##%
- * SuiviObsmer :: Web Interface
+ * Wao :: Web Interface
* Copyright (C) 2009 - 2010 Ifremer
*
* This program is free software: you can redistribute it and/or modify
Modified: trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/components/FeedBack.java
===================================================================
--- trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/components/FeedBack.java 2010-02-16 10:56:02 UTC (rev 353)
+++ trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/components/FeedBack.java 2010-02-16 12:00:05 UTC (rev 354)
@@ -1,5 +1,5 @@
/* *##%
- * SuiviObsmer :: Web Interface
+ * Wao :: Web Interface
* Copyright (C) 2009 - 2010 Ifremer
*
* This program is free software: you can redistribute it and/or modify
Modified: trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/components/Layout.java
===================================================================
--- trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/components/Layout.java 2010-02-16 10:56:02 UTC (rev 353)
+++ trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/components/Layout.java 2010-02-16 12:00:05 UTC (rev 354)
@@ -1,6 +1,6 @@
/*
* *##%
- * SuiviObsmer :: Web Interface
+ * Wao :: Web Interface
* Copyright (C) 2009 - 2010 Ifremer
*
* This program is free software: you can redistribute it and/or modify
@@ -21,13 +21,13 @@
package fr.ifremer.suiviobsmer.ui.components;
-import fr.ifremer.suiviobsmer.SuiviObsmerBusinessException;
-import fr.ifremer.suiviobsmer.SuiviObsmerBusinessException.Type;
-import fr.ifremer.suiviobsmer.SuiviObsmerContext;
-import fr.ifremer.suiviobsmer.SuiviObsmerException;
+import fr.ifremer.suiviobsmer.WaoBusinessException;
+import fr.ifremer.suiviobsmer.WaoBusinessException.Type;
+import fr.ifremer.suiviobsmer.WaoContext;
+import fr.ifremer.suiviobsmer.WaoException;
import fr.ifremer.suiviobsmer.entity.WaoUser;
import fr.ifremer.suiviobsmer.services.ServiceUser;
-import fr.ifremer.suiviobsmer.ui.base.SuiviObsmerPage;
+import fr.ifremer.suiviobsmer.ui.base.WaoPage;
import fr.ifremer.suiviobsmer.ui.pages.Index;
import org.apache.commons.lang.StringUtils;
import org.apache.tapestry5.BindingConstants;
@@ -81,7 +81,7 @@
private FeedBack contentFeedback;
@InjectContainer
- private SuiviObsmerPage page;
+ private WaoPage page;
@Inject
private ServiceUser serviceUser;
@@ -113,7 +113,7 @@
}
public String getVersion() {
- return SuiviObsmerContext.getProperty(SuiviObsmerContext.PROP_VERSION);
+ return WaoContext.getProperty(WaoContext.PROP_VERSION);
}
/**
@@ -181,13 +181,13 @@
}
@Log
- Object onSuccessFromConnexionForm() throws SuiviObsmerException {
+ Object onSuccessFromConnexionForm() throws WaoException {
try {
// FIXME-FD20100120 Problem with NPE in Topia --> see Ano #243 on nuiton.org
if (login != null && password != null) {
currentUser = serviceUser.connect(login, password);
}
- } catch (SuiviObsmerBusinessException eee) {
+ } catch (WaoBusinessException eee) {
if (eee.getType().equals(Type.BAD_CONNECTION)) {
connexionFeedback.addError(eee.getMessage());
email = login;
@@ -201,11 +201,11 @@
public boolean hasConnexionErrors() {
return connexionFeedback.hasErrors();
}
- void onSuccessFromForgetPassword() throws SuiviObsmerException {
+ void onSuccessFromForgetPassword() throws WaoException {
try {
serviceUser.forgetPassword(email);
connexionFeedback.addInfo("Un email avec votre nouveau mot de passe vous a été envoyé.");
- } catch (SuiviObsmerBusinessException eee) {
+ } catch (WaoBusinessException eee) {
connexionFeedback.addError(eee.getMessage());
}
}
Modified: trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/components/SubmitContext.java
===================================================================
--- trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/components/SubmitContext.java 2010-02-16 10:56:02 UTC (rev 353)
+++ trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/components/SubmitContext.java 2010-02-16 12:00:05 UTC (rev 354)
@@ -1,6 +1,6 @@
/*
* *##%
- * SuiviObsmer :: Web Interface
+ * Wao :: Web Interface
* Copyright (C) 2009 - 2010 Ifremer
*
* This program is free software: you can redistribute it and/or modify
Modified: trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/data/AbstractMappedGridDataSource.java
===================================================================
--- trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/data/AbstractMappedGridDataSource.java 2010-02-16 10:56:02 UTC (rev 353)
+++ trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/data/AbstractMappedGridDataSource.java 2010-02-16 12:00:05 UTC (rev 354)
@@ -1,7 +1,27 @@
+/*
+ * *##%
+ * Wao :: Web Interface
+ * 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.suiviobsmer.ui.data;
-import fr.ifremer.suiviobsmer.SuiviObsmerException;
+import fr.ifremer.suiviobsmer.WaoException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@@ -48,7 +68,7 @@
if (log.isTraceEnabled()) {
log.trace("Count : " + nbRows);
}
- } catch (SuiviObsmerException eee) {
+ } catch (WaoException eee) {
throw new TapestryException("", eee);
}
}
@@ -67,14 +87,14 @@
// FIXME manage sort columns in execute ???? seems obvious --> needed for Contacts, done for Boats
//sortResults(sortConstraints);
- } catch (SuiviObsmerException eee) {
+ } catch (WaoException eee) {
throw new TapestryException("", eee);
}
}
- protected abstract Map<K, E> execute(int startIndex, int endIndex, SortConstraint orderBy) throws SuiviObsmerException;
+ protected abstract Map<K, E> execute(int startIndex, int endIndex, SortConstraint orderBy) throws WaoException;
- protected abstract int count() throws SuiviObsmerException;
+ protected abstract int count() throws WaoException;
protected SortConstraint getSortConstraint(List<SortConstraint> sortConstraints) {
for (SortConstraint constraint : sortConstraints)
Modified: trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/data/BoatDataSource.java
===================================================================
--- trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/data/BoatDataSource.java 2010-02-16 10:56:02 UTC (rev 353)
+++ trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/data/BoatDataSource.java 2010-02-16 12:00:05 UTC (rev 354)
@@ -1,7 +1,27 @@
+/*
+ * *##%
+ * Wao :: Web Interface
+ * 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.suiviobsmer.ui.data;
-import fr.ifremer.suiviobsmer.SuiviObsmerException;
+import fr.ifremer.suiviobsmer.WaoException;
import fr.ifremer.suiviobsmer.bean.BoatFilter;
import fr.ifremer.suiviobsmer.entity.Boat;
import fr.ifremer.suiviobsmer.services.ServiceBoat;
@@ -38,7 +58,7 @@
@Override
- protected Map<Integer, Boat> execute(int startIndex, int endIndex, SortConstraint orderBy) throws SuiviObsmerException {
+ protected Map<Integer, Boat> execute(int startIndex, int endIndex, SortConstraint orderBy) throws WaoException {
if (log.isInfoEnabled()) {
log.info("BUSINESS REQUEST [getBoatsByFilter]");
}
@@ -64,7 +84,7 @@
}
@Override
- protected int count() throws SuiviObsmerException {
+ protected int count() throws WaoException {
if (log.isInfoEnabled()) {
log.info("BUSINESS REQUEST [getNbBoatsByFilter]");
}
Modified: trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/data/BusinessUtils.java
===================================================================
--- trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/data/BusinessUtils.java 2010-02-16 10:56:02 UTC (rev 353)
+++ trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/data/BusinessUtils.java 2010-02-16 12:00:05 UTC (rev 354)
@@ -1,6 +1,6 @@
/*
* *##%
- * SuiviObsmer :: Web Interface
+ * Wao :: Web Interface
* Copyright (C) 2009 - 2010 Ifremer
*
* This program is free software: you can redistribute it and/or modify
Modified: trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/data/ChartUtils.java
===================================================================
--- trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/data/ChartUtils.java 2010-02-16 10:56:02 UTC (rev 353)
+++ trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/data/ChartUtils.java 2010-02-16 12:00:05 UTC (rev 354)
@@ -1,6 +1,6 @@
/*
* *##%
- * SuiviObsmer :: Web Interface
+ * Wao :: Web Interface
* Copyright (C) 2009 - 2010 Ifremer
*
* This program is free software: you can redistribute it and/or modify
Modified: trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/data/ContactDataSource.java
===================================================================
--- trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/data/ContactDataSource.java 2010-02-16 10:56:02 UTC (rev 353)
+++ trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/data/ContactDataSource.java 2010-02-16 12:00:05 UTC (rev 354)
@@ -1,7 +1,27 @@
+/*
+ * *##%
+ * Wao :: Web Interface
+ * 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.suiviobsmer.ui.data;
-import fr.ifremer.suiviobsmer.SuiviObsmerException;
+import fr.ifremer.suiviobsmer.WaoException;
import fr.ifremer.suiviobsmer.bean.ContactFilter;
import fr.ifremer.suiviobsmer.entity.Contact;
import fr.ifremer.suiviobsmer.services.ServiceContact;
@@ -40,7 +60,7 @@
}
@Override
- protected Map<String, Contact> execute(int startIndex, int endIndex, SortConstraint orderBy) throws SuiviObsmerException {
+ protected Map<String, Contact> execute(int startIndex, int endIndex, SortConstraint orderBy) throws WaoException {
if (log.isInfoEnabled()) {
log.info("BUSINESS REQUEST [getContactsByFilter]");
}
@@ -50,7 +70,7 @@
}
@Override
- protected int count() throws SuiviObsmerException {
+ protected int count() throws WaoException {
if (log.isInfoEnabled()) {
log.info("BUSINESS REQUEST [getNbContacts]");
}
Modified: trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/data/ExportStreamResponse.java
===================================================================
--- trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/data/ExportStreamResponse.java 2010-02-16 10:56:02 UTC (rev 353)
+++ trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/data/ExportStreamResponse.java 2010-02-16 12:00:05 UTC (rev 354)
@@ -1,7 +1,27 @@
+/*
+ * *##%
+ * Wao :: Web Interface
+ * 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.suiviobsmer.ui.data;
-import fr.ifremer.suiviobsmer.SuiviObsmerContext;
+import fr.ifremer.suiviobsmer.WaoContext;
import java.util.Date;
import org.apache.tapestry5.StreamResponse;
import org.apache.tapestry5.services.Response;
@@ -48,7 +68,7 @@
*/
@Override
public void prepareResponse(Response response) {
- Date current = SuiviObsmerContext.getCurrentDate();
+ Date current = WaoContext.getCurrentDate();
filename += "-" + DateUtils.formatDate(current, "dd-MM-yyyy") + ".csv";
response.setHeader("Content-Disposition",
"attachment; filename=\"" + filename +"\"");
Deleted: trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/data/SuiviObsmerPropertyChangeListener.java
===================================================================
--- trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/data/SuiviObsmerPropertyChangeListener.java 2010-02-16 10:56:02 UTC (rev 353)
+++ trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/data/SuiviObsmerPropertyChangeListener.java 2010-02-16 12:00:05 UTC (rev 354)
@@ -1,81 +0,0 @@
-/*
- * *##%
- * SuiviObsmer :: Web Interface
- * 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.suiviobsmer.ui.data;
-
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-import java.util.HashMap;
-import java.util.Map;
-import org.nuiton.topia.persistence.TopiaEntity;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * BoatInfosPropertyChangeListener
- *
- * Created: 18 nov. 2009
- *
- * @author fdesbois
- * @version $Revision$
- *
- * Mise a jour: $Date$
- * par : $Author$
- */
-public class SuiviObsmerPropertyChangeListener implements PropertyChangeListener {
-
- private static final Logger log = LoggerFactory.getLogger(SuiviObsmerPropertyChangeListener.class);
-
- //private boolean changed;
-
- private Map<String, Object> data;
-
- @Override
- public void propertyChange(PropertyChangeEvent evt) {
- if (log.isDebugEnabled()) {
- log.debug("property change : old = " + evt.getOldValue() +
- " _ new = " + evt.getNewValue());
- }
- TopiaEntity entity = (TopiaEntity)evt.getSource();
- getData().put(entity.getTopiaId(), entity);
- }
-
- protected Map<String, Object> getData() {
- if (data == null) {
- data = new HashMap<String, Object>();
- }
- return data;
- }
-
- public boolean hasChanged(String topiaId) {
-
- if (log.isTraceEnabled()) {
- log.trace("data size : " + getData().size());
- }
-
- return getData().containsKey(topiaId);
- }
-
- public void reset() {
- data = null;
- }
-
-}
Modified: trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/data/SynthesisId.java
===================================================================
--- trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/data/SynthesisId.java 2010-02-16 10:56:02 UTC (rev 353)
+++ trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/data/SynthesisId.java 2010-02-16 12:00:05 UTC (rev 354)
@@ -1,3 +1,23 @@
+/*
+ * *##%
+ * Wao :: Web Interface
+ * 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.suiviobsmer.ui.data;
/**
Copied: trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/data/WaoPropertyChangeListener.java (from rev 350, trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/data/SuiviObsmerPropertyChangeListener.java)
===================================================================
--- trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/data/WaoPropertyChangeListener.java (rev 0)
+++ trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/data/WaoPropertyChangeListener.java 2010-02-16 12:00:05 UTC (rev 354)
@@ -0,0 +1,81 @@
+/*
+ * *##%
+ * Wao :: Web Interface
+ * 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.suiviobsmer.ui.data;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.util.HashMap;
+import java.util.Map;
+import org.nuiton.topia.persistence.TopiaEntity;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * BoatInfosPropertyChangeListener
+ *
+ * Created: 18 nov. 2009
+ *
+ * @author fdesbois
+ * @version $Revision$
+ *
+ * Mise a jour: $Date$
+ * par : $Author$
+ */
+public class WaoPropertyChangeListener implements PropertyChangeListener {
+
+ private static final Logger log = LoggerFactory.getLogger(WaoPropertyChangeListener.class);
+
+ //private boolean changed;
+
+ private Map<String, Object> data;
+
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+ if (log.isDebugEnabled()) {
+ log.debug("property change : old = " + evt.getOldValue() +
+ " _ new = " + evt.getNewValue());
+ }
+ TopiaEntity entity = (TopiaEntity)evt.getSource();
+ getData().put(entity.getTopiaId(), entity);
+ }
+
+ protected Map<String, Object> getData() {
+ if (data == null) {
+ data = new HashMap<String, Object>();
+ }
+ return data;
+ }
+
+ public boolean hasChanged(String topiaId) {
+
+ if (log.isTraceEnabled()) {
+ log.trace("data size : " + getData().size());
+ }
+
+ return getData().containsKey(topiaId);
+ }
+
+ public void reset() {
+ data = null;
+ }
+
+}
Property changes on: trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/data/WaoPropertyChangeListener.java
___________________________________________________________________
Added: svn:mergeinfo
+
Modified: trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/mixins/Confirm.java
===================================================================
--- trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/mixins/Confirm.java 2010-02-16 10:56:02 UTC (rev 353)
+++ trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/mixins/Confirm.java 2010-02-16 12:00:05 UTC (rev 354)
@@ -1,6 +1,6 @@
/**
* *##%
- * SuiviObsmer :: Web Interface
+ * Wao :: Web Interface
* Copyright (C) 2009 - 2010 Ifremer
*
* This program is free software: you can redistribute it and/or modify
Modified: trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/mixins/PopupPageLink.java
===================================================================
--- trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/mixins/PopupPageLink.java 2010-02-16 10:56:02 UTC (rev 353)
+++ trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/mixins/PopupPageLink.java 2010-02-16 12:00:05 UTC (rev 354)
@@ -1,6 +1,6 @@
/*
* *##%
- * SuiviObsmer :: Web Interface
+ * Wao :: Web Interface
* Copyright (C) 2009 - 2010 Ifremer
*
* This program is free software: you can redistribute it and/or modify
Modified: trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/mixins/ZoneUpdater.java
===================================================================
--- trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/mixins/ZoneUpdater.java 2010-02-16 10:56:02 UTC (rev 353)
+++ trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/mixins/ZoneUpdater.java 2010-02-16 12:00:05 UTC (rev 354)
@@ -1,6 +1,6 @@
/**
* *##%
- * SuiviObsmer :: Web Interface
+ * Wao :: Web Interface
* Copyright (C) 2009 - 2010 Ifremer
*
* This program is free software: you can redistribute it and/or modify
Modified: trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/Administration.java
===================================================================
--- trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/Administration.java 2010-02-16 10:56:02 UTC (rev 353)
+++ trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/Administration.java 2010-02-16 12:00:05 UTC (rev 354)
@@ -1,6 +1,6 @@
/*
* *##%
- * SuiviObsmer :: Web Interface
+ * Wao :: Web Interface
* Copyright (C) 2009 - 2010 Ifremer
*
* This program is free software: you can redistribute it and/or modify
@@ -21,8 +21,8 @@
package fr.ifremer.suiviobsmer.ui.pages;
-import fr.ifremer.suiviobsmer.SuiviObsmerBusinessException;
-import fr.ifremer.suiviobsmer.SuiviObsmerException;
+import fr.ifremer.suiviobsmer.WaoBusinessException;
+import fr.ifremer.suiviobsmer.WaoException;
import fr.ifremer.suiviobsmer.entity.Company;
import fr.ifremer.suiviobsmer.entity.CompanyImpl;
import fr.ifremer.suiviobsmer.entity.WaoUser;
@@ -30,7 +30,7 @@
import fr.ifremer.suiviobsmer.services.ServiceReferential;
import fr.ifremer.suiviobsmer.services.ServiceUser;
import fr.ifremer.suiviobsmer.ui.base.GenericSelectModel;
-import fr.ifremer.suiviobsmer.ui.base.SuiviObsmerPage;
+import fr.ifremer.suiviobsmer.ui.base.WaoPage;
import fr.ifremer.suiviobsmer.ui.components.Layout;
import java.util.List;
import org.apache.commons.lang.StringUtils;
@@ -58,7 +58,7 @@
* par : $Author$
*/
@IncludeStylesheet("context:css/administration.css")
-public class Administration implements SuiviObsmerPage {
+public class Administration implements WaoPage {
@Override
public boolean isOnlyForAdmin() {
@@ -114,7 +114,7 @@
private boolean addNewUserSelected;
private boolean deleteUserSelected;
- void setupRender() throws SuiviObsmerException {
+ void setupRender() throws WaoException {
companies = null;
getCompanies();
user = null;
@@ -146,14 +146,14 @@
try {
int result = serviceReferential.importFishingZoneCsv(fishingZoneCsvFile.getStream());
layout.getFeedBack().addInfo(result + " zones de pêche importées");
- } catch (SuiviObsmerException eee) {
+ } catch (WaoException eee) {
layout.getFeedBack().addError(eee.getMessage());
}
}
/**************************** FORMS ****************************************/
- public List<Company> getCompanies() throws SuiviObsmerException {
+ public List<Company> getCompanies() throws WaoException {
if (companies == null) {
if (log.isInfoEnabled()) {
log.info("BUSINESS REQUEST [getCompanies]");
@@ -163,14 +163,14 @@
return companies;
}
- public GenericSelectModel<Company> getCompaniesSelectModel() throws SuiviObsmerException {
+ public GenericSelectModel<Company> getCompaniesSelectModel() throws WaoException {
if (companiesSelectModel == null) {
companiesSelectModel = new GenericSelectModel<Company>(getCompanies(), Company.class, Company.NAME, "id", propertyAccess);
}
return companiesSelectModel;
}
- public Company getCompany() throws SuiviObsmerException {
+ public Company getCompany() throws WaoException {
if (company == null) {
if (companyId != null) {
company = getCompaniesSelectModel().findObject(companyId);
@@ -181,7 +181,7 @@
return company;
}
- public boolean isUsersAvailable() throws SuiviObsmerException {
+ public boolean isUsersAvailable() throws WaoException {
return !StringUtils.isEmpty(getCompany().getId()) && getCompany().getActive();
}
@@ -197,13 +197,13 @@
user = null;
}
- void onSuccessFromCompany() throws SuiviObsmerException {
+ void onSuccessFromCompany() throws WaoException {
serviceUser.createUpdateCompany(company);
companyId = company.getId();
}
@Log
- public GenericSelectModel<WaoUser> getUsersSelectModel() throws SuiviObsmerException {
+ public GenericSelectModel<WaoUser> getUsersSelectModel() throws WaoException {
if (usersSelectModel == null) {
List<WaoUser> users = getCompany().getWaoUser();
if (log.isDebugEnabled()) {
@@ -215,7 +215,7 @@
}
@Log
- public WaoUser getUser() throws SuiviObsmerException {
+ public WaoUser getUser() throws WaoException {
if (user == null) {
if (userId != null) {
if (log.isDebugEnabled()) {
@@ -242,7 +242,7 @@
deleteUserSelected = true;
}
- void onSuccessFromUserActionsForm() throws SuiviObsmerException {
+ void onSuccessFromUserActionsForm() throws WaoException {
if (addNewUserSelected) {
userId = null;
} else if (deleteUserSelected && userId != null) {
@@ -252,14 +252,14 @@
user = null;
userId = null;
layout.getFeedBack().addInfo("Utilisateur supprimé avec succès !");
- } catch (SuiviObsmerBusinessException eee) {
+ } catch (WaoBusinessException eee) {
layout.getFeedBack().addError(eee.getMessage());
}
}
}
@Log
- void onSuccessFromUser() throws SuiviObsmerException {
+ void onSuccessFromUser() throws WaoException {
if (log.isDebugEnabled()) {
log.debug("User : " + user);
}
@@ -272,7 +272,7 @@
// TODO return true if mail ok
serviceUser.createUpdateUser(user, generatePassword);
userId = user.getId();
- } catch (SuiviObsmerBusinessException eee) {
+ } catch (WaoBusinessException eee) {
layout.getFeedBack().addError(eee.getMessage());
}
}
Modified: trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/BoatActivityCalendar.java
===================================================================
--- trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/BoatActivityCalendar.java 2010-02-16 10:56:02 UTC (rev 353)
+++ trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/BoatActivityCalendar.java 2010-02-16 12:00:05 UTC (rev 354)
@@ -1,6 +1,6 @@
/*
* *##%
- * SuiviObsmer :: Web Interface
+ * Wao :: Web Interface
* Copyright (C) 2009 - 2010 Ifremer
*
* This program is free software: you can redistribute it and/or modify
@@ -21,7 +21,7 @@
package fr.ifremer.suiviobsmer.ui.pages;
-import fr.ifremer.suiviobsmer.SuiviObsmerException;
+import fr.ifremer.suiviobsmer.WaoException;
import fr.ifremer.suiviobsmer.entity.ActivityCalendar;
import fr.ifremer.suiviobsmer.entity.ActivityMonth;
import fr.ifremer.suiviobsmer.entity.ActivityProfession;
@@ -29,7 +29,7 @@
import fr.ifremer.suiviobsmer.entity.Boat;
import fr.ifremer.suiviobsmer.entity.WaoUser;
import fr.ifremer.suiviobsmer.services.ServiceBoat;
-import fr.ifremer.suiviobsmer.ui.base.SuiviObsmerPage;
+import fr.ifremer.suiviobsmer.ui.base.WaoPage;
import java.util.Collections;
import java.util.List;
import org.apache.commons.lang.StringUtils;
@@ -54,7 +54,7 @@
* par : $Author$
*/
@IncludeStylesheet("context:css/boats.css")
-public class BoatActivityCalendar implements SuiviObsmerPage {
+public class BoatActivityCalendar implements WaoPage {
@Inject
private Logger log;
@@ -103,7 +103,7 @@
return Collections.singletonList(boat);
}
- public ActivityCalendar getActivityCalendar() throws SuiviObsmerException {
+ public ActivityCalendar getActivityCalendar() throws WaoException {
if (activityCalendar == null) {
if (log.isInfoEnabled()) {
log.info("BUSINESS REQUEST [getLastActivityCalendar]");
@@ -113,7 +113,7 @@
return activityCalendar;
}
- public ActivityMonth getActivityMonth() throws SuiviObsmerException {
+ public ActivityMonth getActivityMonth() throws WaoException {
return getActivityCalendar().getActivityMonth(month);
}
@@ -137,7 +137,7 @@
return getProfessionIndexMax() != -1;
}
- public ActivityProfession getActivityProfession() throws SuiviObsmerException {
+ public ActivityProfession getActivityProfession() throws WaoException {
if (getActivityMonth() == null) {
return null;
}
@@ -147,7 +147,7 @@
return getActivityMonth().getActivityProfession().get(professionIndex);
}
- public int getZoneIndexMax() throws SuiviObsmerException {
+ public int getZoneIndexMax() throws WaoException {
int result = 0;
for (ActivityMonth activityMonth : activityCalendar.getActivityMonth()) {
month = activityMonth.getMonth();
@@ -174,7 +174,7 @@
// return getZoneIndexMax() != -1;
// }
- public ActivityZone getActivityZone() throws SuiviObsmerException {
+ public ActivityZone getActivityZone() throws WaoException {
ActivityProfession profession = getActivityProfession();
if (profession == null) {
return null;
Modified: trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/Boats.java
===================================================================
--- trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/Boats.java 2010-02-16 10:56:02 UTC (rev 353)
+++ trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/Boats.java 2010-02-16 12:00:05 UTC (rev 354)
@@ -1,6 +1,6 @@
/*
* *##%
- * SuiviObsmer :: Web Interface
+ * Wao :: Web Interface
* Copyright (C) 2009 - 2010 Ifremer
*
* This program is free software: you can redistribute it and/or modify
@@ -21,8 +21,8 @@
package fr.ifremer.suiviobsmer.ui.pages;
-import fr.ifremer.suiviobsmer.SuiviObsmerContext;
-import fr.ifremer.suiviobsmer.SuiviObsmerException;
+import fr.ifremer.suiviobsmer.WaoContext;
+import fr.ifremer.suiviobsmer.WaoException;
import fr.ifremer.suiviobsmer.bean.BoatFilterImpl;
import fr.ifremer.suiviobsmer.entity.Boat;
import fr.ifremer.suiviobsmer.bean.BoatFilter;
@@ -41,7 +41,7 @@
import fr.ifremer.suiviobsmer.ui.base.AbstractFilteredPage;
import fr.ifremer.suiviobsmer.ui.data.BusinessUtils;
import fr.ifremer.suiviobsmer.ui.base.GenericSelectModel;
-import fr.ifremer.suiviobsmer.ui.base.SuiviObsmerPage;
+import fr.ifremer.suiviobsmer.ui.base.WaoPage;
import fr.ifremer.suiviobsmer.ui.components.FeedBack;
import fr.ifremer.suiviobsmer.ui.components.Layout;
import fr.ifremer.suiviobsmer.ui.data.BoatDataSource;
@@ -88,7 +88,7 @@
* par : $Author$
*/
@IncludeStylesheet("context:css/boats.css")
-public class Boats extends AbstractFilteredPage implements SuiviObsmerPage {
+public class Boats extends AbstractFilteredPage implements WaoPage {
@Override
public boolean isOnlyForAdmin() {
@@ -135,7 +135,7 @@
@InjectComponent
private FeedBack filterFeedback;
- void setupRender() throws SuiviObsmerException {
+ void setupRender() throws WaoException {
sampleRow = null;
getSampleRow();
// Profession select reset
@@ -186,7 +186,7 @@
// Suppress persitant list of boats
boats = null;
layout.getFeedBack().addInfo(result[0] + " navires importés dont " + result[1] + " nouveaux");
- } catch (SuiviObsmerException eee) {
+ } catch (WaoException eee) {
layout.getFeedBack().addError(eee.getMessage());
}
}
@@ -248,7 +248,7 @@
}
@Log
- void onSuccessFromImportActivityCalendarsForm() throws SuiviObsmerException, IOException {
+ void onSuccessFromImportActivityCalendarsForm() throws WaoException, IOException {
InputStream input = activityCalendarsCsvFile.getStream();
if (log.isDebugEnabled()) {
log.debug("Content type : " + activityCalendarsCsvFile.getContentType());
@@ -329,11 +329,11 @@
* Filters to apply on boats list. Method used by AbstractFilteredPage superclass.
*
* @return the current BoatFilter to apply
- * @throws SuiviObsmerException
+ * @throws WaoException
* @see AbstractFilteredPage
*/
@Override
- public BoatFilter getFilter() throws SuiviObsmerException {
+ public BoatFilter getFilter() throws WaoException {
if (boatFilter == null) {
if (log.isDebugEnabled()) {
log.debug("Create filter");
@@ -355,9 +355,9 @@
* When the sampleRow is not null, the filters are disabled to optimize searching boats for this row.
*
* @return the sampleRow from business
- * @throws SuiviObsmerException
+ * @throws WaoException
*/
- public SampleRow getSampleRow() throws SuiviObsmerException {
+ public SampleRow getSampleRow() throws WaoException {
if (sampleRow == null && !StringUtils.isEmpty(sampleRowContextId)) {
if (log.isInfoEnabled()) {
log.info("BUSINESS REQUEST [getSampleRow]");
@@ -367,11 +367,11 @@
return sampleRow;
}
- public boolean isSampleRowExists() throws SuiviObsmerException {
+ public boolean isSampleRowExists() throws WaoException {
return getSampleRow() != null;
}
- public GenericSelectModel<Profession> getProfessionSelectModel() throws SuiviObsmerException {
+ public GenericSelectModel<Profession> getProfessionSelectModel() throws WaoException {
if (professionSelectModel == null) {
if (log.isInfoEnabled()) {
log.info("BUSINESS REQUEST [getProfessions]");
@@ -414,11 +414,11 @@
* EVENT_SELECTED :: search sumit button for filtersForm. Get profession from selectModel to add it in filters.
* Other filters are managed by AbstractFilteredPage superclass.
*
- * @throws SuiviObsmerException for business errors
+ * @throws WaoException for business errors
* @see AbstractFilteredPage#onSelectedFromSearch()
*/
@Override
- public void onSelectedFromSearch() throws SuiviObsmerException {
+ public void onSelectedFromSearch() throws WaoException {
super.onSelectedFromSearch();
if (log.isDebugEnabled()) {
log.debug("FILTER : facadeName=" + boatFilter.getFacadeName());
@@ -438,9 +438,9 @@
* EVENT_SUCCESS :: for filtersForm. Reset persitant data to have new data using filters selected.
*
* @return the filtersZone if it's a refresh data for select, or the page otherwise
- * @throws SuiviObsmerException for business errors
+ * @throws WaoException for business errors
*/
- Object onSuccessFromFiltersForm() throws SuiviObsmerException {
+ Object onSuccessFromFiltersForm() throws WaoException {
if (isEdited()) {
return filtersZone.getBody();
}
@@ -475,10 +475,10 @@
* BoatDataSource uses serviceBoat to retrieve boats with filters.
*
* @return the BoatDataSource which contains the boats map
- * @throws SuiviObsmerException
+ * @throws WaoException
* @see BoatDataSource
*/
- public BoatDataSource getBoats() throws SuiviObsmerException {
+ public BoatDataSource getBoats() throws WaoException {
if (boats == null) {
boats = new BoatDataSource(getFilter(), serviceBoat);
}
@@ -508,7 +508,7 @@
return new SimpleDateFormat("dd/MM/yyyy");
}
- public boolean canCreateNewContactFromList() throws SuiviObsmerException {
+ public boolean canCreateNewContactFromList() throws WaoException {
if (!user.getAdmin() && isSampleRowExists()) {
return boat.canCreateContact(user.getCompany());
}
@@ -526,7 +526,7 @@
log.debug("Filter sampleRow : " + getFilter().getSampleRow());
}
result = serviceBoat.exportBoatCsv(getFilter());
- } catch (SuiviObsmerException eee) {
+ } catch (WaoException eee) {
throw new IOException(eee);
}
return result;
@@ -534,7 +534,7 @@
};
}
- Block onActionFromShowBoatInfos(Integer boatImma) throws SuiviObsmerException {
+ Block onActionFromShowBoatInfos(Integer boatImma) throws WaoException {
boatSelectedImmatriculation = boatImma;
// Suppress persistant boat informations
companyBoatInfos = null;
@@ -585,12 +585,12 @@
private Company company;
/*@Persist
- private SuiviObsmerPropertyChangeListener propertyChange;*/
+ private WaoPropertyChangeListener propertyChange;*/
/** /////////////////////// GLOBAL TO THE BLOCK /////////////////////// **/
public boolean isActivityCalendarImportRun() {
- return SuiviObsmerContext.isActivityCalendarImportRun();
+ return WaoContext.isActivityCalendarImportRun();
}
public Block getActiveBoatInfosBlock() {
@@ -600,7 +600,7 @@
return displayBoatInfos;
}
- public CompanyBoatInfos getCompanyBoatInfos() throws SuiviObsmerException {
+ public CompanyBoatInfos getCompanyBoatInfos() throws WaoException {
if (companyBoatInfos == null && boatSelectedImmatriculation != null && getCompany() != null) {
if (log.isInfoEnabled()) {
log.info("BUSINESS REQUEST [getElligibleBoats]");
@@ -615,9 +615,9 @@
* will be used for this model.
*
* @return the GenericSelectModel<Company>
- * @throws SuiviObsmerException
+ * @throws WaoException
*/
- public GenericSelectModel<Company> getCompanies() throws SuiviObsmerException {
+ public GenericSelectModel<Company> getCompanies() throws WaoException {
if (companies == null) {
if (log.isDebugEnabled()) {
log.debug("BUSINESS REQUEST [getCompanies]");
@@ -633,9 +633,9 @@
* selected one otherwise.
*
* @return the current Company
- * @throws SuiviObsmerException
+ * @throws WaoException
*/
- public Company getCompany() throws SuiviObsmerException {
+ public Company getCompany() throws WaoException {
if (company == null) {
if (StringUtils.isNotEmpty(companySelectedId)) {
company = getCompanies().findObject(companySelectedId);
@@ -650,9 +650,9 @@
* Used to get the selected boat.
*
* @return the selected boat from the grid
- * @throws SuiviObsmerException
+ * @throws WaoException
*/
- public Boat getBoatSelected() throws SuiviObsmerException {
+ public Boat getBoatSelected() throws WaoException {
if (log.isDebugEnabled()) {
log.debug("selected imma : " + boatSelectedImmatriculation);
log.debug("exist boat ? : " + getBoats().contains(boatSelectedImmatriculation));
@@ -684,7 +684,7 @@
this.boardingFromDate = boardingFromDate;
}
- public BoatInfos getBoatInfos() throws SuiviObsmerException {
+ public BoatInfos getBoatInfos() throws WaoException {
if (getCompanyBoatInfos() == null) {
return null;
}
@@ -695,10 +695,10 @@
* Get CSS style class to apply on lastContact depends on its state.
*
* @return the CSS style to apply on contact block
- * @throws SuiviObsmerException
+ * @throws WaoException
* @see BusinessUtils#getContactStyle(Contact, boolean)
*/
- public String getlastContactStyle() throws SuiviObsmerException {
+ public String getlastContactStyle() throws WaoException {
Contact contact = getCompanyBoatInfos().getLastContact();
return BusinessUtils.getContactStyle(contact, user.getAdmin());
}
@@ -713,7 +713,7 @@
return BooleanUtils.isFalse(elligibleBoat.getCompanyActive());
}
- public boolean canCreateNewContactFromElligibleBoat() throws SuiviObsmerException {
+ public boolean canCreateNewContactFromElligibleBoat() throws WaoException {
if (!user.getAdmin() && !isElligibleBoatCompanyActiveFalse()) {
Boat currentBoat = getBoatInfos().getBoat();
return currentBoat.canCreateContact(user.getCompany());
@@ -728,19 +728,19 @@
/** /////////////////////// ACTIONS //////////////////////////////////// **/
- void onSuccess() throws SuiviObsmerException {
+ void onSuccess() throws WaoException {
if (getBoatInfos() != null) {
boatSelectedImmatriculation = getBoatInfos().getBoat().getImmatriculation();
}
}
- Block onSuccessFromCompanySelectForm() throws SuiviObsmerException {
+ Block onSuccessFromCompanySelectForm() throws WaoException {
companyBoatInfos = null;
getCompanyBoatInfos();
return boatInfosZone.getBody();
}
- Block onActionFromEditBoatInfos() throws SuiviObsmerException {
+ Block onActionFromEditBoatInfos() throws WaoException {
boatInfosEditable = true;
// WARNING :: Reset sampleRow select for edition mode, no limit for
// showing sampleRows instead of filters
@@ -750,7 +750,7 @@
return boatInfosZone.getBody();
}
- Block onActionFromCancelEditBoatInfos() throws SuiviObsmerException {
+ Block onActionFromCancelEditBoatInfos() throws WaoException {
/*if (propertyChange.isChanged()) {
if (log.isDebugEnabled()) {
log.debug("Change property");
@@ -764,7 +764,7 @@
return boatInfosZone.getBody();
}
- void onSelectedFromAddBoatInfosSampleRow() throws SuiviObsmerException {
+ void onSelectedFromAddBoatInfosSampleRow() throws WaoException {
// We stay in edition mode
boatInfosEditable = true;
if (StringUtils.isNotEmpty(boatInfosSampleRowId)) {
@@ -773,17 +773,17 @@
}
}
- void onSelectedFromRemoveBoatInfosSampleRow(String sampleRowCode) throws SuiviObsmerException {
+ void onSelectedFromRemoveBoatInfosSampleRow(String sampleRowCode) throws WaoException {
boatInfosEditable = true;
companyBoatInfos.removeElligibleBoat(sampleRowCode);
}
- void onSelectedFromActiveBoatInfosSampleRow(String sampleRowCode) throws SuiviObsmerException {
+ void onSelectedFromActiveBoatInfosSampleRow(String sampleRowCode) throws WaoException {
boatInfosEditable = true;
companyBoatInfos.activeElligibleBoat(sampleRowCode);
}
- Block onSuccessFromBoatInfosForm() throws SuiviObsmerException {
+ Block onSuccessFromBoatInfosForm() throws WaoException {
if (!boatInfosEditable) {
// Save data
serviceBoat.createUpdateCompanyBoatInfos(companyBoatInfos);
@@ -792,7 +792,7 @@
return boatInfosZone.getBody();
}
- Block onSuccessFromCalculateBoardings() throws SuiviObsmerException {
+ Block onSuccessFromCalculateBoardings() throws WaoException {
//boatSelectedImmatriculation = getBoatInfos().getBoat().getImmatriculation();
return boatInfosZone.getBody();
}
@@ -802,7 +802,7 @@
@InjectPage
private Contacts contacts;
- Object onActionFromAddNewContactFromBoat(int boatImmatriculation) throws SuiviObsmerException {
+ Object onActionFromAddNewContactFromBoat(int boatImmatriculation) throws WaoException {
// Get selected sampleRow
sampleRow = getSampleRow();
// Get boat from list
@@ -811,7 +811,7 @@
return contacts;
}
- Object onActionFromAddNewContactFromSampleRow(String sampleRowCode) throws SuiviObsmerException {
+ Object onActionFromAddNewContactFromSampleRow(String sampleRowCode) throws WaoException {
// Get sampleRow from elligibleBoat list
ElligibleBoat elligible = getCompanyBoatInfos().getElligibleBoat(sampleRowCode);
sampleRow = elligible.getSampleRow();
@@ -824,11 +824,11 @@
@InjectPage
private BoatActivityCalendar calendarPage;
- public boolean hasActivityCalendar() throws SuiviObsmerException {
+ public boolean hasActivityCalendar() throws WaoException {
return getBoatSelected().sizeActivityCalendar() != 0;
}
- Object onActionFromShowLastActivityCalendar() throws SuiviObsmerException {
+ Object onActionFromShowLastActivityCalendar() throws WaoException {
calendarPage.setBoat(getBoatSelected());
return calendarPage;
}
Modified: trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/Contacts.java
===================================================================
--- trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/Contacts.java 2010-02-16 10:56:02 UTC (rev 353)
+++ trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/Contacts.java 2010-02-16 12:00:05 UTC (rev 354)
@@ -1,6 +1,6 @@
/*
* *##%
- * SuiviObsmer :: Web Interface
+ * Wao :: Web Interface
* Copyright (C) 2009 - 2010 Ifremer
*
* This program is free software: you can redistribute it and/or modify
@@ -21,9 +21,9 @@
package fr.ifremer.suiviobsmer.ui.pages;
-import fr.ifremer.suiviobsmer.SuiviObsmerBusinessException;
-import fr.ifremer.suiviobsmer.SuiviObsmerContext;
-import fr.ifremer.suiviobsmer.SuiviObsmerException;
+import fr.ifremer.suiviobsmer.WaoBusinessException;
+import fr.ifremer.suiviobsmer.WaoContext;
+import fr.ifremer.suiviobsmer.WaoException;
import fr.ifremer.suiviobsmer.bean.BoatFilter;
import fr.ifremer.suiviobsmer.bean.ContactFilter;
import fr.ifremer.suiviobsmer.bean.ContactFilterImpl;
@@ -40,7 +40,7 @@
import fr.ifremer.suiviobsmer.ui.data.ContactDataSource;
import fr.ifremer.suiviobsmer.ui.data.BusinessUtils;
import fr.ifremer.suiviobsmer.ui.base.GenericSelectModel;
-import fr.ifremer.suiviobsmer.ui.base.SuiviObsmerPage;
+import fr.ifremer.suiviobsmer.ui.base.WaoPage;
import fr.ifremer.suiviobsmer.ui.components.Layout;
import fr.ifremer.suiviobsmer.ui.data.ExportStreamResponse;
import fr.ifremer.suiviobsmer.ui.services.ContactModelFactory;
@@ -84,7 +84,7 @@
* par : $Author$
*/
@IncludeStylesheet("context:css/contacts.css")
-public class Contacts extends AbstractFilteredPage implements SuiviObsmerPage {
+public class Contacts extends AbstractFilteredPage implements WaoPage {
@Override
public boolean isOnlyForAdmin() {
@@ -114,7 +114,7 @@
// private String contactEditedId;
@Log
- void setupRender() throws SuiviObsmerException {
+ void setupRender() throws WaoException {
// if (contactEdited == null) {
if (log.isDebugEnabled()) {
log.debug("RESET DATA");
@@ -142,7 +142,7 @@
@Property
private ContactState stateFilter;
- public ContactFilter getContactFilter() throws SuiviObsmerException {
+ public ContactFilter getContactFilter() throws WaoException {
if (contactFilter == null) {
if (log.isDebugEnabled()) {
log.debug("Init contactFilter");
@@ -161,7 +161,7 @@
}
@Override
- protected BoatFilter getFilter() throws SuiviObsmerException {
+ protected BoatFilter getFilter() throws WaoException {
return getContactFilter();
}
@@ -184,7 +184,7 @@
}
@Log
- Object onSuccessFromFiltersForm() throws SuiviObsmerException {
+ Object onSuccessFromFiltersForm() throws WaoException {
if (isEdited()) {
return filtersZone.getBody();
}
@@ -203,7 +203,7 @@
private UploadedFile contactsCsvFile;
@Log
- void onSuccessFromImportContacts() throws SuiviObsmerException {
+ void onSuccessFromImportContacts() throws WaoException {
//importBoatsForm.clearErrors();
try {
ImportResults result = serviceContact.importContactCsv(user, contactsCsvFile.getStream());
@@ -214,7 +214,7 @@
for (String error : result.getErrors()) {
layout.getFeedBack().addInfo(error);
}
- } catch (SuiviObsmerBusinessException eee) {
+ } catch (WaoBusinessException eee) {
layout.getFeedBack().addError(eee.getMessage());
}
//return importBoatsForm.getHasErrors() ? importBoatsForm : this;
@@ -228,7 +228,7 @@
InputStream result = null;
try {
result = serviceContact.exportContactCsv(getContactFilter());
- } catch (SuiviObsmerException eee) {
+ } catch (WaoException eee) {
throw new IOException(eee);
}
return result;
@@ -269,7 +269,7 @@
private boolean even = true;
- public ContactDataSource getContacts() throws SuiviObsmerException {
+ public ContactDataSource getContacts() throws WaoException {
if (contacts == null) {
if (log.isInfoEnabled()) {
log.info("Create DataSource");
@@ -279,7 +279,7 @@
return contacts;
}
-// public Map<String, Contact> getContacts() throws SuiviObsmerException {
+// public Map<String, Contact> getContacts() throws WaoException {
// if (contacts == null) {
// if (log.isInfoEnabled()) {
// log.info("BUSINESS REQUEST [getContactsByFilter]");
@@ -340,7 +340,7 @@
return BusinessUtils.getTooltipBoat(contact.getBoat());
}
- public String getTooltipExportFrom() throws SuiviObsmerException {
+ public String getTooltipExportFrom() throws WaoException {
if (getContactFilter().getFromDate() != null) {
return "depuis le " + getDateFormat().format(getContactFilter().getFromDate());
}
@@ -388,7 +388,7 @@
@Persist
private String oldComment;
- public void prepareContactEdited(String contactId) throws SuiviObsmerException {
+ public void prepareContactEdited(String contactId) throws WaoException {
if (contactEdited == null) {
contactEdited = getContacts().get(contactId);
}
@@ -420,7 +420,7 @@
return contact.getValidationProgram() != null;
}
- void onSelectedFromAcceptContact(String contactId) throws SuiviObsmerException {
+ void onSelectedFromAcceptContact(String contactId) throws WaoException {
//contact = getContacts().get(contactId);
prepareContactEdited(contactId);
if (user.getAdmin()) {
@@ -432,7 +432,7 @@
}
}
- void onSelectedFromRefuseContact(String contactId) throws SuiviObsmerException {
+ void onSelectedFromRefuseContact(String contactId) throws WaoException {
//contact = getContacts().get(contactId);
prepareContactEdited(contactId);
if (user.getAdmin()) {
@@ -444,7 +444,7 @@
}
}
- void onSelectedFromUnvalidateContact(String contactId) throws SuiviObsmerException {
+ void onSelectedFromUnvalidateContact(String contactId) throws WaoException {
//contact = getContacts().get(contactId);
prepareContactEdited(contactId);
if (user.getAdmin()) {
@@ -463,7 +463,7 @@
}
}
- void onSelectedFromEditContact(String contactId) throws SuiviObsmerException {
+ void onSelectedFromEditContact(String contactId) throws WaoException {
//contact = getContacts().get(contactId);
prepareContactEdited(contactId);
contactUserId = contactEdited.getObserver().getTopiaId();
@@ -473,13 +473,13 @@
edited = true;
}
- void onSelectedFromDeleteContact(String contactId) throws SuiviObsmerException {
+ void onSelectedFromDeleteContact(String contactId) throws WaoException {
//contact = getContacts().get(contactId);
prepareContactEdited(contactId);
deleted = true;
}
- void onSelectedFromSaveContact(String contactId) throws SuiviObsmerException {
+ void onSelectedFromSaveContact(String contactId) throws WaoException {
//contact = getContacts().get(contactId);
prepareContactEdited(contactId);
contactEdited.setState(contactState.toString());
@@ -491,13 +491,13 @@
}
}
- void onSelectedFromCancelEditContact() throws SuiviObsmerException {
+ void onSelectedFromCancelEditContact() throws WaoException {
contactEdited = null;
edited = true;
}
// @Log
-// void onSelectedFromSaveComment(String contactId) throws SuiviObsmerException {
+// void onSelectedFromSaveComment(String contactId) throws WaoException {
// contact = getContacts().get(contactId);
// if (log.isInfoEnabled()) {
// log.info("Comment : " + contact.getComment());
@@ -556,7 +556,7 @@
contactsForm.recordError(endDate, "La date de fin de la marée ne peut pas être antérieure à celle de début");
}
- Date current = SuiviObsmerContext.getCurrentDate();
+ Date current = WaoContext.getCurrentDate();
if (end != null && end.after(current)) {
contactsForm.recordError(endDate, "La date de fin de la marée ne peut pas être postérieure à la date du jour");
@@ -610,7 +610,7 @@
contactSelectedId = contactEdited.getTopiaId();
oldComment = null;
contactEdited = null;
- } catch (SuiviObsmerException eee) {
+ } catch (WaoException eee) {
layout.getFeedBack().addError(eee.getMessage());
}
}
@@ -630,7 +630,7 @@
//return gridZone;
}
- public void createNewContact(Boat boat, SampleRow sampleRow) throws SuiviObsmerException {
+ public void createNewContact(Boat boat, SampleRow sampleRow) throws WaoException {
contact = serviceContact.getNewContact(user, sampleRow, boat);
serviceContact.saveContact(contact, Boolean.FALSE);
contactSelectedId = contact.getTopiaId();
Modified: trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/ExceptionReport.java
===================================================================
--- trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/ExceptionReport.java 2010-02-16 10:56:02 UTC (rev 353)
+++ trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/ExceptionReport.java 2010-02-16 12:00:05 UTC (rev 354)
@@ -1,6 +1,6 @@
/*
* *##%
- * SuiviObsmer :: Web Interface
+ * Wao :: Web Interface
* Copyright (C) 2009 - 2010 Ifremer
*
* This program is free software: you can redistribute it and/or modify
@@ -21,8 +21,8 @@
package fr.ifremer.suiviobsmer.ui.pages;
-import fr.ifremer.suiviobsmer.SuiviObsmerException;
-import fr.ifremer.suiviobsmer.ui.base.SuiviObsmerPage;
+import fr.ifremer.suiviobsmer.WaoException;
+import fr.ifremer.suiviobsmer.ui.base.WaoPage;
import fr.ifremer.suiviobsmer.ui.components.Layout;
import org.apache.tapestry5.annotations.InjectComponent;
import org.apache.tapestry5.annotations.Property;
@@ -41,7 +41,7 @@
* Mise a jour: $Date$
* par : $Author$
*/
-public class ExceptionReport implements ExceptionReporter, SuiviObsmerPage {
+public class ExceptionReport implements ExceptionReporter, WaoPage {
@InjectComponent
private Layout layout;
@@ -54,7 +54,7 @@
@Override
public void reportException(Throwable eee) {
- this.exception = getSuiviObsmerException(eee);
+ this.exception = getWaoException(eee);
if (exception != null) {
layout.getFeedBack().addError(exception.getMessage());
this.exception = exception.getCause();
@@ -65,14 +65,14 @@
layout.getFeedBack().addError("Erreur : " + this.exception.getClass().getSimpleName() + " : " + this.exception.getMessage());
}
- protected Throwable getSuiviObsmerException(Throwable eee) {
+ protected Throwable getWaoException(Throwable eee) {
if (eee == null) {
return eee;
}
- if (eee instanceof SuiviObsmerException) {
+ if (eee instanceof WaoException) {
return eee;
}
- return getSuiviObsmerException(eee.getCause());
+ return getWaoException(eee.getCause());
}
@Override
Modified: trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/Index.java
===================================================================
--- trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/Index.java 2010-02-16 10:56:02 UTC (rev 353)
+++ trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/Index.java 2010-02-16 12:00:05 UTC (rev 354)
@@ -1,6 +1,6 @@
/*
* *##%
- * SuiviObsmer :: Web Interface
+ * Wao :: Web Interface
* Copyright (C) 2009 - 2010 Ifremer
*
* This program is free software: you can redistribute it and/or modify
@@ -21,12 +21,12 @@
package fr.ifremer.suiviobsmer.ui.pages;
-import fr.ifremer.suiviobsmer.SuiviObsmerException;
+import fr.ifremer.suiviobsmer.WaoException;
import fr.ifremer.suiviobsmer.entity.News;
import fr.ifremer.suiviobsmer.entity.NewsImpl;
import fr.ifremer.suiviobsmer.entity.WaoUser;
import fr.ifremer.suiviobsmer.services.ServiceNews;
-import fr.ifremer.suiviobsmer.ui.base.SuiviObsmerPage;
+import fr.ifremer.suiviobsmer.ui.base.WaoPage;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
@@ -54,7 +54,7 @@
* par : $Author$
*/
@IncludeStylesheet("context:css/news.css")
-public class Index implements SuiviObsmerPage {
+public class Index implements WaoPage {
@Override
public boolean isOnlyForAdmin() {
@@ -92,7 +92,7 @@
@Log
- void setupRender() throws SuiviObsmerException {
+ void setupRender() throws WaoException {
if (editedId == null || !"NEW".equals(editedId)) {
newsList = null;
getNewsList();
@@ -109,7 +109,7 @@
// return editedId;
// }
- public List<News> getNewsList() throws SuiviObsmerException {
+ public List<News> getNewsList() throws WaoException {
if (newsList == null) {
newsList = serviceNews.getNews();
}
@@ -131,7 +131,7 @@
return dateFormat;
}
- void onActionFromAddNews() throws SuiviObsmerException {
+ void onActionFromAddNews() throws WaoException {
news = new NewsImpl();
// Create a new list with the new news in first position
List<News> list = new ArrayList<News>();
@@ -141,12 +141,12 @@
editedId = "NEW";
}
- void onActionFromEditNews(int rowIndex) throws SuiviObsmerException {
+ void onActionFromEditNews(int rowIndex) throws WaoException {
news = getNewsList().get(rowIndex);
this.editedId = news.getTopiaId();
}
- void onActionFromDeleteNews(int rowIndex) throws SuiviObsmerException {
+ void onActionFromDeleteNews(int rowIndex) throws WaoException {
news = getNewsList().get(rowIndex);
serviceNews.saveNews(news, true);
//newsList = null;
@@ -155,11 +155,11 @@
void onActionFromCancelEdit() {
}
- void onSelectedFromSaveNews(int rowIndex) throws SuiviObsmerException {
+ void onSelectedFromSaveNews(int rowIndex) throws WaoException {
news = getNewsList().get(rowIndex);
}
- void onSuccessFromNewsForm() throws SuiviObsmerException {
+ void onSuccessFromNewsForm() throws WaoException {
serviceNews.saveNews(news, false);
//this.editedId = null;
if (log.isDebugEnabled()) {
Modified: trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/SampleRowForm.java
===================================================================
--- trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/SampleRowForm.java 2010-02-16 10:56:02 UTC (rev 353)
+++ trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/SampleRowForm.java 2010-02-16 12:00:05 UTC (rev 354)
@@ -1,6 +1,6 @@
/*
* *##%
- * SuiviObsmer :: Web Interface
+ * Wao :: Web Interface
* Copyright (C) 2009 - 2010 Ifremer
*
* This program is free software: you can redistribute it and/or modify
@@ -21,9 +21,9 @@
package fr.ifremer.suiviobsmer.ui.pages;
-import fr.ifremer.suiviobsmer.SuiviObsmerBusinessException;
-import fr.ifremer.suiviobsmer.SuiviObsmerContext;
-import fr.ifremer.suiviobsmer.SuiviObsmerException;
+import fr.ifremer.suiviobsmer.WaoBusinessException;
+import fr.ifremer.suiviobsmer.WaoContext;
+import fr.ifremer.suiviobsmer.WaoException;
import fr.ifremer.suiviobsmer.entity.Boat;
import fr.ifremer.suiviobsmer.entity.Company;
import fr.ifremer.suiviobsmer.entity.FishingZone;
@@ -39,8 +39,8 @@
import fr.ifremer.suiviobsmer.services.ServiceSampling;
import fr.ifremer.suiviobsmer.services.ServiceUser;
import fr.ifremer.suiviobsmer.ui.base.GenericSelectModel;
-import fr.ifremer.suiviobsmer.ui.base.SuiviObsmerPage;
-import fr.ifremer.suiviobsmer.ui.data.SuiviObsmerPropertyChangeListener;
+import fr.ifremer.suiviobsmer.ui.base.WaoPage;
+import fr.ifremer.suiviobsmer.ui.data.WaoPropertyChangeListener;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
@@ -80,7 +80,7 @@
* par : $Author$
*/
@IncludeStylesheet("context:css/sampling.css")
-public class SampleRowForm implements SuiviObsmerPage {
+public class SampleRowForm implements WaoPage {
@Override
public boolean isOnlyForAdmin() {
@@ -121,7 +121,7 @@
return sampleRowId;
}
- void setupRender() throws SuiviObsmerException {
+ void setupRender() throws WaoException {
// Reset data
sampleRow = null;
getSampleRow();
@@ -180,9 +180,9 @@
* Get SelectModel for profession input Select. The select contains all existing professions.
*
* @return a GenericSelectModel<Profession>
- * @throws SuiviObsmerException
+ * @throws WaoException
*/
- public GenericSelectModel<Profession> getProfessionSelectModel() throws SuiviObsmerException {
+ public GenericSelectModel<Profession> getProfessionSelectModel() throws WaoException {
if (professionSelectModel == null) {
if (log.isInfoEnabled()) {
log.info("BUSINESS REQUEST [getProfessions]");
@@ -206,9 +206,9 @@
/**
* Action on submit : addNewProfession. Used to set a new profession from the selected one.
*
- * @throws SuiviObsmerException
+ * @throws WaoException
*/
- void onSelectedFromAddNewProfession() throws SuiviObsmerException {
+ void onSelectedFromAddNewProfession() throws WaoException {
Profession profession = new ProfessionImpl();
if (!StringUtils.isEmpty(professionId)) {
Profession professionSelected = getProfessionSelectModel().findObject(professionId);
@@ -247,9 +247,9 @@
* Get the select model for FishingZone. The select contains all existing fishingZones.
*
* @return a GenericSelectModel<FishingZone>
- * @throws SuiviObsmerException
+ * @throws WaoException
*/
- public GenericSelectModel<FishingZone> getFishingZoneSelectModel() throws SuiviObsmerException {
+ public GenericSelectModel<FishingZone> getFishingZoneSelectModel() throws WaoException {
if (fishingZoneSelectModel == null) {
if (log.isInfoEnabled()) {
log.info("BUSINESS REQUEST [getFishingZones]");
@@ -265,18 +265,18 @@
* Get the list of FishingZones from the SampleRow.
*
* @return a List of FishingZone linked with the SampleRow
- * @throws SuiviObsmerException
+ * @throws WaoException
*/
- public List<FishingZone> getFishingZones() throws SuiviObsmerException {
+ public List<FishingZone> getFishingZones() throws WaoException {
return getSampleRow().getFishingZone();
}
/**
* Action on submit : addFishingZone. Used to add the selected fishingZone to the SampleRow.
*
- * @throws SuiviObsmerException
+ * @throws WaoException
*/
- void onSelectedFromAddFishingZone() throws SuiviObsmerException {
+ void onSelectedFromAddFishingZone() throws WaoException {
fishingZone = getFishingZoneSelectModel().findObject(fishingZoneId);
if (!getFishingZones().contains(fishingZone)) {
if (log.isDebugEnabled()) {
@@ -291,9 +291,9 @@
* Action on submit : removeFishingZone. Used to remove the fishingZone from the SampleRow.
*
* @param index of the FishingZone in the list (from loop component)
- * @throws SuiviObsmerException
+ * @throws WaoException
*/
- void onSelectedFromRemoveFishingZone(int index) throws SuiviObsmerException {
+ void onSelectedFromRemoveFishingZone(int index) throws WaoException {
if (log.isDebugEnabled()) {
log.debug("Remove fishingZone at position : " + index);
}
@@ -340,7 +340,7 @@
private boolean periodChanged;
- public SelectModel getProgramSelectModel() throws SuiviObsmerException {
+ public SelectModel getProgramSelectModel() throws WaoException {
if (programSelectModel == null) {
if (log.isInfoEnabled()) {
log.info("BUSINESS REQUEST [getPrograms]");
@@ -354,7 +354,7 @@
return programSelectModel;
}
-// public List<Date> getMonths() throws SuiviObsmerException {
+// public List<Date> getMonths() throws WaoException {
// if (months == null) {
// if (log.isDebugEnabled()) {
// log.debug("Reset months list");
@@ -366,11 +366,11 @@
// return months;
// }
-// public Program getProgram() throws SuiviObsmerException {
+// public Program getProgram() throws WaoException {
// return getSampleRow().getProgram();
// }
- public PeriodDates getPeriod() throws SuiviObsmerException {
+ public PeriodDates getPeriod() throws WaoException {
if (period == null) {
Date begin = getSampleRow().getPeriodBegin();
Date end = getSampleRow().getPeriodEnd();
@@ -379,7 +379,7 @@
return period;
}
- public List<SampleMonth> getSampleMonths() throws SuiviObsmerException {
+ public List<SampleMonth> getSampleMonths() throws WaoException {
if (sampleMonths == null) {
sampleMonths = new ArrayList<SampleMonth>();
for (Date currMonth : getPeriod().getMonths()) {
@@ -405,7 +405,7 @@
public String getMonthStyle() {
String style = " ";
- Date current = SuiviObsmerContext.getCurrentDate();
+ Date current = WaoContext.getCurrentDate();
if (sampleMonth.isCurrentMonth()) {
style += "selected";
} else if (current.after(sampleMonth.getPeriodDate())) {
@@ -417,10 +417,10 @@
/**
* Search a program from the list.
* The program will be set from the one selected. If no selection, a new one will be set.
- * @throws SuiviObsmerException
+ * @throws WaoException
*/
// @Log
-// void onSelectedFromSearchProgram() throws SuiviObsmerException {
+// void onSelectedFromSearchProgram() throws WaoException {
// if (!StringUtils.isEmpty(programId)) {
// programName = null;
//// period = null;
@@ -436,10 +436,10 @@
* Refresh months from program period.
* If the programName is not empty, a new program will be set.
* The period dates will be saved in program (validation will be done in onSuccess).
- * @throws SuiviObsmerException
+ * @throws WaoException
*/
@Log
- void onSelectedFromRefreshMonths() throws SuiviObsmerException {
+ void onSelectedFromRefreshMonths() throws WaoException {
getSampleRow().setPeriod(period);
periodChanged = true;
// Reset sampleMonths for new period
@@ -448,7 +448,7 @@
saveProgram();
}
- protected void saveProgram() throws SuiviObsmerException {
+ protected void saveProgram() throws WaoException {
// Save programName
if (StringUtils.isNotEmpty(programName)) {
getSampleRow().setProgramName(programName);
@@ -462,7 +462,7 @@
}
@Log
- void onSelectedFromDeleteMonth(int index) throws SuiviObsmerException {
+ void onSelectedFromDeleteMonth(int index) throws WaoException {
getSampleMonths().remove(index);
edited = true;
}
@@ -498,16 +498,16 @@
private boolean cancel;
@Persist
- private SuiviObsmerPropertyChangeListener propertyChange;
+ private WaoPropertyChangeListener propertyChange;
- public SampleRow getSampleRow() throws SuiviObsmerException {
+ public SampleRow getSampleRow() throws WaoException {
if (sampleRow == null) {
if (!StringUtils.isEmpty(sampleRowId)) {
if (log.isInfoEnabled()) {
log.info("BUSINESS REQUEST [getSampleRow]");
}
sampleRow = serviceSampling.getSampleRow(sampleRowId);
- propertyChange = new SuiviObsmerPropertyChangeListener();
+ propertyChange = new WaoPropertyChangeListener();
for (SampleMonth month : sampleRow.getSampleMonth()) {
month.addPropertyChangeListener(SampleMonth.EXPECTED_TIDES_VALUE, propertyChange);
}
@@ -518,7 +518,7 @@
return sampleRow;
}
- public SampleRowLog getSampleRowLog() throws SuiviObsmerException {
+ public SampleRowLog getSampleRowLog() throws WaoException {
if (sampleRowLog == null) {
sampleRowLog = new SampleRowLogImpl();
sampleRowLog.setSampleRow(getSampleRow());
@@ -537,7 +537,7 @@
return sampleRowModel;
}
- public GenericSelectModel<Company> getCompanySelectModel() throws SuiviObsmerException {
+ public GenericSelectModel<Company> getCompanySelectModel() throws WaoException {
if (companySelectModel == null) {
if (log.isInfoEnabled()) {
log.info("BUSINESS REQUEST [getCompanies]");
@@ -549,7 +549,7 @@
return companySelectModel;
}
- public boolean isCreateMode() throws SuiviObsmerException {
+ public boolean isCreateMode() throws WaoException {
return StringUtils.isEmpty(getSampleRow().getTopiaId());
}
@@ -557,12 +557,12 @@
cancel = true;
}
- void onSelectedFromSaveData() throws SuiviObsmerException {
+ void onSelectedFromSaveData() throws WaoException {
saveProgram();
}
@Log
- void onValidateFormFromSampleRowForm() throws SuiviObsmerException {
+ void onValidateFormFromSampleRowForm() throws WaoException {
sampleRowForm.clearErrors();
try {
// Only for save or periodChanged (refreshMonth)
@@ -641,7 +641,7 @@
getSampleRow().setCode(rowCode);
}
}
- } catch (SuiviObsmerBusinessException eee) {
+ } catch (WaoBusinessException eee) {
sampleRowForm.recordError(eee.getMessage());
log.error("BUSINESS ERROR : " + eee.getType() + " depuis " + eee.getServiceName() +
" : " + eee.getMessage());
@@ -653,7 +653,7 @@
}
@Log
- Object onSuccessFromSampleRowForm() throws SuiviObsmerException {
+ Object onSuccessFromSampleRowForm() throws WaoException {
if (cancel) {
return this;
}
Modified: trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/SampleRowHistoric.java
===================================================================
--- trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/SampleRowHistoric.java 2010-02-16 10:56:02 UTC (rev 353)
+++ trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/SampleRowHistoric.java 2010-02-16 12:00:05 UTC (rev 354)
@@ -1,6 +1,6 @@
/*
* *##%
- * SuiviObsmer :: Web Interface
+ * Wao :: Web Interface
* Copyright (C) 2009 - 2010 Ifremer
*
* This program is free software: you can redistribute it and/or modify
@@ -21,11 +21,11 @@
package fr.ifremer.suiviobsmer.ui.pages;
-import fr.ifremer.suiviobsmer.SuiviObsmerException;
+import fr.ifremer.suiviobsmer.WaoException;
import fr.ifremer.suiviobsmer.entity.SampleRow;
import fr.ifremer.suiviobsmer.entity.SampleRowLog;
import fr.ifremer.suiviobsmer.services.ServiceSampling;
-import fr.ifremer.suiviobsmer.ui.base.SuiviObsmerPage;
+import fr.ifremer.suiviobsmer.ui.base.WaoPage;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Locale;
@@ -47,7 +47,7 @@
* par : $Author$
*/
@IncludeStylesheet("context:css/sampling.css")
-public class SampleRowHistoric implements SuiviObsmerPage {
+public class SampleRowHistoric implements WaoPage {
@Override
public boolean isOnlyForAdmin() {
@@ -76,12 +76,12 @@
return sampleRowId;
}
- void setupRender() throws SuiviObsmerException {
+ void setupRender() throws WaoException {
sampleRow = null;
getSampleRow();
}
- public SampleRow getSampleRow() throws SuiviObsmerException {
+ public SampleRow getSampleRow() throws WaoException {
if (sampleRow == null) {
if (log.isInfoEnabled()) {
log.info("BUSINESS REQUEST [getSampleRow]");
Modified: trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/SamplingPlan.java
===================================================================
--- trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/SamplingPlan.java 2010-02-16 10:56:02 UTC (rev 353)
+++ trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/SamplingPlan.java 2010-02-16 12:00:05 UTC (rev 354)
@@ -1,6 +1,6 @@
/*
* *##%
- * SuiviObsmer :: Web Interface
+ * Wao :: Web Interface
* Copyright (C) 2009 - 2010 Ifremer
*
* This program is free software: you can redistribute it and/or modify
@@ -22,8 +22,8 @@
package fr.ifremer.suiviobsmer.ui.pages;
-import fr.ifremer.suiviobsmer.SuiviObsmerBusinessException;
-import fr.ifremer.suiviobsmer.SuiviObsmerException;
+import fr.ifremer.suiviobsmer.WaoBusinessException;
+import fr.ifremer.suiviobsmer.WaoException;
import fr.ifremer.suiviobsmer.bean.FacadeRow;
import fr.ifremer.suiviobsmer.bean.ImportResults;
import fr.ifremer.suiviobsmer.entity.Company;
@@ -32,7 +32,7 @@
import fr.ifremer.suiviobsmer.entity.SampleRow;
import fr.ifremer.suiviobsmer.entity.WaoUser;
import fr.ifremer.suiviobsmer.services.ServiceSampling;
-import fr.ifremer.suiviobsmer.ui.base.SuiviObsmerPage;
+import fr.ifremer.suiviobsmer.ui.base.WaoPage;
import fr.ifremer.suiviobsmer.ui.components.Layout;
import fr.ifremer.suiviobsmer.ui.data.ExportStreamResponse;
import java.io.IOException;
@@ -66,7 +66,7 @@
* par : $Author$
*/
@IncludeStylesheet("context:css/sampling.css")
-public class SamplingPlan implements SuiviObsmerPage {
+public class SamplingPlan implements WaoPage {
@Override
public boolean isOnlyForAdmin() {
@@ -111,7 +111,7 @@
private UploadedFile samplingPlanCsvFile;
@Log
- void onSuccessFromImportSamplingPlan() throws SuiviObsmerException {
+ void onSuccessFromImportSamplingPlan() throws WaoException {
try {
ImportResults result = serviceSampling.importSamplingPlanCsv(samplingPlanCsvFile.getStream());
layout.getFeedBack().addInfo(result.getNbRowsImported() + " lignes du plan importés, " +
@@ -119,7 +119,7 @@
for (String error : result.getErrors()) {
layout.getFeedBack().addInfo(error);
}
- } catch (SuiviObsmerBusinessException eee) {
+ } catch (WaoBusinessException eee) {
layout.getFeedBack().addError(eee.getMessage());
}
}
@@ -134,7 +134,7 @@
InputStream result = null;
try {
result = serviceSampling.exportSamplingPlanCsv(user, getPeriod());
- } catch (SuiviObsmerException eee) {
+ } catch (WaoException eee) {
throw new IOException(eee);
}
return result;
@@ -196,9 +196,9 @@
/**
* Return List of SampleRow from suiviobsmer-business
* @return List of SampleRow
- * @throws SuiviObsmerException
+ * @throws WaoException
*/
- public List<SampleRow> getData() throws SuiviObsmerException {
+ public List<SampleRow> getData() throws WaoException {
if (data == null) {
if (log.isInfoEnabled()) {
log.info("BUSINESS REQUEST [getSampleRowsOrderedByFishingZone]");
@@ -374,15 +374,15 @@
/**
* Used to filter period using dates from the program selected in table.
* @param rowIndex index of the row in the table
- * @throws SuiviObsmerException for a data problem
+ * @throws WaoException for a data problem
*/
- void onActionFromFilterPeriodDates(int rowIndex) throws SuiviObsmerException {
+ void onActionFromFilterPeriodDates(int rowIndex) throws WaoException {
row = getData().get(rowIndex);
period.setFromDate(row.getPeriodBegin());
period.setThruDate(row.getPeriodEnd());
}
- void onActionFromDeleteSampleRow(int rowIndex) throws SuiviObsmerException {
+ void onActionFromDeleteSampleRow(int rowIndex) throws WaoException {
row = getData().get(rowIndex);
serviceSampling.deleteSampleRow(row);
}
Modified: trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/Synthesis.java
===================================================================
--- trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/Synthesis.java 2010-02-16 10:56:02 UTC (rev 353)
+++ trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/Synthesis.java 2010-02-16 12:00:05 UTC (rev 354)
@@ -1,6 +1,6 @@
/*
* *##%
- * SuiviObsmer :: Web Interface
+ * Wao :: Web Interface
* Copyright (C) 2009 - 2010 Ifremer
*
* This program is free software: you can redistribute it and/or modify
@@ -21,7 +21,7 @@
package fr.ifremer.suiviobsmer.ui.pages;
-import fr.ifremer.suiviobsmer.SuiviObsmerException;
+import fr.ifremer.suiviobsmer.WaoException;
import fr.ifremer.suiviobsmer.bean.BoardingResult;
import fr.ifremer.suiviobsmer.bean.BoatFilter;
import fr.ifremer.suiviobsmer.bean.BoatFilterImpl;
@@ -32,7 +32,7 @@
import fr.ifremer.suiviobsmer.entity.WaoUser;
import fr.ifremer.suiviobsmer.services.ServiceSynthesis;
import fr.ifremer.suiviobsmer.ui.base.AbstractFilteredPage;
-import fr.ifremer.suiviobsmer.ui.base.SuiviObsmerPage;
+import fr.ifremer.suiviobsmer.ui.base.WaoPage;
import fr.ifremer.suiviobsmer.ui.data.BusinessUtils;
import fr.ifremer.suiviobsmer.ui.data.ChartUtils;
import fr.ifremer.suiviobsmer.ui.data.ChartUtils.ChartType;
@@ -74,7 +74,7 @@
* par : $Author$
*/
@IncludeStylesheet("context:css/synthesis.css")
-public class Synthesis extends AbstractFilteredPage implements SuiviObsmerPage {
+public class Synthesis extends AbstractFilteredPage implements WaoPage {
@Override
public boolean isOnlyForAdmin() {
@@ -100,7 +100,7 @@
@InjectComponent
private Zone delegator;
- public Block getActiveBlock() throws SuiviObsmerException {
+ public Block getActiveBlock() throws WaoException {
if (activeSynthesis == null) {
// Initialize default synthesis by Data Sampling
activeSynthesis = SynthesisId.GRAPH_SAMPLING;
@@ -160,12 +160,12 @@
private boolean reset;
- private void initSamplingBlock() throws SuiviObsmerException {
+ private void initSamplingBlock() throws WaoException {
initSelectFilters(true, false, true);
}
@Override
- public BoatFilter getFilter() throws SuiviObsmerException {
+ public BoatFilter getFilter() throws WaoException {
if (dataSamplingFilter == null) {
dataSamplingFilter = new BoatFilterImpl();
if (!user.getAdmin()) {
@@ -175,7 +175,7 @@
return dataSamplingFilter;
}
- public PeriodDates getPeriod() throws SuiviObsmerException {
+ public PeriodDates getPeriod() throws WaoException {
if (getFilter().getPeriod() == null) {
PeriodDates period = PeriodDates.createMonthsPeriodFromToday(-12);
if (log.isDebugEnabled()) {
@@ -191,7 +191,7 @@
return false;
}
- public JFreeChart getDataSamplingChart() throws SuiviObsmerException {
+ public JFreeChart getDataSamplingChart() throws WaoException {
if (log.isInfoEnabled()) {
log.info("BUSINESS REQUEST [getDataSampling]");
}
@@ -238,7 +238,7 @@
@Property
private String companyIdForBoarding;
- private void initBoardingBlock() throws SuiviObsmerException {
+ private void initBoardingBlock() throws WaoException {
resetCompanySelect();
// Set the companyIdForBoarding is only necessary for an admin which
// have access to a select with all active companies (from Filters :
@@ -251,7 +251,7 @@
}
}
- public JFreeChart getBoardingBoatsChart() throws SuiviObsmerException {
+ public JFreeChart getBoardingBoatsChart() throws WaoException {
Map<String, Map<?, Integer>> data =
new HashMap<String, Map<?, Integer>>();
data.put("Navires", getBoardingResult().getData());
@@ -267,7 +267,7 @@
"Nb embarquements", ChartType.BAR, data);
}
- public BoardingResult getBoardingResult() throws SuiviObsmerException {
+ public BoardingResult getBoardingResult() throws WaoException {
if (boardingResult == null) {
if (log.isInfoEnabled()) {
log.info("BUSINESS REQUEST [getBoardingBoats]");
@@ -295,7 +295,7 @@
}
@Log
- void onSuccessFromFilterCompanyForBoarding() throws SuiviObsmerException {
+ void onSuccessFromFilterCompanyForBoarding() throws WaoException {
companyForBoarding = getCompanySelectModel().findObject(companyIdForBoarding);
}
@@ -312,10 +312,10 @@
* only one row, if the current user is an observer.
*
* @return a Map with companies and there values for nonComplianceBoarding
- * @throws SuiviObsmerException
+ * @throws WaoException
*/
public Map<String, Double> getNonComplianceBoarding()
- throws SuiviObsmerException {
+ throws WaoException {
if (nonComplianceBoarding == null) {
Company company = !user.getAdmin() ? user.getCompany() : null;
nonComplianceBoarding =
@@ -329,9 +329,9 @@
* observer user.
*
* @return the value of the indicator
- * @throws SuiviObsmerException
+ * @throws WaoException
*/
- public Double getNonComplianceBoardingValue() throws SuiviObsmerException {
+ public Double getNonComplianceBoardingValue() throws WaoException {
return getNonComplianceBoarding().get(user.getCompany().getName());
}
@@ -362,10 +362,10 @@
* only one result if the current user is an observer.
*
* @return all contactStateStatistics depends on company and selected period
- * @throws SuiviObsmerException
+ * @throws WaoException
*/
public Collection<ContactStateStatistics> getContactStateStatistics()
- throws SuiviObsmerException {
+ throws WaoException {
if (contactStateStatistics == null) {
Company company = !user.getAdmin() ? user.getCompany() : null;
contactStateStatistics =
@@ -416,7 +416,7 @@
private ContactAverageReactivity allegroReactivityEntry;
public Collection<ContactAverageReactivity> getAllegroReactivity()
- throws SuiviObsmerException {
+ throws WaoException {
if (allegroReactivity == null) {
Company company = !user.getAdmin() ? user.getCompany() : null;
allegroReactivity =
@@ -432,13 +432,13 @@
return periodForAllegroReactivity;
}
- public Double getAllegroReactivityValue() throws SuiviObsmerException {
+ public Double getAllegroReactivityValue() throws WaoException {
ContactAverageReactivity entry =
(ContactAverageReactivity) CollectionUtils.get(getAllegroReactivity(), 0);
return entry.getResult();
}
- public String getAllegroReactivityStyle() throws SuiviObsmerException {
+ public String getAllegroReactivityStyle() throws WaoException {
double value = user.getAdmin() ?
allegroReactivityEntry.getResult() : getAllegroReactivityValue();
if (value >= 15.) {
Modified: trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/UserProfile.java
===================================================================
--- trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/UserProfile.java 2010-02-16 10:56:02 UTC (rev 353)
+++ trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/UserProfile.java 2010-02-16 12:00:05 UTC (rev 354)
@@ -1,6 +1,6 @@
/*
* *##%
- * SuiviObsmer :: Web Interface
+ * Wao :: Web Interface
* Copyright (C) 2009 - 2010 Ifremer
*
* This program is free software: you can redistribute it and/or modify
@@ -21,11 +21,11 @@
package fr.ifremer.suiviobsmer.ui.pages;
-import fr.ifremer.suiviobsmer.SuiviObsmerBusinessException;
-import fr.ifremer.suiviobsmer.SuiviObsmerException;
+import fr.ifremer.suiviobsmer.WaoBusinessException;
+import fr.ifremer.suiviobsmer.WaoException;
import fr.ifremer.suiviobsmer.entity.WaoUser;
import fr.ifremer.suiviobsmer.services.ServiceUser;
-import fr.ifremer.suiviobsmer.ui.base.SuiviObsmerPage;
+import fr.ifremer.suiviobsmer.ui.base.WaoPage;
import fr.ifremer.suiviobsmer.ui.components.Layout;
import org.apache.commons.lang.StringUtils;
import org.apache.tapestry5.annotations.IncludeStylesheet;
@@ -48,7 +48,7 @@
* par : $Author$
*/
@IncludeStylesheet("context:css/userProfile.css")
-public class UserProfile implements SuiviObsmerPage {
+public class UserProfile implements WaoPage {
@Override
public boolean isOnlyForAdmin() {
@@ -85,7 +85,7 @@
return userEditable;
}
- void onSuccessFromUserForm() throws SuiviObsmerException {
+ void onSuccessFromUserForm() throws WaoException {
if (password != null && !password.equals(password2)) {
userForm.recordError("Les deux password ne sont pas identiques, vérifiez la saisie !");
@@ -97,7 +97,7 @@
}
serviceUser.createUpdateUser(userEditable, false);
layout.getFeedBack().addInfo("Modifications enregistrées avec succès !");
- } catch (SuiviObsmerBusinessException eee) {
+ } catch (WaoBusinessException eee) {
userForm.recordError(eee.getMessage());
// if (log.isErrorEnabled()) {
// log.error("Error during user save", eee);
Modified: trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/services/AppModule.java
===================================================================
--- trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/services/AppModule.java 2010-02-16 10:56:02 UTC (rev 353)
+++ trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/services/AppModule.java 2010-02-16 12:00:05 UTC (rev 354)
@@ -1,5 +1,5 @@
/* *##%
- * SuiviObsmer :: Web Interface
+ * Wao :: Web Interface
* Copyright (C) 2009 - 2010 Ifremer
*
* This program is free software: you can redistribute it and/or modify
@@ -58,8 +58,8 @@
binder.bind(ServiceContact.class, ServiceContactImpl.class);
binder.bind(ContactModelFactory.class);
binder.bind(ServiceSynthesis.class, ServiceSynthesisImpl.class);
-// binder.bind(SuiviObsmerModelDAOHelper.getContractClass(User.class),
-// SuiviObsmerModelDAOHelper.getImplementationClass(User.class));
+// binder.bind(WaoModelDAOHelper.getContractClass(User.class),
+// WaoModelDAOHelper.getImplementationClass(User.class));
}
public static void contributeApplicationDefaults(
@@ -125,15 +125,15 @@
* @return
*/
@EagerLoad
- public RegistryShutdownListener buildSuiviObsmerShutdown(
+ public RegistryShutdownListener buildWaoShutdown(
@InjectService("RegistryShutdownHub") RegistryShutdownHub hub) {
- RegistryShutdownListener listener = new SuiviObsmerManager();
+ RegistryShutdownListener listener = new WaoManager();
hub.addRegistryShutdownListener(listener);
return listener;
}
public static void contributeRegistryStartup(OrderedConfiguration<Runnable> configuration) {
- configuration.add("SuiviObsmerStartup", new SuiviObsmerManager());
+ configuration.add("WaoStartup", new WaoManager());
}
/**
Modified: trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/services/ContactModelFactory.java
===================================================================
--- trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/services/ContactModelFactory.java 2010-02-16 10:56:02 UTC (rev 353)
+++ trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/services/ContactModelFactory.java 2010-02-16 12:00:05 UTC (rev 354)
@@ -1,6 +1,6 @@
/*
* *##%
- * SuiviObsmer :: Web Interface
+ * Wao :: Web Interface
* Copyright (C) 2009 - 2010 Ifremer
*
* This program is free software: you can redistribute it and/or modify
Deleted: trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/services/SuiviObsmerManager.java
===================================================================
--- trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/services/SuiviObsmerManager.java 2010-02-16 10:56:02 UTC (rev 353)
+++ trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/services/SuiviObsmerManager.java 2010-02-16 12:00:05 UTC (rev 354)
@@ -1,79 +0,0 @@
-/*
- * *##%
- * SuiviObsmer :: Web Interface
- * 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.suiviobsmer.ui.services;
-
-import fr.ifremer.suiviobsmer.SuiviObsmerException;
-import fr.ifremer.suiviobsmer.SuiviObsmerRunner;
-import fr.ifremer.suiviobsmer.SuiviObsmerRunnerImpl;
-import org.apache.tapestry5.ioc.services.RegistryShutdownListener;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * SuiviObsmerManager
- *
- * Created: 24 nov. 2009
- *
- * @author fdesbois
- * @version $Revision$
- *
- * Mise a jour: $Date$
- * par : $Author$
- */
-public class SuiviObsmerManager implements Runnable, RegistryShutdownListener {
-
- private static final Logger log = LoggerFactory.getLogger(SuiviObsmerManager.class);
-
- private SuiviObsmerRunner runner;
-
- @Override
- public void run() {
- runner = new SuiviObsmerRunnerImpl();
- try {
- if (log.isInfoEnabled()) {
- log.info("Start SuiviObsmer");
- }
- runner.start();
- } catch (SuiviObsmerException eee) {
- if (log.isErrorEnabled()) {
- log.error("Error on start", eee);
- }
- }
- }
-
- @Override
- public void registryDidShutdown() {
- // No problem with reinstanciate the runner, all context is in SuiviObsmerContext which is static
- runner = new SuiviObsmerRunnerImpl();
- try {
- if (log.isInfoEnabled()) {
- log.info("Stop SuiviObsmer");
- }
- runner.stop();
- } catch (SuiviObsmerException eee) {
- if (log.isErrorEnabled()) {
- log.error("Error on stop", eee);
- }
- }
- }
-
-}
Copied: trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/services/WaoManager.java (from rev 350, trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/services/SuiviObsmerManager.java)
===================================================================
--- trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/services/WaoManager.java (rev 0)
+++ trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/services/WaoManager.java 2010-02-16 12:00:05 UTC (rev 354)
@@ -0,0 +1,79 @@
+/*
+ * *##%
+ * Wao :: Web Interface
+ * 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.suiviobsmer.ui.services;
+
+import fr.ifremer.suiviobsmer.WaoException;
+import fr.ifremer.suiviobsmer.WaoRunner;
+import fr.ifremer.suiviobsmer.WaoRunnerImpl;
+import org.apache.tapestry5.ioc.services.RegistryShutdownListener;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * WaoManager
+ *
+ * Created: 24 nov. 2009
+ *
+ * @author fdesbois
+ * @version $Revision$
+ *
+ * Mise a jour: $Date$
+ * par : $Author$
+ */
+public class WaoManager implements Runnable, RegistryShutdownListener {
+
+ private static final Logger log = LoggerFactory.getLogger(WaoManager.class);
+
+ private WaoRunner runner;
+
+ @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);
+ }
+ }
+ }
+
+}
Property changes on: trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/services/WaoManager.java
___________________________________________________________________
Added: svn:mergeinfo
+
Modified: trunk/suiviobsmer-ui/src/main/resources/fr/ifremer/suiviobsmer/ui/components/Layout.tml
===================================================================
--- trunk/suiviobsmer-ui/src/main/resources/fr/ifremer/suiviobsmer/ui/components/Layout.tml 2010-02-16 10:56:02 UTC (rev 353)
+++ trunk/suiviobsmer-ui/src/main/resources/fr/ifremer/suiviobsmer/ui/components/Layout.tml 2010-02-16 12:00:05 UTC (rev 354)
@@ -116,7 +116,7 @@
<p><t:label for="password" /> : </p>
<p><input t:type="passwordfield" t:id="password" t:value="password" /></p>
<div class="fright" id="so-connexion-form-buttons">
- <input class="ico accept" t:type="submit" value="Connexion" title="Connexion à l'application SuiviObsmer" />
+ <input class="ico accept" t:type="submit" value="Connexion" title="Connexion à l'application Wao" />
</div>
</div>
<div class="fright" id="so-connexion-logo">
Modified: trunk/suiviobsmer-ui/src/main/resources/log4j.properties
===================================================================
--- trunk/suiviobsmer-ui/src/main/resources/log4j.properties 2010-02-16 10:56:02 UTC (rev 353)
+++ trunk/suiviobsmer-ui/src/main/resources/log4j.properties 2010-02-16 12:00:05 UTC (rev 354)
@@ -21,5 +21,5 @@
log4j.logger.org.apache.tapestry5.TapestryFilter=INFO
log4j.logger.fr.ifremer.suiviobsmer=DEBUG
-log4j.logger.org.nuiton.util=DEBUG
+log4j.logger.org.nuiton.util=INFO
log4j.logger.org.nuiton.topia=INFO
Modified: trunk/suiviobsmer-ui/src/main/webapp/WEB-INF/web.xml
===================================================================
--- trunk/suiviobsmer-ui/src/main/webapp/WEB-INF/web.xml 2010-02-16 10:56:02 UTC (rev 353)
+++ trunk/suiviobsmer-ui/src/main/webapp/WEB-INF/web.xml 2010-02-16 12:00:05 UTC (rev 354)
@@ -19,7 +19,7 @@
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
- <display-name>SuiviObsmer</display-name>
+ <display-name>Wao</display-name>
<context-param>
<!-- The only significant configuration for Tapestry 5, this informs Tapestry
of where to look for pages, components and mixins. -->
Modified: trunk/suiviobsmer-ui/src/main/webapp/css/common.css
===================================================================
--- trunk/suiviobsmer-ui/src/main/webapp/css/common.css 2010-02-16 10:56:02 UTC (rev 353)
+++ trunk/suiviobsmer-ui/src/main/webapp/css/common.css 2010-02-16 12:00:05 UTC (rev 354)
@@ -3,7 +3,7 @@
Created on : 9 nov. 2009, 10:33:06
Author : fdesbois
Description:
- Common style cheets for SuiviObsmer
+ Common style cheets for Wao
*/
* {
1
0
[Suiviobsmer-commits] r353 - trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity
by fdesbois@users.labs.libre-entreprise.org 16 Feb '10
by fdesbois@users.labs.libre-entreprise.org 16 Feb '10
16 Feb '10
Author: fdesbois
Date: 2010-02-16 10:56:02 +0000 (Tue, 16 Feb 2010)
New Revision: 353
Modified:
trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/SampleMonthImpl.java
Log:
Improve isCurrentMonth method adding year test
Modified: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/SampleMonthImpl.java
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/SampleMonthImpl.java 2010-02-12 18:18:54 UTC (rev 352)
+++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/SampleMonthImpl.java 2010-02-16 10:56:02 UTC (rev 353)
@@ -103,8 +103,10 @@
int currentMonth = current.get(Calendar.MONTH);
int month = calendar.get(Calendar.MONTH);
+ int currentYear = current.get(Calendar.YEAR);
+ int year = calendar.get(Calendar.YEAR);
- return month == currentMonth;
+ return month == currentMonth && currentYear == year;
}
}
1
0
[Suiviobsmer-commits] r352 - in trunk: suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/services suiviobsmer-ui/src/main/resources/fr/ifremer/suiviobsmer/ui/pages suiviobsmer-ui/src/main/webapp
by fdesbois@users.labs.libre-entreprise.org 12 Feb '10
by fdesbois@users.labs.libre-entreprise.org 12 Feb '10
12 Feb '10
Author: fdesbois
Date: 2010-02-12 18:18:54 +0000 (Fri, 12 Feb 2010)
New Revision: 352
Modified:
trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services/ServiceSynthesisImpl.java
trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/services/ServiceSynthesisImplTest.java
trunk/suiviobsmer-ui/src/main/resources/fr/ifremer/suiviobsmer/ui/pages/Synthesis.properties
trunk/suiviobsmer-ui/src/main/webapp/Synthesis.tml
Log:
Evo #1985 : Add day in date format, suppress validation and use createQueryForContactDone.
Modified: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services/ServiceSynthesisImpl.java
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services/ServiceSynthesisImpl.java 2010-02-12 18:01:51 UTC (rev 351)
+++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services/ServiceSynthesisImpl.java 2010-02-12 18:18:54 UTC (rev 352)
@@ -91,6 +91,7 @@
if (period == null || period.getFromDate() == null || period.getThruDate() == null) {
return results;
}
+ period.initDayOfMonthExtremities();
// Expected
SortedMap<Date, Integer> serie1 = new TreeMap<Date,Integer>();
@@ -369,7 +370,8 @@
"AND " + tideBeginDate + " BETWEEN :fromDate AND :thruDate)" +
" OR (" + tideBeginDate + " IS NULL " +
"AND " + createDate + " BETWEEN :fromDate AND :thruDate)");
-
+
+ period.initDayOfMonthExtremities();
query.addParam("fromDate", period.getFromDate()).
addParam("thruDate", period.getThruDate());
}
@@ -429,9 +431,12 @@
ContactDAO dao = SuiviObsmerModelDAOHelper.getContactDAO(transaction);
- String contact = "C";
- TopiaQuery query = dao.createQuery(contact);
+// String contact = "C";
+// TopiaQuery query = dao.createQuery(contact);
+
+ TopiaQuery query = dao.createQueryDoneContactsFromDate(null, period.getFromDate());
+ String contact = query.getMainAlias();
String companyKey = contact + "." + Contact.OBSERVER + "." + WaoUser.COMPANY;
String companyName = companyKey + "." + Company.NAME;
@@ -440,13 +445,14 @@
}
String tideBegin = contact + "." + Contact.TIDE_BEGIN_DATE;
- period.initDayOfMonthExtremities();
- query.add(tideBegin + " BETWEEN :fromDate AND :thruDate").
- addParam("fromDate", period.getFromDate()).
- addParam("thruDate", period.getThruDate());
+ //period.initDayOfMonthExtremities();
+ if (period.getThruDate() != null) {
+ query.add(tideBegin, Op.LE, period.getThruDate());
+ }
+
String dataInput = contact + "." + Contact.DATA_INPUT_DATE;
- query.addNotNull(dataInput);
+ //query.addNotNull(dataInput);
// FIXME-FD20100212 Hack for H2 which not managed day for date diff
// TopiaContextImplementor context = (TopiaContextImplementor)transaction;
Modified: trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/services/ServiceSynthesisImplTest.java
===================================================================
--- trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/services/ServiceSynthesisImplTest.java 2010-02-12 18:01:51 UTC (rev 351)
+++ trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/services/ServiceSynthesisImplTest.java 2010-02-12 18:18:54 UTC (rev 352)
@@ -473,6 +473,8 @@
contact1.setTideBeginDate(begin);
Date inputDate = DateUtils.createDate(15, 4, 2009);
contact1.setDataInputDate(inputDate);
+ contact1.setState(ContactState.BOARDING_DONE.toString());
+ contact1.setValidationCompany(Boolean.TRUE);
serviceContact.saveContact(contact1, false);
Contact contact2 = new ContactImpl();
@@ -481,6 +483,8 @@
contact2.setTideBeginDate(begin);
inputDate = DateUtils.createDate(15, 3, 2009);
contact2.setDataInputDate(inputDate);
+ contact2.setState(ContactState.BOARDING_DONE.toString());
+ contact2.setValidationCompany(Boolean.TRUE);
serviceContact.saveContact(contact2, false);
Contact contact3 = new ContactImpl();
@@ -488,6 +492,8 @@
begin = DateUtils.createDate(3, 3, 2009);
contact3.setTideBeginDate(begin);
contact3.setDataInputDate(begin);
+ contact3.setState(ContactState.BOARDING_DONE.toString());
+ contact3.setValidationCompany(Boolean.TRUE);
serviceContact.saveContact(contact3, false);
/** EXEC METHOD **/
Modified: trunk/suiviobsmer-ui/src/main/resources/fr/ifremer/suiviobsmer/ui/pages/Synthesis.properties
===================================================================
--- trunk/suiviobsmer-ui/src/main/resources/fr/ifremer/suiviobsmer/ui/pages/Synthesis.properties 2010-02-12 18:01:51 UTC (rev 351)
+++ trunk/suiviobsmer-ui/src/main/resources/fr/ifremer/suiviobsmer/ui/pages/Synthesis.properties 2010-02-12 18:18:54 UTC (rev 352)
@@ -22,5 +22,5 @@
filtersForm-periodEnd-required-message: La date de fin est obligatoire
filterPeriodForContactStates-periodBeginForContactStates-required-message: La date de d\u00E9but est obligatoire
filterPeriodForContactStates-periodEndForContactStates-required-message: La date de fin est obligatoire
-filterPeriodForAllegroReactivity-periodBeginForAllegroReactivity-required-message: La date de d\u00E9but est obligatoire
-filterPeriodForAllegroReactivity-periodEndForAllegroReactivity-required-message: La date de fin est obligatoire
\ No newline at end of file
+#filterPeriodForAllegroReactivity-periodBeginForAllegroReactivity-required-message: La date de d\u00E9but est obligatoire
+#filterPeriodForAllegroReactivity-periodEndForAllegroReactivity-required-message: La date de fin est obligatoire
\ No newline at end of file
Modified: trunk/suiviobsmer-ui/src/main/webapp/Synthesis.tml
===================================================================
--- trunk/suiviobsmer-ui/src/main/webapp/Synthesis.tml 2010-02-12 18:01:51 UTC (rev 351)
+++ trunk/suiviobsmer-ui/src/main/webapp/Synthesis.tml 2010-02-12 18:18:54 UTC (rev 352)
@@ -144,7 +144,7 @@
<t:if t:test="user.admin">
<p>
Ces résultats concernent l'ensemble des contrats en cours
- ayant des données réelles.
+ ayant des données réelles (contacts validés).
</p>
<table class="t-data-grid">
<thead>
@@ -165,7 +165,7 @@
<p:else>
<p>
Ce résultat concerne l'ensemble des contrats en cours
- pour votre société ayant des données réelles.
+ pour votre société ayant des données réelles (contacts validés).
</p>
<div class="indicator">
<p class="number">
@@ -238,16 +238,16 @@
<h2>Réactivité de la saisie dans Allegro par rapport à la date de fin de la marée</h2>
<br />
<p>
- Ce résultat est une moyenne du nombre de jours entre la date de saisie dans Allegro et la date de fin de la marée des contacts.
+ Ce résultat est une moyenne du nombre de jours entre la date de saisie dans Allegro et la date de fin de la marée des contacts validés.
</p>
<br />
<p>
<form t:type="form" t:id="filterPeriodForAllegroReactivity">
<label>Période : </label>
<t:label t:for="periodBeginForAllegroReactivity" />
- <input t:type="datefield" class="width70" t:id="periodBeginForAllegroReactivity" t:value="periodForAllegroReactivity.fromDate" t:format="MM/yyyy" t:validate="required"/>
+ <input t:type="datefield" class="width70" t:id="periodBeginForAllegroReactivity" t:value="periodForAllegroReactivity.fromDate" />
<t:label t:for="periodEndForAllegroReactivity" />
- <input t:type="datefield" class="width70" t:id="periodEndForAllegroReactivity" t:value="periodForAllegroReactivity.thruDate" t:format="MM/yyyy" t:validate="required" />
+ <input t:type="datefield" class="width70" t:id="periodEndForAllegroReactivity" t:value="periodForAllegroReactivity.thruDate" />
<input t:type="submit" class="ico search-32px" t:id="searchForAllegroReactivity" value="Search"
title="Calcul de la moyenne du nombre de jours entre la date de saisie dans Allegro et la date de fin de marée sur la période sélectionnée"/>
</form>
1
0
[Suiviobsmer-commits] r351 - in trunk: suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/bean suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services suiviobsmer-business/src/main/xmi suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/services suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages suiviobsmer-ui/src/main/resources/fr/ifremer/suiviobsmer/ui/pages suiviobsmer-ui/src/main/webapp
by fdesbois@users.labs.libre-entreprise.org 12 Feb '10
by fdesbois@users.labs.libre-entreprise.org 12 Feb '10
12 Feb '10
Author: fdesbois
Date: 2010-02-12 18:01:51 +0000 (Fri, 12 Feb 2010)
New Revision: 351
Added:
trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/bean/ContactAverageReactivityImpl.java
Modified:
trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services/ServiceBoatImpl.java
trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services/ServiceSamplingImpl.java
trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services/ServiceSynthesisImpl.java
trunk/suiviobsmer-business/src/main/xmi/suiviobsmer.zargo
trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/services/ServiceSynthesisImplTest.java
trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/Boats.java
trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/Synthesis.java
trunk/suiviobsmer-ui/src/main/resources/fr/ifremer/suiviobsmer/ui/pages/Synthesis.properties
trunk/suiviobsmer-ui/src/main/webapp/Synthesis.tml
Log:
Ano #2103 : Problem with inPlace and GridPage when changing page and return to it : the page is not saved. The inPlace is not used anymore neither the passivate/activate for boatSelectedImmatriculation put in @Persist("flash") to preserve it in BoatInfos. The page loading is necessary to keep page change for navigation and reset boatInfos data to avoid gridDataSource problem (search a boat which is not in the dataSource).
Added: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/bean/ContactAverageReactivityImpl.java
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/bean/ContactAverageReactivityImpl.java (rev 0)
+++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/bean/ContactAverageReactivityImpl.java 2010-02-12 18:01:51 UTC (rev 351)
@@ -0,0 +1,32 @@
+
+package fr.ifremer.suiviobsmer.bean;
+
+/**
+ * ContactAverageReactivityImpl
+ *
+ * Created: 12 févr. 2010
+ *
+ * @author fdesbois
+ * @version $Revision$
+ *
+ * Mise a jour: $Date$
+ * par : $Author$
+ */
+public class ContactAverageReactivityImpl extends ContactAverageReactivity {
+
+ @Override
+ public void addValue(int nbDays) {
+ nbResults++;
+ if (nbDays < 0) {
+ // Not normal, problem with some existing data (maybe from import)
+ nbDays = 0;
+ }
+ totalDays += nbDays;
+ }
+
+ @Override
+ public double getResult() {
+ return (double)totalDays / (double)nbResults;
+ }
+
+}
Property changes on: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/bean/ContactAverageReactivityImpl.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL"
Modified: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services/ServiceBoatImpl.java
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services/ServiceBoatImpl.java 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services/ServiceBoatImpl.java 2010-02-12 18:01:51 UTC (rev 351)
@@ -414,8 +414,8 @@
String activeStr = ImportHelper.read(reader, BOAT.NAVS_ACTIVE);
boolean active = !activeStr.equals(BOAT.getBoatInactiveCode());
- if (log.isDebugEnabled()) {
- log.debug("Active : " + active + " (" + activeStr + ")");
+ if (log.isTraceEnabled()) {
+ log.trace("Active : " + active + " (" + activeStr + ")");
}
// Find existing boat with immatriculation
Modified: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services/ServiceSamplingImpl.java
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services/ServiceSamplingImpl.java 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services/ServiceSamplingImpl.java 2010-02-12 18:01:51 UTC (rev 351)
@@ -810,9 +810,9 @@
List<String> districtList = new ArrayList<String>(Arrays.asList(districts.split(FISHING_ZONE.getDistrictCodeSeparator())));
- if (log.isDebugEnabled()) {
- log.debug("FishingZone districts : " + districts);
- log.debug("FishingZone nb zones : " + districtList.size());
+ if (log.isTraceEnabled()) {
+ log.trace("FishingZone districts : " + districts);
+ log.trace("FishingZone nb zones : " + districtList.size());
}
for (String districtCode : districtList) {
FishingZone zone = dao.findByDistrictCode(districtCode.trim());
@@ -887,31 +887,7 @@
}
month.setExpectedTidesValue(monthValue);
}
-// else if (monthValue != null) {
-// // exception, outOfBounds month
-// if (log.isErrorEnabled()) {
-// log.error("Month out of bounds : value=" + monthValue + " _ monthDate=" + monthDate +
-// " _ periode=" + sampleRow.getPeriodBegin() + " au " + sampleRow.getPeriodEnd());
-// }
-// }
}
}
-// protected static final int TAB_MONTH = 0;
-// protected static final int TAB_YEAR = 1;
-
-// @Deprecated
-// protected int[] getMonthAndYear(String str) throws ParseException {
-// DateFormat dateFormat = new SimpleDateFormat("MM/yyyy");
-// int[] result = new int[2];
-//
-// Date date = dateFormat.parse(str);
-// Calendar calendar = new GregorianCalendar();
-// calendar.setTime(date);
-//
-// result[TAB_MONTH] = calendar.get(Calendar.MONTH) + 1;
-// result[TAB_YEAR] = calendar.get(Calendar.YEAR);
-// return result;
-// }
-
}
Modified: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services/ServiceSynthesisImpl.java
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services/ServiceSynthesisImpl.java 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services/ServiceSynthesisImpl.java 2010-02-12 18:01:51 UTC (rev 351)
@@ -24,6 +24,8 @@
import fr.ifremer.suiviobsmer.SuiviObsmerContext;
import fr.ifremer.suiviobsmer.SuiviObsmerException;
import fr.ifremer.suiviobsmer.SuiviObsmerModelDAOHelper;
+import fr.ifremer.suiviobsmer.bean.ContactAverageReactivityImpl;
+import fr.ifremer.suiviobsmer.bean.ContactAverageReactivity;
import fr.ifremer.suiviobsmer.bean.BoardingResult;
import fr.ifremer.suiviobsmer.bean.BoardingResultImpl;
import fr.ifremer.suiviobsmer.bean.ContactStateStatistics;
@@ -49,10 +51,10 @@
import java.util.SortedMap;
import java.util.TreeMap;
import org.nuiton.topia.TopiaContext;
-import org.nuiton.topia.framework.TopiaContextImplementor;
import org.nuiton.topia.framework.TopiaQuery;
import org.nuiton.topia.framework.TopiaQuery.Op;
import org.nuiton.topia.persistence.TopiaEntity;
+import org.nuiton.util.DateUtils;
import org.nuiton.util.PeriodDates;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -416,11 +418,12 @@
}
@Override
- public Map<String, Double> getContactDataInputDateReactivity(Company company, PeriodDates period) throws SuiviObsmerException {
+ public Collection<ContactAverageReactivity> getContactDataInputDateReactivity(Company company, PeriodDates period) throws SuiviObsmerException {
TopiaContext transaction = null;
// Carefull with results, the company may not be present in the map :
// only if there is no unfinished sampleRow or no contact done
- Map<String, Double> results = new HashMap<String, Double>();
+
+ Map<String, ContactAverageReactivity> results = new HashMap<String, ContactAverageReactivity>();
try {
transaction = rootContext.beginTransaction();
@@ -428,7 +431,7 @@
String contact = "C";
TopiaQuery query = dao.createQuery(contact);
-
+
String companyKey = contact + "." + Contact.OBSERVER + "." + WaoUser.COMPANY;
String companyName = companyKey + "." + Company.NAME;
@@ -446,36 +449,67 @@
query.addNotNull(dataInput);
// FIXME-FD20100212 Hack for H2 which not managed day for date diff
- TopiaContextImplementor context = (TopiaContextImplementor)transaction;
- String dialect = context.getHibernateConfiguration().getProperty("hibernate.dialect");
+// TopiaContextImplementor context = (TopiaContextImplementor)transaction;
+// String dialect = context.getHibernateConfiguration().getProperty("hibernate.dialect");
- String avg = "AVG(day(" + dataInput + " - " + tideBegin + "))";
- if (dialect.contains("H2Dialect")) {
- avg = "AVG(" + dataInput + " - " + tideBegin + ")";
- }
+// String avg = "AVG(day(" + dataInput + " - " + tideBegin + "))";
+// if (dialect.contains("H2Dialect")) {
+// avg = "AVG(" + dataInput + " - " + tideBegin + ")";
+// }
- query.setSelect(companyName, avg).addGroup(companyName);
+ //query.setSelect(companyName, avg).addGroup(companyName);
+ query.setSelect(companyName, dataInput, tideBegin);
- if (log.isTraceEnabled()) {
- log.trace("Exec query : " + query);
+ if (log.isDebugEnabled()) {
+ log.debug("Exec query : " + query);
}
List<Object[]> res = query.execute();
for (Object[] row : res) {
String rowCompanyName = (String)row[0];
- Double rowAverage = (Double)row[1];
- if (log.isTraceEnabled()) {
- log.trace("Company : " + rowCompanyName);
- log.trace("Res : " + rowAverage.doubleValue());
+ Date rowDataInputDate = (Date)row[1];
+ Date rowTideBeginDate = (Date)row[2];
+
+ int nbDays = DateUtils.getDifferenceInDays(rowTideBeginDate, rowDataInputDate);
+
+ if (log.isDebugEnabled()) {
+ log.debug("Company : " + rowCompanyName);
+ log.debug("tideBegin : " + rowTideBeginDate);
+ log.debug("dataInput : " + rowDataInputDate);
+ log.debug("nbDays : " + nbDays);
}
- if (rowAverage < 0) {
- rowAverage = 0.;
+
+ ContactAverageReactivity avg = results.get(rowCompanyName);
+ if (avg == null) {
+ avg = new ContactAverageReactivityImpl();
+ avg.setCompanyName(rowCompanyName);
+ results.put(rowCompanyName, avg);
}
- results.put(rowCompanyName, rowAverage);
+
+ avg.addValue(nbDays);
+
+
+
+// String rowCompanyName = (String)row[0];
+// Object rowAverage = row[1];
+// if (log.isDebugEnabled()) {
+// log.debug("Company : " + rowCompanyName);
+// log.debug("Res : " + rowAverage.getClass().getName());
+// log.debug("Res : " + rowAverage);
+// log.debug("tideBegin : " + (Date)row[3]);
+// log.debug("dataInput : " + (Date)row[2]);
+// }
+//// Double d = new Double((double)rowAverage.intValue());
+//// if (rowAverage < 0) {
+//// rowAverage = 0.;
+//// }
+// results.put(rowCompanyName, 0.);
}
+
+
} catch (Exception eee) {
String msgEnd = "";
if (company != null) {
@@ -487,7 +521,7 @@
} finally {
SuiviObsmerContext.closeTransaction(transaction);
}
- return results;
+ return results.values();
}
}
Modified: trunk/suiviobsmer-business/src/main/xmi/suiviobsmer.zargo
===================================================================
(Binary files differ)
Modified: trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/services/ServiceSynthesisImplTest.java
===================================================================
--- trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/services/ServiceSynthesisImplTest.java 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/services/ServiceSynthesisImplTest.java 2010-02-12 18:01:51 UTC (rev 351)
@@ -6,6 +6,7 @@
import fr.ifremer.suiviobsmer.SuiviObsmerRunner;
import fr.ifremer.suiviobsmer.SuiviObsmerRunnerTest;
import fr.ifremer.suiviobsmer.bean.BoardingResult;
+import fr.ifremer.suiviobsmer.bean.ContactAverageReactivity;
import fr.ifremer.suiviobsmer.bean.ContactState;
import fr.ifremer.suiviobsmer.bean.ContactStateStatistics;
import fr.ifremer.suiviobsmer.entity.Boat;
@@ -27,6 +28,7 @@
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;
@@ -493,19 +495,24 @@
PeriodDates period = new PeriodDates(begin, begin);
// result for company TARTANPION
- Map<String, Double> results =
+ Collection<ContactAverageReactivity> results =
service.getContactDataInputDateReactivity(company, period);
assertEquals(1, results.size());
// 12 days for contact1 + 43 days for contact2 / 2 = 27.5 days
- assertEquals(28, results.get(company.getName()), 0.01);
+ ContactAverageReactivity res =
+ (ContactAverageReactivity)CollectionUtils.get(results, 0);
+ assertEquals(27., res.getResult(), 0.01);
+
// result for company BIS using admin mode (no company filtered)
results = service.getContactDataInputDateReactivity(null, period);
// 0 days for contact3 / 1 = O days
- assertEquals(0, results.get(company2.getName()), 0.01);
+ res = (ContactAverageReactivity)CollectionUtils.get(results, 0);
+
+ assertEquals(0, res.getResult(), 0.01);
}
}
\ No newline at end of file
Modified: trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/Boats.java
===================================================================
--- trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/Boats.java 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/Boats.java 2010-02-12 18:01:51 UTC (rev 351)
@@ -728,9 +728,15 @@
/** /////////////////////// ACTIONS //////////////////////////////////// **/
+ void onSuccess() throws SuiviObsmerException {
+ if (getBoatInfos() != null) {
+ boatSelectedImmatriculation = getBoatInfos().getBoat().getImmatriculation();
+ }
+ }
+
Block onSuccessFromCompanySelectForm() throws SuiviObsmerException {
companyBoatInfos = null;
- getCompanyBoatInfos();
+ getCompanyBoatInfos();
return boatInfosZone.getBody();
}
@@ -752,7 +758,7 @@
}*/
// Set boatSelectedImmatriculation for boatInfos to reinitialize it (next getBoatInfos() call)
- //boatSelectedImmatriculation = getBoatInfos().getBoat().getImmatriculation();
+ boatSelectedImmatriculation = getBoatInfos().getBoat().getImmatriculation();
// Suppress boatInfos to get the one from serviceBoat (not updated yet)
companyBoatInfos = null;
return boatInfosZone.getBody();
@@ -782,10 +788,12 @@
// Save data
serviceBoat.createUpdateCompanyBoatInfos(companyBoatInfos);
}
+ //boatSelectedImmatriculation = getBoatInfos().getBoat().getImmatriculation();
return boatInfosZone.getBody();
}
Block onSuccessFromCalculateBoardings() throws SuiviObsmerException {
+ //boatSelectedImmatriculation = getBoatInfos().getBoat().getImmatriculation();
return boatInfosZone.getBody();
}
Modified: trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/Synthesis.java
===================================================================
--- trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/Synthesis.java 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/Synthesis.java 2010-02-12 18:01:51 UTC (rev 351)
@@ -27,6 +27,7 @@
import fr.ifremer.suiviobsmer.bean.BoatFilterImpl;
import fr.ifremer.suiviobsmer.bean.ContactState;
import fr.ifremer.suiviobsmer.bean.ContactStateStatistics;
+import fr.ifremer.suiviobsmer.bean.ContactAverageReactivity;
import fr.ifremer.suiviobsmer.entity.Company;
import fr.ifremer.suiviobsmer.entity.WaoUser;
import fr.ifremer.suiviobsmer.services.ServiceSynthesis;
@@ -45,6 +46,7 @@
import java.util.List;
import java.util.Map;
import java.util.SortedMap;
+import org.apache.commons.collections.CollectionUtils;
import org.apache.tapestry5.Block;
import org.apache.tapestry5.ComponentResources;
import org.apache.tapestry5.annotations.IncludeStylesheet;
@@ -405,15 +407,15 @@
/********************* INDICATOR : NONCOMPLIANCEBOARDING ******************/
- private Map<String, Double> allegroReactivity;
+ private Collection<ContactAverageReactivity> allegroReactivity;
@Persist
private PeriodDates periodForAllegroReactivity;
@Property
- private Map.Entry<String, Double> allegroReactivityEntry;
+ private ContactAverageReactivity allegroReactivityEntry;
- public Map<String, Double> getAllegroReactivity()
+ public Collection<ContactAverageReactivity> getAllegroReactivity()
throws SuiviObsmerException {
if (allegroReactivity == null) {
Company company = !user.getAdmin() ? user.getCompany() : null;
@@ -431,12 +433,14 @@
}
public Double getAllegroReactivityValue() throws SuiviObsmerException {
- return getAllegroReactivity().get(user.getCompany().getName());
+ ContactAverageReactivity entry =
+ (ContactAverageReactivity) CollectionUtils.get(getAllegroReactivity(), 0);
+ return entry.getResult();
}
public String getAllegroReactivityStyle() throws SuiviObsmerException {
double value = user.getAdmin() ?
- allegroReactivityEntry.getValue() : getAllegroReactivityValue();
+ allegroReactivityEntry.getResult() : getAllegroReactivityValue();
if (value >= 15.) {
return " warn";
}
Modified: trunk/suiviobsmer-ui/src/main/resources/fr/ifremer/suiviobsmer/ui/pages/Synthesis.properties
===================================================================
--- trunk/suiviobsmer-ui/src/main/resources/fr/ifremer/suiviobsmer/ui/pages/Synthesis.properties 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/suiviobsmer-ui/src/main/resources/fr/ifremer/suiviobsmer/ui/pages/Synthesis.properties 2010-02-12 18:01:51 UTC (rev 351)
@@ -15,4 +15,12 @@
periodEndForContactStates-label: au
periodBeginForAllegroReactivity-label: du
-periodEndForAllegroReactivity-label: au
\ No newline at end of file
+periodEndForAllegroReactivity-label: au
+
+# Validation messages
+filtersForm-periodBegin-required-message: La date de d\u00E9but est obligatoire
+filtersForm-periodEnd-required-message: La date de fin est obligatoire
+filterPeriodForContactStates-periodBeginForContactStates-required-message: La date de d\u00E9but est obligatoire
+filterPeriodForContactStates-periodEndForContactStates-required-message: La date de fin est obligatoire
+filterPeriodForAllegroReactivity-periodBeginForAllegroReactivity-required-message: La date de d\u00E9but est obligatoire
+filterPeriodForAllegroReactivity-periodEndForAllegroReactivity-required-message: La date de fin est obligatoire
\ No newline at end of file
Modified: trunk/suiviobsmer-ui/src/main/webapp/Synthesis.tml
===================================================================
--- trunk/suiviobsmer-ui/src/main/webapp/Synthesis.tml 2010-02-12 17:26:04 UTC (rev 350)
+++ trunk/suiviobsmer-ui/src/main/webapp/Synthesis.tml 2010-02-12 18:01:51 UTC (rev 351)
@@ -57,9 +57,9 @@
<div class="filterRow">
<label>Période: </label>
<t:label t:for="periodBegin" />:
- <input t:type="datefield" class="width70" t:id="periodBegin" t:value="period.fromDate" t:format="MM/yyyy"/>
+ <input t:type="datefield" class="width70" t:id="periodBegin" t:value="period.fromDate" t:format="MM/yyyy" t:validate="required"/>
<t:label t:for="periodEnd" />:
- <input t:type="datefield" class="width70" t:id="periodEnd" t:value="period.thruDate" t:format="MM/yyyy" />
+ <input t:type="datefield" class="width70" t:id="periodEnd" t:value="period.thruDate" t:format="MM/yyyy" t:validate="required"/>
</div>
<div>
<t:if t:test="user.admin">
@@ -192,9 +192,9 @@
<form t:type="form" t:id="filterPeriodForContactStates">
<label>Période : </label>
<t:label t:for="periodBeginForContactStates" />
- <input t:type="datefield" class="width70" t:id="periodBeginForContactStates" t:value="periodForContactStates.fromDate" t:format="MM/yyyy"/>
+ <input t:type="datefield" class="width70" t:id="periodBeginForContactStates" t:value="periodForContactStates.fromDate" t:format="MM/yyyy" t:validate="required"/>
<t:label t:for="periodEndForContactStates" />
- <input t:type="datefield" class="width70" t:id="periodEndForContactStates" t:value="periodForContactStates.thruDate" t:format="MM/yyyy" />
+ <input t:type="datefield" class="width70" t:id="periodEndForContactStates" t:value="periodForContactStates.thruDate" t:format="MM/yyyy" t:validate="required" />
<input t:type="submit" class="ico search-32px" t:id="searchForContactStates" value="Search"
title="Rechercher les états des contacts sur cette période"/>
</form>
@@ -245,9 +245,9 @@
<form t:type="form" t:id="filterPeriodForAllegroReactivity">
<label>Période : </label>
<t:label t:for="periodBeginForAllegroReactivity" />
- <input t:type="datefield" class="width70" t:id="periodBeginForAllegroReactivity" t:value="periodForAllegroReactivity.fromDate" t:format="MM/yyyy"/>
+ <input t:type="datefield" class="width70" t:id="periodBeginForAllegroReactivity" t:value="periodForAllegroReactivity.fromDate" t:format="MM/yyyy" t:validate="required"/>
<t:label t:for="periodEndForAllegroReactivity" />
- <input t:type="datefield" class="width70" t:id="periodEndForAllegroReactivity" t:value="periodForAllegroReactivity.thruDate" t:format="MM/yyyy" />
+ <input t:type="datefield" class="width70" t:id="periodEndForAllegroReactivity" t:value="periodForAllegroReactivity.thruDate" t:format="MM/yyyy" t:validate="required" />
<input t:type="submit" class="ico search-32px" t:id="searchForAllegroReactivity" value="Search"
title="Calcul de la moyenne du nombre de jours entre la date de saisie dans Allegro et la date de fin de marée sur la période sélectionnée"/>
</form>
@@ -261,10 +261,10 @@
</tr>
</thead>
<tbody>
- <tr t:type="loop" t:source="allegroReactivity.entrySet()" t:value="allegroReactivityEntry">
- <td class="company">${allegroReactivityEntry.key}</td>
+ <tr t:type="loop" t:source="allegroReactivity" t:value="allegroReactivityEntry">
+ <td class="company">${allegroReactivityEntry.companyName}</td>
<td class="number${allegroReactivityStyle}">
- <t:output t:value="allegroReactivityEntry.value" t:format="numberFormat" />
+ <t:output t:value="allegroReactivityEntry.result" t:format="numberFormat" />
</td>
</tr>
</tbody>
1
0
[Suiviobsmer-commits] r350 - trunk/src/site/rst/user
by jcouteau@users.labs.libre-entreprise.org 12 Feb '10
by jcouteau@users.labs.libre-entreprise.org 12 Feb '10
12 Feb '10
Author: jcouteau
Date: 2010-02-12 17:26:04 +0000 (Fri, 12 Feb 2010)
New Revision: 350
Modified:
trunk/src/site/rst/user/createAContact.rst
Log:
Add instruction on create a contact doc
Modified: trunk/src/site/rst/user/createAContact.rst
===================================================================
--- trunk/src/site/rst/user/createAContact.rst 2010-02-12 15:33:58 UTC (rev 349)
+++ trunk/src/site/rst/user/createAContact.rst 2010-02-12 17:26:04 UTC (rev 350)
@@ -21,8 +21,10 @@
Pour cela, désactivez les filtres qui ont été mis pour vous proposer les navires
de la ligne du plan (icone 'fleche' rouge) afin de rechercher le navire que vous
-souhaitez. Vous pouvez lui assigner une ligne du plan en sélectionnant la ligne
+souhaitez. Vous pouvez lui assigner une ligne du plan en éditant le navire
+(icone 'modifier') puis en sélectionnant la ligne
concernée dans la liste déroulante et en cliquant sur l'icone 'plus'.
+Enregistrez les modifications pour les rendre disponibles.
.. image:: boats_edit.png
:width: 800px
1
0
[Suiviobsmer-commits] r349 - in trunk/src/site: . rst/user
by jcouteau@users.labs.libre-entreprise.org 12 Feb '10
by jcouteau@users.labs.libre-entreprise.org 12 Feb '10
12 Feb '10
Author: jcouteau
Date: 2010-02-12 15:33:58 +0000 (Fri, 12 Feb 2010)
New Revision: 349
Added:
trunk/src/site/rst/user/createAContact.rst
Modified:
trunk/src/site/site_fr.xml
Log:
Add doc about how to create a contact
Added: trunk/src/site/rst/user/createAContact.rst
===================================================================
--- trunk/src/site/rst/user/createAContact.rst (rev 0)
+++ trunk/src/site/rst/user/createAContact.rst 2010-02-12 15:33:58 UTC (rev 349)
@@ -0,0 +1,40 @@
+Comment créer un contact ?
+==========================
+
+1. Choisir la ligne du plan d'échantillonage concernée
+------------------------------------------------------
+
+La première étape consiste à choisir la ligne du plan d'échantillonage sur
+laquelle vous souhaitez embarquer et cliquer sur l'icone 'navire' à droite de la
+ligne concernée.
+
+.. image::sampling_plan.png
+ :width: 800px
+
+2. Choisir le navire sur lequel vous souhaitez embarquer
+--------------------------------------------------------
+
+La seconde étape consiste à sélectionner le navire sur lequel vous souhaitez
+embarqué. Des navires sont associés à chaque ligne du plan. Vous pouvez choisir
+parmis ces derniers. Dans le cas ou le navire sur lequel vous souhaitez embarquer
+n'est pas présent dans la liste, il est possible de l'ajouter à la main.
+
+Pour cela, désactivez les filtres qui ont été mis pour vous proposer les navires
+de la ligne du plan (icone 'fleche' rouge) afin de rechercher le navire que vous
+souhaitez. Vous pouvez lui assigner une ligne du plan en sélectionnant la ligne
+concernée dans la liste déroulante et en cliquant sur l'icone 'plus'.
+
+.. image:: boats_edit.png
+ :width: 800px
+
+3. Créer le contact
+-------------------
+
+Une fois le navire choisi, on crée le contact en cliquant sur l'icone 'enveloppe'
+Le contact est créé. Pour gérer la contact, veuillez vous référer à la
+documentation_ ad-hoc.
+
+.. image:: boats_contact.png
+ :width: 800px
+
+.. _documentation: contacts.html
\ No newline at end of file
Modified: trunk/src/site/site_fr.xml
===================================================================
--- trunk/src/site/site_fr.xml 2010-02-12 14:51:40 UTC (rev 348)
+++ trunk/src/site/site_fr.xml 2010-02-12 15:33:58 UTC (rev 349)
@@ -49,6 +49,7 @@
<item name="La base des navires" href="user/boats.html"/>
<item name="Les contacts" href="user/contacts.html"/>
<item name="Les synthèses" href="user/syntheses.html"/>
+ <item name="Créer un contact" href="user/createAContact.html"/>
</item>
<item name="Import/Export" href="import/samplingPlan.html">
1
0
[Suiviobsmer-commits] r348 - in trunk: . suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/data suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages suiviobsmer-ui/src/main/webapp
by fdesbois@users.labs.libre-entreprise.org 12 Feb '10
by fdesbois@users.labs.libre-entreprise.org 12 Feb '10
12 Feb '10
Author: fdesbois
Date: 2010-02-12 14:51:40 +0000 (Fri, 12 Feb 2010)
New Revision: 348
Modified:
trunk/changelog.txt
trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/data/AbstractMappedGridDataSource.java
trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/BoatActivityCalendar.java
trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/Boats.java
trunk/suiviobsmer-ui/src/main/webapp/BoatActivityCalendar.tml
trunk/suiviobsmer-ui/src/main/webapp/Boats.tml
trunk/suiviobsmer-ui/src/main/webapp/Synthesis.tml
Log:
Ano #2103 : Problem with inPlace and GridPage when changing page and return to it : the page is not saved. The inPlace is not used anymore neither the passivate/activate for boatSelectedImmatriculation put in @Persist("flash") to preserve it in BoatInfos. The page loading is necessary to keep page change for navigation and reset boatInfos data to avoid gridDataSource problem (search a boat which is not in the dataSource).
Modified: trunk/changelog.txt
===================================================================
--- trunk/changelog.txt 2010-02-12 00:58:46 UTC (rev 347)
+++ trunk/changelog.txt 2010-02-12 14:51:40 UTC (rev 348)
@@ -32,6 +32,8 @@
Anomalies
+++++++++
+
+- [fdesbois] Ano #2103 : Erreur chargement infos d'un navire
- [fdesbois] Ano #2096 : Administration : Mail incomplet lors d'un changement
de mot de passe
- [fdesbois] Ano #2095 : Administration : Les zones de pêche ayant le même
Modified: trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/data/AbstractMappedGridDataSource.java
===================================================================
--- trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/data/AbstractMappedGridDataSource.java 2010-02-12 00:58:46 UTC (rev 347)
+++ trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/data/AbstractMappedGridDataSource.java 2010-02-12 14:51:40 UTC (rev 348)
@@ -3,12 +3,9 @@
import fr.ifremer.suiviobsmer.SuiviObsmerException;
import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
import java.util.List;
import java.util.Map;
import org.apache.commons.collections.CollectionUtils;
-import org.apache.tapestry5.PropertyConduit;
import org.apache.tapestry5.grid.ColumnSort;
import org.apache.tapestry5.grid.GridDataSource;
import org.apache.tapestry5.grid.SortConstraint;
@@ -167,4 +164,8 @@
return listResults;
}
+ public boolean contains(K key) {
+ return mapResults.containsKey(key);
+ }
+
}
Modified: trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/BoatActivityCalendar.java
===================================================================
--- trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/BoatActivityCalendar.java 2010-02-12 00:58:46 UTC (rev 347)
+++ trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/BoatActivityCalendar.java 2010-02-12 14:51:40 UTC (rev 348)
@@ -34,6 +34,7 @@
import java.util.List;
import org.apache.commons.lang.StringUtils;
import org.apache.tapestry5.annotations.IncludeStylesheet;
+import org.apache.tapestry5.annotations.InjectPage;
import org.apache.tapestry5.annotations.Persist;
import org.apache.tapestry5.annotations.Property;
import org.apache.tapestry5.annotations.SessionState;
@@ -183,4 +184,14 @@
}
return profession.getActivityZone().get(zoneIndex);
}
+
+ /*************************** RETURN LINK **********************************/
+
+ @InjectPage
+ private Boats boatsPage;
+
+ Object onActionFromReturnToBoats() {
+ boatsPage.setBoatSelectedImmatriculation(getBoat().getImmatriculation());
+ return boatsPage;
+ }
}
Modified: trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/Boats.java
===================================================================
--- trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/Boats.java 2010-02-12 00:58:46 UTC (rev 347)
+++ trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/Boats.java 2010-02-12 14:51:40 UTC (rev 348)
@@ -121,9 +121,17 @@
private String sampleRowContextId;
/** Selected boat immatriculation for showing boatInfos */
- @Property
+ @Persist("flash")
private Integer boatSelectedImmatriculation;
+ public Integer getBoatSelectedImmatriculation() {
+ return boatSelectedImmatriculation;
+ }
+
+ public void setBoatSelectedImmatriculation(Integer boatSelectedImmatriculation) {
+ this.boatSelectedImmatriculation = boatSelectedImmatriculation;
+ }
+
@InjectComponent
private FeedBack filterFeedback;
@@ -152,16 +160,16 @@
}
void onActivate(EventContext ec) {
- if (ec.getCount() > 0) {
- sampleRowContextId = ec.get(String.class, 0);
- if (ec.getCount() > 1) {
- boatSelectedImmatriculation = ec.get(Integer.class, 1);
- }
- }
+ sampleRowContextId = ec.get(String.class, 0);
+// boatSelectedImmatriculation = ec.get(Integer.class, 1);
}
- Object[] onPassivate() {
- return new Object[] { sampleRowContextId, boatSelectedImmatriculation };
+// Object[] onPassivate() {
+// return new Object[] { sampleRowContextId, boatSelectedImmatriculation };
+// }
+
+ String onPassivate() {
+ return sampleRowContextId;
}
/**************************** Import Forms ********************************/
@@ -531,6 +539,10 @@
// Suppress persistant boat informations
companyBoatInfos = null;
+ if (log.isDebugEnabled()) {
+ log.debug("Show infos for boat : " + boatImma);
+ }
+
if (user.getAdmin() && getCompany() != null) {
companySelectedId = getCompany().getTopiaId();
}
@@ -641,6 +653,10 @@
* @throws SuiviObsmerException
*/
public Boat getBoatSelected() throws SuiviObsmerException {
+ if (log.isDebugEnabled()) {
+ log.debug("selected imma : " + boatSelectedImmatriculation);
+ log.debug("exist boat ? : " + getBoats().contains(boatSelectedImmatriculation));
+ }
return getBoats().get(boatSelectedImmatriculation);
}
Modified: trunk/suiviobsmer-ui/src/main/webapp/BoatActivityCalendar.tml
===================================================================
--- trunk/suiviobsmer-ui/src/main/webapp/BoatActivityCalendar.tml 2010-02-12 00:58:46 UTC (rev 347)
+++ trunk/suiviobsmer-ui/src/main/webapp/BoatActivityCalendar.tml 2010-02-12 14:51:40 UTC (rev 348)
@@ -5,7 +5,7 @@
<t:if t:test="activityCalendar">
<h1>Calendrier d'activité ${activityCalendar.year}</h1>
<p class="acenter">
- <a t:type="pagelink" class="return" t:context="[norow,activityCalendar.boat.immatriculation]" t:page="boats" title="Retour sur ${activityCalendar.boat.name}">
+ <a t:type="actionlink" t:id="returnToBoats" class="return" title="Retour sur ${activityCalendar.boat.name}">
<img src="${asset:context:}/img/boat.png" alt="Navire"/>
Revenir sur les informations du navire
<img src="${asset:context:}/img/boat.png" alt="Navire"/>
Modified: trunk/suiviobsmer-ui/src/main/webapp/Boats.tml
===================================================================
--- trunk/suiviobsmer-ui/src/main/webapp/Boats.tml 2010-02-12 00:58:46 UTC (rev 347)
+++ trunk/suiviobsmer-ui/src/main/webapp/Boats.tml 2010-02-12 14:51:40 UTC (rev 348)
@@ -119,7 +119,7 @@
title="Exporter les ${boats.availableRows} navires avec leurs informations privées" />
</a>
</h1>
- <div t:type="grid" t:source="boats" t:row="boat" t:inPlace="true"
+ <div t:type="grid" t:source="boats" t:row="boat"
t:include="name, immatriculation, districtCode, boatLength, buildYear" t:rowClass="prop:rowStyle" t:rowsPerPage="20">
<p:nameCell>
<t:if t:test="canCreateNewContactFromList()">
Modified: trunk/suiviobsmer-ui/src/main/webapp/Synthesis.tml
===================================================================
--- trunk/suiviobsmer-ui/src/main/webapp/Synthesis.tml 2010-02-12 00:58:46 UTC (rev 347)
+++ trunk/suiviobsmer-ui/src/main/webapp/Synthesis.tml 2010-02-12 14:51:40 UTC (rev 348)
@@ -117,7 +117,7 @@
<div class="acenter">
<h2>Sollicitations des navires</h2>
<br />
- <p>Ces résultats ne concernent que les lignes du plan d'échantillonnage<br /> ayant une durée moyenne de marées inférieure ou égale à 2</p>
+ <p>Ces résultats ne concernent que les lignes du plan d'échantillonnage<br /> ayant une durée moyenne de marées inférieure ou égale à 48h</p>
<br />
<t:if t:test="user.admin">
<form t:type="form" t:id="filterCompanyForBoarding">
1
0
[Suiviobsmer-commits] r347 - in trunk: . suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services suiviobsmer-business/src/main/xmi suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/services suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages suiviobsmer-ui/src/main/resources/fr/ifremer/suiviobsmer/ui/pages suiviobsmer-ui/src/main/webapp suiviobsmer-ui/src/main/webapp/css suiviobsmer-ui/src/main/webapp/img
by fdesbois@users.labs.libre-entreprise.org 12 Feb '10
by fdesbois@users.labs.libre-entreprise.org 12 Feb '10
12 Feb '10
Author: fdesbois
Date: 2010-02-12 00:58:46 +0000 (Fri, 12 Feb 2010)
New Revision: 347
Added:
trunk/suiviobsmer-ui/src/main/webapp/img/synthesis-ind-allegro-reactivity.png
Modified:
trunk/changelog.txt
trunk/pom.xml
trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/SuiviObsmerContext.java
trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services/ServiceSynthesisImpl.java
trunk/suiviobsmer-business/src/main/xmi/suiviobsmer.zargo
trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/services/ServiceSynthesisImplTest.java
trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/Synthesis.java
trunk/suiviobsmer-ui/src/main/resources/fr/ifremer/suiviobsmer/ui/pages/Synthesis.properties
trunk/suiviobsmer-ui/src/main/webapp/Synthesis.tml
trunk/suiviobsmer-ui/src/main/webapp/css/synthesis.css
Log:
Evo #1985 : Indicator for allegro reactivity. Seems to be a wrong calcul using HQL method AVG(day(tideBegin - dataInput)). Moreover a hack was created for H2 which does'nt support this syntax... Must be refactor to be calculated in Java and not in HQL. It's a shame, tests are OK with H2 using only AVG(tideBegin - dataInput)... Difficult to test with Postgresql because of specificity of clear method in ToPIA for dropping database.
Modified: trunk/changelog.txt
===================================================================
--- trunk/changelog.txt 2010-02-11 20:04:33 UTC (rev 346)
+++ trunk/changelog.txt 2010-02-12 00:58:46 UTC (rev 347)
@@ -9,6 +9,8 @@
Evolutions
++++++++++
+- [fdesbois] Evo #1985 : Synthèse : indicateur nombre de jour moyen entre date
+ de saisie dans Allegro et date de fin de marée des contacts
- [fdesbois] Evo #2022 : Plan d'échantillonnage : Export CSV
- [fdesbois] Evo #1986 : Synthèse : indicateur sur les états des contacts
- [fdesbois] Evo #1984 : Synthèse : indicateur de non respect du nombre
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2010-02-11 20:04:33 UTC (rev 346)
+++ trunk/pom.xml 2010-02-12 00:58:46 UTC (rev 347)
@@ -222,7 +222,7 @@
<!-- libraries version -->
<nuitonutils.version>1.1.3</nuitonutils.version>
- <topia.version>2.3.0-beta-8-SNAPSHOT</topia.version>
+ <topia.version>2.3.0-beta-8</topia.version>
<eugene.version>2.0.0-beta-4</eugene.version>
<tapestry.version>5.1.0.5</tapestry.version>
Modified: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/SuiviObsmerContext.java
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/SuiviObsmerContext.java 2010-02-11 20:04:33 UTC (rev 346)
+++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/SuiviObsmerContext.java 2010-02-12 00:58:46 UTC (rev 347)
@@ -219,6 +219,8 @@
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);
Modified: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services/ServiceSynthesisImpl.java
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services/ServiceSynthesisImpl.java 2010-02-11 20:04:33 UTC (rev 346)
+++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services/ServiceSynthesisImpl.java 2010-02-12 00:58:46 UTC (rev 347)
@@ -49,6 +49,7 @@
import java.util.SortedMap;
import java.util.TreeMap;
import org.nuiton.topia.TopiaContext;
+import org.nuiton.topia.framework.TopiaContextImplementor;
import org.nuiton.topia.framework.TopiaQuery;
import org.nuiton.topia.framework.TopiaQuery.Op;
import org.nuiton.topia.persistence.TopiaEntity;
@@ -414,4 +415,79 @@
return results.values();
}
+ @Override
+ public Map<String, Double> getContactDataInputDateReactivity(Company company, PeriodDates period) throws SuiviObsmerException {
+ TopiaContext transaction = null;
+ // Carefull with results, the company may not be present in the map :
+ // only if there is no unfinished sampleRow or no contact done
+ Map<String, Double> results = new HashMap<String, Double>();
+ try {
+ transaction = rootContext.beginTransaction();
+
+ ContactDAO dao = SuiviObsmerModelDAOHelper.getContactDAO(transaction);
+
+ String contact = "C";
+ TopiaQuery query = dao.createQuery(contact);
+
+ String companyKey = contact + "." + Contact.OBSERVER + "." + WaoUser.COMPANY;
+ String companyName = companyKey + "." + Company.NAME;
+
+ if (company != null) {
+ query.add(companyKey, company);
+ }
+
+ String tideBegin = contact + "." + Contact.TIDE_BEGIN_DATE;
+ period.initDayOfMonthExtremities();
+ query.add(tideBegin + " BETWEEN :fromDate AND :thruDate").
+ addParam("fromDate", period.getFromDate()).
+ addParam("thruDate", period.getThruDate());
+
+ String dataInput = contact + "." + Contact.DATA_INPUT_DATE;
+ query.addNotNull(dataInput);
+
+ // FIXME-FD20100212 Hack for H2 which not managed day for date diff
+ TopiaContextImplementor context = (TopiaContextImplementor)transaction;
+ String dialect = context.getHibernateConfiguration().getProperty("hibernate.dialect");
+
+ String avg = "AVG(day(" + dataInput + " - " + tideBegin + "))";
+ if (dialect.contains("H2Dialect")) {
+ avg = "AVG(" + dataInput + " - " + tideBegin + ")";
+ }
+
+ query.setSelect(companyName, avg).addGroup(companyName);
+
+ if (log.isTraceEnabled()) {
+ log.trace("Exec query : " + query);
+ }
+
+ List<Object[]> res = query.execute();
+
+ for (Object[] row : res) {
+ String rowCompanyName = (String)row[0];
+ Double rowAverage = (Double)row[1];
+ if (log.isTraceEnabled()) {
+ log.trace("Company : " + rowCompanyName);
+ log.trace("Res : " + rowAverage.doubleValue());
+ }
+ if (rowAverage < 0) {
+ rowAverage = 0.;
+ }
+ results.put(rowCompanyName, rowAverage);
+ }
+
+
+ } catch (Exception eee) {
+ String msgEnd = "";
+ if (company != null) {
+ msgEnd = " pour la société " + company.getName();
+ }
+ SuiviObsmerContext.serviceException(transaction,
+ "Impossible de récupérer l'indicateur de réactivité sur " +
+ "les dates de saisies dans Allegro" + msgEnd, eee);
+ } finally {
+ SuiviObsmerContext.closeTransaction(transaction);
+ }
+ return results;
+ }
+
}
Modified: trunk/suiviobsmer-business/src/main/xmi/suiviobsmer.zargo
===================================================================
(Binary files differ)
Modified: trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/services/ServiceSynthesisImplTest.java
===================================================================
--- trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/services/ServiceSynthesisImplTest.java 2010-02-11 20:04:33 UTC (rev 346)
+++ trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/services/ServiceSynthesisImplTest.java 2010-02-12 00:58:46 UTC (rev 347)
@@ -416,4 +416,96 @@
assertEquals(0, data.get(ContactState.BOAT_UNAVAILABLE).intValue());
}
+ /**
+ * Test of getBoardingBoats method, of class ServiceSynthesisImpl.
+ */
+ @Test
+ public void testGetContactDataInputDateReactivity() throws Exception {
+ log.info("getContactDataInputDateReactivity");
+ /** PREPARE DATA **/
+ InputStream input = getClass().getResourceAsStream("/import/navires.csv");
+ ServiceBoat serviceBoat = new ServiceBoatImpl();
+ serviceBoat.importBoatCsv(input);
+ List<Boat> boats = serviceBoat.getBoatsByImmatriculations("174258");
+ Boat boat = boats.get(0);
+
+ List<Boat> boats2 = serviceBoat.getBoatsByImmatriculations("177474");
+ Boat boat2 = boats2.get(0);
+
+ TopiaContext transaction = SuiviObsmerContext.getTopiaRootContext().beginTransaction();
+
+ CompanyDAO companyDAO = SuiviObsmerModelDAOHelper.getCompanyDAO(transaction);
+ Company company = companyDAO.create(Company.NAME, "TARTANPION");
+ Company company2 = companyDAO.create(Company.NAME, "BIS");
+
+ WaoUserDAO userDAO = SuiviObsmerModelDAOHelper.getWaoUserDAO(transaction);
+ WaoUser user = userDAO.create(WaoUser.FIRST_NAME,"Jean", WaoUser.LAST_NAME, "Michmuche",
+ WaoUser.COMPANY, company);
+ company.addWaoUser(user);
+ WaoUser user2 = userDAO.create(WaoUser.FIRST_NAME,"Bill", WaoUser.LAST_NAME, "Murray",
+ WaoUser.COMPANY, company2);
+ company2.addWaoUser(user2);
+
+ transaction.commitTransaction();
+
+ input = getClass().getResourceAsStream("/import/zonesPeche.csv");
+ ServiceReferential serviceReferential = new ServiceReferentialImpl();
+ serviceReferential.importFishingZoneCsv(input);
+
+ input = getClass().getResourceAsStream("/import/echantillonnage.csv");
+ ServiceSampling serviceSampling = new ServiceSamplingImpl();
+ serviceSampling.importSamplingPlanCsv(input);
+
+ SampleRowDAO rowDAO = SuiviObsmerModelDAOHelper.getSampleRowDAO(transaction);
+ SampleRow row = rowDAO.findByCode("2010_0001");
+ SampleRow row2 = rowDAO.findByCode("2009_0006");
+
+ transaction.closeContext();
+
+
+ ServiceContact serviceContact = new ServiceContactImpl();
+ // First contact : OK
+ Contact contact1 = new ContactImpl();
+ contact1.setObserver(user);
+ Date begin = DateUtils.createDate(3, 3, 2009);
+ contact1.setTideBeginDate(begin);
+ Date inputDate = DateUtils.createDate(15, 4, 2009);
+ contact1.setDataInputDate(inputDate);
+ serviceContact.saveContact(contact1, false);
+
+ Contact contact2 = new ContactImpl();
+ contact2.setObserver(user);
+ begin = DateUtils.createDate(3, 3, 2009);
+ contact2.setTideBeginDate(begin);
+ inputDate = DateUtils.createDate(15, 3, 2009);
+ contact2.setDataInputDate(inputDate);
+ serviceContact.saveContact(contact2, false);
+
+ Contact contact3 = new ContactImpl();
+ contact3.setObserver(user2);
+ begin = DateUtils.createDate(3, 3, 2009);
+ contact3.setTideBeginDate(begin);
+ contact3.setDataInputDate(begin);
+ serviceContact.saveContact(contact3, false);
+
+ /** EXEC METHOD **/
+
+ PeriodDates period = new PeriodDates(begin, begin);
+
+ // result for company TARTANPION
+ Map<String, Double> results =
+ service.getContactDataInputDateReactivity(company, period);
+
+ assertEquals(1, results.size());
+
+ // 12 days for contact1 + 43 days for contact2 / 2 = 27.5 days
+ assertEquals(28, results.get(company.getName()), 0.01);
+
+ // result for company BIS using admin mode (no company filtered)
+ results = service.getContactDataInputDateReactivity(null, period);
+
+ // 0 days for contact3 / 1 = O days
+ assertEquals(0, results.get(company2.getName()), 0.01);
+ }
+
}
\ No newline at end of file
Modified: trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/Synthesis.java
===================================================================
--- trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/Synthesis.java 2010-02-11 20:04:33 UTC (rev 346)
+++ trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/Synthesis.java 2010-02-12 00:58:46 UTC (rev 347)
@@ -126,6 +126,12 @@
return new SimpleDateFormat("dd/MM/yyyy");
}
+ public NumberFormat getNumberFormat() {
+ NumberFormat result = NumberFormat.getNumberInstance();
+ result.setMaximumFractionDigits(1);
+ return result;
+ }
+
@Log
Object onAction(String actionType, String actionValue) {
// Delegator action (menu)
@@ -397,7 +403,44 @@
return (double)getNbContactStates() / (double)contactStateStats.getTotal();
}
-// void onSuccessFromFilterPeriodForContactStates() {
-// }
+ /********************* INDICATOR : NONCOMPLIANCEBOARDING ******************/
+ private Map<String, Double> allegroReactivity;
+
+ @Persist
+ private PeriodDates periodForAllegroReactivity;
+
+ @Property
+ private Map.Entry<String, Double> allegroReactivityEntry;
+
+ public Map<String, Double> getAllegroReactivity()
+ throws SuiviObsmerException {
+ if (allegroReactivity == null) {
+ Company company = !user.getAdmin() ? user.getCompany() : null;
+ allegroReactivity =
+ serviceSynthesis.getContactDataInputDateReactivity(company, getPeriodForAllegroReactivity());
+ }
+ return allegroReactivity;
+ }
+
+ public PeriodDates getPeriodForAllegroReactivity() {
+ if (periodForAllegroReactivity == null) {
+ periodForAllegroReactivity = PeriodDates.createMonthsPeriodFromToday(-3);
+ }
+ return periodForAllegroReactivity;
+ }
+
+ public Double getAllegroReactivityValue() throws SuiviObsmerException {
+ return getAllegroReactivity().get(user.getCompany().getName());
+ }
+
+ public String getAllegroReactivityStyle() throws SuiviObsmerException {
+ double value = user.getAdmin() ?
+ allegroReactivityEntry.getValue() : getAllegroReactivityValue();
+ if (value >= 15.) {
+ return " warn";
+ }
+ return "";
+ }
+
}
Modified: trunk/suiviobsmer-ui/src/main/resources/fr/ifremer/suiviobsmer/ui/pages/Synthesis.properties
===================================================================
--- trunk/suiviobsmer-ui/src/main/resources/fr/ifremer/suiviobsmer/ui/pages/Synthesis.properties 2010-02-11 20:04:33 UTC (rev 346)
+++ trunk/suiviobsmer-ui/src/main/resources/fr/ifremer/suiviobsmer/ui/pages/Synthesis.properties 2010-02-12 00:58:46 UTC (rev 347)
@@ -12,4 +12,7 @@
companyForBoarding-label: Soci\u00E9t\u00E9
periodBeginForContactStates-label: du
-periodEndForContactStates-label: au
\ No newline at end of file
+periodEndForContactStates-label: au
+
+periodBeginForAllegroReactivity-label: du
+periodEndForAllegroReactivity-label: au
\ No newline at end of file
Modified: trunk/suiviobsmer-ui/src/main/webapp/Synthesis.tml
===================================================================
--- trunk/suiviobsmer-ui/src/main/webapp/Synthesis.tml 2010-02-11 20:04:33 UTC (rev 346)
+++ trunk/suiviobsmer-ui/src/main/webapp/Synthesis.tml 2010-02-12 00:58:46 UTC (rev 347)
@@ -30,6 +30,12 @@
title="Indicateur sur les états des contacts" />
</a>
</li>
+ <li>
+ <a t:type="actionlink" t:context="[actionSynthesisId,'IND_ALLEGRO_REACTIVITY']" t:zone="so-synthesis-main">
+ <img src="${asset:context:}/img/synthesis-ind-allegro-reactivity.png" alt="Indicateur"
+ title="Indicateur de réactivité sur la saisie des données dans Allegro" />
+ </a>
+ </li>
</ul>
</div>
<div t:type="zone" t:id="delegator" class="fleft" t:update="show" id="so-synthesis-main">
@@ -226,4 +232,51 @@
</table>
</div>
</t:block>
+ <!-- IND3 : ALLEGRO_REACTIVITY -->
+ <t:block t:id="ind3">
+ <div class="ind-table acenter" id="so-allegroreactivity">
+ <h2>Réactivité de la saisie dans Allegro par rapport à la date de fin de la marée</h2>
+ <br />
+ <p>
+ Ce résultat est une moyenne du nombre de jours entre la date de saisie dans Allegro et la date de fin de la marée des contacts.
+ </p>
+ <br />
+ <p>
+ <form t:type="form" t:id="filterPeriodForAllegroReactivity">
+ <label>Période : </label>
+ <t:label t:for="periodBeginForAllegroReactivity" />
+ <input t:type="datefield" class="width70" t:id="periodBeginForAllegroReactivity" t:value="periodForAllegroReactivity.fromDate" t:format="MM/yyyy"/>
+ <t:label t:for="periodEndForAllegroReactivity" />
+ <input t:type="datefield" class="width70" t:id="periodEndForAllegroReactivity" t:value="periodForAllegroReactivity.thruDate" t:format="MM/yyyy" />
+ <input t:type="submit" class="ico search-32px" t:id="searchForAllegroReactivity" value="Search"
+ title="Calcul de la moyenne du nombre de jours entre la date de saisie dans Allegro et la date de fin de marée sur la période sélectionnée"/>
+ </form>
+ </p>
+ <t:if t:test="user.admin">
+ <table class="t-data-grid">
+ <thead>
+ <tr>
+ <th class="company">Société</th>
+ <th>Indicateur</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr t:type="loop" t:source="allegroReactivity.entrySet()" t:value="allegroReactivityEntry">
+ <td class="company">${allegroReactivityEntry.key}</td>
+ <td class="number${allegroReactivityStyle}">
+ <t:output t:value="allegroReactivityEntry.value" t:format="numberFormat" />
+ </td>
+ </tr>
+ </tbody>
+ </table>
+ <p:else>
+ <div class="indicator">
+ <p class="number${allegroReactivityStyle}">
+ <t:output t:value="allegroReactivityValue" t:format="numberFormat" />
+ </p>
+ </div>
+ </p:else>
+ </t:if>
+ </div>
+ </t:block>
</t:layout>
Modified: trunk/suiviobsmer-ui/src/main/webapp/css/synthesis.css
===================================================================
--- trunk/suiviobsmer-ui/src/main/webapp/css/synthesis.css 2010-02-11 20:04:33 UTC (rev 346)
+++ trunk/suiviobsmer-ui/src/main/webapp/css/synthesis.css 2010-02-12 00:58:46 UTC (rev 347)
@@ -54,7 +54,7 @@
div#so-synthesis-menu {
border-right: 2px solid #133852;
padding-left: 15px;
- height: 406px;
+ height: 478px;
width: 10%;
}
@@ -63,7 +63,7 @@
}
div#so-synthesis-menu ul li {
- padding-bottom: 20px;
+ padding-bottom: 10px;
}
div.indicator {
@@ -147,3 +147,6 @@
text-align: center;
}
+div#so-allegroreactivity td.warn {
+ color: red;
+}
Added: trunk/suiviobsmer-ui/src/main/webapp/img/synthesis-ind-allegro-reactivity.png
===================================================================
(Binary files differ)
Property changes on: trunk/suiviobsmer-ui/src/main/webapp/img/synthesis-ind-allegro-reactivity.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
1
0
[Suiviobsmer-commits] r346 - in trunk: . suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/io suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services suiviobsmer-business/src/main/xmi suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages suiviobsmer-ui/src/main/resources/fr/ifremer/suiviobsmer/ui/pages suiviobsmer-ui/src/main/webapp
by fdesbois@users.labs.libre-entreprise.org 11 Feb '10
by fdesbois@users.labs.libre-entreprise.org 11 Feb '10
11 Feb '10
Author: fdesbois
Date: 2010-02-11 20:04:33 +0000 (Thu, 11 Feb 2010)
New Revision: 346
Added:
trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/io/
trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/io/ExportHelper.java
trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/io/ImportHelper.java
trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/io/SamplingExport.java
trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/io/WaoCsvHeader.java
Removed:
trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/ImportHelper.java
Modified:
trunk/changelog.txt
trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services/ActivityCalendarImport.java
trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services/ServiceBoatImpl.java
trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services/ServiceContactImpl.java
trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services/ServiceReferentialImpl.java
trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services/ServiceSamplingImpl.java
trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services/ServiceSynthesisImpl.java
trunk/suiviobsmer-business/src/main/xmi/suiviobsmer.zargo
trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/ImportHelperTest.java
trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/Boats.java
trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/SamplingPlan.java
trunk/suiviobsmer-ui/src/main/resources/fr/ifremer/suiviobsmer/ui/pages/Boats.properties
trunk/suiviobsmer-ui/src/main/webapp/SamplingPlan.tml
Log:
- Evo #2022 : Export SamplingPlan
- Improve import/export : new ExportHelper abstract class + new io package + headers enumerations put in WaoCsvHeader class. Of course ImportHelper has less methods now.
- Note : correction of query for boats export
Modified: trunk/changelog.txt
===================================================================
--- trunk/changelog.txt 2010-02-10 22:04:27 UTC (rev 345)
+++ trunk/changelog.txt 2010-02-11 20:04:33 UTC (rev 346)
@@ -9,6 +9,8 @@
Evolutions
++++++++++
+- [fdesbois] Evo #2022 : Plan d'échantillonnage : Export CSV
+- [fdesbois] Evo #1986 : Synthèse : indicateur sur les états des contacts
- [fdesbois] Evo #1984 : Synthèse : indicateur de non respect du nombre
d'observateurs embarqués
- [fdesbois] Evo #2092 : Contacts : Ajouter filtres sur les validations du
Deleted: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/ImportHelper.java
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/ImportHelper.java 2010-02-10 22:04:27 UTC (rev 345)
+++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/ImportHelper.java 2010-02-11 20:04:33 UTC (rev 346)
@@ -1,564 +0,0 @@
-/*
- * *##%
- * SuiviObsmer :: 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.suiviobsmer;
-
-import com.csvreader.CsvReader;
-import java.io.IOException;
-import java.text.DateFormat;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.GregorianCalendar;
-import java.util.Locale;
-import org.apache.commons.lang.BooleanUtils;
-import org.apache.commons.lang.StringUtils;
-import org.apache.commons.lang.time.DurationFormatUtils;
-import org.nuiton.util.PeriodDates;
-import org.slf4j.Logger;
-
-/**
- * ImportHelper
- *
- * Created: 4 janv. 2010
- *
- * @author fdesbois
- * @version $Revision$
- *
- * Mise a jour: $Date$
- * par : $Author$
- */
-public class ImportHelper {
-
- public interface ImportHeader {
-
- int forContactCsv();
-
- String name();
-
- /**
- * Pattern for Date parsing. This pattern can be null, if no format date is necessary.
- *
- * @return a String corresponding to the date pattern
- */
- String datePattern();
- }
-
- /**
- * CSV headers for Boat
- */
- public enum BOAT implements ImportHeader {
- /** Boat immatriculation **/
- NAVS_COD(1, "Immatriculation", 20),
- /** Boat name **/
- CARN_NOM(2, "Nom", 21),
- /** Boat length **/
- CARN_LONGUEUR_HT(3, "Longueur (m)"),
- /** Boat build year **/
- CARN_ANNEE(4, "Année de construction"),
- /** Boat district code **/
- QUARTIER_IMMA(5, "Code quartier", 22),
- /** ShipOwner code **/
- PER_COD,
- /** ShipOwner last name **/
- PER_NOM,
- /** ShipOwner first name **/
- PER_PRENOM,
- /** Boat active **/
- NAVS_ACTIVE(0, "Actif/Inactif"),
- /** BoatInfos contactFirstName **/
- CONT_PRENOM(6, "Prénom du contact"),
- /** BoatInfos contactLastName **/
- CONT_NOM(7, "Nom du contact"),
- /** BoatInfos contactEmail **/
- CONT_EMAIL(8, "Email du contact"),
- /** BoatInfos contactPhoneNumber **/
- CONT_TEL(9, "Tél du contact"),
- /** BoatInfos dup **/
- NAVS_DUP(10, "Capacité d'accueil du navire en personnels spécialisés"),
- /** BoatInfos comment **/
- NAVS_COMMENT(11, "Commentaire");
-
- private int contactHeader;
-
- private int boatHeader;
-
- private String title;
-
- BOAT(int indexBoat, String title, int indexContact) {
- contactHeader = indexContact;
- boatHeader = indexBoat;
- this.title = title;
- }
-
- BOAT(int indexBoat, String title) {
- boatHeader = indexBoat;
- this.title = title;
- }
-
- BOAT() {
- contactHeader = -1;
- boatHeader = -1;
- title = name();
- }
-
- @Override
- public int forContactCsv() {
- return contactHeader;
- }
-
- public int forBoatCsv() {
- return boatHeader;
- }
-
- @Override
- public String datePattern() {
- return null;
- }
-
- @Override
- public String toString() {
- return title;
- }
- }
-
- /**
- * CSV headers for SamplingPlan
- */
- public enum SAMPLING implements ImportHeader {
- /** SampleRow code **/
- PLAN_CODE(6),
- /** Company name **/
- SOCIETE_NOM(5),
- /** Program code **/
- PROGRAMME_CODE(7),
- /** Program period begin **/
- PROGRAMME_DEBUT(8),
- /** Program period end **/
- PROGRAMME_FIN(9),
- /** FishingZone other infos **/
- PECHE_AUTRE(13),
- /** Profession code DCF5 **/
- METIER_CODE_DCF5(14),
- /** Profession mesh size **/
- METIER_MAILLAGE(15),
- /** Profession size **/
- METIER_TAILLE(16),
- /** Profession other infos **/
- METIER_AUTRE(17),
- /** Profession libelle **/
- METIER_LIBELLE(18),
- /** Profession species **/
- METIER_ESPECES(19),
- /** SampleRow nb observants **/
- PLAN_NB_OBSERV,
- /** SampleRow average tide time **/
- PLAN_DUREE_MOY,
- /** SampleRow comment **/
- PLAN_COMMENT;
-
- private int contactHeader;
-
- SAMPLING(int index) {
- this.contactHeader = index;
- }
-
- SAMPLING() {
- this.contactHeader = -1;
- }
-
- @Override
- public int forContactCsv() {
- return contactHeader;
- }
-
- @Override
- public String datePattern() {
- return defaultDatePattern();
- }
-
- public static String defaultDatePattern() {
- return "MM/yyyy";
- }
- }
-
- /**
- * CSV headers for FishingZone
- */
- public enum FISHING_ZONE implements ImportHeader {
- /** FishingZone facade **/
- PECHE_FACADE(10),
- /** FishingZone sector **/
- PECHE_ZONE(11),
- /** FishingZone district code **/
- PECHE_DIVISION(12);
-
- private int contactHeader;
-
- FISHING_ZONE(int index) {
- this.contactHeader = index;
- }
-
- @Override
- public int forContactCsv() {
- return contactHeader;
- }
-
- @Override
- public String datePattern() {
- return null;
- }
- }
-
- /**
- * CSV headers for Contact
- */
- public enum CONTACT implements ImportHeader {
- /** Contact code (create date time for existing contact) **/
- CONT_CODE(0),
- /** Contact create date **/
- CONT_CREATION(1),
- /** User id **/
- OBSERV_ID(2),
- /** User prenom **/
- OBSERV_PRENOM(3),
- /** User nom **/
- OBSERV_NOM(4),
- /** Company id **/
- //SOCIETE_ID,
- /** Contact state **/
- CONT_ETAT(23),
- /** Contact tide begin **/
- CONT_DEBUT_MAREE(24),
- /** Contact tide end **/
- CONT_FIN_MAREE(25),
- /** Contact nb observants **/
- CONT_NB_OBSERV(26),
- /** Contact mammals capture **/
- CONT_MAM_CAPT(27),
- /** Contact mammals observation **/
- CONT_MAM_OBS(28),
- /** Contact comment **/
- CONT_COMMENT(29),
- /** Contact data input **/
- CONT_ALLEGRO(30),
- /** Contact company validation **/
- CONT_SOCIETE_VALID(31),
- /** Contact program validation **/
- CONT_PROGRAM_VALID(32);
-
- private int contactHeader;
-
- CONTACT(int index) {
- this.contactHeader = index;
- }
-
- @Override
- public int forContactCsv() {
- return contactHeader;
- }
-
- @Override
- public String datePattern() {
- return "dd/MM/yyyy";
- }
- }
-
- public enum ACTIVITY_CALENDAR implements ImportHeader {
- /** ActivityCalendar year **/
- SYNA_AN,
- /** ActivityCalendar fiability **/
- INDQ_COD,
- /** ActivityMonth month **/
- SYNA_MOI,
- /** ActivityMonth harbourCode **/
- SYNA_POR_COD,
- /** ActivityMonth nbSeaDays **/
- SYNA_NOMJDM,
- /** ActivityMonth nbFishingDays **/
- SYNA_NOMJDP,
- /** ActivityMonth nbBoardingPersons **/
- SYNA_NOMHE,
- /** ActivityMonth harbourId **/
- SYNA_TPOR_COD,
- /** ActivityMonth harbourLibelle **/
- SYNA_POR_LIB,
- /** ActivityProfession professionOrder **/
- META_ORDRE,
- /** ActivityProfession code **/
- MET_COD,
- /** ActivityProfession id **/
- MET_ID,
- /** ActivityProfession libelle **/
- MET_LIB,
- /** ActivityZone code **/
- SECT_COD,
- /** ActivityZone gradiantCode **/
- GRA_COD,
- /** ActivityZone gradiantLibelle **/
- GRA_LIB,
- /** ActivityZone zoneId **/
- TSECT_COD,
- /** ActivityZone zoneLibelle **/
- SECT_LIB;
-
- @Override
- public int forContactCsv() {
- return -1;
- }
-
- @Override
- public String datePattern() {
- return "";
- }
- }
-
- public static final int CONTACT_NB_HEADERS = 33;
-
- public static final int BOAT_NB_HEADERS = 12;
-
- public static final String BOAT_INACTIVE_CODE = "I";
-
- public static String getHeaderForContactCsv(int index) {
- for (BOAT boatEnum : BOAT.values()) {
- if (boatEnum.forContactCsv() == index) {
- return boatEnum.name();
- }
- }
- for (SAMPLING samplingEnum : SAMPLING.values()) {
- if (samplingEnum.forContactCsv() == index) {
- return samplingEnum.name();
- }
- }
- for (FISHING_ZONE zoneEnum : FISHING_ZONE.values()) {
- if (zoneEnum.forContactCsv() == index) {
- return zoneEnum.name();
- }
- }
- for (CONTACT contactEnum : CONTACT.values()) {
- if (contactEnum.forContactCsv() == index) {
- return contactEnum.name();
- }
- }
- return "";
- }
-
- public static String getHeaderForBoatCsv(int index) {
- for (BOAT boatEnum : BOAT.values()) {
- if (boatEnum.forBoatCsv() == index) {
- return boatEnum.toString();
- }
- }
- return "";
- }
-
- public static String formatContactValidation(Boolean validation) {
- String valid = "";
- if (validation == null) {
- valid = "N";
- } else if (BooleanUtils.isTrue(validation)) {
- valid = "A";
- } else {
- valid = "R";
- }
- return valid;
- }
-
- public static Boolean parseContactValidation(CsvReader reader, ImportHeader header) throws IOException {
- String validation = read(reader, header);
- Boolean result = null;
- if ("A".equals(validation)) {
- result = Boolean.TRUE;
- } else if ("R".equals(validation)) {
- result = Boolean.FALSE;
- }
- return result;
- }
-
- public static String formatContactMammals(boolean mammals) {
- return mammals ? "X" : "";
- }
-
- public static boolean parseContactMammals(CsvReader reader, ImportHeader header) throws IOException {
- String mammals = read(reader, header);
- return "X".equals(mammals);
- }
-
- protected static String CONTACT_TIME_PATTERN = "HHmmssS";
-
- protected static String CONTACT_DATE_PATTERN = "dd/MM/yyyy";
-
- public static String formatContactCode(Date createDate) {
- DateFormat timeFormat = new SimpleDateFormat(CONTACT_TIME_PATTERN, Locale.FRENCH);
- String result = timeFormat.format(createDate);
- return result;
- }
-
- public static Date parseContactCreateDate(String code, String createDate) throws ParseException {
- Calendar time = new GregorianCalendar(Locale.FRENCH);
- if (StringUtils.isNotEmpty(code)) {
- DateFormat timeFormat = new SimpleDateFormat(CONTACT_TIME_PATTERN, Locale.FRENCH);
- time = new GregorianCalendar(Locale.FRENCH);
- time.setTime(timeFormat.parse(code));
- } else {
- // Use current date with no time as a reference if no code is set
- time.setTime(SuiviObsmerContext.getCurrentDate());
- time.set(Calendar.HOUR_OF_DAY, 0);
- time.set(Calendar.MINUTE, 0);
- time.set(Calendar.SECOND, 0);
- time.set(Calendar.MILLISECOND, 0);
- }
-
- Calendar result = new GregorianCalendar(Locale.FRENCH);
- if (StringUtils.isNotEmpty(createDate)) {
- DateFormat dateFormat = getContactDateFormat();
- result.setTime(dateFormat.parse(createDate));
- result.set(Calendar.HOUR_OF_DAY, time.get(Calendar.HOUR_OF_DAY));
- result.set(Calendar.MINUTE, time.get(Calendar.MINUTE));
- result.set(Calendar.SECOND, time.get(Calendar.SECOND));
- result.set(Calendar.MILLISECOND, time.get(Calendar.MILLISECOND));
- } else {
- result.setTime(SuiviObsmerContext.getCurrentDate());
- }
- return result.getTime();
- }
-
- public static String readSampleRowCode(CsvReader reader) throws IOException {
- String code = read(reader, SAMPLING.PLAN_CODE);
- return SuiviObsmerContext.prepareSampleRowCode(code);
- }
-
- public static DateFormat getContactDateFormat() {
- return new SimpleDateFormat(CONTACT_DATE_PATTERN, Locale.FRENCH);
- }
-
- public static long logTimeAndMemory(Logger log, long tic1, String msg) {
- if (log.isInfoEnabled()) {
- log.info("RUNNING... Import : " + msg);
- Runtime runtime = Runtime.getRuntime();
- long mem = (runtime.totalMemory() - runtime.freeMemory()) / 1048576;
- //long memMega = mem / 1024 / 1024;
- log.info("Memory : " + mem + " Mo");
- long tic2 = System.currentTimeMillis();
- log.info("Time : " + DurationFormatUtils.formatDurationHMS(tic2 - tic1));
- }
- return System.currentTimeMillis();
- }
-
- /**
- * Read a string value in CsvReader from {@code header} column.
- * In ActivityCalendarImport the result value can be null if the read value is "NA".
- *
- * @param reader CsvReader used to read the value
- * @param header Column header in the CsvReader
- * @return the String value read or null if set to "NA" in ActivityCalendar import.
- * @throws IOException
- */
- public static String read(CsvReader reader, ImportHeader header) throws IOException {
- String result = reader.get(header.name()).trim();
- if (header instanceof ACTIVITY_CALENDAR && "NA".equals(result)) {
- return null;
- }
- return result;
- }
-
- /**
- * Read an int value in CsvReader from {@code header} column.
- *
- * @param reader CsvReader used to read the value
- * @param header Column header in the CsvReader
- * @return the int value or -1 if the value read is null
- * @throws IOException
- * @see ImportHelper#read(CsvReader, ImportHeader)
- */
- public static int readInt(CsvReader reader, ImportHeader header) throws IOException {
- String str = read(reader, header);
- if (StringUtils.isEmpty(str)) {
- return -1;
- }
- return Integer.parseInt(str);
- }
-
- /**
- * Read an Integer value in CsvReader from {@code header} column.
- *
- * @param reader CsvReader used to read the value
- * @param header Column header in the CsvReader
- * @return the Integer value or null if the value read is null
- * @throws IOException
- * @see ImportHelper#readInt(CsvReader, ImportHeader)
- */
- public static Integer readInteger(CsvReader reader, ImportHeader header) throws IOException {
- int result = readInt(reader, header);
- return result != -1 ? result : null;
- }
-
- /**
- * Read two values in CsvReader corresponding to a period from {@code headerBegin} and {@code headEnd} column.
- *
- * @param reader CsvReader used to read the value
- * @param headerBegin Column header in the CsvReader for periodBegin
- * @param headerEnd Column header in the CsvReader for periodEnd
- * @return the PeriodDates created from periodBegin and periodEnd read from Csv file
- * @throws IOException
- * @throws ParseException
- * @throws IllegalArgumentException
- * @see ImportHelper#readDate(CsvReader, ImportHeader)
- */
- public static PeriodDates readPeriod(CsvReader reader, ImportHeader headerBegin, ImportHeader headerEnd)
- throws IOException, ParseException {
- Date end = readDate(reader, headerEnd);
- Date begin = readDate(reader, headerBegin);
- if (begin != null && end != null) {
- PeriodDates period = new PeriodDates(begin, end);
- period.initDayOfMonthExtremities();
- return period;
- }
- return null;
- }
-
- /**
- * Read a Date value in CsvReader from {@code header} column.
- *
- * @param reader CsvReader used to read the value
- * @param header Column header in the CsvReader
- * @return the Date value or null if the value read is null
- * @throws IOException
- * @throws ParseException
- * @see ImportHelper#read(CsvReader, ImportHeader)
- */
- public static Date readDate(CsvReader reader, ImportHeader header)
- throws IOException, ParseException {
- DateFormat dateFormat = new SimpleDateFormat(header.datePattern());
- String str = read(reader, header);
- if (StringUtils.isEmpty(str)) {
- return null;
- }
- // Parsing problem with Pattern dd/MM/yyyy which is valid for dd/MM/yy date
- // The length is tested to avoid accepting wrong dates
- if (str.length() != header.datePattern().length()) {
- throw new ParseException("Date error : " + str, str.length());
- }
- return dateFormat.parse(str);
- }
-
-}
Added: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/io/ExportHelper.java
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/io/ExportHelper.java (rev 0)
+++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/io/ExportHelper.java 2010-02-11 20:04:33 UTC (rev 346)
@@ -0,0 +1,125 @@
+
+package fr.ifremer.suiviobsmer.io;
+
+import com.csvreader.CsvWriter;
+import fr.ifremer.suiviobsmer.io.WaoCsvHeader.IOHeader;
+import java.io.IOException;
+
+/**
+ * Helper for CSV Export. This class must be inherited to be used in services
+ * implementations. Two methods needed :
+ * <pre>
+ * - {@link #record(IOHeader, String)} : record a value in the file
+ * - {@link #getHeaderValue(int)} : get the string header value corresponding
+ * to the index value.
+ * </pre>
+ * You have to used {@link WaoCsvHeader} to manage this two methods,
+ * to retrieve good indexes and good values for printing data headers.
+ * Steps :
+ * <pre>
+ * - Instanciate {@link #ExportHelper(CsvWriter, int) }
+ * (with abstract method implementations if needed).
+ * - Call {@link #writeHeaders() } method to prepare columns and write
+ * first row in the resulting file.
+ * - In the loop data, first use {@link #newRecord() } to prepare the current
+ * record.
+ * - Then used for each column, the {@link #record(IOHeader, String) } method.
+ * - Finally call the {@link #writeRecord() } to write the record in file.
+ * </pre>
+ *
+ * Created: 11 févr. 2010
+ *
+ * @param <H>
+ * @author fdesbois
+ * @version $Revision$
+ *
+ * Mise a jour: $Date$
+ * par : $Author$
+ */
+public abstract class ExportHelper<H extends IOHeader> {
+
+ /** Writer used to record data **/
+ protected CsvWriter writer;
+
+ /** Current record to write **/
+ protected String[] record;
+
+ /** Number of columns/headers in resulting export **/
+ protected int nbHeaders;
+
+ /**
+ * Constructor of ExportHelper. Need an existing CsvWriter ready to
+ * write data in it.
+ *
+ * @param writer the CsvWriter used for record data
+ * @param nbHeaders number of columns in the resulting file
+ * @throws IOException
+ */
+ public ExportHelper(CsvWriter writer, int nbHeaders) throws IOException {
+ this.writer = writer;
+ this.nbHeaders = nbHeaders;
+ }
+
+ /**
+ * Record a value for a header corresponding to the H generic type from
+ * {@link WaoCsvReader } class.
+ *
+ * @param header IOHeader used to record the value (column in the file)
+ * @param value the value to record
+ */
+ public abstract void record(H header, String value);
+
+ /**
+ * Return the header String value based on index. All matching integers for
+ * headers are defined in {@link WaoCsvReader } class.
+ *
+ * @param index of the header
+ * @return the String value of the header
+ * @throws IOException
+ */
+ protected abstract String getHeaderValue(int index) throws IOException;
+
+ /**
+ * Write the first header line of the file. This method uses
+ * {@link #getHeaderValue(int) } to retrieve the corresponding name of the
+ * header depends on its index.
+ *
+ * @throws IOException
+ */
+ public void writeHeaders() throws IOException {
+ for (int i = 0; i < nbHeaders; i++) {
+ String header = getHeaderValue(i);
+ writer.write(header);
+ }
+ writer.endRecord();
+ }
+
+ /**
+ * Record a value in the current record.
+ *
+ * @param index of the column
+ * @param value of the data to record
+ */
+ public void record(int index, String value) {
+ if (value != null) {
+ record[index] = value;
+ }
+ }
+
+ /**
+ * Prepare a new record (new file row).
+ */
+ public void newRecord() {
+ record = new String[nbHeaders];
+ }
+
+ /**
+ * Write the current record in the resulting file.
+ *
+ * @throws IOException
+ */
+ public void writeRecord() throws IOException {
+ writer.writeRecord(record);
+ writer.flush();
+ }
+}
Property changes on: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/io/ExportHelper.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL"
Copied: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/io/ImportHelper.java (from rev 338, trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/ImportHelper.java)
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/io/ImportHelper.java (rev 0)
+++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/io/ImportHelper.java 2010-02-11 20:04:33 UTC (rev 346)
@@ -0,0 +1,225 @@
+/*
+ * *##%
+ * SuiviObsmer :: 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.suiviobsmer.io;
+
+import fr.ifremer.suiviobsmer.*;
+import com.csvreader.CsvReader;
+import fr.ifremer.suiviobsmer.io.WaoCsvHeader.ACTIVITY_CALENDAR;
+import fr.ifremer.suiviobsmer.io.WaoCsvHeader.CONTACT;
+import fr.ifremer.suiviobsmer.io.WaoCsvHeader.DatedHeader;
+import fr.ifremer.suiviobsmer.io.WaoCsvHeader.IOHeader;
+import fr.ifremer.suiviobsmer.io.WaoCsvHeader.SAMPLING;
+import fr.ifremer.suiviobsmer.io.WaoCsvHeader.SamplingHeader;
+import java.io.IOException;
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.GregorianCalendar;
+import java.util.Locale;
+import org.apache.commons.lang.BooleanUtils;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang.time.DurationFormatUtils;
+import org.nuiton.util.PeriodDates;
+import org.slf4j.Logger;
+
+/**
+ * ImportHelper
+ *
+ * Created: 4 janv. 2010
+ *
+ * @author fdesbois
+ * @version $Revision$
+ *
+ * Mise a jour: $Date$
+ * par : $Author$
+ */
+public class ImportHelper {
+
+ protected CsvReader reader;
+
+ public ImportHelper(CsvReader reader) {
+ this.reader = reader;
+ }
+
+ public static Boolean parseContactValidation(CsvReader reader, IOHeader header) throws IOException {
+ String validation = read(reader, header);
+ Boolean result = null;
+ if ("A".equals(validation)) {
+ result = Boolean.TRUE;
+ } else if ("R".equals(validation)) {
+ result = Boolean.FALSE;
+ }
+ return result;
+ }
+
+ public static boolean parseContactMammals(CsvReader reader, IOHeader header) throws IOException {
+ String mammals = read(reader, header);
+ return "X".equals(mammals);
+ }
+
+ public static Date parseContactCreateDate(String code, String createDate) throws ParseException {
+ Calendar time = new GregorianCalendar(Locale.FRENCH);
+ if (StringUtils.isNotEmpty(code)) {
+ DateFormat timeFormat = CONTACT.getTimeFormat();
+ time = new GregorianCalendar(Locale.FRENCH);
+ time.setTime(timeFormat.parse(code));
+ } else {
+ // Use current date with no time as a reference if no code is set
+ time.setTime(SuiviObsmerContext.getCurrentDate());
+ time.set(Calendar.HOUR_OF_DAY, 0);
+ time.set(Calendar.MINUTE, 0);
+ time.set(Calendar.SECOND, 0);
+ time.set(Calendar.MILLISECOND, 0);
+ }
+
+ Calendar result = new GregorianCalendar(Locale.FRENCH);
+ if (StringUtils.isNotEmpty(createDate)) {
+ DateFormat dateFormat = CONTACT.getDateFormat();
+ result.setTime(dateFormat.parse(createDate));
+ result.set(Calendar.HOUR_OF_DAY, time.get(Calendar.HOUR_OF_DAY));
+ result.set(Calendar.MINUTE, time.get(Calendar.MINUTE));
+ result.set(Calendar.SECOND, time.get(Calendar.SECOND));
+ result.set(Calendar.MILLISECOND, time.get(Calendar.MILLISECOND));
+ } else {
+ result.setTime(SuiviObsmerContext.getCurrentDate());
+ }
+ return result.getTime();
+ }
+
+ public static String readSampleRowCode(CsvReader reader) throws IOException {
+ String code = read(reader, SAMPLING.PLAN_CODE);
+ return SuiviObsmerContext.prepareSampleRowCode(code);
+ }
+
+ /**
+ * Read a string value in CsvReader from {@code header} column.
+ * In ActivityCalendarImport the result value can be null if the read value is "NA".
+ *
+ * @param reader CsvReader used to read the value
+ * @param header Column header in the CsvReader
+ * @return the String value read or null if set to "NA" in ActivityCalendar import.
+ * @throws IOException
+ */
+ public static String read(CsvReader reader, IOHeader header) throws IOException {
+ String result = reader.get(header.name()).trim();
+ if (header instanceof ACTIVITY_CALENDAR && "NA".equals(result)) {
+ return null;
+ }
+ return result;
+ }
+
+ /**
+ * Read an int value in CsvReader from {@code header} column.
+ *
+ * @param reader CsvReader used to read the value
+ * @param header Column header in the CsvReader
+ * @return the int value or -1 if the value read is null
+ * @throws IOException
+ * @see ImportHelper#read(CsvReader, IOHeader)
+ */
+ public static int readInt(CsvReader reader, IOHeader header) throws IOException {
+ String str = read(reader, header);
+ if (StringUtils.isEmpty(str)) {
+ return -1;
+ }
+ return Integer.parseInt(str);
+ }
+
+ /**
+ * Read an Integer value in CsvReader from {@code header} column.
+ *
+ * @param reader CsvReader used to read the value
+ * @param header Column header in the CsvReader
+ * @return the Integer value or null if the value read is null
+ * @throws IOException
+ * @see ImportHelper#readInt(CsvReader, IOHeader)
+ */
+ public static Integer readInteger(CsvReader reader, IOHeader header) throws IOException {
+ int result = readInt(reader, header);
+ return result != -1 ? result : null;
+ }
+
+ /**
+ * Read two values in CsvReader corresponding to a period from {@code headerBegin} and {@code headEnd} column.
+ *
+ * @param reader CsvReader used to read the value
+ * @param headerBegin Column header in the CsvReader for periodBegin
+ * @param headerEnd Column header in the CsvReader for periodEnd
+ * @return the PeriodDates created from periodBegin and periodEnd read from Csv file
+ * @throws IOException
+ * @throws ParseException
+ * @throws IllegalArgumentException
+ * @see ImportHelper#readDate(CsvReader, IOHeader)
+ */
+ public static PeriodDates readPeriod(CsvReader reader, DatedHeader headerBegin, DatedHeader headerEnd)
+ throws IOException, ParseException {
+ Date end = readDate(reader, headerEnd);
+ Date begin = readDate(reader, headerBegin);
+ if (begin != null && end != null) {
+ PeriodDates period = new PeriodDates(begin, end);
+ period.initDayOfMonthExtremities();
+ return period;
+ }
+ return null;
+ }
+
+ /**
+ * Read a Date value in CsvReader from {@code header} column.
+ *
+ * @param reader CsvReader used to read the value
+ * @param header Column header in the CsvReader
+ * @return the Date value or null if the value read is null
+ * @throws IOException
+ * @throws ParseException
+ * @see ImportHelper#read(CsvReader, IOHeader)
+ */
+ public static Date readDate(CsvReader reader, DatedHeader header)
+ throws IOException, ParseException {
+ DateFormat dateFormat = new SimpleDateFormat(header.datePattern());
+ String str = read(reader, header);
+ if (StringUtils.isEmpty(str)) {
+ return null;
+ }
+ // Parsing problem with Pattern dd/MM/yyyy which is valid for dd/MM/yy date
+ // The length is tested to avoid accepting wrong dates
+ if (str.length() != header.datePattern().length()) {
+ throw new ParseException("Date error : " + str, str.length());
+ }
+ return dateFormat.parse(str);
+ }
+
+ public static long logTimeAndMemory(Logger log, long tic1, String msg) {
+ if (log.isInfoEnabled()) {
+ log.info("RUNNING... Import : " + msg);
+ Runtime runtime = Runtime.getRuntime();
+ long mem = (runtime.totalMemory() - runtime.freeMemory()) / 1048576;
+ //long memMega = mem / 1024 / 1024;
+ log.info("Memory : " + mem + " Mo");
+ long tic2 = System.currentTimeMillis();
+ log.info("Time : " + DurationFormatUtils.formatDurationHMS(tic2 - tic1));
+ }
+ return System.currentTimeMillis();
+ }
+
+}
Property changes on: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/io/ImportHelper.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL"
Added: svn:mergeinfo
+
Added: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/io/SamplingExport.java
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/io/SamplingExport.java (rev 0)
+++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/io/SamplingExport.java 2010-02-11 20:04:33 UTC (rev 346)
@@ -0,0 +1,103 @@
+
+package fr.ifremer.suiviobsmer.io;
+
+import com.csvreader.CsvWriter;
+import fr.ifremer.suiviobsmer.entity.SampleMonth;
+import fr.ifremer.suiviobsmer.entity.SampleRow;
+import fr.ifremer.suiviobsmer.entity.WaoUser;
+import fr.ifremer.suiviobsmer.io.WaoCsvHeader.SAMPLING;
+import fr.ifremer.suiviobsmer.io.WaoCsvHeader.SamplingHeader;
+import java.io.IOException;
+import java.text.ParseException;
+import java.util.Date;
+import java.util.List;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * SamplingExport
+ *
+ * Created: 11 févr. 2010
+ *
+ * @author fdesbois
+ * @version $Revision$
+ *
+ * Mise a jour: $Date$
+ * par : $Author$
+ */
+public class SamplingExport extends ExportHelper<SamplingHeader> {
+
+ private static final Logger log = LoggerFactory.getLogger(SamplingExport.class);
+
+ protected WaoUser user;
+
+ protected List<String> monthHeaders;
+
+ /** Used for {@link #getHeaderValue(int)} : changed for each call to the method **/
+ protected int currMonthIndex;
+
+ /**
+ * Constructor with {@code user} and {@code monthHeaders} needed to prepare
+ * headers and record months values.
+ *
+ * @param writer CsvWriter used to write data in the resulting file.
+ * @param user WaoUser who called the export
+ * @param monthHeaders String values of months to put in header row
+ * @throws IOException
+ */
+ public SamplingExport(CsvWriter writer, WaoUser user, List<String> monthHeaders) throws IOException {
+ super(writer, SAMPLING.getTotalHeaders() + monthHeaders.size());
+ this.monthHeaders = monthHeaders;
+ this.user = user;
+ }
+
+ @Override
+ protected String getHeaderValue(int index) throws IOException {
+ int nbHeadersForMonths = monthHeaders.size();
+ String result = "";
+ if (index >= SAMPLING.getStartIndexForMonths() && currMonthIndex < nbHeadersForMonths) {
+ result = monthHeaders.get(currMonthIndex);
+ currMonthIndex++;
+ } else {
+ SamplingHeader header = WaoCsvHeader.getHeaderForSamplingCsv(index, nbHeadersForMonths);
+ // for an admin, same text as in Import (enum name)
+ // for a user, the text is complete
+ result = user.getAdmin() ? header.name() : header.toString();
+ }
+ return result;
+ }
+
+ @Override
+ public void record(SamplingHeader header, String value) {
+ int index = header.forSamplingCsv();
+ if (index >= SAMPLING.getStartIndexForMonths()) {
+ index += monthHeaders.size();
+ }
+ record(index, value);
+ }
+
+ public void recordMonths(SampleRow row) throws ParseException {
+ for (int i = 0; i < monthHeaders.size(); i++) {
+ // Get date from monthHeaders list
+ Date month = SAMPLING.getDateFormat().parse(monthHeaders.get(i));
+ // Retrieve sampleMonth corresponding
+ SampleMonth sampleMonth = row.getSampleMonth(month);
+ // Add it to the file if it exists
+ if (sampleMonth != null) {
+ // Prepare index for record
+ int index = SAMPLING.getStartIndexForMonths() + i;
+ String expected = String.valueOf(sampleMonth.getExpectedTidesValue());
+ String real = String.valueOf(sampleMonth.getRealTidesValue());
+ // The admin as only expected value (to be the same as
+ // in import)
+ if (user.getAdmin()) {
+ record(index, expected); //record[index] = expected;
+ // The user as both expected and real values
+ } else {
+ record(index, expected + " (" + real + ")");
+ }
+ }
+ }
+ }
+
+}
Property changes on: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/io/SamplingExport.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL"
Added: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/io/WaoCsvHeader.java
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/io/WaoCsvHeader.java (rev 0)
+++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/io/WaoCsvHeader.java 2010-02-11 20:04:33 UTC (rev 346)
@@ -0,0 +1,451 @@
+
+package fr.ifremer.suiviobsmer.io;
+
+import java.text.DateFormat;
+import java.text.NumberFormat;
+import java.text.SimpleDateFormat;
+import java.util.Locale;
+import org.apache.commons.lang.BooleanUtils;
+
+/**
+ * CsvHeader
+ *
+ * Created: 11 févr. 2010
+ *
+ * @author fdesbois
+ * @version $Revision$
+ *
+ * Mise a jour: $Date$
+ * par : $Author$
+ */
+public class WaoCsvHeader {
+
+ public interface IOHeader {
+
+ /**
+ * Name of the header. This method is automatically implemented for an
+ * enum.
+ *
+ * @return the name of the header
+ */
+ String name();
+ }
+
+ public interface DatedHeader extends IOHeader {
+
+ /**
+ * Pattern for Date parsing. This pattern can be null, if no format date is necessary.
+ *
+ * @return a String corresponding to the date pattern
+ */
+ String datePattern();
+ }
+
+ public interface ContactHeader extends IOHeader {
+
+ int forContactCsv();
+ }
+
+ public interface SamplingHeader extends IOHeader {
+
+ int forSamplingCsv();
+ }
+
+ /**
+ * CSV headers for Boat
+ */
+ public enum BOAT implements ContactHeader {
+ /** Boat immatriculation **/
+ NAVS_COD(1, "Immatriculation", 20),
+ /** Boat name **/
+ CARN_NOM(2, "Nom", 21),
+ /** Boat length **/
+ CARN_LONGUEUR_HT(3, "Longueur (m)"),
+ /** Boat build year **/
+ CARN_ANNEE(4, "Année de construction"),
+ /** Boat district code **/
+ QUARTIER_IMMA(5, "Code quartier", 22),
+ /** ShipOwner code **/
+ PER_COD,
+ /** ShipOwner last name **/
+ PER_NOM,
+ /** ShipOwner first name **/
+ PER_PRENOM,
+ /** Boat active **/
+ NAVS_ACTIVE(0, "Actif/Inactif"),
+ /** BoatInfos contactFirstName **/
+ CONT_PRENOM(6, "Prénom du contact"),
+ /** BoatInfos contactLastName **/
+ CONT_NOM(7, "Nom du contact"),
+ /** BoatInfos contactEmail **/
+ CONT_EMAIL(8, "Email du contact"),
+ /** BoatInfos contactPhoneNumber **/
+ CONT_TEL(9, "Tél du contact"),
+ /** BoatInfos dup **/
+ NAVS_DUP(10, "Capacité d'accueil du navire en personnels spécialisés"),
+ /** BoatInfos comment **/
+ NAVS_COMMENT(11, "Commentaire");
+
+ private int contactHeader;
+
+ private int boatHeader;
+
+ private String title;
+
+ BOAT(int indexBoat, String title, int indexContact) {
+ contactHeader = indexContact;
+ boatHeader = indexBoat;
+ this.title = title;
+ }
+
+ BOAT(int indexBoat, String title) {
+ boatHeader = indexBoat;
+ this.title = title;
+ contactHeader = -1;
+ }
+
+ BOAT() {
+ contactHeader = -1;
+ boatHeader = -1;
+ title = name();
+ }
+
+ @Override
+ public int forContactCsv() {
+ return contactHeader;
+ }
+
+ public int forBoatCsv() {
+ return boatHeader;
+ }
+
+ @Override
+ public String toString() {
+ return title;
+ }
+
+ public static int getTotalHeaders() {
+ // NAVS_COMMENT is the last column
+ return NAVS_COMMENT.forBoatCsv() + 1;
+ }
+
+ public static String getBoatInactiveCode() {
+ return "I";
+ }
+ }
+
+ /**
+ * CSV headers for SamplingPlan
+ */
+ public enum SAMPLING implements SamplingHeader, ContactHeader, DatedHeader {
+ /** SampleRow code **/
+ PLAN_CODE(0, "Code ligne du plan", 6),
+ /** Company name **/
+ SOCIETE_NOM(1, "Société prestataire", 5),
+ /** Program code **/
+ PROGRAMME_CODE(12, "Programme de rattachement", 7),
+ /** Program period begin **/
+ PROGRAMME_DEBUT(13, "Date de début", 8),
+ /** Program period end **/
+ PROGRAMME_FIN(14, "Date de fin", 9),
+ /** FishingZone other infos **/
+ PECHE_AUTRE(5, "Zone de pêche autres informations", 13),
+ /** Profession code DCF5 **/
+ METIER_CODE_DCF5(6, "Métier (Code DCF niveau 5)", 14),
+ /** Profession mesh size **/
+ METIER_MAILLAGE(7, "Métier maillage (mm)", 15),
+ /** Profession size **/
+ METIER_TAILLE(8, "Métier taille (m)", 16),
+ /** Profession other infos **/
+ METIER_AUTRE(9, "Métier autre information", 17),
+ /** Profession libelle **/
+ METIER_LIBELLE(10, "Métier libellé", 18),
+ /** Profession species **/
+ METIER_ESPECES(11, "Métier espèces cibles", 19),
+ /** SampleRow nb observants **/
+ PLAN_NB_OBSERV(16, "Nombre d'observateurs"),
+ /** SampleRow average tide time **/
+ PLAN_DUREE_MOY(15, "Durée moyenne d'une marée (jours)"),
+ /** SampleRow comment **/
+ PLAN_COMMENT(17, "Commentaire");
+
+ private int contactHeader;
+
+ private int samplingHeader;
+
+ private String title;
+
+ SAMPLING(int indexSampling, String title, int indexContact) {
+ this(indexSampling, title);
+ contactHeader = indexContact;
+ }
+
+ SAMPLING(int indexSampling, String title) {
+ samplingHeader = indexSampling;
+ this.title = title;
+ contactHeader = -1;
+ }
+
+ @Override
+ public int forContactCsv() {
+ return contactHeader;
+ }
+
+ @Override
+ public int forSamplingCsv() {
+ return samplingHeader;
+ }
+
+ @Override
+ public String toString() {
+ return title;
+ }
+
+ @Override
+ public String datePattern() {
+ return defaultDatePattern();
+ }
+
+ public static String defaultDatePattern() {
+ return "MM/yyyy";
+ }
+
+ public static DateFormat getDateFormat() {
+ return new SimpleDateFormat(defaultDatePattern(), Locale.FRENCH);
+ }
+
+ public static NumberFormat getNumberFormat() {
+ return NumberFormat.getNumberInstance(Locale.FRENCH);
+ }
+
+ public static int getStartIndexForMonths() {
+ // PROGRAMME_FIN is the last column before months
+ return PROGRAMME_FIN.forSamplingCsv() + 1;
+ }
+
+ public static int getTotalHeaders() {
+ // PLAN_COMMENT is the last column
+ return PLAN_COMMENT.forSamplingCsv() + 1;
+ }
+ }
+
+ /**
+ * CSV headers for FishingZone
+ */
+ public enum FISHING_ZONE implements SamplingHeader, ContactHeader {
+ /** FishingZone facade **/
+ PECHE_FACADE(2, "Zone de pêche façade", 10),
+ /** FishingZone sector **/
+ PECHE_ZONE(3, "Zone de pêche", 11),
+ /** FishingZone district code **/
+ PECHE_DIVISION(4, "Zone de pêche divisions", 12);
+
+ private int contactHeader;
+
+ private int samplingHeader;
+
+ String title;
+
+ FISHING_ZONE(int indexSampling, String title, int indexContact) {
+ contactHeader = indexContact;
+ samplingHeader = indexSampling;
+ this.title = title;
+ }
+
+ @Override
+ public int forContactCsv() {
+ return contactHeader;
+ }
+
+ @Override
+ public int forSamplingCsv() {
+ return samplingHeader;
+ }
+
+ @Override
+ public String toString() {
+ return title;
+ }
+
+ public static String getDistrictCodeSeparator() {
+ return " / ";
+ }
+ }
+
+ /**
+ * CSV headers for Contact
+ */
+ public enum CONTACT implements ContactHeader, DatedHeader {
+ /** Contact code (create date time for existing contact) **/
+ CONT_CODE(0),
+ /** Contact create date **/
+ CONT_CREATION(1),
+ /** User id **/
+ OBSERV_ID(2),
+ /** User prenom **/
+ OBSERV_PRENOM(3),
+ /** User nom **/
+ OBSERV_NOM(4),
+ /** Company id **/
+ //SOCIETE_ID,
+ /** Contact state **/
+ CONT_ETAT(23),
+ /** Contact tide begin **/
+ CONT_DEBUT_MAREE(24),
+ /** Contact tide end **/
+ CONT_FIN_MAREE(25),
+ /** Contact nb observants **/
+ CONT_NB_OBSERV(26),
+ /** Contact mammals capture **/
+ CONT_MAM_CAPT(27),
+ /** Contact mammals observation **/
+ CONT_MAM_OBS(28),
+ /** Contact comment **/
+ CONT_COMMENT(29),
+ /** Contact data input **/
+ CONT_ALLEGRO(30),
+ /** Contact company validation **/
+ CONT_SOCIETE_VALID(31),
+ /** Contact program validation **/
+ CONT_PROGRAM_VALID(32);
+
+ private int contactHeader;
+
+ CONTACT(int index) {
+ this.contactHeader = index;
+ }
+
+ @Override
+ public int forContactCsv() {
+ return contactHeader;
+ }
+
+ @Override
+ public String datePattern() {
+ return defaultDatePattern();
+ }
+
+ private static String defaultDatePattern() {
+ return "dd/MM/yyyy";
+ }
+
+ public static DateFormat getDateFormat() {
+ return new SimpleDateFormat(defaultDatePattern(), Locale.FRENCH);
+ }
+
+ public static DateFormat getTimeFormat() {
+ return new SimpleDateFormat("HHmmssS", Locale.FRENCH);
+ }
+
+ public static int getTotalHeaders() {
+ // CONT_PROGRAM_VALID is the last column
+ return CONT_PROGRAM_VALID.forContactCsv() + 1;
+ }
+
+ public static String formatValidation(Boolean validation) {
+ String valid = "";
+ if (validation == null) {
+ valid = "N";
+ } else if (BooleanUtils.isTrue(validation)) {
+ valid = "A";
+ } else {
+ valid = "R";
+ }
+ return valid;
+ }
+
+ public static String formatMammals(boolean mammals) {
+ return mammals ? "X" : "";
+ }
+ }
+
+ public enum ACTIVITY_CALENDAR implements IOHeader {
+ /** ActivityCalendar year **/
+ SYNA_AN,
+ /** ActivityCalendar fiability **/
+ INDQ_COD,
+ /** ActivityMonth month **/
+ SYNA_MOI,
+ /** ActivityMonth harbourCode **/
+ SYNA_POR_COD,
+ /** ActivityMonth nbSeaDays **/
+ SYNA_NOMJDM,
+ /** ActivityMonth nbFishingDays **/
+ SYNA_NOMJDP,
+ /** ActivityMonth nbBoardingPersons **/
+ SYNA_NOMHE,
+ /** ActivityMonth harbourId **/
+ SYNA_TPOR_COD,
+ /** ActivityMonth harbourLibelle **/
+ SYNA_POR_LIB,
+ /** ActivityProfession professionOrder **/
+ META_ORDRE,
+ /** ActivityProfession code **/
+ MET_COD,
+ /** ActivityProfession id **/
+ MET_ID,
+ /** ActivityProfession libelle **/
+ MET_LIB,
+ /** ActivityZone code **/
+ SECT_COD,
+ /** ActivityZone gradiantCode **/
+ GRA_COD,
+ /** ActivityZone gradiantLibelle **/
+ GRA_LIB,
+ /** ActivityZone zoneId **/
+ TSECT_COD,
+ /** ActivityZone zoneLibelle **/
+ SECT_LIB;
+ }
+
+ public static String getHeaderForContactCsv(int index) {
+ for (BOAT boatEnum : BOAT.values()) {
+ if (boatEnum.forContactCsv() == index) {
+ return boatEnum.name();
+ }
+ }
+ for (SAMPLING samplingEnum : SAMPLING.values()) {
+ if (samplingEnum.forContactCsv() == index) {
+ return samplingEnum.name();
+ }
+ }
+ for (FISHING_ZONE zoneEnum : FISHING_ZONE.values()) {
+ if (zoneEnum.forContactCsv() == index) {
+ return zoneEnum.name();
+ }
+ }
+ for (CONTACT contactEnum : CONTACT.values()) {
+ if (contactEnum.forContactCsv() == index) {
+ return contactEnum.name();
+ }
+ }
+ return "";
+ }
+
+ public static String getHeaderForBoatCsv(int index) {
+ for (BOAT boatEnum : BOAT.values()) {
+ if (boatEnum.forBoatCsv() == index) {
+ return boatEnum.toString();
+ }
+ }
+ return "";
+ }
+
+ public static SamplingHeader getHeaderForSamplingCsv(int index, int nbMonthHeaders) {
+ if (index > SAMPLING.getStartIndexForMonths()) {
+ index -= nbMonthHeaders;
+ }
+
+ for (SAMPLING samplingEnum : SAMPLING.values()) {
+ if (samplingEnum.forSamplingCsv() == index) {
+ return samplingEnum;
+ }
+ }
+ for (FISHING_ZONE zoneEnum : FISHING_ZONE.values()) {
+ if (zoneEnum.forSamplingCsv() == index) {
+ return zoneEnum;
+ }
+ }
+ return null;
+ }
+}
Property changes on: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/io/WaoCsvHeader.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL"
Modified: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services/ActivityCalendarImport.java
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services/ActivityCalendarImport.java 2010-02-10 22:04:27 UTC (rev 345)
+++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services/ActivityCalendarImport.java 2010-02-11 20:04:33 UTC (rev 346)
@@ -23,8 +23,6 @@
import fr.ifremer.suiviobsmer.*;
import com.csvreader.CsvReader;
-import fr.ifremer.suiviobsmer.ImportHelper.ACTIVITY_CALENDAR;
-import fr.ifremer.suiviobsmer.ImportHelper.BOAT;
import fr.ifremer.suiviobsmer.entity.ActivityCalendar;
import fr.ifremer.suiviobsmer.entity.ActivityCalendarDAO;
import fr.ifremer.suiviobsmer.entity.ActivityMonth;
@@ -35,6 +33,9 @@
import fr.ifremer.suiviobsmer.entity.ActivityZoneDAO;
import fr.ifremer.suiviobsmer.entity.Boat;
import fr.ifremer.suiviobsmer.entity.BoatDAO;
+import fr.ifremer.suiviobsmer.io.ImportHelper;
+import fr.ifremer.suiviobsmer.io.WaoCsvHeader.ACTIVITY_CALENDAR;
+import fr.ifremer.suiviobsmer.io.WaoCsvHeader.BOAT;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
@@ -49,7 +50,6 @@
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
-import java.util.logging.Level;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang.time.DurationFormatUtils;
import org.nuiton.topia.TopiaContext;
Modified: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services/ServiceBoatImpl.java
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services/ServiceBoatImpl.java 2010-02-10 22:04:27 UTC (rev 345)
+++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services/ServiceBoatImpl.java 2010-02-11 20:04:33 UTC (rev 346)
@@ -23,14 +23,11 @@
import com.csvreader.CsvReader;
import com.csvreader.CsvWriter;
-import fr.ifremer.suiviobsmer.ImportHelper;
-import fr.ifremer.suiviobsmer.ImportHelper.BOAT;
import fr.ifremer.suiviobsmer.SuiviObsmerBusinessException;
import fr.ifremer.suiviobsmer.SuiviObsmerBusinessException.Type;
import fr.ifremer.suiviobsmer.SuiviObsmerContext;
import fr.ifremer.suiviobsmer.SuiviObsmerException;
import fr.ifremer.suiviobsmer.SuiviObsmerModelDAOHelper;
-import java.util.logging.Level;
import org.nuiton.topia.TopiaException;
import org.nuiton.topia.framework.TopiaQuery;
import org.nuiton.topia.framework.TopiaQuery.Op;
@@ -38,7 +35,10 @@
import fr.ifremer.suiviobsmer.bean.CompanyBoatInfos;
import fr.ifremer.suiviobsmer.bean.CompanyBoatInfosImpl;
import fr.ifremer.suiviobsmer.entity.*;
-import fr.ifremer.suiviobsmer.services.ServiceBoat;
+import fr.ifremer.suiviobsmer.io.ImportHelper;
+import fr.ifremer.suiviobsmer.io.ExportHelper;
+import fr.ifremer.suiviobsmer.io.WaoCsvHeader;
+import fr.ifremer.suiviobsmer.io.WaoCsvHeader.BOAT;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
@@ -91,9 +91,9 @@
query = createQueryForBoatFilter(query, filter);
- if (StringUtils.isNotEmpty(filter.getOrderBy())) {
- query.addOrder("B." + filter.getOrderBy());
- }
+// if (StringUtils.isNotEmpty(filter.getOrderBy())) {
+// query.addOrder("B." + filter.getOrderBy());
+// }
query.addLoad(Boat.ACTIVITY_CALENDAR);
@@ -154,6 +154,10 @@
}
}
+ if (StringUtils.isNotEmpty(filter.getOrderBy())) {
+ query.addOrder(main + "." + filter.getOrderBy());
+ }
+
return query;
}
@@ -408,7 +412,7 @@
String shipOwnerFirstName = ImportHelper.read(reader, BOAT.PER_PRENOM);
//String activeStr = reader.get(BOAT.NAVS_ACTIVE.name()).trim();
String activeStr = ImportHelper.read(reader, BOAT.NAVS_ACTIVE);
- boolean active = !activeStr.equals(ImportHelper.BOAT_INACTIVE_CODE);
+ boolean active = !activeStr.equals(BOAT.getBoatInactiveCode());
if (log.isDebugEnabled()) {
log.debug("Active : " + active + " (" + activeStr + ")");
@@ -484,7 +488,7 @@
@Override
public InputStream exportBoatCsv(BoatFilter filter) throws SuiviObsmerException {
- TopiaContext transaction = null;
+ TopiaContext transaction = null;
InputStream result = null;
CsvWriter writer = null;
try {
@@ -496,56 +500,62 @@
FileOutputStream output = new FileOutputStream(file);
writer = new CsvWriter(output, ',', Charset.forName("UTF-8"));
- // Headers
- for (int i = 0; i < ImportHelper.BOAT_NB_HEADERS; i++) {
- String header = ImportHelper.getHeaderForBoatCsv(i);
- if (log.isDebugEnabled()) {
- log.debug("header : " + header);
+ ExportHelper<BOAT> export = new ExportHelper<BOAT>(writer, BOAT.getTotalHeaders()) {
+ @Override
+ public String getHeaderValue(int index) throws IOException {
+ return WaoCsvHeader.getHeaderForBoatCsv(index);
}
- writer.write(header);
- }
- writer.endRecord();
+ @Override
+ public void record(BOAT header, String value) {
+ record(header.forBoatCsv(), value);
+ }
+ };
+
+ export.writeHeaders();
+
// Get boats from database filterd by filter in argument
BoatDAO dao = SuiviObsmerModelDAOHelper.getBoatDAO(transaction);
TopiaQuery query = dao.createQuery("B");
- query = filter.prepareQueryForBoat(query, "B");
+ query = createQueryForBoatFilter(query, filter);
// Reset limit : no pagination needed for results
query.resetLimit();
+
+ if (log.isDebugEnabled()) {
+ log.debug("Exec query : " + query);
+ }
List<Boat> boats = dao.findAllByQuery(query);
for (Boat boat : boats) {
- String[] record = new String[ImportHelper.BOAT_NB_HEADERS];
+ export.newRecord();
- if (log.isDebugEnabled()) {
- log.debug("add boat : " + boat.getName() + " (" + boat.getImmatriculation() + ")");
+ if (log.isTraceEnabled()) {
+ log.trace("add boat : " + boat.getName() + " (" + boat.getImmatriculation() + ")");
}
- record[BOAT.NAVS_COD.forBoatCsv()] = String.valueOf(boat.getImmatriculation());
- record[BOAT.CARN_NOM.forBoatCsv()] = boat.getName();
- record[BOAT.CARN_LONGUEUR_HT.forBoatCsv()] = String.valueOf(boat.getBoatLength());
- record[BOAT.CARN_ANNEE.forBoatCsv()] = String.valueOf(boat.getBuildYear());
- record[BOAT.QUARTIER_IMMA.forBoatCsv()] = boat.getDistrictCode();
- record[BOAT.NAVS_ACTIVE.forBoatCsv()] = !boat.getActive() ?
- ImportHelper.BOAT_INACTIVE_CODE : "";
+ 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.QUARTIER_IMMA, boat.getDistrictCode());
+ export.record(BOAT.NAVS_ACTIVE, (!boat.getActive() ? BOAT.getBoatInactiveCode() : ""));
if (filter.getCompany() != null) {
BoatInfos boatInfos = boat.getCompanyBoatInfos(filter.getCompany());
if (boatInfos != null) {
- record[BOAT.CONT_PRENOM.forBoatCsv()] = boatInfos.getContactFirstName();
- record[BOAT.CONT_NOM.forBoatCsv()] = boatInfos.getContactLastName();
- record[BOAT.CONT_EMAIL.forBoatCsv()] = boatInfos.getContactEmail();
- record[BOAT.CONT_TEL.forBoatCsv()] = boatInfos.getContactPhoneNumber();
- record[BOAT.NAVS_DUP.forBoatCsv()] = String.valueOf(boatInfos.getDup());
- record[BOAT.NAVS_COMMENT.forBoatCsv()] = 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());
}
}
- writer.writeRecord(record);
- writer.flush();
+ export.writeRecord();
}
result = new FileInputStream(file);
Modified: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services/ServiceContactImpl.java
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services/ServiceContactImpl.java 2010-02-10 22:04:27 UTC (rev 345)
+++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services/ServiceContactImpl.java 2010-02-11 20:04:33 UTC (rev 346)
@@ -23,8 +23,8 @@
import com.csvreader.CsvReader;
import com.csvreader.CsvWriter;
-import fr.ifremer.suiviobsmer.ImportHelper;
-import fr.ifremer.suiviobsmer.ImportHelper.*;
+import fr.ifremer.suiviobsmer.io.ImportHelper;
+import fr.ifremer.suiviobsmer.io.ImportHelper.*;
import fr.ifremer.suiviobsmer.SuiviObsmerBusinessException;
import fr.ifremer.suiviobsmer.SuiviObsmerBusinessException.Type;
import fr.ifremer.suiviobsmer.SuiviObsmerException;
@@ -52,7 +52,13 @@
import fr.ifremer.suiviobsmer.entity.SampleRowDAO;
import fr.ifremer.suiviobsmer.entity.WaoUser;
import fr.ifremer.suiviobsmer.entity.WaoUserDAO;
-import fr.ifremer.suiviobsmer.services.ServiceContact;
+import fr.ifremer.suiviobsmer.io.ExportHelper;
+import fr.ifremer.suiviobsmer.io.WaoCsvHeader;
+import fr.ifremer.suiviobsmer.io.WaoCsvHeader.BOAT;
+import fr.ifremer.suiviobsmer.io.WaoCsvHeader.CONTACT;
+import fr.ifremer.suiviobsmer.io.WaoCsvHeader.ContactHeader;
+import fr.ifremer.suiviobsmer.io.WaoCsvHeader.FISHING_ZONE;
+import fr.ifremer.suiviobsmer.io.WaoCsvHeader.SAMPLING;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
@@ -205,19 +211,30 @@
FileOutputStream output = new FileOutputStream(file);
writer = new CsvWriter(output, ',', Charset.forName("UTF-8"));
- // Headers
- for (int i = 0; i < ImportHelper.CONTACT_NB_HEADERS; i++) {
- String header = ImportHelper.getHeaderForContactCsv(i);
- writer.write(header);
- }
- writer.endRecord();
+ ExportHelper<ContactHeader> export = new ExportHelper<ContactHeader>(writer, CONTACT.getTotalHeaders()) {
+ @Override
+ public void record(ContactHeader header, String value) {
+ record(header.forContactCsv(), value);
+ }
+
+ @Override
+ protected String getHeaderValue(int index) throws IOException {
+ if (log.isDebugEnabled()) {
+ log.debug("record header : " + index + " = " + WaoCsvHeader.getHeaderForContactCsv(index));
+ }
+ return WaoCsvHeader.getHeaderForContactCsv(index);
+ }
+ };
+
+ export.writeHeaders();
- DateFormat dateFormat = ImportHelper.getContactDateFormat();
+ DateFormat dateFormat = CONTACT.getDateFormat();
// Get contacts from database
ContactDAO dao = SuiviObsmerModelDAOHelper.getContactDAO(transaction);
TopiaQuery query = dao.createQuery("C");
+ query.addOrderDesc("C." + TopiaEntity.TOPIA_CREATE_DATE);
// No page limit in this case
query = filter.prepareQueryForContact(query).resetLimit();
@@ -228,77 +245,73 @@
List<Contact> contacts = dao.findAllByQuery(query);
+ DateFormat timeFormat = CONTACT.getTimeFormat();
+
for (Contact contact : contacts) {
- String[] record = new String[ImportHelper.CONTACT_NB_HEADERS];
+ export.newRecord();
// Contact part
- record[CONTACT.CONT_CODE.forContactCsv()] = ImportHelper.formatContactCode(contact.getTopiaCreateDate());
- record[CONTACT.CONT_CREATION.forContactCsv()] = dateFormat.format(contact.getTopiaCreateDate());
- record[CONTACT.CONT_ETAT.forContactCsv()] = contact.getState();
+ export.record(CONTACT.CONT_CODE, timeFormat.format(contact.getTopiaCreateDate()));
+ export.record(CONTACT.CONT_CREATION, dateFormat.format(contact.getTopiaCreateDate()));
+ export.record(CONTACT.CONT_ETAT, contact.getState());
if (contact.getTideBeginDate() != null) {
- record[CONTACT.CONT_DEBUT_MAREE.forContactCsv()] = dateFormat.format(contact.getTideBeginDate());
+ export.record(CONTACT.CONT_DEBUT_MAREE, dateFormat.format(contact.getTideBeginDate()));
}
if (contact.getTideEndDate() != null) {
- record[CONTACT.CONT_FIN_MAREE.forContactCsv()] = dateFormat.format(contact.getTideEndDate());
+ export.record(CONTACT.CONT_FIN_MAREE, dateFormat.format(contact.getTideEndDate()));
}
- record[CONTACT.CONT_NB_OBSERV.forContactCsv()] = String.valueOf(contact.getNbObservants());
- record[CONTACT.CONT_MAM_CAPT.forContactCsv()] =
- ImportHelper.formatContactMammals(contact.getMammalsCapture());
- record[CONTACT.CONT_MAM_OBS.forContactCsv()] =
- ImportHelper.formatContactMammals(contact.getMammalsObservation());
- record[CONTACT.CONT_COMMENT.forContactCsv()] = contact.getComment();
+ export.record(CONTACT.CONT_NB_OBSERV, String.valueOf(contact.getNbObservants()));
+ export.record(CONTACT.CONT_MAM_CAPT, CONTACT.formatMammals(contact.getMammalsCapture()));
+ export.record(CONTACT.CONT_MAM_OBS, CONTACT.formatMammals(contact.getMammalsObservation()));
+ export.record(CONTACT.CONT_COMMENT, contact.getComment());
if (contact.getDataInputDate() != null) {
- record[CONTACT.CONT_ALLEGRO.forContactCsv()] = dateFormat.format(contact.getDataInputDate());
+ export.record(CONTACT.CONT_ALLEGRO, dateFormat.format(contact.getDataInputDate()));
}
- record[CONTACT.CONT_SOCIETE_VALID.forContactCsv()] =
- ImportHelper.formatContactValidation(contact.getValidationCompany());
- record[CONTACT.CONT_PROGRAM_VALID.forContactCsv()] =
- ImportHelper.formatContactValidation(contact.getValidationProgram());
+ export.record(CONTACT.CONT_SOCIETE_VALID, CONTACT.formatValidation(contact.getValidationCompany()));
+ export.record(CONTACT.CONT_PROGRAM_VALID, CONTACT.formatValidation(contact.getValidationProgram()));
// Observer part
WaoUser observer = contact.getObserver();
Company company = observer.getCompany();
- record[CONTACT.OBSERV_ID.forContactCsv()] = observer.getLogin();
- record[CONTACT.OBSERV_PRENOM.forContactCsv()] = observer.getFirstName();
- record[CONTACT.OBSERV_NOM.forContactCsv()] = observer.getLastName();
- record[SAMPLING.SOCIETE_NOM.forContactCsv()] = company.getName();
+ export.record(CONTACT.OBSERV_ID, observer.getLogin());
+ export.record(CONTACT.OBSERV_PRENOM, observer.getFirstName());
+ export.record(CONTACT.OBSERV_NOM, observer.getLastName());
+ export.record(SAMPLING.SOCIETE_NOM, company.getName());
// SampleRow part
SampleRow row = contact.getSampleRow();
- record[SAMPLING.PLAN_CODE.forContactCsv()] = row.getCode();
- record[SAMPLING.PROGRAMME_CODE.forContactCsv()] = row.getProgramName();
- record[SAMPLING.PROGRAMME_DEBUT.forContactCsv()] = dateFormat.format(row.getPeriodBegin());
- record[SAMPLING.PROGRAMME_FIN.forContactCsv()] = dateFormat.format(row.getPeriodEnd());
- record[SAMPLING.PECHE_AUTRE.forContactCsv()] = row.getFishingZonesInfos();
+ export.record(SAMPLING.PLAN_CODE, row.getCode());
+ export.record(SAMPLING.PROGRAMME_CODE, row.getProgramName());
+ export.record(SAMPLING.PROGRAMME_DEBUT, dateFormat.format(row.getPeriodBegin()));
+ export.record(SAMPLING.PROGRAMME_FIN, dateFormat.format(row.getPeriodEnd()));
+ export.record(SAMPLING.PECHE_AUTRE, row.getFishingZonesInfos());
// FishingZone part
- List<FishingZone> zones = row.getFishingZone();
- String fishingDistrict = "";
- for (FishingZone zone : zones) {
- fishingDistrict += zone.getDistrictCode() + " - ";
+ String divisions = "";
+ String separator = " - ";
+ for (FishingZone zone : row.getFishingZone()) {
+ divisions += separator + zone.getDistrictCode();
}
- fishingDistrict = fishingDistrict.substring(fishingDistrict.length() - 3);
- record[FISHING_ZONE.PECHE_FACADE.forContactCsv()] = zones.get(0).getFacadeName();
- record[FISHING_ZONE.PECHE_ZONE.forContactCsv()] = zones.get(0).getSectorName();
- record[FISHING_ZONE.PECHE_DIVISION.forContactCsv()] = fishingDistrict;
+ export.record(FISHING_ZONE.PECHE_DIVISION, divisions.substring(separator.length()));
+ export.record(FISHING_ZONE.PECHE_FACADE, row.getFacade());
+ export.record(FISHING_ZONE.PECHE_ZONE, row.getSectors());
// Profession part
Profession profession = row.getProfession();
- record[SAMPLING.METIER_CODE_DCF5.forContactCsv()] = profession.getCodeDCF5();
- record[SAMPLING.METIER_MAILLAGE.forContactCsv()] = profession.getMeshSize();
- record[SAMPLING.METIER_TAILLE.forContactCsv()] = profession.getSize();
- record[SAMPLING.METIER_AUTRE.forContactCsv()] = profession.getOther();
- record[SAMPLING.METIER_LIBELLE.forContactCsv()] = profession.getLibelle();
- record[SAMPLING.METIER_ESPECES.forContactCsv()] = profession.getSpecies();
+ export.record(SAMPLING.METIER_CODE_DCF5, profession.getCodeDCF5());
+ export.record(SAMPLING.METIER_MAILLAGE, profession.getMeshSize());
+ export.record(SAMPLING.METIER_TAILLE, profession.getSize());
+ export.record(SAMPLING.METIER_AUTRE, profession.getOther());
+ export.record(SAMPLING.METIER_LIBELLE, profession.getLibelle());
+ export.record(SAMPLING.METIER_ESPECES, profession.getSpecies());
// Boat part
Boat boat = contact.getBoat();
- record[BOAT.NAVS_COD.forContactCsv()] = String.valueOf(boat.getImmatriculation());
- record[BOAT.CARN_NOM.forContactCsv()] = boat.getName();
- record[BOAT.QUARTIER_IMMA.forContactCsv()] = boat.getDistrictCode();
+ export.record(BOAT.NAVS_COD, String.valueOf(boat.getImmatriculation()));
+ export.record(BOAT.CARN_NOM, boat.getName());
+ export.record(BOAT.QUARTIER_IMMA, boat.getDistrictCode());
- writer.writeRecord(record);
- writer.flush();
+ export.writeRecord();
}
result = new FileInputStream(file);
Modified: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services/ServiceReferentialImpl.java
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services/ServiceReferentialImpl.java 2010-02-10 22:04:27 UTC (rev 345)
+++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services/ServiceReferentialImpl.java 2010-02-11 20:04:33 UTC (rev 346)
@@ -22,7 +22,6 @@
package fr.ifremer.suiviobsmer.services;
import com.csvreader.CsvReader;
-import fr.ifremer.suiviobsmer.ImportHelper.FISHING_ZONE;
import fr.ifremer.suiviobsmer.SuiviObsmerException;
import fr.ifremer.suiviobsmer.SuiviObsmerModelDAOHelper;
import fr.ifremer.suiviobsmer.SuiviObsmerContext;
@@ -32,7 +31,8 @@
import fr.ifremer.suiviobsmer.entity.Profession;
import fr.ifremer.suiviobsmer.entity.ProfessionDAO;
import fr.ifremer.suiviobsmer.entity.SampleRow;
-import fr.ifremer.suiviobsmer.services.ServiceReferential;
+import fr.ifremer.suiviobsmer.io.ImportHelper;
+import fr.ifremer.suiviobsmer.io.WaoCsvHeader.FISHING_ZONE;
import java.io.InputStream;
import java.nio.charset.Charset;
import java.util.ArrayList;
@@ -192,9 +192,9 @@
log.trace(" " + Arrays.asList(reader.getValues()));
}
- String facadeName = reader.get(FISHING_ZONE.PECHE_FACADE.name()).trim();
- String sectorName = reader.get(FISHING_ZONE.PECHE_ZONE.name()).trim();
- String districtCode = reader.get(FISHING_ZONE.PECHE_DIVISION.name()).trim();
+ 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);
Modified: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services/ServiceSamplingImpl.java
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services/ServiceSamplingImpl.java 2010-02-10 22:04:27 UTC (rev 345)
+++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services/ServiceSamplingImpl.java 2010-02-11 20:04:33 UTC (rev 346)
@@ -22,9 +22,8 @@
package fr.ifremer.suiviobsmer.services;
import com.csvreader.CsvReader;
-import fr.ifremer.suiviobsmer.ImportHelper;
-import fr.ifremer.suiviobsmer.ImportHelper.FISHING_ZONE;
-import fr.ifremer.suiviobsmer.ImportHelper.SAMPLING;
+import com.csvreader.CsvWriter;
+import fr.ifremer.suiviobsmer.io.ImportHelper;
import fr.ifremer.suiviobsmer.SuiviObsmerBusinessException;
import fr.ifremer.suiviobsmer.SuiviObsmerBusinessException.Type;
import fr.ifremer.suiviobsmer.SuiviObsmerException;
@@ -36,11 +35,20 @@
import fr.ifremer.suiviobsmer.bean.ImportResultsImpl;
import fr.ifremer.suiviobsmer.bean.SamplingFilter;
import fr.ifremer.suiviobsmer.entity.*;
-import fr.ifremer.suiviobsmer.services.ServiceSampling;
+import fr.ifremer.suiviobsmer.io.WaoCsvHeader.FISHING_ZONE;
+import fr.ifremer.suiviobsmer.io.WaoCsvHeader.SAMPLING;
+import fr.ifremer.suiviobsmer.io.WaoCsvHeader.SamplingHeader;
+import fr.ifremer.suiviobsmer.io.ExportHelper;
+import fr.ifremer.suiviobsmer.io.ExportHelper;
+import fr.ifremer.suiviobsmer.io.SamplingExport;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.Charset;
import java.text.DateFormat;
+import java.text.NumberFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
@@ -514,6 +522,140 @@
}
@Override
+ public InputStream exportSamplingPlanCsv(WaoUser user, PeriodDates period) throws SuiviObsmerException {
+ TopiaContext transaction = null;
+ InputStream result = null;
+ CsvWriter writer = null;
+ try {
+ transaction = rootContext.beginTransaction();
+
+ File file = File.createTempFile("wao-samplingPlan-", ".csv");
+ file.deleteOnExit();
+
+ FileOutputStream output = new FileOutputStream(file);
+ writer = new CsvWriter(output, ',', Charset.forName("UTF-8"));
+
+ // Get min and max dates to have the biggest period
+// Date min = (Date)query.executeToObject("MIN(S." + SampleRow.PERIOD_BEGIN + ")");
+// Date max = (Date)query.executeToObject("MAX(S." + SampleRow.PERIOD_END + ")");
+
+// PeriodDates periodMax = new PeriodDates(min, max);
+ period.setPattern(SAMPLING.defaultDatePattern());
+ List<String> monthHeaders = period.getFormatedMonths();
+
+ SamplingExport export = new SamplingExport(writer, user, monthHeaders);
+
+ export.writeHeaders();
+
+ // Get sampleRows from database filtered by company if needed
+ // (only for user) and period
+ SampleRowDAO dao = SuiviObsmerModelDAOHelper.getSampleRowDAO(transaction);
+ TopiaQuery query = dao.createQuery("S");
+
+ if (!user.getAdmin()) {
+ query.add("S." + SampleRow.COMPANY, user.getCompany());
+ }
+
+ // Prepare period dates
+ period.initDayOfMonthExtremities();
+ query.add("S." + SampleRow.PERIOD_BEGIN, Op.LT, period.getThruDate()).
+ add("S." + SampleRow.PERIOD_END, Op.GT, period.getFromDate());
+
+ query.addOrder("S." + SampleRow.CODE);
+
+ List<SampleRow> rows = dao.findAllByQuery(query);
+
+ DateFormat dateFormat = SAMPLING.getDateFormat();
+ NumberFormat numberFormat = SAMPLING.getNumberFormat();
+
+ for (SampleRow row : rows) {
+ export.newRecord();
+
+ if (log.isDebugEnabled()) {
+ log.debug("add sampleRow : " + row.getCode());
+ }
+
+ export.record(SAMPLING.PLAN_CODE, row.getCode());
+ Company company = row.getCompany();
+ if (company != null) {
+ export.record(SAMPLING.SOCIETE_NOM, company.getName());
+ }
+
+ // Profession can't be null
+ Profession profession = row.getProfession();
+ export.record(SAMPLING.METIER_CODE_DCF5, profession.getCodeDCF5());
+ export.record(SAMPLING.METIER_MAILLAGE, profession.getMeshSize());
+ export.record(SAMPLING.METIER_TAILLE, profession.getSize());
+ export.record(SAMPLING.METIER_AUTRE, profession.getOther());
+ export.record(SAMPLING.METIER_LIBELLE, profession.getLibelle());
+ export.record(SAMPLING.METIER_ESPECES, profession.getSpecies());
+
+ export.record(SAMPLING.PROGRAMME_CODE, row.getProgramName());
+ export.record(SAMPLING.PROGRAMME_DEBUT, dateFormat.format(row.getPeriodBegin()));
+ export.record(SAMPLING.PROGRAMME_FIN, dateFormat.format(row.getPeriodEnd()));
+
+ export.record(FISHING_ZONE.PECHE_FACADE, row.getFacade());
+ export.record(FISHING_ZONE.PECHE_ZONE, row.getSectors());
+ export.record(SAMPLING.PECHE_AUTRE, row.getFishingZonesInfos());
+
+ String divisions = "";
+ String separator = FISHING_ZONE.getDistrictCodeSeparator();
+ for (FishingZone zone : row.getFishingZone()) {
+ divisions += separator + zone.getDistrictCode();
+ }
+
+ // There is at least one district in row, so no problem with substring
+ export.record(FISHING_ZONE.PECHE_DIVISION, divisions.substring(separator.length()));
+
+ export.record(SAMPLING.PLAN_NB_OBSERV, numberFormat.format(row.getNbObservants()));
+ export.record(SAMPLING.PLAN_DUREE_MOY, numberFormat.format(row.getAverageTideTime()));
+ export.record(SAMPLING.PLAN_COMMENT, String.valueOf(row.getComment()));
+
+ export.recordMonths(row);
+
+// for (int i = 0; i < monthHeaders.size(); i++) {
+// // Get date from monthHeaders list
+// Date month = dateFormat.parse(monthHeaders.get(i));
+// // Retrieve sampleMonth corresponding
+// SampleMonth sampleMonth = row.getSampleMonth(month);
+// // Add it to the file if it exists
+// if (sampleMonth != null) {
+// // Prepare index for record
+// int index = SAMPLING.getStartIndexForMonths() + i;
+// String expected = String.valueOf(sampleMonth.getExpectedTidesValue());
+// String real = String.valueOf(sampleMonth.getRealTidesValue());
+// // The admin as only expected value (to be the same as
+// // in import)
+// if (user.getAdmin()) {
+// export.record(index, expected); //record[index] = expected;
+// // The user as both expected and real values
+// } else {
+// export.record(index, expected + " (" + real + ")");
+// }
+// }
+// }
+
+ export.writeRecord();
+ }
+
+ result = new FileInputStream(file);
+
+ } catch (Exception eee) {
+ DateFormat dateFormat = SAMPLING.getDateFormat();
+ SuiviObsmerContext.serviceException(transaction,
+ "Impossible d'exporter le plan d'échantillonnage sur la période du " +
+ dateFormat.format(period.getFromDate()) + " au " +
+ dateFormat.format(period.getThruDate()), eee);
+ } finally {
+ if (writer != null) {
+ writer.close();
+ }
+ SuiviObsmerContext.closeTransaction(transaction);
+ }
+ return result;
+ }
+
+ @Override
public ImportResults importSamplingPlanCsv(InputStream input) throws SuiviObsmerException {
TopiaContext transaction = null;
ImportResults result = new ImportResultsImpl();
@@ -666,7 +808,7 @@
FishingZoneDAO dao = SuiviObsmerModelDAOHelper.getFishingZoneDAO(transaction);
- List<String> districtList = new ArrayList<String>(Arrays.asList(districts.split(" / ")));
+ List<String> districtList = new ArrayList<String>(Arrays.asList(districts.split(FISHING_ZONE.getDistrictCodeSeparator())));
if (log.isDebugEnabled()) {
log.debug("FishingZone districts : " + districts);
@@ -725,7 +867,7 @@
// Note : nbTotalColumns must be > nbFixedColumns
int lastMonthColumnId = firstMonthColumnId + nbTotalColumns - nbFixedColumns;
- DateFormat dateFormat = new SimpleDateFormat(SAMPLING.defaultDatePattern());
+ DateFormat dateFormat = SAMPLING.getDateFormat();
for (int i = firstMonthColumnId; i < lastMonthColumnId; i++) {
Modified: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services/ServiceSynthesisImpl.java
===================================================================
--- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services/ServiceSynthesisImpl.java 2010-02-10 22:04:27 UTC (rev 345)
+++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/services/ServiceSynthesisImpl.java 2010-02-11 20:04:33 UTC (rev 346)
@@ -89,7 +89,9 @@
return results;
}
+ // Expected
SortedMap<Date, Integer> serie1 = new TreeMap<Date,Integer>();
+ // Real
SortedMap<Date, Integer> serie2 = new TreeMap<Date,Integer>();
results.add(serie1);
results.add(serie2);
Modified: trunk/suiviobsmer-business/src/main/xmi/suiviobsmer.zargo
===================================================================
(Binary files differ)
Modified: trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/ImportHelperTest.java
===================================================================
--- trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/ImportHelperTest.java 2010-02-10 22:04:27 UTC (rev 345)
+++ trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/ImportHelperTest.java 2010-02-11 20:04:33 UTC (rev 346)
@@ -22,10 +22,13 @@
package fr.ifremer.suiviobsmer;
import com.csvreader.CsvReader;
-import fr.ifremer.suiviobsmer.ImportHelper.SAMPLING;
+import fr.ifremer.suiviobsmer.io.ImportHelper;
+import fr.ifremer.suiviobsmer.io.WaoCsvHeader.CONTACT;
+import fr.ifremer.suiviobsmer.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;
@@ -127,7 +130,8 @@
calendar.set(Calendar.SECOND, 50);
calendar.set(Calendar.MILLISECOND, 260);
String expResult = "100150260";
- String result = ImportHelper.formatContactCode(calendar.getTime());
+ DateFormat timeFormat = CONTACT.getTimeFormat();
+ String result = timeFormat.format(calendar.getTime());
assertEquals(expResult, result);
}
Modified: trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/Boats.java
===================================================================
--- trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/Boats.java 2010-02-10 22:04:27 UTC (rev 345)
+++ trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/Boats.java 2010-02-11 20:04:33 UTC (rev 346)
@@ -514,6 +514,9 @@
public InputStream getStream() throws IOException {
InputStream result = null;
try {
+ if (log.isDebugEnabled()) {
+ log.debug("Filter sampleRow : " + getFilter().getSampleRow());
+ }
result = serviceBoat.exportBoatCsv(getFilter());
} catch (SuiviObsmerException eee) {
throw new IOException(eee);
Modified: trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/SamplingPlan.java
===================================================================
--- trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/SamplingPlan.java 2010-02-10 22:04:27 UTC (rev 345)
+++ trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/SamplingPlan.java 2010-02-11 20:04:33 UTC (rev 346)
@@ -34,11 +34,15 @@
import fr.ifremer.suiviobsmer.services.ServiceSampling;
import fr.ifremer.suiviobsmer.ui.base.SuiviObsmerPage;
import fr.ifremer.suiviobsmer.ui.components.Layout;
+import fr.ifremer.suiviobsmer.ui.data.ExportStreamResponse;
+import java.io.IOException;
+import java.io.InputStream;
import java.text.DateFormat;
import java.text.NumberFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
+import org.apache.tapestry5.StreamResponse;
import org.apache.tapestry5.annotations.IncludeStylesheet;
import org.apache.tapestry5.annotations.InjectComponent;
import org.apache.tapestry5.annotations.Log;
@@ -119,7 +123,25 @@
layout.getFeedBack().addError(eee.getMessage());
}
}
+
+ /**************************** EXPORT **************************************/
+ StreamResponse onActionFromExportSamplingPlan() {
+ return new ExportStreamResponse("wao-echantillonnage") {
+
+ @Override
+ public InputStream getStream() throws IOException {
+ InputStream result = null;
+ try {
+ result = serviceSampling.exportSamplingPlanCsv(user, getPeriod());
+ } catch (SuiviObsmerException eee) {
+ throw new IOException(eee);
+ }
+ return result;
+ }
+ };
+ }
+
/**************************** PERIOD SELECTION *****************************/
@Persist
Modified: trunk/suiviobsmer-ui/src/main/resources/fr/ifremer/suiviobsmer/ui/pages/Boats.properties
===================================================================
--- trunk/suiviobsmer-ui/src/main/resources/fr/ifremer/suiviobsmer/ui/pages/Boats.properties 2010-02-10 22:04:27 UTC (rev 345)
+++ trunk/suiviobsmer-ui/src/main/resources/fr/ifremer/suiviobsmer/ui/pages/Boats.properties 2010-02-11 20:04:33 UTC (rev 346)
@@ -28,4 +28,5 @@
contactEmail-label: E-mail
shipOwner-label: Armateur
fromDate-label: Sollicitations du navire depuis le
-dup-label: Capacit\u00E9 d'accueil du navire en personnels sp\u00E9cialis\u00E9s
\ No newline at end of file
+dup-label: Capacit\u00E9 d'accueil du navire en personnels sp\u00E9cialis\u00E9s
+comment-label: Commentaire
\ No newline at end of file
Modified: trunk/suiviobsmer-ui/src/main/webapp/SamplingPlan.tml
===================================================================
--- trunk/suiviobsmer-ui/src/main/webapp/SamplingPlan.tml 2010-02-10 22:04:27 UTC (rev 345)
+++ trunk/suiviobsmer-ui/src/main/webapp/SamplingPlan.tml 2010-02-11 20:04:33 UTC (rev 346)
@@ -17,7 +17,13 @@
</t:if>
<div class="clearfix mbottom10">
<div class="fleft">
- <h1>Plan d'échantillonnage</h1>
+ <h1>
+ Plan d'échantillonnage
+ <a t:type="actionlink" t:id="exportSamplingPlan">
+ <img src="${asset:context:}/img/file-export-22px.png" alt="Export CSV"
+ title="Exporter le plan d'échantillonnage du ${dateFormat.format(period.fromDate)} au ${dateFormat.format(period.thruDate)}" />
+ </a>
+ </h1>
<form t:type="form" t:id="periodForm">
<t:label t:for="periodBegin" /> : <input t:type="datefield" class="width70" t:id="periodBegin" t:format="MM/yyyy" />
<t:label t:for="periodEnd" /> : <input t:type="datefield" class="width70" t:id="periodEnd" t:format="MM/yyyy" />
1
0