branch develop updated (12328c6 -> ddc9f4e)
This is an automated email from the git hooks/post-receive script. New change to branch develop in repository wao. See http://git.codelutin.com/wao.git from 12328c6 La version 4.3 n'aura pas lieu, on renomme la migration new 6bf8157 Ouverture de l'accès au programme Scléro pour le compte 'admin', correction du formulaire d'administration des utilisateurs pour ne pas pouvoir utiliser la notion d'invité et de professionnel new fd59834 Modification du modèle de la ligne du plan, introduction du service et de la vue pour le plan scléro, migration new 2c6e908 Dans l'écran de gestion des référentiels, on n'affiche que ce qui est pertinent pour scléro new 675f001 Suppression d'un fichier obsdeb new f4a83c2 Import du plan d'échantillonnage scléro new fde3c64 On gère les filtres dans le plan scléro new 321824f Ajout des champs scléro dans le formulaire de modification d'une ligne du plan new 626b064 Les filtres du plan sont désormais effectifs new 5bcc4c2 Dans le plan scléro, on ajoute une colonne pour l'espèce new 50588e1 On adapte la génération de la liste des modifications pour considérer les changements sur une ligne scléro new a182c8a Impact des données de test suite à changement de modèle CSV new 1a11c49 Correction du message généré quand on compare les organisations (qui ne sont plus forcément des sociétés) new 44b8232 Pour les coordinateurs et les observateurs, on affiche que les lignes du plan d'échantillonnage de l'organisation new e2e361a Dans la scléro, on utilise pas la notion de Profession new ddc9f4e Ajout du plan d'échantillonnage pour le programme sclérochronologie (fixes #2263) The 15 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Detailed log of new commits: commit ddc9f4ef1d0a4ca7258ee1e143b03415822f5743 Merge: 12328c6 e2e361a Author: Brendan Le Ny <bleny@codelutin.com> Date: Mon Dec 22 14:36:19 2014 +0100 Ajout du plan d'échantillonnage pour le programme sclérochronologie (fixes #2263) commit e2e361a595fc675c909553ec5aea137a804a2eb7 Author: Brendan Le Ny <bleny@codelutin.com> Date: Mon Dec 22 11:15:09 2014 +0100 Dans la scléro, on utilise pas la notion de Profession commit 44b82321eb517d338f8e5d1faa327e6523b60bb6 Author: Brendan Le Ny <bleny@codelutin.com> Date: Fri Dec 19 14:58:17 2014 +0100 Pour les coordinateurs et les observateurs, on affiche que les lignes du plan d'échantillonnage de l'organisation commit 1a11c491eb88690a423def59c6a278948ad0a43b Author: Brendan Le Ny <bleny@codelutin.com> Date: Fri Dec 19 12:04:50 2014 +0100 Correction du message généré quand on compare les organisations (qui ne sont plus forcément des sociétés) commit a182c8a6bb2769f803bc54491143330e4cb9b2a3 Author: Brendan Le Ny <bleny@codelutin.com> Date: Fri Dec 19 11:48:38 2014 +0100 Impact des données de test suite à changement de modèle CSV commit 50588e180aed02fe197bbb2242e5f0e771e6afb6 Author: Brendan Le Ny <bleny@codelutin.com> Date: Fri Dec 19 11:44:13 2014 +0100 On adapte la génération de la liste des modifications pour considérer les changements sur une ligne scléro commit 5bcc4c289cf3ff8473efda00a0a1af960f537de5 Author: Brendan Le Ny <bleny@codelutin.com> Date: Thu Dec 18 16:59:10 2014 +0100 Dans le plan scléro, on ajoute une colonne pour l'espèce commit 626b064a5985fa0ac36176bfc71e7091e7271220 Author: Brendan Le Ny <bleny@codelutin.com> Date: Thu Dec 18 16:56:26 2014 +0100 Les filtres du plan sont désormais effectifs commit 321824f7e06ca6331d81be51c38b135eed7962a6 Author: Brendan Le Ny <bleny@codelutin.com> Date: Thu Dec 18 16:37:42 2014 +0100 Ajout des champs scléro dans le formulaire de modification d'une ligne du plan commit fde3c645ee6d1671b268b802f58d3fa5e3833fa8 Author: Brendan Le Ny <bleny@codelutin.com> Date: Thu Dec 18 15:09:42 2014 +0100 On gère les filtres dans le plan scléro commit f4a83c25404158e2e637ef5c7e34e85a70319154 Author: Brendan Le Ny <bleny@codelutin.com> Date: Thu Dec 18 11:36:37 2014 +0100 Import du plan d'échantillonnage scléro commit 675f00192651555d766d6237e3268c0b57b01305 Author: Brendan Le Ny <bleny@codelutin.com> Date: Thu Dec 18 10:27:01 2014 +0100 Suppression d'un fichier obsdeb commit 2c6e908c8db51c57862224a7a2ec9b69fd233573 Author: Brendan Le Ny <bleny@codelutin.com> Date: Thu Dec 18 09:59:41 2014 +0100 Dans l'écran de gestion des référentiels, on n'affiche que ce qui est pertinent pour scléro commit fd59834846ebbb3791bedd46b9a6884483e60643 Author: Brendan Le Ny <bleny@codelutin.com> Date: Mon Dec 15 15:49:36 2014 +0100 Modification du modèle de la ligne du plan, introduction du service et de la vue pour le plan scléro, migration commit 6bf81571ac6d97cd7abdd5161eec6fcceb9ba17f Author: Brendan Le Ny <bleny@codelutin.com> Date: Mon Dec 15 10:45:50 2014 +0100 Ouverture de l'accès au programme Scléro pour le compte 'admin', correction du formulaire d'administration des utilisateurs pour ne pas pouvoir utiliser la notion d'invité et de professionnel Summary of changes: .../main/java/fr/ifremer/wao/SampleRowsFilter.java | 68 ++++++- .../java/fr/ifremer/wao/entity/BoatTopiaDao.java | 2 +- .../main/java/fr/ifremer/wao/entity/Companies.java | 9 +- .../wao/entity/IndividualMeasurementStrategy.java | 39 ++++ .../java/fr/ifremer/wao/entity/Organisations.java | 23 +++ .../java/fr/ifremer/wao/entity/SampleRowImpl.java | 15 +- .../fr/ifremer/wao/entity/SampleRowLogImpl.java | 94 +++++++-- .../fr/ifremer/wao/entity/SampleRowTopiaDao.java | 16 +- .../entity/SclerochronologySamplingContext.java | 38 ++++ .../main/java/fr/ifremer/wao/entity/Specieses.java | 19 ++ .../db/migration/V5_0__sclerochronology.sql | 18 ++ .../i18n/wao-persistence_en_GB.properties | 7 + .../i18n/wao-persistence_fr_FR.properties | 7 + wao-persistence/src/main/xmi/wao-model.properties | 2 +- wao-persistence/src/main/xmi/wao-model.zargo | Bin 61366 -> 61993 bytes .../ifremer/wao/services/AuthenticatedWaoUser.java | 5 + .../fr/ifremer/wao/services/ObsMerFixtures.java | 222 --------------------- .../ifremer/wao/services/service/BoatsService.java | 6 +- .../wao/services/service/ContactsService.java | 2 +- ...singIndividualMeasurementStrategyException.java | 10 + ...ngSclerochronologySamplingContextException.java | 10 + .../services/service/MissingSpeciesException.java | 10 + .../services/service/SampleRowsFilterValues.java | 88 +++++--- .../ifremer/wao/services/service/SamplingPlan.java | 14 +- .../wao/services/service/SamplingPlanService.java | 135 +++++++++---- .../service/SclerochronologySamplingPlan.java | 118 +++++++++++ ...va => SclerochronologySamplingPlanBuilder.java} | 38 ++-- ...va => SclerochronologySamplingPlanService.java} | 9 +- .../services/service/UpdateSampleRowCommand.java | 79 ++++++-- .../wao/services/service/WaoServiceSupport.java | 5 + .../administration/OrganisationsService.java | 18 ++ .../service/administration/ReferentialService.java | 9 + .../administration/UpdateWaoUserCommand.java | 9 + .../service/csv/ContactImportExportModel.java | 12 +- ...bsMerObsVenteSamplingPlanImportExportModel.java | 46 +++-- ...atter.java => OrganisationParserFormatter.java} | 48 ++--- .../csv/operations/SpeciesParserFormatter.java | 51 +++++ .../resources/i18n/wao-services_en_GB.properties | 5 + .../resources/i18n/wao-services_fr_FR.properties | 5 + .../wao/services/service/BoatsServiceTest.java | 1 - .../wao/services/service/ContactsServiceTest.java | 1 - .../wao/services/service/ObsMerFixtures.java | 93 +++++++++ .../service/ObsMerSamplingPlanServiceTest.java | 1 - .../services/service/SclerochronologyFixtures.java | 73 +++++++ .../SclerochronologySamplingPlanServiceTest.java | 135 +++++++++++++ .../ifremer/wao/services/service/WaoFixtures.java | 119 +++++++++++ .../src/test/resources/import/echantillonnage.csv | 20 +- .../resources/import/plan-sclerochronologie.csv | 6 + .../test/resources/import/samplingPlan-obsdeb.csv | 3 - .../wao/web/action/EditSampleRowAction.java | 15 +- .../action/SampleRowsFilterValuesJsonAction.java | 34 +++- .../action/administration/ImportSpeciesAction.java | 4 +- .../SamplingPlanAction.java | 12 +- .../SamplingPlanAction-conversion.properties | 1 + .../main/resources/i18n/wao-web_en_GB.properties | 5 + .../main/resources/i18n/wao-web_fr_FR.properties | 5 + .../content/administration/edit-wao-user.jsp | 4 +- .../administration/referential-management.jsp | 94 ++++----- .../main/webapp/WEB-INF/content/boat-details.jsp | 2 +- .../src/main/webapp/WEB-INF/content/contacts.jsp | 2 +- .../WEB-INF/content/edit-sample-row-input.jsp | 116 +++++++---- .../WEB-INF/content/obsmer/sampling-plan.jsp | 6 +- .../WEB-INF/content/obsvente/sampling-plan.jsp | 6 +- .../sampling-plan.jsp | 107 +++------- .../src/main/webapp/WEB-INF/content/synthesis.jsp | 4 +- .../src/main/webapp/WEB-INF/decorators/layout.jsp | 50 ++--- 66 files changed, 1580 insertions(+), 650 deletions(-) create mode 100644 wao-persistence/src/main/java/fr/ifremer/wao/entity/IndividualMeasurementStrategy.java create mode 100644 wao-persistence/src/main/java/fr/ifremer/wao/entity/Organisations.java create mode 100644 wao-persistence/src/main/java/fr/ifremer/wao/entity/SclerochronologySamplingContext.java create mode 100644 wao-persistence/src/main/java/fr/ifremer/wao/entity/Specieses.java create mode 100644 wao-persistence/src/main/resources/db/migration/V5_0__sclerochronology.sql delete mode 100644 wao-services/src/main/java/fr/ifremer/wao/services/ObsMerFixtures.java create mode 100644 wao-services/src/main/java/fr/ifremer/wao/services/service/MissingIndividualMeasurementStrategyException.java create mode 100644 wao-services/src/main/java/fr/ifremer/wao/services/service/MissingSclerochronologySamplingContextException.java create mode 100644 wao-services/src/main/java/fr/ifremer/wao/services/service/MissingSpeciesException.java create mode 100644 wao-services/src/main/java/fr/ifremer/wao/services/service/SclerochronologySamplingPlan.java copy wao-services/src/main/java/fr/ifremer/wao/services/service/{ObsVenteSamplingPlanBuilder.java => SclerochronologySamplingPlanBuilder.java} (86%) copy wao-services/src/main/java/fr/ifremer/wao/services/service/{ObsVenteSamplingPlanService.java => SclerochronologySamplingPlanService.java} (88%) rename wao-services/src/main/java/fr/ifremer/wao/services/service/csv/operations/{CompanyParserFormatter.java => OrganisationParserFormatter.java} (50%) create mode 100644 wao-services/src/main/java/fr/ifremer/wao/services/service/csv/operations/SpeciesParserFormatter.java create mode 100644 wao-services/src/test/java/fr/ifremer/wao/services/service/ObsMerFixtures.java create mode 100644 wao-services/src/test/java/fr/ifremer/wao/services/service/SclerochronologyFixtures.java create mode 100644 wao-services/src/test/java/fr/ifremer/wao/services/service/SclerochronologySamplingPlanServiceTest.java create mode 100644 wao-services/src/test/java/fr/ifremer/wao/services/service/WaoFixtures.java create mode 100644 wao-services/src/test/resources/import/plan-sclerochronologie.csv delete mode 100644 wao-services/src/test/resources/import/samplingPlan-obsdeb.csv copy wao-web/src/main/java/fr/ifremer/wao/web/action/{obsvente => sclerochronology}/SamplingPlanAction.java (72%) create mode 100644 wao-web/src/main/resources/fr/ifremer/wao/web/action/sclerochronology/SamplingPlanAction-conversion.properties copy wao-web/src/main/webapp/WEB-INF/content/{obsvente => sclerochronology}/sampling-plan.jsp (80%) -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository wao. See http://git.codelutin.com/wao.git commit 6bf81571ac6d97cd7abdd5161eec6fcceb9ba17f Author: Brendan Le Ny <bleny@codelutin.com> Date: Mon Dec 15 10:45:50 2014 +0100 Ouverture de l'accès au programme Scléro pour le compte 'admin', correction du formulaire d'administration des utilisateurs pour ne pas pouvoir utiliser la notion d'invité et de professionnel --- .../db/migration/V5_0__sclerochronology.sql | 13 ++++++ wao-persistence/src/main/xmi/wao-model.properties | 2 +- .../administration/UpdateWaoUserCommand.java | 9 ++++ .../content/administration/edit-wao-user.jsp | 4 +- .../src/main/webapp/WEB-INF/decorators/layout.jsp | 50 ++++++++++++---------- 5 files changed, 52 insertions(+), 26 deletions(-) diff --git a/wao-persistence/src/main/resources/db/migration/V5_0__sclerochronology.sql b/wao-persistence/src/main/resources/db/migration/V5_0__sclerochronology.sql new file mode 100644 index 0000000..ee61e50 --- /dev/null +++ b/wao-persistence/src/main/resources/db/migration/V5_0__sclerochronology.sql @@ -0,0 +1,13 @@ + + +-- Ouverture de l'accès au programme sclérochronologie du compte admin +insert into UserProfile values ( + 'fr.ifremer.wao.entities.UserProfile#129111142543000#933200987654321550', + 1, + now(), + (select topiaId from WaoUser where login = 'admin'), + 'SCLEROCHRONOLOGY', + 'ADMIN', + true, + uuid_in(md5(random()::text || now()::text)::cstring) +); diff --git a/wao-persistence/src/main/xmi/wao-model.properties b/wao-persistence/src/main/xmi/wao-model.properties index 86db9ad..b807930 100644 --- a/wao-persistence/src/main/xmi/wao-model.properties +++ b/wao-persistence/src/main/xmi/wao-model.properties @@ -21,7 +21,7 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. # #L% ### -model.tagValue.version=4.3 +model.tagValue.version=5.0 model.tagValue.useEnumerationName=true # orderBy tagValues diff --git a/wao-services/src/main/java/fr/ifremer/wao/services/service/administration/UpdateWaoUserCommand.java b/wao-services/src/main/java/fr/ifremer/wao/services/service/administration/UpdateWaoUserCommand.java index d40c5dd..ef67ec0 100644 --- a/wao-services/src/main/java/fr/ifremer/wao/services/service/administration/UpdateWaoUserCommand.java +++ b/wao-services/src/main/java/fr/ifremer/wao/services/service/administration/UpdateWaoUserCommand.java @@ -257,4 +257,13 @@ public class UpdateWaoUserCommand implements Serializable{ public void setObsProgram(ObsProgram obsProgram) { this.obsProgram = obsProgram; } + + public boolean isGuestRoleAvailable() { + return ! obsProgram.isSclerochronology(); + } + + public boolean isProfessionalRoleAvailable() { + return ! obsProgram.isSclerochronology(); + } + } diff --git a/wao-web/src/main/webapp/WEB-INF/content/administration/edit-wao-user.jsp b/wao-web/src/main/webapp/WEB-INF/content/administration/edit-wao-user.jsp index 66e6cac..9466a5f 100644 --- a/wao-web/src/main/webapp/WEB-INF/content/administration/edit-wao-user.jsp +++ b/wao-web/src/main/webapp/WEB-INF/content/administration/edit-wao-user.jsp @@ -149,11 +149,11 @@ <s:checkbox name="updateWaoUserCommand.observer" label="%{getText('wao.ui.form.updateWaoUserCommand.observer')}" /> <s:checkbox name="updateWaoUserCommand.observerReadOnly" label="%{getText('wao.ui.form.updateWaoUserCommand.observerReadOnly')}" /> </s:if> - <s:if test="authenticatedWaoUser.authorizedToSetGuest"> + <s:if test="authenticatedWaoUser.authorizedToSetGuest && updateWaoUserCommand.guestRoleAvailable"> <s:checkbox name="updateWaoUserCommand.guest" label="%{getText('wao.ui.form.updateWaoUserCommand.guest')}" /> <s:checkbox name="updateWaoUserCommand.guestReadOnly" label="%{getText('wao.ui.form.updateWaoUserCommand.guestReadOnly')}" /> </s:if> - <s:if test="authenticatedWaoUser.authorizedToSetProfessional"> + <s:if test="authenticatedWaoUser.authorizedToSetProfessional && updateWaoUserCommand.professionalRoleAvailable"> <s:checkbox name="updateWaoUserCommand.professional" label="%{getText('wao.ui.form.updateWaoUserCommand.professional')}" /> <s:checkbox name="updateWaoUserCommand.professionalReadOnly" label="%{getText('wao.ui.form.updateWaoUserCommand.professionalReadOnly')}" /> <div id="defineCanReadBoats"> diff --git a/wao-web/src/main/webapp/WEB-INF/decorators/layout.jsp b/wao-web/src/main/webapp/WEB-INF/decorators/layout.jsp index 3f9cf39..7f9a39f 100644 --- a/wao-web/src/main/webapp/WEB-INF/decorators/layout.jsp +++ b/wao-web/src/main/webapp/WEB-INF/decorators/layout.jsp @@ -115,8 +115,6 @@ <div class="navbar"> <div class="navbar-inner"> <a class="brand" href="#"><span>WAO</span> <s:text name="%{obsProgram.getI18nKey()}"/></a> - - <%--<a class="brand" href="#">Wao <s:property value="%{getText(#obsProgram.getI18nKey())}" /></a>--%> <ul class="nav"> <li class="<decorator:getProperty property="page.newsMenuItemClass"/>"> <s:url namespace="/%{obsProgram.name().toLowerCase()}" action="news" id="newsUrl" /> @@ -130,29 +128,35 @@ <i class="fa fa-calendar"></i> <s:text name="wao.ui.page.SamplingPlan.title" /> </s:a> </li> - <s:if test="authenticatedWaoUser.authorizedToViewBoats"> - <li class="<decorator:getProperty property="page.boatsMenuItemClass"/>"> - <s:url namespace="/%{obsProgram.name().toLowerCase()}" action="boats" id="boatsUrl" /> - <s:a href="%{boatsUrl}"> - <i class="fa fa-anchor"></i> <s:text name="wao.ui.page.Boats.title" /> - </s:a> - </li> + <s:if test=" ! sclerochronology"> + <s:if test="authenticatedWaoUser.authorizedToViewBoats"> + <li class="<decorator:getProperty property="page.boatsMenuItemClass"/>"> + <s:url namespace="/%{obsProgram.name().toLowerCase()}" action="boats" id="boatsUrl" /> + <s:a href="%{boatsUrl}"> + <i class="fa fa-anchor"></i> <s:text name="wao.ui.page.Boats.title" /> + </s:a> + </li> + </s:if> </s:if> - <s:if test="authenticatedWaoUser.authorizedToViewContacts"> - <li class="<decorator:getProperty property="page.contactsMenuItemClass"/>"> - <s:url namespace="/%{obsProgram.name().toLowerCase()}" action="contacts" id="contactsUrl" /> - <s:a href="%{contactsUrl}"> - <i class="fa fa-stack-exchange"></i> <s:text name="wao.ui.page.Contacts.title" /> - </s:a> - </li> + <s:if test=" ! sclerochronology"> + <s:if test="authenticatedWaoUser.authorizedToViewContacts"> + <li class="<decorator:getProperty property="page.contactsMenuItemClass"/>"> + <s:url namespace="/%{obsProgram.name().toLowerCase()}" action="contacts" id="contactsUrl" /> + <s:a href="%{contactsUrl}"> + <i class="fa fa-stack-exchange"></i> <s:text name="wao.ui.page.Contacts.title" /> + </s:a> + </li> + </s:if> </s:if> - <s:if test="authenticatedWaoUser.authorizedToViewSynthesis"> - <li class="<decorator:getProperty property="page.synthesisMenuItemClass"/>"> - <s:url namespace="/%{obsProgram.name().toLowerCase()}" action="synthesis" id="synthesisUrl" /> - <s:a href="%{synthesisUrl}"> - <i class="fa fa-bar-chart-o"></i> <s:text name="wao.ui.page.Synthesis.title" /> - </s:a> - </li> + <s:if test=" ! sclerochronology"> + <s:if test="authenticatedWaoUser.authorizedToViewSynthesis"> + <li class="<decorator:getProperty property="page.synthesisMenuItemClass"/>"> + <s:url namespace="/%{obsProgram.name().toLowerCase()}" action="synthesis" id="synthesisUrl" /> + <s:a href="%{synthesisUrl}"> + <i class="fa fa-bar-chart-o"></i> <s:text name="wao.ui.page.Synthesis.title" /> + </s:a> + </li> + </s:if> </s:if> </ul> <ul class="nav pull-right"> -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository wao. See http://git.codelutin.com/wao.git commit fd59834846ebbb3791bedd46b9a6884483e60643 Author: Brendan Le Ny <bleny@codelutin.com> Date: Mon Dec 15 15:49:36 2014 +0100 Modification du modèle de la ligne du plan, introduction du service et de la vue pour le plan scléro, migration --- .../wao/entity/IndividualMeasurementStrategy.java | 39 ++ .../entity/SclerochronologySamplingContext.java | 38 ++ .../db/migration/V5_0__sclerochronology.sql | 5 + .../i18n/wao-persistence_en_GB.properties | 6 + .../i18n/wao-persistence_fr_FR.properties | 6 + wao-persistence/src/main/xmi/wao-model.zargo | Bin 61366 -> 61993 bytes .../service/SclerochronologySamplingPlan.java | 107 +++++ .../SclerochronologySamplingPlanBuilder.java | 326 +++++++++++++++ .../SclerochronologySamplingPlanService.java | 89 ++++ .../sclerochronology/SamplingPlanAction.java | 43 ++ .../SamplingPlanAction-conversion.properties | 1 + .../main/resources/i18n/wao-web_en_GB.properties | 4 + .../main/resources/i18n/wao-web_fr_FR.properties | 4 + .../content/sclerochronology/sampling-plan.jsp | 449 +++++++++++++++++++++ 14 files changed, 1117 insertions(+) diff --git a/wao-persistence/src/main/java/fr/ifremer/wao/entity/IndividualMeasurementStrategy.java b/wao-persistence/src/main/java/fr/ifremer/wao/entity/IndividualMeasurementStrategy.java new file mode 100644 index 0000000..0f69565 --- /dev/null +++ b/wao-persistence/src/main/java/fr/ifremer/wao/entity/IndividualMeasurementStrategy.java @@ -0,0 +1,39 @@ +package fr.ifremer.wao.entity; + +import static org.nuiton.i18n.I18n.n; + +/** + * Dans la sclérochronologie, représente les caractéristiques qu'il est demander de mesurer + * lors de l'échantillonnage d'un individu. + * + * @since 5.0 + */ +public enum IndividualMeasurementStrategy implements I18nAble { + + /** + * Taille, poids » et « » + */ + SIZE_WEIGHT(n("IndividualMeasurementStrategy.SIZE_WEIGHT")), + + /** + * Taille, poids, sexe + */ + SIZE_WEIGHT_SEX(n("IndividualMeasurementStrategy.SIZE_WEIGHT_SEX")), + + /** + * Taille, poids, sexe, maturité, âge + */ + SIZE_WEIGHT_SEX_MATURITY_AGE(n("IndividualMeasurementStrategy.SIZE_WEIGHT_SEX_MATURITY_AGE")); + + protected String i18nKey; + + IndividualMeasurementStrategy(String i18nKey) { + this.i18nKey = i18nKey; + } + + @Override + public String getI18nKey() { + return i18nKey; + } + +} diff --git a/wao-persistence/src/main/java/fr/ifremer/wao/entity/SclerochronologySamplingContext.java b/wao-persistence/src/main/java/fr/ifremer/wao/entity/SclerochronologySamplingContext.java new file mode 100644 index 0000000..68648a3 --- /dev/null +++ b/wao-persistence/src/main/java/fr/ifremer/wao/entity/SclerochronologySamplingContext.java @@ -0,0 +1,38 @@ +package fr.ifremer.wao.entity; + + +import static org.nuiton.i18n.I18n.n; + +/** + * Contexte dans lequel l'échantillonnage pour la sclérochronologie a été effectué. + * + * @since 5.0 + */ +public enum SclerochronologySamplingContext implements I18nAble { + + /** + * Campagne scientifique + */ + SCIENTIFIC_CAMPAIGN(n("SclerochronologySamplingContext.SCIENTIFIC_CAMPAIGN")), + + /** + * Échantillonnage en mer + */ + FISHING_TRIP(n("SclerochronologySamplingContext.FISHING_TRIP")), + + /** + * Échantillonnage à terre + */ + TERRESTRIAL_SAMPLING(n("SclerochronologySamplingContext.TERRESTRIAL_SAMPLING")); + + protected String i18nKey; + + SclerochronologySamplingContext(String i18nKey) { + this.i18nKey = i18nKey; + } + + @Override + public String getI18nKey() { + return i18nKey; + } +} diff --git a/wao-persistence/src/main/resources/db/migration/V5_0__sclerochronology.sql b/wao-persistence/src/main/resources/db/migration/V5_0__sclerochronology.sql index ee61e50..fe74d39 100644 --- a/wao-persistence/src/main/resources/db/migration/V5_0__sclerochronology.sql +++ b/wao-persistence/src/main/resources/db/migration/V5_0__sclerochronology.sql @@ -11,3 +11,8 @@ insert into UserProfile values ( true, uuid_in(md5(random()::text || now()::text)::cstring) ); + +alter table SampleRow add column species character varying(255) references Species(topiaId); +alter table SampleRow add column sclerochronologySamplingContext character varying(255); +alter table SampleRow add column individualMeasurementStrategy character varying(255); +alter table SampleRow add column sclerochronologySamplingContextInfo text; diff --git a/wao-persistence/src/main/resources/i18n/wao-persistence_en_GB.properties b/wao-persistence/src/main/resources/i18n/wao-persistence_en_GB.properties index 4334ea7..e4f6dfb 100644 --- a/wao-persistence/src/main/resources/i18n/wao-persistence_en_GB.properties +++ b/wao-persistence/src/main/resources/i18n/wao-persistence_en_GB.properties @@ -21,6 +21,9 @@ GlobalIndicatorValue.GOOD=Level 1 bonus GlobalIndicatorValue.NEUTRAL=Conform GlobalIndicatorValue.VERY_BAD=Level 2 penalty GlobalIndicatorValue.VERY_GOOD=Level 2 bonus +IndividualMeasurementStrategy.SIZE_WEIGHT=Size, weight +IndividualMeasurementStrategy.SIZE_WEIGHT_SEX=Size, weight, sex +IndividualMeasurementStrategy.SIZE_WEIGHT_SEX_MATURITY_AGE=Size, weight, sex, maturity, age LocationType.AUCTION=Auction LocationType.DISTRICT=District LocationType.PORT=Port @@ -37,6 +40,9 @@ SamplingStrategy.SIMULTANEOUS_ALL_SPECIES=Simultaneous \: All commercial species SamplingStrategy.SIMULTANEOUS_G1_G2_SPECIES=Simultaneous \: G1+G2 species SamplingStrategy.SIMULTANEOUS_G1_SPECIES=Simultaneous \: G1 species SamplingStrategy.SPECIFIC_STOCK=Specific stock +SclerochronologySamplingContext.FISHING_TRIP=Fishing trip +SclerochronologySamplingContext.SCIENTIFIC_CAMPAIGN=Scientific campaign +SclerochronologySamplingContext.TERRESTRIAL_SAMPLING=Terrestrial sampling StrategyValues.CONTACTS_STATES=Contact states by boat district StrategyValues.CONTACTS_STATES_MOTIFS=Refusal motives StrategyValues.CONTACTS_STATES_SEABOARDS=Contact states by seaboard diff --git a/wao-persistence/src/main/resources/i18n/wao-persistence_fr_FR.properties b/wao-persistence/src/main/resources/i18n/wao-persistence_fr_FR.properties index cf72839..972c780 100644 --- a/wao-persistence/src/main/resources/i18n/wao-persistence_fr_FR.properties +++ b/wao-persistence/src/main/resources/i18n/wao-persistence_fr_FR.properties @@ -21,6 +21,9 @@ GlobalIndicatorValue.GOOD=Bonus de niveau 1 GlobalIndicatorValue.NEUTRAL=Conforme au cahier des charges GlobalIndicatorValue.VERY_BAD=Pénalité de niveau 2 GlobalIndicatorValue.VERY_GOOD=Bonus de niveau 2 +IndividualMeasurementStrategy.SIZE_WEIGHT=Poids, taille +IndividualMeasurementStrategy.SIZE_WEIGHT_SEX=Poids, taille, sexe +IndividualMeasurementStrategy.SIZE_WEIGHT_SEX_MATURITY_AGE=Poids, taille, sexe, maturité, âge LocationType.AUCTION=Criée LocationType.DISTRICT=Quartier maritime LocationType.PORT=Port @@ -37,6 +40,9 @@ SamplingStrategy.SIMULTANEOUS_ALL_SPECIES=Simultané \: Toutes espèces commerci SamplingStrategy.SIMULTANEOUS_G1_G2_SPECIES=Simultané \: espèces G1+G2 SamplingStrategy.SIMULTANEOUS_G1_SPECIES=Simultané \: espèces G1 SamplingStrategy.SPECIFIC_STOCK=Stock spécifique +SclerochronologySamplingContext.FISHING_TRIP=Échantillonnage en mer +SclerochronologySamplingContext.SCIENTIFIC_CAMPAIGN=Campagne scientifique +SclerochronologySamplingContext.TERRESTRIAL_SAMPLING=Échantillonnage à terre StrategyValues.CONTACTS_STATES=États des contacts selon le quartier maritime StrategyValues.CONTACTS_STATES_MOTIFS=Motifs de refus StrategyValues.CONTACTS_STATES_SEABOARDS=États des contacts selon la façade maritime diff --git a/wao-persistence/src/main/xmi/wao-model.zargo b/wao-persistence/src/main/xmi/wao-model.zargo index 5f27d3a..5535ef4 100644 Binary files a/wao-persistence/src/main/xmi/wao-model.zargo and b/wao-persistence/src/main/xmi/wao-model.zargo differ diff --git a/wao-services/src/main/java/fr/ifremer/wao/services/service/SclerochronologySamplingPlan.java b/wao-services/src/main/java/fr/ifremer/wao/services/service/SclerochronologySamplingPlan.java new file mode 100644 index 0000000..d23fefd --- /dev/null +++ b/wao-services/src/main/java/fr/ifremer/wao/services/service/SclerochronologySamplingPlan.java @@ -0,0 +1,107 @@ +package fr.ifremer.wao.services.service; + +/* + * #%L + * Wao :: Services + * %% + * Copyright (C) 2009 - 2014 Ifremer + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ + +import fr.ifremer.wao.WaoUtils; +import fr.ifremer.wao.entity.ObsProgram; +import fr.ifremer.wao.entity.SampleRow; + +import java.util.Collection; +import java.util.Date; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.Set; + +public class SclerochronologySamplingPlan extends SamplingPlan implements Iterable<SamplingPlan.SamplingPlanFacadePart> { + + public SclerochronologySamplingPlan(List<Date> months, Collection<SamplingPlanFacadePart> facadeParts, Map<Date, Effort> totalEffortInObservationsPerMonths, Effort highTotalEffortInObservations, SampleRowsFilterValues filterValues, Set<String> sampleRowIds) { + super(months, facadeParts, totalEffortInObservationsPerMonths, highTotalEffortInObservations, filterValues, sampleRowIds); + } + + public static class SclerochronologySamplingPlanSampleRowPart extends SamplingPlanSampleRowPart { + + protected String samplingContext; + + protected String samplingContextInfo; + + protected String individualMeasurementStrategy; + + protected String species; + + public SclerochronologySamplingPlanSampleRowPart(Locale locale, Map<Date, Effort> effortInObservationsPerMonths, SampleRow sampleRow, long sampleRowContactCounts) { + super(locale, effortInObservationsPerMonths, sampleRow, sampleRowContactCounts); + species = sampleRow.getSpecies().getVernacularName(); + samplingContext = WaoUtils.l(locale, sampleRow.getSclerochronologySamplingContext()); + samplingContextInfo = sampleRow.getSclerochronologySamplingContextInfo(); + individualMeasurementStrategy = WaoUtils.l(locale, sampleRow.getIndividualMeasurementStrategy()); + } + + public String getSamplingContextInfo() { + return samplingContextInfo; + } + + public String getIndividualMeasurementStrategy() { + return individualMeasurementStrategy; + } + + public String getSpecies() { + return species; + } + + public String getSamplingContext() { + return samplingContext; + } + + @Override + public Map<String, String> getDcf5CodesAndDescriptions() { + throw new UnsupportedOperationException("not in " + ObsProgram.SCLEROCHRONOLOGY); + } + + @Override + public String getProfessionMeshSize() { + throw new UnsupportedOperationException("not in " + ObsProgram.SCLEROCHRONOLOGY); + } + + @Override + public String getProfessionSize() { + throw new UnsupportedOperationException("not in " + ObsProgram.SCLEROCHRONOLOGY); + } + + @Override + public String getProfessionOther() { + throw new UnsupportedOperationException("not in " + ObsProgram.SCLEROCHRONOLOGY); + } + + @Override + public String getProfessionLibelle() { + throw new UnsupportedOperationException("not in " + ObsProgram.SCLEROCHRONOLOGY); + } + + @Override + public String getProfessionSpecies() { + throw new UnsupportedOperationException("not in " + ObsProgram.SCLEROCHRONOLOGY); + } + + } + +} \ No newline at end of file diff --git a/wao-services/src/main/java/fr/ifremer/wao/services/service/SclerochronologySamplingPlanBuilder.java b/wao-services/src/main/java/fr/ifremer/wao/services/service/SclerochronologySamplingPlanBuilder.java new file mode 100644 index 0000000..aed9964 --- /dev/null +++ b/wao-services/src/main/java/fr/ifremer/wao/services/service/SclerochronologySamplingPlanBuilder.java @@ -0,0 +1,326 @@ +package fr.ifremer.wao.services.service; + +/* + * #%L + * Wao :: Services + * %% + * Copyright (C) 2009 - 2014 Ifremer + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ + +import com.google.common.base.Function; +import com.google.common.base.Optional; +import com.google.common.collect.Ordering; +import fr.ifremer.wao.SampleRowsFilter; +import fr.ifremer.wao.entity.ObsProgram; +import fr.ifremer.wao.entity.SampleRow; +import fr.ifremer.wao.entity.SampleRows; +import org.apache.commons.lang3.mutable.MutableInt; +import org.nuiton.util.PeriodDates; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Date; +import java.util.HashSet; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.Set; +import java.util.TreeMap; + +/** + * @since 5.0 + */ +public class SclerochronologySamplingPlanBuilder { + + /** + * Incoming filter used. + */ + protected SampleRowsFilter sampleRowsFilter; + + /** + * Bean to hold all values that user can select to fill {@link fr.ifremer.wao.SampleRowsFilter}. + */ + protected SampleRowsFilterValues sampleRowsFilterValues; + + /** + * Ids of all the sample rows included in this sampling plan. + */ + protected Set<String> sampleRowIds; + + /** + * List of month computed from the filter. + */ + protected List<Date> months; + + /** + * Dictionnary of facades indexed by their facade name. + */ + protected Map<String, FacadeContext> facadeMap; + + /** + * To compute the high total expected. + * + * @see fr.ifremer.wao.services.service.SclerochronologySamplingPlan#highTotalEffortInObservations + */ + protected int highTotalExpected; + + /** + * To compute the high total real. + * + * @see fr.ifremer.wao.services.service.SclerochronologySamplingPlan#highTotalEffortInObservations + */ + protected int highTotalReal; + + /** + * To compute the high total estimated. + * + * @see fr.ifremer.wao.services.service.SclerochronologySamplingPlan#highTotalEffortInObservations + */ + protected int highTotalEstimated; + + /** + * To compute by month the total of expected tides. + * + * @see fr.ifremer.wao.services.service.SamplingPlan.Effort#expected + */ + protected Map<Date, MutableInt> totalExpectedForMonths; + + /** + * To compute by month the total of expected tides. + * + * @see fr.ifremer.wao.services.service.SamplingPlan.Effort#estimated + */ + protected Map<Date, MutableInt> totalEstimatedForMonths; + + /** + * To compute by month the total of real tides. + * + * @see fr.ifremer.wao.services.service.SamplingPlan.Effort#real + */ + protected Map<Date, MutableInt> totalRealForMonths; + + public SclerochronologySamplingPlanBuilder(Locale locale, + Optional<String> optionalCompanyId, + SampleRowsFilter sampleRowsFilter) { + this.sampleRowsFilter = sampleRowsFilter; + this.sampleRowsFilterValues = new SampleRowsFilterValues(locale, ObsProgram.SCLEROCHRONOLOGY, optionalCompanyId); + this.sampleRowIds = new HashSet<>(); + this.facadeMap = new TreeMap<>(); + this.totalExpectedForMonths = new TreeMap<>(); + this.totalRealForMonths = new TreeMap<>(); + this.totalEstimatedForMonths = new TreeMap<>(); + + PeriodDates periodDates = new PeriodDates(sampleRowsFilter.getPeriodFrom(), + sampleRowsFilter.getPeriodTo()); + this.months = periodDates.getMonths(); + } + + public SclerochronologySamplingPlanBuilder addSampleRow(SampleRow sampleRow, long sampleRowContactCounts) { + + String facade = sampleRow.getFacade(); + FacadeContext facadeContext = facadeMap.get(facade); + + if (facadeContext == null) { + + // register a new facade + facadeContext = new FacadeContext(facade); + facadeMap.put(facade, facadeContext); + } + + String sectors = sampleRow.getSectors(); + + // get sector context + SectorContext sectorPart = facadeContext.getOrAddSectorContext(sectors); + + // compute nb tides per month + Map<Date, SamplingPlan.Effort> effortInObservationsPerMonths = getEffortInObservationsPerMonths(sampleRow); + + // add sample row + sectorPart.addSampleRow(sampleRowsFilterValues.getLocale(), + sampleRow, + effortInObservationsPerMonths, + sampleRowContactCounts); + + sampleRowsFilterValues.addSampleRow(sampleRow); + + sampleRowIds.add(sampleRow.getTopiaId()); + + return this; + } + + public SclerochronologySamplingPlan toPlan() { + + // Get facade parts + Collection<SamplingPlan.SamplingPlanFacadePart> facadeParts = new ArrayList<>(); + for (FacadeContext facadeContext : facadeMap.values()) { + SamplingPlan.SamplingPlanFacadePart facadePart = facadeContext.toBean(); + facadeParts.add(facadePart); + } + + // Sort them + Collection<SamplingPlan.SamplingPlanFacadePart> sortedFacades = Ordering.natural().onResultOf(new Function<SamplingPlan.SamplingPlanFacadePart, String>() { + public String apply(SamplingPlan.SamplingPlanFacadePart input) { + return input.getFacade(); + } + }).immutableSortedCopy(facadeParts); + + // Get statistics + Map<Date, SamplingPlan.Effort> statisticsMap = new TreeMap<>(); + for (Date month : months) { + + MutableInt totalExpected = totalExpectedForMonths.get(month); + MutableInt totalReal = totalRealForMonths.get(month); + MutableInt totalEstimated = totalEstimatedForMonths.get(month); + SamplingPlan.Effort planStatistics = + new SamplingPlan.Effort(totalExpected == null ? null : totalExpected.toInteger(), + totalReal == null ? null : totalReal.toInteger(), + totalEstimated == null ? null : totalEstimated.toInteger()); + statisticsMap.put(month, planStatistics); + } + + SamplingPlan.Effort highTotals = new SamplingPlan.Effort(highTotalExpected, highTotalReal, highTotalEstimated); + + SclerochronologySamplingPlan result = new SclerochronologySamplingPlan(months, + sortedFacades, + statisticsMap, + highTotals, + sampleRowsFilterValues, + sampleRowIds); + return result; + } + + protected Map<Date, SamplingPlan.Effort> getEffortInObservationsPerMonths(SampleRow sampleRow) { + Map<Date, SamplingPlan.Effort> result = new TreeMap<>(); + for (Date month : months) { + Integer expectedTidesValue = SampleRows.getExpectedTidesValue(sampleRow, month); + if (expectedTidesValue != null) { + MutableInt mutableInt = totalExpectedForMonths.get(month); + if (mutableInt == null) { + totalExpectedForMonths.put(month, mutableInt = new MutableInt()); + } + mutableInt.add(expectedTidesValue); + highTotalExpected += expectedTidesValue; + } + Integer realTidesValue = SampleRows.getRealTidesValue(sampleRow, month); + if (realTidesValue != null) { + MutableInt mutableInt = totalRealForMonths.get(month); + if (mutableInt == null) { + totalRealForMonths.put(month, mutableInt = new MutableInt()); + } + mutableInt.add(realTidesValue); + highTotalReal += realTidesValue; + } + + Integer estimatedTidesValue = SampleRows.getEstimatedTidesValue(sampleRow, month); + if (estimatedTidesValue != null) { + MutableInt mutableInt = totalEstimatedForMonths.get(month); + if (mutableInt == null) { + totalEstimatedForMonths.put(month, mutableInt = new MutableInt()); + } + mutableInt.add(estimatedTidesValue); + highTotalEstimated += estimatedTidesValue; + } + result.put(month, new SamplingPlan.Effort(expectedTidesValue, + realTidesValue, + estimatedTidesValue)); + + } + return result; + } + + protected static class FacadeContext { + + protected String facade; + + protected Map<String, SectorContext> sectorMap; + + protected FacadeContext(String facade) { + this.facade = facade; + this.sectorMap = new TreeMap<>(); + } + + protected SectorContext getOrAddSectorContext(String sectors) { + SectorContext sectorPart = sectorMap.get(sectors); + if (sectorPart == null) { + + // register a new sector + sectorPart = new SectorContext(sectors); + sectorMap.put(sectors, sectorPart); + } + return sectorPart; + } + + protected SamplingPlan.SamplingPlanFacadePart toBean() { + + // get sector parts + Collection<SamplingPlan.SamplingPlanSectorPart> sectorParts = new ArrayList<>(); + for (SectorContext sectorContext : sectorMap.values()) { + SamplingPlan.SamplingPlanSectorPart sectorPart = sectorContext.toBean(); + sectorParts.add(sectorPart); + } + // sort them + Collection<SamplingPlan.SamplingPlanSectorPart> sortedSectors = Ordering.natural().onResultOf(new Function<SamplingPlan.SamplingPlanSectorPart, String>() { + public String apply(SamplingPlan.SamplingPlanSectorPart input) { + return input.getSectors(); + } + }).immutableSortedCopy(sectorParts); + SamplingPlan.SamplingPlanFacadePart result = + new SamplingPlan.SamplingPlanFacadePart(facade, sortedSectors); + return result; + } + } + + protected static class SectorContext { + + protected String sectors; + + protected Collection<SclerochronologySamplingPlan.SclerochronologySamplingPlanSampleRowPart> rows; + + protected SectorContext(String sectors) { + this.sectors = sectors; + this.rows = new ArrayList<>(); + } + + protected ObsMerSamplingPlan.SamplingPlanSampleRowPart addSampleRow(Locale locale, + SampleRow row, + Map<Date, SamplingPlan.Effort> effortInObservationsPerMonths, + long sampleRowContactCounts) { + + SclerochronologySamplingPlan.SclerochronologySamplingPlanSampleRowPart rowPart = + new SclerochronologySamplingPlan.SclerochronologySamplingPlanSampleRowPart( + locale, + effortInObservationsPerMonths, + row, + sampleRowContactCounts); + rows.add(rowPart); + + return rowPart; + } + + protected SamplingPlan.SamplingPlanSectorPart toBean() { + + Collection<SclerochronologySamplingPlan.SclerochronologySamplingPlanSampleRowPart> sortedRows = Ordering.natural().onResultOf(new Function<SclerochronologySamplingPlan.SclerochronologySamplingPlanSampleRowPart, String>() { + public String apply(SclerochronologySamplingPlan.SclerochronologySamplingPlanSampleRowPart input) { + return input.getCode(); + } + }).immutableSortedCopy(rows); + SamplingPlan.SamplingPlanSectorPart result = + new SamplingPlan.SamplingPlanSectorPart(sectors, sortedRows); + return result; + } + } +} diff --git a/wao-services/src/main/java/fr/ifremer/wao/services/service/SclerochronologySamplingPlanService.java b/wao-services/src/main/java/fr/ifremer/wao/services/service/SclerochronologySamplingPlanService.java new file mode 100644 index 0000000..f0cd05f --- /dev/null +++ b/wao-services/src/main/java/fr/ifremer/wao/services/service/SclerochronologySamplingPlanService.java @@ -0,0 +1,89 @@ +package fr.ifremer.wao.services.service; + +/* + * #%L + * Wao :: Services + * %% + * Copyright (C) 2009 - 2014 Ifremer + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ + +import com.google.common.base.Optional; +import com.google.common.cache.Cache; +import fr.ifremer.wao.SampleRowsFilter; +import fr.ifremer.wao.entity.ContactTopiaDao; +import fr.ifremer.wao.entity.SampleRow; +import fr.ifremer.wao.entity.SampleRowTopiaDao; +import fr.ifremer.wao.services.AuthenticatedWaoUser; + +import java.util.List; + +public class SclerochronologySamplingPlanService extends SamplingPlanService { + + public SclerochronologySamplingPlan getSamplingPlan( + AuthenticatedWaoUser authenticatedWaoUser, + SampleRowsFilter sampleRowsFilter) { + + Optional<String> optionalCompanyId = Optional.absent(); + if (authenticatedWaoUser.isCoordinatorOrObserver()) { + optionalCompanyId = Optional.of(authenticatedWaoUser.getCompany().getTopiaId()); + } + + SamplingPlanCacheKey samplingPlanCacheKey = + new SamplingPlanCacheKey( + serviceContext.getLocale(), + optionalCompanyId, + sampleRowsFilter); + + Cache<SamplingPlanCacheKey, SamplingPlan> samplingPlansCache = + serviceContext.getSamplingPlansCache(); + + SclerochronologySamplingPlan result = (SclerochronologySamplingPlan) samplingPlansCache.getIfPresent(samplingPlanCacheKey); + + if (result == null) { + + SampleRowTopiaDao dao = getSampleRowDao(); + ContactTopiaDao contactDao = getContactDao(); + + // recuperation des lignes du plan + List<SampleRow> sampleRows = dao.findAll(sampleRowsFilter); + + // creation du plan d'echantillonnage + SclerochronologySamplingPlanBuilder builder = new SclerochronologySamplingPlanBuilder( + serviceContext.getLocale(), + optionalCompanyId, + sampleRowsFilter); + + for (SampleRow sampleRow : sampleRows) { + + long sampleRowContactCounts = contactDao.forSampleRowEquals(sampleRow).count(); + + // ajout de la ligne au build de plan + builder.addSampleRow(sampleRow, sampleRowContactCounts); + + } + + result = builder.toPlan(); + + samplingPlansCache.put(samplingPlanCacheKey.clone(), result); + + } + + return result; + + } + +} diff --git a/wao-web/src/main/java/fr/ifremer/wao/web/action/sclerochronology/SamplingPlanAction.java b/wao-web/src/main/java/fr/ifremer/wao/web/action/sclerochronology/SamplingPlanAction.java new file mode 100644 index 0000000..fe9f68a --- /dev/null +++ b/wao-web/src/main/java/fr/ifremer/wao/web/action/sclerochronology/SamplingPlanAction.java @@ -0,0 +1,43 @@ +package fr.ifremer.wao.web.action.sclerochronology; + +/* + * #%L + * Wao :: Web + * %% + * Copyright (C) 2009 - 2014 Ifremer + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ + +import fr.ifremer.wao.services.service.SclerochronologySamplingPlan; +import fr.ifremer.wao.services.service.SclerochronologySamplingPlanService; +import fr.ifremer.wao.web.action.AbstractSamplingPlanAction; + +public class SamplingPlanAction extends AbstractSamplingPlanAction { + + protected SclerochronologySamplingPlanService service; + + public void setService(SclerochronologySamplingPlanService service) { + this.service = service; + } + + @Override + protected SclerochronologySamplingPlan samplingPlan() { + + return service.getSamplingPlan(getAuthenticatedWaoUser(), filter); + + } + +} diff --git a/wao-web/src/main/resources/fr/ifremer/wao/web/action/sclerochronology/SamplingPlanAction-conversion.properties b/wao-web/src/main/resources/fr/ifremer/wao/web/action/sclerochronology/SamplingPlanAction-conversion.properties new file mode 100644 index 0000000..977bee2 --- /dev/null +++ b/wao-web/src/main/resources/fr/ifremer/wao/web/action/sclerochronology/SamplingPlanAction-conversion.properties @@ -0,0 +1 @@ +filter=org.nuiton.web.struts2.converters.JsonConverter diff --git a/wao-web/src/main/resources/i18n/wao-web_en_GB.properties b/wao-web/src/main/resources/i18n/wao-web_en_GB.properties index da6df47..e540698 100644 --- a/wao-web/src/main/resources/i18n/wao-web_en_GB.properties +++ b/wao-web/src/main/resources/i18n/wao-web_en_GB.properties @@ -253,6 +253,7 @@ wao.ui.field.SampleRow.elligibleBoat=Eligible boats wao.ui.field.SampleRow.expectedDate=Date wao.ui.field.SampleRow.fishingZones=Fishing zone(s) wao.ui.field.SampleRow.fishingZonesInfos=Fishing zone(s) details +wao.ui.field.SampleRow.individualMeasurementStrategy=Individual measurement strategy wao.ui.field.SampleRow.libelle=Labels wao.ui.field.SampleRow.meshSize=Mesh size wao.ui.field.SampleRow.nbObservants=Number of observers @@ -266,7 +267,10 @@ wao.ui.field.SampleRow.profession=Profession wao.ui.field.SampleRow.professionCode=Profession code wao.ui.field.SampleRow.programName=Program wao.ui.field.SampleRow.regionIfremer=Region +wao.ui.field.SampleRow.samplingContext= wao.ui.field.SampleRow.samplingStrategy=Sampling strategy +wao.ui.field.SampleRow.sclerochronologySamplingContext=Context +wao.ui.field.SampleRow.sclerochronologySamplingContextInfo=Context (details) wao.ui.field.SampleRow.size=Boat size wao.ui.field.SampleRow.species=Species wao.ui.field.SampleRow.terrestrialLocation=Maritime district diff --git a/wao-web/src/main/resources/i18n/wao-web_fr_FR.properties b/wao-web/src/main/resources/i18n/wao-web_fr_FR.properties index 5f60f26..0726cc6 100644 --- a/wao-web/src/main/resources/i18n/wao-web_fr_FR.properties +++ b/wao-web/src/main/resources/i18n/wao-web_fr_FR.properties @@ -254,6 +254,7 @@ wao.ui.field.SampleRow.elligibleBoat=Navires éligibles wao.ui.field.SampleRow.expectedDate=Date wao.ui.field.SampleRow.fishingZones=Zone(s) de pêche wao.ui.field.SampleRow.fishingZonesInfos=Autres informations +wao.ui.field.SampleRow.individualMeasurementStrategy=Paramètres à mesurer wao.ui.field.SampleRow.libelle=Libellé wao.ui.field.SampleRow.meshSize=Maillage wao.ui.field.SampleRow.nbObservants=Nombre d'observateurs @@ -267,7 +268,10 @@ wao.ui.field.SampleRow.profession=Métier wao.ui.field.SampleRow.professionCode=Code métier wao.ui.field.SampleRow.programName=Programme wao.ui.field.SampleRow.regionIfremer=Région +wao.ui.field.SampleRow.samplingContext= wao.ui.field.SampleRow.samplingStrategy=Stratégie d'échantillonnage +wao.ui.field.SampleRow.sclerochronologySamplingContext=Contexte +wao.ui.field.SampleRow.sclerochronologySamplingContextInfo=Contexte (complément) wao.ui.field.SampleRow.size=Taille du navire wao.ui.field.SampleRow.species=Espèces cibles wao.ui.field.SampleRow.terrestrialLocation=Quartier maritime diff --git a/wao-web/src/main/webapp/WEB-INF/content/sclerochronology/sampling-plan.jsp b/wao-web/src/main/webapp/WEB-INF/content/sclerochronology/sampling-plan.jsp new file mode 100644 index 0000000..30dd0c5 --- /dev/null +++ b/wao-web/src/main/webapp/WEB-INF/content/sclerochronology/sampling-plan.jsp @@ -0,0 +1,449 @@ +<%-- + #%L + Wao :: Web + %% + Copyright (C) 2009 - 2014 Ifremer + %% + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + #L% + --%> +<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%> +<%@taglib uri="/struts-tags" prefix="s" %> + +<html> + + <head> + <title> + <s:text name="wao.ui.page.SamplingPlan.title" /> + </title> + + <script> + + $(document).ready(function () { + + // var sampleRowsFilterController = new FilterController(WAO.SAMPLE_ROWS_FILTER_VALUES_JSON_URL, $('#sampling-plan-filters-form')); + // sampleRowsFilterController.init(); + + var sampleRowsFilterMappings = [ + <s:if test="authenticatedWaoUser.authorizedToViewOtherCompanies"> + { + filterName: 'companyIds', + filterLabel: "<s:text name="wao.ui.entity.Company"/>", + filterValuesField: 'companies', + }, + </s:if> + { + filterName: 'programNames', + filterLabel: "<s:text name="wao.ui.field.SampleRow.programName"/>", + filterValuesField: 'programNames', + }, + { + filterName: 'sampleRowCodes', + filterLabel: "<s:text name="wao.ui.field.SampleRow.code"/>", + filterValuesField: 'sampleRowCodes', + }, + { + filterName: 'fishingZoneFacadeNames', + filterLabel: "<s:text name="wao.ui.field.FishingZone.facadeName"/>", + filterValuesField: 'fishingZoneFacadeNames', + }, + { + filterName: 'fishingZoneSectorNames', + filterLabel: "<s:text name="wao.ui.field.FishingZone.sectorName"/>", + filterValuesField: 'fishingZoneSectorNames', + }, + { + filterName: 'samplingContext', + filterLabel: "<s:text name="wao.ui.field.SampleRow.sclerochronologySamplingContext"/>", + filterValuesField: 'samplingContexts', + }, + { + filterName: 'individualMeasurementStrategy', + filterLabel: "<s:text name="wao.ui.field.SampleRow.individualMeasurementStrategy"/>", + filterValuesField: 'individualMeasurementStrategies', + }, + { + filterName: 'species', + filterLabel: "<s:text name="wao.ui.field.SampleRow.species"/>", + filterValuesField: 'species' + } + ]; + + filter = <s:property value="filter" escapeHtml="false"/>; + + sampleRowsFilterController2 = new FilterController2(sampleRowsFilterMappings, filter, WAO.SAMPLE_ROWS_FILTER_VALUES_JSON_URL, $('#sampling-plan-filters-form fieldset.extra-filters')); + sampleRowsFilterController2.init(); + + $('#switch-estimated-real').click(function () { + $('#switch-estimated-real').toggleClass('show-estimated').toggleClass('show-real'); + $('table.sampling-plan').toggleClass('show-estimated').toggleClass('show-real'); + $('.estimated-differ-from-real').effect( "highlight", "slow" ) + }); + + var $views = $('#switch-compact-full-view, table.sampling-plan'); + $views.toggleCompactFullView(WAO.getCookie().samplingPlanFullView); + + $('#switch-compact-full-view').click(function () { + WAO.getCookie().samplingPlanFullView = ! WAO.getCookie().samplingPlanFullView; + $views.toggleCompactFullView(WAO.getCookie().samplingPlanFullView); + }); + + }); + + </script> + + </head> + + <content tag="mainClass">large</content> + <content tag="samplingPlanMenuItemClass">active</content> + + <s:if test="authenticatedWaoUser.authorizedToEditSamplingPlan"> + <content tag="administrationMenuOtherOptions"> + <li> + <s:url action="edit-sample-row!input" id="createSampleRow"/> + <s:a href="%{createSampleRow}"> + <i class="icon-plus"></i> <s:text name="wao.ui.action.createSampleRow"/> + </s:a> + </li> + </content> + </s:if> + + <s:form method="GET" id="sampling-plan-filters-form" cssClass="filters-form"> + + <fieldset class="filters-group"> + + <s:textfield name="filter.periodFrom" + label="%{getText('wao.ui.form.periodFrom')}" + placeholder="%{getFilterPeriodFromPlaceholder()}" + cssClass="input-small" /> + + <s:textfield name="filter.periodTo" + label="%{getText('wao.ui.form.period.to')}" + placeholder="%{getFilterPeriodToPlaceholder()}" + cssClass="input-small" /> + + </fieldset> + + <fieldset class="extra-filters"> + + </fieldset> + + <div class="form-actions"> + + <s:submit type="button" action="sampling-plan!applyFilter" cssClass="btn btn-primary"> + <i class="icon-filter"></i> <s:text name="wao.ui.action.filter" /> + </s:submit> + + <s:submit type="button" action="sampling-plan!resetFilter" cssClass="btn"> + <i class="icon-trash"></i> <s:text name="wao.ui.action.reset"/> + </s:submit> + + <s:if test="authenticatedWaoUser.authorizedToExportSamplingPlan"> + <s:submit action="export-sampling-plan" type="button" cssClass="btn"> + <i class="icon-download"></i> <s:text name="wao.ui.action.csvExport" /> + </s:submit> + </s:if> + + </div> + + </s:form> + + <div class="sticky-buttons"> + <button type="button" id="switch-compact-full-view" class="btn"> + <span class="only-in-compact-view"> + <i class="fa fa-expand"></i><span class="only-on-hover"> <s:text name="wao.ui.action.switchToFullView" /></span> + </span> + <span class="only-in-full-view"> + <i class="fa fa-compress"></i><span class="only-on-hover"> <s:text name="wao.ui.action.switchToCompactView" /></span> + </span> + </button> + + <s:if test="authenticatedWaoUser.authorizedToViewSamplingPlanReal"> + <button type="button" id="switch-estimated-real" class="btn show-estimated"> + <span class="estimated"> + <i class="fa fa-adjust"></i><span class="only-on-hover"> <s:text name="wao.ui.action.viewReal" /></span> + </span> + <span class="real"> + <i class="fa fa-adjust"></i><span class="only-on-hover"> <s:text name="wao.ui.action.viewEstimated" /></span> + </span> + </button> + </s:if> + </div> + +<s:if test="authenticatedWaoUser.authorizedToViewOtherCompanies"> + <s:set var="nbColumnsForProfessionInFullView" value="10" /> +</s:if> +<s:else> + <s:set var="nbColumnsForProfessionInFullView" value="9" /> +</s:else> +<s:set var="nbColumnsForProfessionInCompactView" value="6" /> +<s:set var="nbColumnsForMonths" value="%{samplingPlan.months.size() + 1}" /> +<s:set var="nbColumnsForOther" value="2" /> +<s:set var="nbColumnsTotalInFullView" value="%{#nbColumnsForProfessionInFullView + #nbColumnsForMonths + #nbColumnsForOther}" /> +<s:set var="nbColumnsTotalInCompactView" value="%{#nbColumnsForProfessionInCompactView + #nbColumnsForMonths + #nbColumnsForOther}" /> + + <table id="sampling-plan" class="large-table sampling-plan show-estimated"> + <thead> + <tr> + <th colspan="<s:property value="#nbColumnsForProfessionInFullView" />" class="only-in-full-view"> + <s:text name="wao.ui.samplingPlan.sampledProfessions" /> + </th> + <th colspan="<s:property value="#nbColumnsForProfessionInCompactView" />" class="only-in-compact-view"> + <s:text name="wao.ui.samplingPlan.sampledProfessions" /> + </th> + <th colspan="${nbColumnsForMonths}"> + <s:text name="wao.ui.samplingPlan.effort" /> + + <s:if test="authenticatedWaoUser.authorizedToViewSamplingPlanReal"> + [ + <span class="estimated"> + (<s:text name="wao.ui.samplingPlan.actual" /> + <s:text name="wao.ui.samplingPlan.estimated" />) + </span> + <span class="real"> + <s:text name="wao.ui.samplingPlan.actual" /> + </span> + / + <s:text name="wao.ui.samplingPlan.expected" /> + ] + </s:if> + </th> + <th colspan="${nbColumnsForOther}"><s:text name="wao.ui.misc.others" /></th> + </tr> + <tr> + <!-- Profession columns --> + <th><s:text name="wao.ui.field.SampleRow.code"/></th> + <th><s:text name="wao.ui.samplingPlan.program"/></th> + <s:if test="authenticatedWaoUser.authorizedToViewOtherCompanies"> + <th class="only-in-full-view"> + <s:text name="wao.ui.entity.Organisation"/> + </th> + </s:if> + <th><s:text name="wao.ui.entity.FishingZone"/></th> + <th class="only-in-full-view"><s:text name="wao.ui.samplingPlan.fishingZoneInfo"/></th> + <th><s:text name="wao.ui.field.SampleRow.sclerochronologySamplingContext"/></th> + <th><s:text name="wao.ui.field.SampleRow.sclerochronologySamplingContextInfo"/></th> + <th><s:text name="wao.ui.field.SampleRow.individualMeasurementStrategy"/></th> + <th class="only-in-full-view"><s:text name="wao.ui.field.SampleRow.periodBegin"/></th> + <th class="only-in-full-view"><s:text name="wao.ui.field.SampleRow.periodEnd"/></th> + + <!-- Months columns --> + <s:iterator value="samplingPlan.months" var="month"> + <th class="effort <s:if test="isCurrentMonth(#month)"> now</s:if>"> + <span class="month"><s:property value="%{formatDateMonth(#month)}"/></span> + <span class="year"><s:property value="%{formatDateYear(#month)}"/></span> + </th> + </s:iterator> + <th><s:text name="wao.ui.misc.total"/></th> + <!-- Other columns --> + <th><s:text name="wao.ui.misc.comment"/></th> + <th><s:text name="wao.ui.samplingPlan.actions"/></th> + </tr> + </thead> + <tbody> + +<%--Iterate on Facades--%> +<s:iterator value="samplingPlan" var="samplingPlanFacade"> + <tr class="facade-row"> + <th colspan="${nbColumnsTotalInFullView}" class="facade only-in-full-view"> + <s:property value="%{#samplingPlanFacade.facade}"/> + </th> + <th colspan="${nbColumnsTotalInCompactView}" class="facade only-in-compact-view"> + <s:property value="%{#samplingPlanFacade.facade}"/> + </th> + </tr> +<%--Iterate on Sectors --%> +<s:iterator value="samplingPlanFacade" var="samplingPlanSector"> + <tr class="sector-row"> + <th colspan="${nbColumnsTotalInFullView}" class="sector only-in-full-view"> + <s:property value="%{#samplingPlanSector.sectors}"/> + </th> + </tr> + <tr class="sector-row"> + <th colspan="${nbColumnsTotalInCompactView}" class="sector only-in-compact-view"> + <s:property value="%{#samplingPlanSector.sectors}"/> + </th> + </tr> +<%--Iterate on SampleRows --%> +<s:iterator value="samplingPlanSector" var="samplingPlanRow"> + <tr class="sample-row-row<s:if test="sampleRowId.equals(sampleRowToHighlightId)"> highlight</s:if>"> + <th> + <s:property value="code" /> + <s:if test="recentlyUpdated"> + <span class="label label-important"> + <s:text name="wao.ui.misc.recentUpdate" /> + </span> + </s:if> + </th> + <td><s:property value="programName" /></td> + <s:if test="authenticatedWaoUser.authorizedToViewOtherCompanies"> + <td class="only-in-full-view"> + <s:property value="companyName" /> + </td> + </s:if> + <td class="only-in-full-view"><s:property value="fishingZones" /></td> + <td class="only-in-compact-view"> + <s:if test="fishingZonesInfos == null"> + <s:property value="fishingZones"/> + </s:if> + <s:else> + <span data-original-title="<s:property value="fishingZonesInfos" escapeHtml="false"/>" data-toggle="tooltip" data-placement="left"> + <s:property value="fishingZones"/> + </span> + </s:else> + </td> + <td class="only-in-full-view"> + <s:property value="fishingZonesInfos" /> + </td> + <td> + <s:property value="samplingContext"/> + </td> + <td> + <s:property value="samplingContextInfo"/> + </td> + <td> + <s:property value="individualMeasurementStrategy"/> + </td> + <td class="only-in-full-view"><s:property value="%{formatMonth(periodBegin)}" /></td> + <td class="only-in-full-view"><s:property value="%{formatMonth(periodEnd)}" /></td> + <!-- Months columns --> +<s:iterator value="samplingPlan.months" var="month"> + <s:set var="effort" value="#samplingPlanRow.effortInObservationsPerMonths.get(#month)"/> + <s:set var="now" value="%{isCurrentMonth(#month)}"/> + <s:set var="showPercentage" value="false"/> + <%@include file="../templates/td-effort.jsp" %> +</s:iterator> + + <s:set var="effort" value="#samplingPlanRow.totalObservations"/> + <s:set var="now" value="false"/> + <s:set var="showPercentage" value="true"/> + <%@include file="../templates/td-effort.jsp" %> + + <td> + <s:if test=" ! comment.empty"> + <i title="<s:property value="comment" escapeHtml="true"/>" class="fa fa-comment"></i> + </s:if> + </td> + + <td class="actions"> + <div class="dropdown"> + <a class="btn dropdown-toggle" data-toggle="dropdown" href="#"> + <s:text name="wao.ui.actions" /> + <b class="caret"></b> + </a> + <ul class="dropdown-menu"> + <s:if test="authenticatedWaoUser.authorizedToEditSamplingPlan"> + <li> + <s:url action="edit-sample-row!input" id="editSampleRowUrl"> + <s:param name="sampleRowId" value="sampleRowId" /> + </s:url> + <s:a href="%{editSampleRowUrl}"> + <i class="icon-edit"></i> <s:text name="wao.ui.action.editOrDeleteSampleRow" /> + </s:a> + </li> + </s:if> + <s:if test="authenticatedWaoUser.authorizedToViewSampleRowLog"> + <li> + <s:url action="sample-row-log" id="sampleRowLogUrl"> + <s:param name="sampleRowId" value="sampleRowId" /> + </s:url> + <s:a href="%{sampleRowLogUrl}"> + <i class="icon-time"></i> <s:text name="wao.ui.action.viewSampleRowLog" /> + </s:a> + </li> + </s:if> + <li> + <s:url action="sampling-plan!applyFilter" id="sampleRowZoomUrl"> + <s:param name="filter.periodFrom" value="%{formatMonth(firstSampleMonthDate)}"/> + <s:param name="filter.periodTo" value="%{formatMonth(lastSampleMonthDate)}"/> + <s:param name="filter.companyIds" value="%{filter.companyIds}"/> + <s:param name="filter.programNames" value="%{filter.programNames}"/> + <s:param name="filter.sampleRowCodes" value="%{filter.sampleRowCodes}"/> + <s:param name="filter.fishingZoneFacadeNames" value="%{filter.targetSpeciesDcfIds}"/> + <s:param name="filter.fishingZoneSectorNames" value="%{filter.targetSpeciesDcfIds}"/> + <s:param name="filter.fishingGearDcfIds" value="%{filter.targetSpeciesDcfIds}"/> + <s:param name="filter.targetSpeciesDcfIds" value="%{filter.targetSpeciesDcfIds}"/> + </s:url> + <s:a href="%{sampleRowZoomUrl}"> + <i class="icon-filter"></i> <s:text name="wao.ui.action.zoomOnSampleRowPeriod" /> + </s:a> + </li> + <s:if test="authenticatedWaoUser.authorizedToViewBoats && elligibleBoatsProvided"> + <li> + <s:url action="boats!applyFilter" id="viewElligibleBoatsUrl"> + <s:param name="filter.elligibleForSampleRowsFilter.sampleRowCodes" value="code" /> + </s:url> + <s:a href="%{viewElligibleBoatsUrl}"> + <i class="fa fa-anchor"></i> <s:text name="wao.ui.action.viewElligibleBoats" /> + </s:a> + </li> + </s:if> + <s:if test="authenticatedWaoUser.authorizedToViewContacts && sampleRowContactCounts > 0"> + <li> + <s:url action="contacts!applyFilter" id="viewAssociatedContactsUrl"> + <s:param name="filter.sampleRowFilter.sampleRowCodes" value="code" /> + <s:param name="filter.periodFrom" /> + <s:param name="filter.periodTo" /> + </s:url> + <s:a href="%{viewAssociatedContactsUrl}"> + <i class="fa fa-stack-exchange"></i> <s:text name="wao.ui.action.viewAssociatedContacts" /> + </s:a> + </li> + </s:if> + <s:if test="authenticatedWaoUser.authorizedToCreateContact && newContactCreatable"> + <li> + <s:url action="boats!applyFilter" id="createAssociatedContactUrl"> + <s:param name="startBoatSelectionForSampleRowId" value="sampleRowId" /> + </s:url> + <s:a href="%{createAssociatedContactUrl}"> + <i class="icon-plus"></i> <s:text name="wao.ui.action.createAssociatedContact" /> + </s:a> + </li> + </s:if> + </ul> + </div> + </td> + </tr> +<%--Iterate on SampleRows --%> +</s:iterator> +<%--Iterate on Sectors --%> +</s:iterator> +<%--Iterate on Facades--%> +</s:iterator> + + </todby> + <tfoot> + <th colspan="<s:property value="#nbColumnsForProfessionInFullView" />" class="only-in-full-view"> + <s:text name="wao.ui.misc.totals" /> + </th> + <th colspan="<s:property value="#nbColumnsForProfessionInCompactView" />" class="only-in-compact-view"> + <s:text name="wao.ui.misc.totals" /> + </th> + <!-- Months columns --> + <s:iterator value="samplingPlan.months" var="month"> + <s:set var="effort" value="samplingPlan.totalEffortInObservationsPerMonths.get(#month)"/> + <s:set var="now" value="%{isCurrentMonth(#month)}"/> + <s:set var="showPercentage" value="true"/> + <%@include file="../templates/td-effort.jsp" %> + </s:iterator> + + <s:set var="effort" value="samplingPlan.highTotalEffortInObservations"/> + <s:set var="now" value="false"/> + <s:set var="showPercentage" value="true"/> + <%@include file="../templates/td-effort.jsp" %> + + <th colspan="${nbColumnsForOther}"></th> + </tfoot> + </table> + +</html> -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository wao. See http://git.codelutin.com/wao.git commit 2c6e908c8db51c57862224a7a2ec9b69fd233573 Author: Brendan Le Ny <bleny@codelutin.com> Date: Thu Dec 18 09:59:41 2014 +0100 Dans l'écran de gestion des référentiels, on n'affiche que ce qui est pertinent pour scléro --- .../administration/referential-management.jsp | 94 +++++++++++----------- 1 file changed, 49 insertions(+), 45 deletions(-) diff --git a/wao-web/src/main/webapp/WEB-INF/content/administration/referential-management.jsp b/wao-web/src/main/webapp/WEB-INF/content/administration/referential-management.jsp index b550216..28b2b37 100644 --- a/wao-web/src/main/webapp/WEB-INF/content/administration/referential-management.jsp +++ b/wao-web/src/main/webapp/WEB-INF/content/administration/referential-management.jsp @@ -51,37 +51,39 @@ </s:form> - <s:form action="import-terrestrial-locations" method="POST" enctype="multipart/form-data"> - - <fieldset> - <legend> - <s:text name="wao.import.terrestrialLocations.prompt" /> - </legend> - - <s:file name="csvFile" cssClass="float-left" /> - - <s:submit type="button"> - <i class="icon-upload"></i> <s:text name="wao.ui.action.csvImport" /> - </s:submit> - </fieldset> - - </s:form> - - <s:form action="import-boats" method="POST" enctype="multipart/form-data"> - - <fieldset> - <legend> - <s:text name="wao.import.boats.prompt" /> - </legend> - - <s:file name="csvFile" cssClass="float-left"/> - - <s:submit type="button"> - <i class="icon-upload"></i> <s:text name="wao.ui.action.csvImport" /> - </s:submit> - </fieldset> + <s:if test="obsMer || obsVente"> + <s:form action="import-terrestrial-locations" method="POST" enctype="multipart/form-data"> + + <fieldset> + <legend> + <s:text name="wao.import.terrestrialLocations.prompt" /> + </legend> + + <s:file name="csvFile" cssClass="float-left" /> + + <s:submit type="button"> + <i class="icon-upload"></i> <s:text name="wao.ui.action.csvImport" /> + </s:submit> + </fieldset> + + </s:form> - </s:form> + <s:form action="import-boats" method="POST" enctype="multipart/form-data"> + + <fieldset> + <legend> + <s:text name="wao.import.boats.prompt" /> + </legend> + + <s:file name="csvFile" cssClass="float-left"/> + + <s:submit type="button"> + <i class="icon-upload"></i> <s:text name="wao.ui.action.csvImport" /> + </s:submit> + </fieldset> + + </s:form> + </s:if> <s:if test="obsMer"> <s:form action="import-contact-state-motives" method="POST" enctype="multipart/form-data"> @@ -101,21 +103,23 @@ </s:form> </s:if> - <s:form action="import-species" method="POST" enctype="multipart/form-data"> - - <fieldset> - <legend> - <s:text name="wao.import.species.prompt" /> - </legend> - - <s:file name="csvFile" cssClass="float-left" /> - - <s:submit type="button"> - <i class="icon-upload"></i> <s:text name="wao.ui.action.csvImport" /> - </s:submit> - </fieldset> - - </s:form> + <s:if test="sclerochronology"> + <s:form action="import-species" method="POST" enctype="multipart/form-data"> + + <fieldset> + <legend> + <s:text name="wao.import.species.prompt" /> + </legend> + + <s:file name="csvFile" cssClass="float-left" /> + + <s:submit type="button"> + <i class="icon-upload"></i> <s:text name="wao.ui.action.csvImport" /> + </s:submit> + </fieldset> + + </s:form> + </s:if> <table class="table table-bordered"> <tr> -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository wao. See http://git.codelutin.com/wao.git commit 675f00192651555d766d6237e3268c0b57b01305 Author: Brendan Le Ny <bleny@codelutin.com> Date: Thu Dec 18 10:27:01 2014 +0100 Suppression d'un fichier obsdeb --- wao-services/src/test/resources/import/samplingPlan-obsdeb.csv | 3 --- 1 file changed, 3 deletions(-) diff --git a/wao-services/src/test/resources/import/samplingPlan-obsdeb.csv b/wao-services/src/test/resources/import/samplingPlan-obsdeb.csv deleted file mode 100644 index 186f9ef..0000000 --- a/wao-services/src/test/resources/import/samplingPlan-obsdeb.csv +++ /dev/null @@ -1,3 +0,0 @@ -PLAN_CODE;REGION_IFREMER_COD;OBSERVATEUR_COD;OBSERVATION_DATE;UNITE_OBSERVATION_COD -2011_D0888;GA;OBS1;05/01/2010;UO007 -2011_D0889;MA;OBS2;25/02/2010;UO087 -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository wao. See http://git.codelutin.com/wao.git commit f4a83c25404158e2e637ef5c7e34e85a70319154 Author: Brendan Le Ny <bleny@codelutin.com> Date: Thu Dec 18 11:36:37 2014 +0100 Import du plan d'échantillonnage scléro --- .../main/java/fr/ifremer/wao/entity/Companies.java | 9 +- .../java/fr/ifremer/wao/entity/Organisations.java | 23 +++ .../main/java/fr/ifremer/wao/entity/Specieses.java | 19 ++ .../i18n/wao-persistence_en_GB.properties | 7 +- .../i18n/wao-persistence_fr_FR.properties | 7 +- .../fr/ifremer/wao/services/ObsMerFixtures.java | 222 --------------------- ...singIndividualMeasurementStrategyException.java | 10 + ...ngSclerochronologySamplingContextException.java | 10 + .../services/service/MissingSpeciesException.java | 10 + .../wao/services/service/SamplingPlanService.java | 81 +++++--- .../wao/services/service/WaoServiceSupport.java | 5 + .../administration/OrganisationsService.java | 18 ++ .../service/administration/ReferentialService.java | 9 + .../service/csv/ContactImportExportModel.java | 12 +- ...bsMerObsVenteSamplingPlanImportExportModel.java | 42 ++-- ...atter.java => OrganisationParserFormatter.java} | 48 ++--- .../csv/operations/SpeciesParserFormatter.java | 51 +++++ .../resources/i18n/wao-services_en_GB.properties | 5 + .../resources/i18n/wao-services_fr_FR.properties | 5 + .../wao/services/service/BoatsServiceTest.java | 1 - .../wao/services/service/ContactsServiceTest.java | 1 - .../wao/services/service/ObsMerFixtures.java | 93 +++++++++ .../service/ObsMerSamplingPlanServiceTest.java | 1 - .../services/service/SclerochronologyFixtures.java | 50 +++++ .../SclerochronologySamplingPlanServiceTest.java | 51 +++++ .../ifremer/wao/services/service/WaoFixtures.java | 88 ++++++++ .../src/test/resources/import/echantillonnage.csv | 18 +- .../resources/import/plan-sclerochronologie.csv | 6 + .../wao/web/action/EditSampleRowAction.java | 12 ++ .../action/administration/ImportSpeciesAction.java | 4 +- 30 files changed, 602 insertions(+), 316 deletions(-) diff --git a/wao-persistence/src/main/java/fr/ifremer/wao/entity/Companies.java b/wao-persistence/src/main/java/fr/ifremer/wao/entity/Companies.java index b396747..0b657ae 100644 --- a/wao-persistence/src/main/java/fr/ifremer/wao/entity/Companies.java +++ b/wao-persistence/src/main/java/fr/ifremer/wao/entity/Companies.java @@ -26,14 +26,7 @@ import com.google.common.base.Function; public class Companies { public static Function<Company, String> getName() { - return new GetName(); + return Organisations.getName(); } - protected static class GetName implements Function<Company, String> { - - @Override - public String apply(Company input) { - return input.getName(); - } - } } diff --git a/wao-persistence/src/main/java/fr/ifremer/wao/entity/Organisations.java b/wao-persistence/src/main/java/fr/ifremer/wao/entity/Organisations.java new file mode 100644 index 0000000..bdd649b --- /dev/null +++ b/wao-persistence/src/main/java/fr/ifremer/wao/entity/Organisations.java @@ -0,0 +1,23 @@ +package fr.ifremer.wao.entity; + +import com.google.common.base.Function; +import com.google.common.collect.Ordering; + +public class Organisations { + + public static <T extends Organisation> Function<T, String> getName() { + return new GetName<>(); + } + + public static Ordering<Organisation> comparator() { + return Ordering.natural().onResultOf(getName()); + } + + protected static class GetName<T extends Organisation> implements Function<T, String> { + + @Override + public String apply(T input) { + return input.getName(); + } + } +} diff --git a/wao-persistence/src/main/java/fr/ifremer/wao/entity/Specieses.java b/wao-persistence/src/main/java/fr/ifremer/wao/entity/Specieses.java new file mode 100644 index 0000000..f7f12d6 --- /dev/null +++ b/wao-persistence/src/main/java/fr/ifremer/wao/entity/Specieses.java @@ -0,0 +1,19 @@ +package fr.ifremer.wao.entity; + +import com.google.common.base.Function; + +public class Specieses { + + public static Function<Species, String> getPermanentCode() { + return new GetPermanentCode(); + } + + protected static class GetPermanentCode implements Function<Species, String> { + + @Override + public String apply(Species input) { + return input.getPermanentCode(); + } + } + +} diff --git a/wao-persistence/src/main/resources/i18n/wao-persistence_en_GB.properties b/wao-persistence/src/main/resources/i18n/wao-persistence_en_GB.properties index e4f6dfb..4770f3f 100644 --- a/wao-persistence/src/main/resources/i18n/wao-persistence_en_GB.properties +++ b/wao-persistence/src/main/resources/i18n/wao-persistence_en_GB.properties @@ -21,9 +21,9 @@ GlobalIndicatorValue.GOOD=Level 1 bonus GlobalIndicatorValue.NEUTRAL=Conform GlobalIndicatorValue.VERY_BAD=Level 2 penalty GlobalIndicatorValue.VERY_GOOD=Level 2 bonus -IndividualMeasurementStrategy.SIZE_WEIGHT=Size, weight -IndividualMeasurementStrategy.SIZE_WEIGHT_SEX=Size, weight, sex -IndividualMeasurementStrategy.SIZE_WEIGHT_SEX_MATURITY_AGE=Size, weight, sex, maturity, age +IndividualMeasurementStrategy.SIZE_WEIGHT=Size/Weight +IndividualMeasurementStrategy.SIZE_WEIGHT_SEX=Size/Weight/Sex +IndividualMeasurementStrategy.SIZE_WEIGHT_SEX_MATURITY_AGE=Size/Weight/Sex/Maturity/Age LocationType.AUCTION=Auction LocationType.DISTRICT=District LocationType.PORT=Port @@ -127,6 +127,7 @@ fr.ifremer.wao.entity.FishingGearDcf.TM=Midwater trawls (not specified) fr.ifremer.wao.entity.FishingGearDcf.TMS=Shrimp trawls fr.ifremer.wao.entity.FishingGearDcf.TX=Other trawls (not specified) fr.ifremer.wao.entity.FishingZone=Fishing zones +fr.ifremer.wao.entity.Species=Species fr.ifremer.wao.entity.TargetSpeciesDcf.=Not specified fr.ifremer.wao.entity.TargetSpeciesDcf.ALG=Algae fr.ifremer.wao.entity.TargetSpeciesDcf.ANA=Espèces anadromes diff --git a/wao-persistence/src/main/resources/i18n/wao-persistence_fr_FR.properties b/wao-persistence/src/main/resources/i18n/wao-persistence_fr_FR.properties index 972c780..2b2467c 100644 --- a/wao-persistence/src/main/resources/i18n/wao-persistence_fr_FR.properties +++ b/wao-persistence/src/main/resources/i18n/wao-persistence_fr_FR.properties @@ -21,9 +21,9 @@ GlobalIndicatorValue.GOOD=Bonus de niveau 1 GlobalIndicatorValue.NEUTRAL=Conforme au cahier des charges GlobalIndicatorValue.VERY_BAD=Pénalité de niveau 2 GlobalIndicatorValue.VERY_GOOD=Bonus de niveau 2 -IndividualMeasurementStrategy.SIZE_WEIGHT=Poids, taille -IndividualMeasurementStrategy.SIZE_WEIGHT_SEX=Poids, taille, sexe -IndividualMeasurementStrategy.SIZE_WEIGHT_SEX_MATURITY_AGE=Poids, taille, sexe, maturité, âge +IndividualMeasurementStrategy.SIZE_WEIGHT=Poids/Taille +IndividualMeasurementStrategy.SIZE_WEIGHT_SEX=Poids/Taille/Sexe +IndividualMeasurementStrategy.SIZE_WEIGHT_SEX_MATURITY_AGE=Poids/Taille/Sexe/Maturité/Âge LocationType.AUCTION=Criée LocationType.DISTRICT=Quartier maritime LocationType.PORT=Port @@ -127,6 +127,7 @@ fr.ifremer.wao.entity.FishingGearDcf.TM=Chalut pélagique (non spécifié) fr.ifremer.wao.entity.FishingGearDcf.TMS=Chalut pélagique à crevettes fr.ifremer.wao.entity.FishingGearDcf.TX=Autre chalut (non spécifié) fr.ifremer.wao.entity.FishingZone=Zones de pêche +fr.ifremer.wao.entity.Species=Espèces fr.ifremer.wao.entity.TargetSpeciesDcf.=Non spécifié fr.ifremer.wao.entity.TargetSpeciesDcf.ALG=Algues fr.ifremer.wao.entity.TargetSpeciesDcf.ANA=Espèces anadromes diff --git a/wao-services/src/main/java/fr/ifremer/wao/services/ObsMerFixtures.java b/wao-services/src/main/java/fr/ifremer/wao/services/ObsMerFixtures.java deleted file mode 100644 index 6b42b3c..0000000 --- a/wao-services/src/main/java/fr/ifremer/wao/services/ObsMerFixtures.java +++ /dev/null @@ -1,222 +0,0 @@ -package fr.ifremer.wao.services; - -/* - * #%L - * Wao :: Services - * %% - * Copyright (C) 2009 - 2014 Ifremer - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * #L% - */ - -import fr.ifremer.wao.WaoTechnicalException; -import fr.ifremer.wao.entity.Company; -import fr.ifremer.wao.entity.CompanyTopiaDao; -import fr.ifremer.wao.entity.FishingGearDcf; -import fr.ifremer.wao.entity.FishingGearDcfTopiaDao; -import fr.ifremer.wao.entity.ObsProgram; -import fr.ifremer.wao.entity.TargetSpeciesDcf; -import fr.ifremer.wao.entity.TargetSpeciesDcfTopiaDao; -import fr.ifremer.wao.entity.UserProfile; -import fr.ifremer.wao.entity.UserProfileImpl; -import fr.ifremer.wao.entity.UserProfileTopiaDao; -import fr.ifremer.wao.entity.UserRole; -import fr.ifremer.wao.entity.WaoUser; -import fr.ifremer.wao.entity.WaoUserImpl; -import fr.ifremer.wao.entity.WaoUserTopiaDao; -import fr.ifremer.wao.services.service.ContactsService; -import fr.ifremer.wao.services.service.ImportErrorException; -import fr.ifremer.wao.services.service.ObsMerSamplingPlanService; -import fr.ifremer.wao.services.service.administration.ReferentialService; -import org.apache.commons.io.IOUtils; - -import java.io.InputStream; -import java.util.HashMap; -import java.util.Map; - -public class ObsMerFixtures { - - protected WaoServiceContext serviceContext; - - protected Map<String, Company> companies = new HashMap<>(); - - protected Map<String, WaoUser> waoUsers = new HashMap<>(); - - protected Map<String, UserProfile> userProfiles = new HashMap<>(); - - public ObsMerFixtures(WaoServiceContext serviceContext) { - this.serviceContext = serviceContext; - } - - protected Company getCompany(String companyName) { - Company company = companies.get(companyName); - if (company == null) { - CompanyTopiaDao companyDao = serviceContext.getPersistenceContext().getCompanyDao(); - company = companyDao.create( - Company.PROPERTY_NAME, companyName, - Company.PROPERTY_ACTIVE, true); - companies.put(companyName, company); - serviceContext.getPersistenceContext().commit(); - } - return company; - } - - protected UserProfile getUserProfile(String userRole) { - UserProfile userProfile = userProfiles.get(userRole); - if (userProfile == null) { - switch (userRole) { - case "admin": - userProfile = new UserProfileImpl(); - userProfile.setUserRole(UserRole.ADMIN); - userProfile.setObsProgram(ObsProgram.OBSMER); - userProfile.setCanWrite(true); - break; - case "jmichmuche": - userProfile = new UserProfileImpl(); - userProfile.setUserRole(UserRole.COORDINATOR); - userProfile.setObsProgram(ObsProgram.OBSMER); - userProfile.setCanWrite(true); - break; - default: - throw new IllegalArgumentException("Don't know userRole: " + userRole); - } - UserProfileTopiaDao userProfileDao = serviceContext.getPersistenceContext().getUserProfileDao(); - userProfileDao.create(userProfile); - serviceContext.getPersistenceContext().commit(); - userProfiles.put(userRole, userProfile); - } - return userProfile; - } - - protected WaoUser getWaoUser(String login) { - WaoUser waoUser = waoUsers.get(login); - if (waoUser == null) { - - switch (login) { - case "admin": - waoUser = new WaoUserImpl(); - waoUser.setOrganisation(ifremer()); - waoUser.setLogin(login); - waoUser.setActive(true); - waoUser.addUserProfile(getUserProfile("admin")); - break; - case "jmichmuche": - waoUser = new WaoUserImpl(); - waoUser.setOrganisation(ifremer()); - waoUser.setLogin(login); - waoUser.setActive(true); - waoUser.addUserProfile(getUserProfile("jmichmuche")); - break; - default: - throw new IllegalArgumentException("Don't know user: " + login); - } - - WaoUserTopiaDao waoUserDao = serviceContext.getPersistenceContext().getWaoUserDao(); - waoUserDao.create(waoUser); - serviceContext.getPersistenceContext().commit(); - waoUsers.put(login, waoUser); - } - return waoUser; - } - - public Company ifremer() { - return getCompany("Ifremer"); - } - - public Company oceanet() { - return getCompany("OCEANET"); - } - - public AuthenticatedWaoUser admin() { - WaoUser admin = getWaoUser("admin"); - UserProfile userProfile = getUserProfile("admin"); - AuthenticatedWaoUser authenticatedWaoUser = new AuthenticatedWaoUser(admin, userProfile); - return authenticatedWaoUser; - } - - public AuthenticatedWaoUser jmichmuche() { - WaoUser jmichmuche = getWaoUser("jmichmuche"); - UserProfile userProfile = getUserProfile("jmichmuche"); - AuthenticatedWaoUser authenticatedWaoUser = new AuthenticatedWaoUser(jmichmuche, userProfile); - return authenticatedWaoUser; - } - - public void fishingZones() { - InputStream input = null; - try { - input = getClass().getResourceAsStream("/import/zonesPeche.csv"); - serviceContext.newService(ReferentialService.class).importFishingZones(input); - } catch (ImportErrorException e) { - throw new WaoTechnicalException(e); - } finally { - IOUtils.closeQuietly(input); - } - } - - public void navires() { - InputStream input = null; - try { - input = getClass().getResourceAsStream("/import/navires.csv"); - serviceContext.newService(ReferentialService.class).importBoats(input); - } catch (ImportErrorException e) { - throw new WaoTechnicalException(e); - } finally { - IOUtils.closeQuietly(input); - } - } - - public void samplingPlan() { - ifremer(); - oceanet(); - fishingZones(); - InputStream input = null; - try { - input = getClass().getResourceAsStream("/import/echantillonnage.csv"); - serviceContext.newService(ObsMerSamplingPlanService.class).importSamplingPlan(admin(), input); - } catch (ImportErrorException e) { - throw new WaoTechnicalException(e); - } finally { - IOUtils.closeQuietly(input); - } - } - - public void contacts() { - samplingPlan(); - jmichmuche(); - navires(); - InputStream input = null; - try { - input = getClass().getResourceAsStream("/import/contacts.csv"); - serviceContext.newService(ContactsService.class).importContacts(admin(), input); - } catch (ImportErrorException e) { - throw new WaoTechnicalException(e); - } finally { - IOUtils.closeQuietly(input); - } - } - - public FishingGearDcf ptb() { - FishingGearDcfTopiaDao fishingGearDcfDao = serviceContext.getPersistenceContext().getFishingGearDcfDao(); - FishingGearDcf ptb = fishingGearDcfDao.forCodeEquals("PTB").findUnique(); - return ptb; - } - - public TargetSpeciesDcf def() { - TargetSpeciesDcfTopiaDao fishingGearDcfDao = serviceContext.getPersistenceContext().getTargetSpeciesDcfDao(); - TargetSpeciesDcf def = fishingGearDcfDao.forCodeEquals("DEF").findUnique(); - return def; - } - -} diff --git a/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingIndividualMeasurementStrategyException.java b/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingIndividualMeasurementStrategyException.java new file mode 100644 index 0000000..1886359 --- /dev/null +++ b/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingIndividualMeasurementStrategyException.java @@ -0,0 +1,10 @@ +package fr.ifremer.wao.services.service; + +import fr.ifremer.wao.entity.SampleRow; + +public class MissingIndividualMeasurementStrategyException extends SampleRowValidationException { + + public MissingIndividualMeasurementStrategyException(SampleRow sampleRow) { + super(sampleRow); + } +} diff --git a/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingSclerochronologySamplingContextException.java b/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingSclerochronologySamplingContextException.java new file mode 100644 index 0000000..212018a --- /dev/null +++ b/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingSclerochronologySamplingContextException.java @@ -0,0 +1,10 @@ +package fr.ifremer.wao.services.service; + +import fr.ifremer.wao.entity.SampleRow; + +public class MissingSclerochronologySamplingContextException extends SampleRowValidationException { + + public MissingSclerochronologySamplingContextException(SampleRow sampleRow) { + super(sampleRow); + } +} diff --git a/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingSpeciesException.java b/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingSpeciesException.java new file mode 100644 index 0000000..2a6507f --- /dev/null +++ b/wao-services/src/main/java/fr/ifremer/wao/services/service/MissingSpeciesException.java @@ -0,0 +1,10 @@ +package fr.ifremer.wao.services.service; + +import fr.ifremer.wao.entity.SampleRow; + +public class MissingSpeciesException extends SampleRowValidationException { + + public MissingSpeciesException(SampleRow sampleRow) { + super(sampleRow); + } +} diff --git a/wao-services/src/main/java/fr/ifremer/wao/services/service/SamplingPlanService.java b/wao-services/src/main/java/fr/ifremer/wao/services/service/SamplingPlanService.java index a091cc1..6df485f 100644 --- a/wao-services/src/main/java/fr/ifremer/wao/services/service/SamplingPlanService.java +++ b/wao-services/src/main/java/fr/ifremer/wao/services/service/SamplingPlanService.java @@ -36,7 +36,6 @@ import fr.ifremer.wao.WaoUtils; import fr.ifremer.wao.entity.Boat; import fr.ifremer.wao.entity.Boats; import fr.ifremer.wao.entity.Company; -import fr.ifremer.wao.entity.CompanyTopiaDao; import fr.ifremer.wao.entity.Contact; import fr.ifremer.wao.entity.ContactState; import fr.ifremer.wao.entity.Dcf5Code; @@ -47,6 +46,7 @@ import fr.ifremer.wao.entity.FishingZone; import fr.ifremer.wao.entity.FishingZoneTopiaDao; import fr.ifremer.wao.entity.LocationType; import fr.ifremer.wao.entity.ObsProgram; +import fr.ifremer.wao.entity.Organisation; import fr.ifremer.wao.entity.Profession; import fr.ifremer.wao.entity.ProfessionImpl; import fr.ifremer.wao.entity.ProfessionTopiaDao; @@ -159,31 +159,36 @@ public class SamplingPlanService extends WaoServiceSupport { // We don't want to see all rows but the ones important for today Date fromDate = serviceContext.getNow(); - Date toDate = fromDate; // Dans ObsMer et ObsVente, le plan est mensualisé fromDate = DateUtils.truncate(fromDate, Calendar.MONTH); - // la période initiale doit toujours aller d'avril à mars (contractuel). - // on prend la période dans laquelle on se trouve actuellement + if (authenticatedWaoUser.getObsProgram().isSclerochronology()) { + // on est sur un plan de janvier à décembre + fromDate = DateUtils.setMonths(fromDate, 0); - // si on est avant le premier avril de l'année courante - boolean beforePeriodChangeInCurrentYear = DateUtil.getMonth(fromDate) < 3; - - if (beforePeriodChangeInCurrentYear) { - // on prend la période qui a commencé l'année dernière et qui finit - // cette année - fromDate = DateUtils.setMonths(fromDate, 3); - fromDate = DateUtils.addYears(fromDate, -1); } else { - // on prend la période qui commence cette année et se termine - // l'année prochaine - fromDate = DateUtils.setMonths(fromDate, 3); + // la période initiale doit toujours aller d'avril à mars (contractuel). + // on prend la période dans laquelle on se trouve actuellement + + // si on est avant le premier avril de l'année courante + boolean beforePeriodChangeInCurrentYear = DateUtil.getMonth(fromDate) < 3; + + if (beforePeriodChangeInCurrentYear) { + // on prend la période qui a commencé l'année dernière et qui finit + // cette année + fromDate = DateUtils.setMonths(fromDate, 3); + fromDate = DateUtils.addYears(fromDate, -1); + } else { + // on prend la période qui commence cette année et se termine + // l'année prochaine + fromDate = DateUtils.setMonths(fromDate, 3); + } } // on a fromDate sur le premier avril de la bonne année, on va // jusqu'au mois de mars suivant - toDate = DateUtils.addMonths(fromDate, 11); + Date toDate = DateUtils.addMonths(fromDate, 11); newFilter.setPeriodFrom(fromDate); newFilter.setPeriodTo(toDate); @@ -345,6 +350,7 @@ public class SamplingPlanService extends WaoServiceSupport { ImmutableMap<String, Company> allCompanies = Maps.uniqueIndex( + // TODO brendan 15/12/14 getOrganisationsService().getOrganisationsToWorkOnSampleRow(obsProgram); getCompaniesService().getAllCompanies(), TopiaEntities.getTopiaIdFunction() ); @@ -607,6 +613,15 @@ public class SamplingPlanService extends WaoServiceSupport { } catch (NoEffortDefinedException e) { String message = I18n.l(getLocale(), "wao.import.sampleRow.failure.noEffortDefined", lineNumber); throw new ImportErrorException(message); + } catch (MissingSclerochronologySamplingContextException e) { + String message = I18n.l(getLocale(), "wao.import.sampleRow.failure.missingSclerochronologySamplingContext", lineNumber); + throw new ImportErrorException(message); + } catch (MissingIndividualMeasurementStrategyException e) { + String message = I18n.l(getLocale(), "wao.import.sampleRow.failure.missingIndividualMeasurementStrategy", lineNumber); + throw new ImportErrorException(message); + } catch (MissingSpeciesException e) { + String message = I18n.l(getLocale(), "wao.import.sampleRow.failure.missingSpecies", lineNumber); + throw new ImportErrorException(message); } save0(updateSampleRowCommand); @@ -625,8 +640,7 @@ public class SamplingPlanService extends WaoServiceSupport { ObsProgram obsProgram = authenticatedWaoUser.getObsProgram(); - CompanyTopiaDao companyDao = getCompanyDao(); - List<Company> activeCompanies = companyDao.forActiveEquals(true).findAll(); + Set<Organisation> organisations = getOrganisationsService().getOrganisationsToWorkOnSampleRow(obsProgram); TerrestrialLocationTopiaDao terrestrialLocationDao = getTerrestrialLocationDao(); List<TerrestrialLocation> terrestrialDistricts = @@ -640,7 +654,7 @@ public class SamplingPlanService extends WaoServiceSupport { ImportModel<SampleRow> samplingPlanImportModel = new ObsMerObsVenteSamplingPlanImportExportModel(getLocale(), obsProgram, - activeCompanies, + organisations, fishingZones, terrestrialDistricts, referentialService); @@ -713,7 +727,10 @@ public class SamplingPlanService extends WaoServiceSupport { SampleMonthWithIllegalExpectedTidesValueException, MissingDcf5CodesException, SampleRowCodeMustBeUniqueException, - NoEffortDefinedException { + NoEffortDefinedException, + MissingSclerochronologySamplingContextException, + MissingSpeciesException, + MissingIndividualMeasurementStrategyException { SampleRow sampleRow = updateSampleRowCommand.getSampleRow(); @@ -725,8 +742,10 @@ public class SamplingPlanService extends WaoServiceSupport { throw new SampleRowCodeMustBeUniqueException(); } + ObsProgram obsProgram = sampleRow.getObsProgram(); + if (updateSampleRowCommand.isCreation()) { - if ( ! sampleRow.getObsProgram().getSampleRowCodePattern().matcher(sampleRow.getCode()).matches()) { + if ( ! obsProgram.getSampleRowCodePattern().matcher(sampleRow.getCode()).matches()) { throw new WrongSampleRowCodeFormatException(sampleRow); } } else { @@ -751,7 +770,7 @@ public class SamplingPlanService extends WaoServiceSupport { throw new MissingFishingZonesException(sampleRow); } - if (sampleRow.getObsProgram().isObsVente()) { + if (obsProgram.isObsVente()) { if (sampleRow.getSamplingStrategy().isSpecificStock() && StringUtils.isEmpty(sampleRow.getProfession().getSpecies())) { throw new MissingProfessionSpeciesException(sampleRow); } @@ -767,8 +786,22 @@ public class SamplingPlanService extends WaoServiceSupport { } } - if (sampleRow.isDcf5CodeEmpty()) { - throw new MissingDcf5CodesException(sampleRow); + if (obsProgram.isObsVente() || obsProgram.isObsMer()) { + if (sampleRow.isDcf5CodeEmpty()) { + throw new MissingDcf5CodesException(sampleRow); + } + } + + if (obsProgram.isSclerochronology()) { + if (sampleRow.getSclerochronologySamplingContext() == null) { + throw new MissingSclerochronologySamplingContextException(sampleRow); + } + if (sampleRow.getSpecies() == null) { + throw new MissingSpeciesException(sampleRow); + } + if (sampleRow.getIndividualMeasurementStrategy() == null) { + throw new MissingIndividualMeasurementStrategyException(sampleRow); + } } } diff --git a/wao-services/src/main/java/fr/ifremer/wao/services/service/WaoServiceSupport.java b/wao-services/src/main/java/fr/ifremer/wao/services/service/WaoServiceSupport.java index c77f609..ebc60f9 100644 --- a/wao-services/src/main/java/fr/ifremer/wao/services/service/WaoServiceSupport.java +++ b/wao-services/src/main/java/fr/ifremer/wao/services/service/WaoServiceSupport.java @@ -50,6 +50,7 @@ import fr.ifremer.wao.services.WaoService; import fr.ifremer.wao.services.WaoServiceContext; import fr.ifremer.wao.services.WaoWebApplicationContext; import fr.ifremer.wao.services.service.administration.CompaniesService; +import fr.ifremer.wao.services.service.administration.LaboratoriesService; import fr.ifremer.wao.services.service.administration.OrganisationsService; import fr.ifremer.wao.services.service.administration.ReferentialService; import fr.ifremer.wao.services.service.administration.WaoUsersService; @@ -206,4 +207,8 @@ public abstract class WaoServiceSupport implements WaoService { protected LaboratoryTopiaDao getLaboratoryDao() { return getPersistenceContext().getLaboratoryDao(); } + + public LaboratoriesService getLaboratoriesService() { + return newService(LaboratoriesService.class); + } } diff --git a/wao-services/src/main/java/fr/ifremer/wao/services/service/administration/OrganisationsService.java b/wao-services/src/main/java/fr/ifremer/wao/services/service/administration/OrganisationsService.java index 2f7f781..8e90623 100644 --- a/wao-services/src/main/java/fr/ifremer/wao/services/service/administration/OrganisationsService.java +++ b/wao-services/src/main/java/fr/ifremer/wao/services/service/administration/OrganisationsService.java @@ -3,8 +3,10 @@ package fr.ifremer.wao.services.service.administration; import com.google.common.collect.Iterables; import fr.ifremer.wao.entity.Company; import fr.ifremer.wao.entity.Laboratory; +import fr.ifremer.wao.entity.ObsProgram; import fr.ifremer.wao.entity.Organisation; import fr.ifremer.wao.entity.OrganisationTopiaDao; +import fr.ifremer.wao.entity.Organisations; import fr.ifremer.wao.services.service.IllegalDeletionException; import fr.ifremer.wao.services.service.WaoServiceSupport; import org.nuiton.topia.persistence.TopiaEntity; @@ -13,6 +15,8 @@ import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; +import java.util.SortedSet; +import java.util.TreeSet; public class OrganisationsService extends WaoServiceSupport { @@ -74,4 +78,18 @@ public class OrganisationsService extends WaoServiceSupport { } + public SortedSet<Organisation> getOrganisationsToWorkOnSampleRow(ObsProgram obsProgram) { + + SortedSet<Organisation> organisations = new TreeSet<>(Organisations.comparator()); + + organisations.addAll(getCompaniesService().getAllCompanies()); + + if (obsProgram.isSclerochronology()) { + organisations.addAll(getLaboratoriesService().getAllLaboratories()); + } + + return organisations; + + } + } diff --git a/wao-services/src/main/java/fr/ifremer/wao/services/service/administration/ReferentialService.java b/wao-services/src/main/java/fr/ifremer/wao/services/service/administration/ReferentialService.java index 9843992..122c634 100644 --- a/wao-services/src/main/java/fr/ifremer/wao/services/service/administration/ReferentialService.java +++ b/wao-services/src/main/java/fr/ifremer/wao/services/service/administration/ReferentialService.java @@ -861,4 +861,13 @@ public class ReferentialService extends WaoServiceSupport { commit(); } + + public ImmutableSet<Species> getAllSpecies() { + + List<Species> all = getSpeciesDao().findAll(); + + return ImmutableSet.copyOf(all); + + } + } diff --git a/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/ContactImportExportModel.java b/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/ContactImportExportModel.java index afe38e9..ab838bd 100644 --- a/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/ContactImportExportModel.java +++ b/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/ContactImportExportModel.java @@ -26,7 +26,6 @@ package fr.ifremer.wao.services.service.csv; import com.google.common.base.Preconditions; import fr.ifremer.wao.WaoUtils; import fr.ifremer.wao.entity.Boat; -import fr.ifremer.wao.entity.Company; import fr.ifremer.wao.entity.Contact; import fr.ifremer.wao.entity.ContactImpl; import fr.ifremer.wao.entity.ContactStateMotif; @@ -34,11 +33,12 @@ import fr.ifremer.wao.entity.DataReliability; import fr.ifremer.wao.entity.LocationType; import fr.ifremer.wao.entity.ObsProgram; import fr.ifremer.wao.entity.ObservedDataControl; +import fr.ifremer.wao.entity.Organisation; import fr.ifremer.wao.entity.SampleRow; import fr.ifremer.wao.entity.TerrestrialLocation; import fr.ifremer.wao.entity.WaoUser; import fr.ifremer.wao.services.service.csv.operations.BoatParserFormatter; -import fr.ifremer.wao.services.service.csv.operations.CompanyParserFormatter; +import fr.ifremer.wao.services.service.csv.operations.OrganisationParserFormatter; import fr.ifremer.wao.services.service.csv.operations.ContactStateMotivesParserFormatter; import fr.ifremer.wao.services.service.csv.operations.ContactStateParserFormatter; import fr.ifremer.wao.services.service.csv.operations.DayParserFormatter; @@ -164,13 +164,13 @@ public class ContactImportExportModel implements ImportExportModel<Contact> { modelBuilder.newIgnoredColumn("CONTACT_OBSERVATEURS_SOCIETE"); modelBuilder.newColumnForExport( "CONTACT_OBSERVATEURS_SOCIETE", - new ValueGetter<Contact, Company>() { + new ValueGetter<Contact, Organisation>() { @Override - public Company get(Contact contact) { - return contact.getMainObserver().getCompany(); + public Organisation get(Contact contact) { + return contact.getMainObserver().getOrganisation(); } }, - new CompanyParserFormatter(locale, null) + new OrganisationParserFormatter(locale, null) ); modelBuilder.newColumnForImportExport("CONTACT_ETAT", "contactState", new ContactStateParserFormatter(locale, obsProgram)); diff --git a/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/ObsMerObsVenteSamplingPlanImportExportModel.java b/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/ObsMerObsVenteSamplingPlanImportExportModel.java index 824223f..54204a6 100644 --- a/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/ObsMerObsVenteSamplingPlanImportExportModel.java +++ b/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/ObsMerObsVenteSamplingPlanImportExportModel.java @@ -26,9 +26,10 @@ package fr.ifremer.wao.services.service.csv; import com.opensymphony.xwork2.util.logging.Logger; import com.opensymphony.xwork2.util.logging.LoggerFactory; -import fr.ifremer.wao.entity.Company; import fr.ifremer.wao.entity.FishingZone; +import fr.ifremer.wao.entity.IndividualMeasurementStrategy; import fr.ifremer.wao.entity.ObsProgram; +import fr.ifremer.wao.entity.Organisation; import fr.ifremer.wao.entity.Profession; import fr.ifremer.wao.entity.ProfessionImpl; import fr.ifremer.wao.entity.SampleMonth; @@ -36,15 +37,17 @@ import fr.ifremer.wao.entity.SampleMonthImpl; import fr.ifremer.wao.entity.SampleRow; import fr.ifremer.wao.entity.SampleRowImpl; import fr.ifremer.wao.entity.SamplingStrategy; +import fr.ifremer.wao.entity.SclerochronologySamplingContext; import fr.ifremer.wao.entity.TerrestrialLocation; import fr.ifremer.wao.services.service.administration.ReferentialService; -import fr.ifremer.wao.services.service.csv.operations.CompanyParserFormatter; import fr.ifremer.wao.services.service.csv.operations.Dcf5CodesParserFormatter; import fr.ifremer.wao.services.service.csv.operations.DistrictNamesFormatter; import fr.ifremer.wao.services.service.csv.operations.DistrictsParserFormatter; import fr.ifremer.wao.services.service.csv.operations.FishingZonesParserFormatter; import fr.ifremer.wao.services.service.csv.operations.I18nAbleParserFormatter; +import fr.ifremer.wao.services.service.csv.operations.OrganisationParserFormatter; import fr.ifremer.wao.services.service.csv.operations.SampleRowCodeParserFormatter; +import fr.ifremer.wao.services.service.csv.operations.SpeciesParserFormatter; import org.nuiton.csv.Common; import org.nuiton.csv.ExportableColumn; import org.nuiton.csv.ImportExportModel; @@ -59,6 +62,7 @@ import java.text.SimpleDateFormat; import java.util.Date; import java.util.List; import java.util.Locale; +import java.util.Set; import java.util.regex.Pattern; /** @@ -115,7 +119,7 @@ public class ObsMerObsVenteSamplingPlanImportExportModel implements ImportExport protected ObsProgram obsProgram; - protected List<Company> companies; + protected Set<Organisation> organisations; protected List<FishingZone> fishingZones; @@ -136,12 +140,12 @@ public class ObsMerObsVenteSamplingPlanImportExportModel implements ImportExport /** Pour l'import */ public ObsMerObsVenteSamplingPlanImportExportModel(Locale locale, ObsProgram obsProgram, - List<Company> companies, List<FishingZone> fishingZones, + Set<Organisation> organisations, List<FishingZone> fishingZones, List<TerrestrialLocation> terrestrialDistricts, ReferentialService referentialService) { this.locale = locale; this.obsProgram = obsProgram; - this.companies = companies; + this.organisations = organisations; this.fishingZones = fishingZones; this.terrestrialDistricts = terrestrialDistricts; this.referentialService = referentialService; @@ -194,7 +198,7 @@ public class ObsMerObsVenteSamplingPlanImportExportModel implements ImportExport modelBuilder = new ModelBuilder<>(); modelBuilder.newColumnForImportExport("PLAN_CODE", SampleRow.PROPERTY_CODE, new SampleRowCodeParserFormatter(locale, obsProgram)); - modelBuilder.newColumnForImportExport("SOCIETE_NOM", SampleRow.PROPERTY_ORGANISATION, new CompanyParserFormatter(locale, companies)); + modelBuilder.newColumnForImportExport("ORGANISATION_NOM", SampleRow.PROPERTY_ORGANISATION, new OrganisationParserFormatter(locale, organisations)); modelBuilder.newColumnForExport("PECHE_FACADE", "facade"); modelBuilder.newIgnoredColumn("PECHE_FACADE"); @@ -204,12 +208,6 @@ public class ObsMerObsVenteSamplingPlanImportExportModel implements ImportExport modelBuilder.newColumnForImportExport("PECHE_DIVISION", SampleRow.PROPERTY_FISHING_ZONE, new FishingZonesParserFormatter(locale, fishingZones)); modelBuilder.newColumnForImportExport("PECHE_AUTRE", SampleRow.PROPERTY_FISHING_ZONES_INFOS); - modelBuilder.newColumnForImportExport("METIER_CODE_DCF5", SampleRow.PROPERTY_DCF5_CODE, new Dcf5CodesParserFormatter(locale, referentialService)); - modelBuilder.newColumnForImportExport("METIER_MAILLAGE", SampleRow.PROPERTY_PROFESSION + "." + Profession.PROPERTY_MESH_SIZE); - modelBuilder.newColumnForImportExport("METIER_TAILLE", SampleRow.PROPERTY_PROFESSION + "." + Profession.PROPERTY_SIZE); - modelBuilder.newColumnForImportExport("METIER_AUTRE", SampleRow.PROPERTY_PROFESSION + "." + Profession.PROPERTY_OTHER); - modelBuilder.newColumnForImportExport("METIER_LIBELLE", SampleRow.PROPERTY_PROFESSION + "." + Profession.PROPERTY_LIBELLE); - modelBuilder.newColumnForImportExport("METIER_ESPECES", SampleRow.PROPERTY_PROFESSION + "." + Profession.PROPERTY_SPECIES); modelBuilder.newColumnForImportExport("PROGRAMME_CODE", SampleRow.PROPERTY_PROGRAM_NAME); modelBuilder.newColumnForImportExport("PROGRAMME_DEBUT", SampleRow.PROPERTY_PERIOD_BEGIN, MONTH_YEAR_PARSER_FORMATTER); @@ -221,13 +219,29 @@ public class ObsMerObsVenteSamplingPlanImportExportModel implements ImportExport modelBuilder.newColumnForImportExport(headerName, new ExpectedTidesValueGetterSetter(month), Common.INTEGER); } - if (obsProgram == ObsProgram.OBSMER) { + if (obsProgram.isSclerochronology()) { + modelBuilder.newColumnForImportExport("ESPECE_CIBLE", SampleRow.PROPERTY_SPECIES, new SpeciesParserFormatter(locale, referentialService.getAllSpecies())); + modelBuilder.newColumnForImportExport("CONTEXTE", SampleRow.PROPERTY_SCLEROCHRONOLOGY_SAMPLING_CONTEXT, new I18nAbleParserFormatter<>(locale, SclerochronologySamplingContext.values())); + modelBuilder.newColumnForImportExport("CONTEXTE_COMPLEMENT", SampleRow.PROPERTY_SCLEROCHRONOLOGY_SAMPLING_CONTEXT_INFO); + modelBuilder.newColumnForImportExport("MESURES", SampleRow.PROPERTY_INDIVIDUAL_MEASUREMENT_STRATEGY, new I18nAbleParserFormatter<>(locale, IndividualMeasurementStrategy.values())); + } + + if (obsProgram.isObsMer() || obsProgram.isObsVente()) { + modelBuilder.newColumnForImportExport("METIER_CODE_DCF5", SampleRow.PROPERTY_DCF5_CODE, new Dcf5CodesParserFormatter(locale, referentialService)); + modelBuilder.newColumnForImportExport("METIER_MAILLAGE", SampleRow.PROPERTY_PROFESSION + "." + Profession.PROPERTY_MESH_SIZE); + modelBuilder.newColumnForImportExport("METIER_TAILLE", SampleRow.PROPERTY_PROFESSION + "." + Profession.PROPERTY_SIZE); + modelBuilder.newColumnForImportExport("METIER_AUTRE", SampleRow.PROPERTY_PROFESSION + "." + Profession.PROPERTY_OTHER); + modelBuilder.newColumnForImportExport("METIER_LIBELLE", SampleRow.PROPERTY_PROFESSION + "." + Profession.PROPERTY_LIBELLE); + modelBuilder.newColumnForImportExport("METIER_ESPECES", SampleRow.PROPERTY_PROFESSION + "." + Profession.PROPERTY_SPECIES); + } + + if (obsProgram.isObsMer()) { modelBuilder.newColumnForImportExport("PLAN_DUREE_MOY", SampleRow.PROPERTY_AVERAGE_TIDE_TIME, Common.PRIMITIVE_INTEGER); modelBuilder.newColumnForImportExport("PLAN_NB_OBSERV", SampleRow.PROPERTY_NB_OBSERVANTS, Common.PRIMITIVE_INTEGER); modelBuilder.newColumnForImportExport("TAUX_COUVERTURE_APPLIQUE", SampleRow.PROPERTY_APPLIED_COVERAGE_RATE, Common.DOUBLE); } - if (obsProgram == ObsProgram.OBSVENTE) { + if (obsProgram.isObsVente()) { modelBuilder.newColumnForImportExport("PLAN_STRATEGIE", "samplingStrategy", new I18nAbleParserFormatter<>(locale, SamplingStrategy.values())); modelBuilder.newColumnForImportExport("PLAN_LIEU_CODE", SampleRow.PROPERTY_TERRESTRIAL_LOCATIONS, new DistrictsParserFormatter(locale, terrestrialDistricts)); modelBuilder.newColumnForExport("PLAN_LIEU_NOM", SampleRow.PROPERTY_TERRESTRIAL_LOCATIONS, new DistrictNamesFormatter()); diff --git a/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/operations/CompanyParserFormatter.java b/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/operations/OrganisationParserFormatter.java similarity index 50% rename from wao-services/src/main/java/fr/ifremer/wao/services/service/csv/operations/CompanyParserFormatter.java rename to wao-services/src/main/java/fr/ifremer/wao/services/service/csv/operations/OrganisationParserFormatter.java index 1424462..472f0a2 100644 --- a/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/operations/CompanyParserFormatter.java +++ b/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/operations/OrganisationParserFormatter.java @@ -25,51 +25,53 @@ package fr.ifremer.wao.services.service.csv.operations; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Maps; -import fr.ifremer.wao.entity.Companies; -import fr.ifremer.wao.entity.Company; +import fr.ifremer.wao.entity.Organisation; +import fr.ifremer.wao.entity.Organisations; import org.apache.commons.lang3.StringUtils; import org.nuiton.csv.ValueParserFormatter; import org.nuiton.i18n.I18n; import java.text.ParseException; -import java.util.List; import java.util.Locale; +import java.util.Set; -/** Parse a company according to it's name. */ -public class CompanyParserFormatter implements ValueParserFormatter<Company> { +/** + * Parse an {@link fr.ifremer.wao.entity.Organisation} according to it's name. + */ +public class OrganisationParserFormatter implements ValueParserFormatter<Organisation> { protected final Locale locale; - protected List<Company> companies; + protected Set<Organisation> organisations; - protected ImmutableMap<String, Company> indexedCompanies; + protected ImmutableMap<String, Organisation> indexedOrganisations; - public CompanyParserFormatter(Locale locale, List<Company> companies) { + public OrganisationParserFormatter(Locale locale, Set<Organisation> organisations) { this.locale = locale; - this.companies = companies; + this.organisations = organisations; } @Override - public String format(Company company) { - String companyName = ""; - if (company != null) { - companyName = company.getName(); + public String format(Organisation organisation) { + String organisationName = ""; + if (organisation != null) { + organisationName = organisation.getName(); } - return companyName; + return organisationName; } @Override - public Company parse(String companyName) throws ParseException { - if (indexedCompanies == null) { - indexedCompanies = Maps.uniqueIndex(companies, Companies.getName()); + public Organisation parse(String organisationName) throws ParseException { + if (indexedOrganisations == null) { + indexedOrganisations = Maps.uniqueIndex(organisations, Organisations.getName()); } - Company company = null; - if (StringUtils.isNotBlank(companyName)) { - company = indexedCompanies.get(companyName.trim()); - if (company == null) { - throw new IllegalArgumentException(I18n.l(locale, "wao.import.contact.failure.unkwonCompany", companyName)); + Organisation organisation = null; + if (StringUtils.isNotBlank(organisationName)) { + organisation = indexedOrganisations.get(organisationName.trim()); + if (organisation == null) { + throw new IllegalArgumentException(I18n.l(locale, "wao.import.sampleRow.failure.unknownOrganisation", organisationName)); } } - return company; + return organisation; } } diff --git a/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/operations/SpeciesParserFormatter.java b/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/operations/SpeciesParserFormatter.java new file mode 100644 index 0000000..92bea35 --- /dev/null +++ b/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/operations/SpeciesParserFormatter.java @@ -0,0 +1,51 @@ +package fr.ifremer.wao.services.service.csv.operations; + +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Maps; +import fr.ifremer.wao.entity.Species; +import fr.ifremer.wao.entity.Specieses; +import org.apache.commons.lang3.StringUtils; +import org.nuiton.csv.ValueParserFormatter; +import org.nuiton.i18n.I18n; + +import java.text.ParseException; +import java.util.Locale; + +public class SpeciesParserFormatter implements ValueParserFormatter<Species> { + + protected Locale locale; + + protected ImmutableSet<Species> species; + + protected ImmutableMap<String, Species> indexedSpecies; + + public SpeciesParserFormatter(Locale locale, ImmutableSet<Species> species) { + this.locale = locale; + this.species = species; + } + + @Override + public String format(Species species) { + String speciesName = ""; + if (species != null) { + speciesName = species.getPermanentCode(); + } + return speciesName; + } + + @Override + public Species parse(String speciesPermanentCode) throws ParseException { + if (indexedSpecies == null) { + indexedSpecies = Maps.uniqueIndex(species, Specieses.getPermanentCode()); + } + Species species = null; + if (StringUtils.isNotBlank(speciesPermanentCode)) { + species = indexedSpecies.get(speciesPermanentCode.trim()); + if (species == null) { + throw new IllegalArgumentException(I18n.l(locale, "wao.import.sampleRow.failure.unknownSpecies", speciesPermanentCode)); + } + } + return species; + } +} diff --git a/wao-services/src/main/resources/i18n/wao-services_en_GB.properties b/wao-services/src/main/resources/i18n/wao-services_en_GB.properties index 41b794c..a8a104a 100644 --- a/wao-services/src/main/resources/i18n/wao-services_en_GB.properties +++ b/wao-services/src/main/resources/i18n/wao-services_en_GB.properties @@ -86,14 +86,19 @@ wao.import.sampleRow.failure.codeMustBeUnique=Line %s\: The sample row code must wao.import.sampleRow.failure.fishingZoneMissing=Line %s\: You must precise at least one fishing zone wao.import.sampleRow.failure.missingDcf5Codes=Line %s\: You must precise at least one DCF5 code wao.import.sampleRow.failure.missingFishingZones=Line %s\: You must precise at least one fishing zone +wao.import.sampleRow.failure.missingIndividualMeasurementStrategy= Line %s\: You myst precise measurement strategy wao.import.sampleRow.failure.missingPeriodBegin=Line %s\: You must precise the period beginning wao.import.sampleRow.failure.missingPeriodEnd=Line %s\: You must precise the period end wao.import.sampleRow.failure.missingProfessionSpecies=Line %s\: For this sampling strategy, you must provide the species wao.import.sampleRow.failure.missingProgramName=Line %s\: You must precise the program name wao.import.sampleRow.failure.missingSampleRowCode=Line %s\: You must precise a code for the sample row +wao.import.sampleRow.failure.missingSclerochronologySamplingContext=Line %s\:You must precise the context +wao.import.sampleRow.failure.missingSpecies=Line %s\:You must precise the species wao.import.sampleRow.failure.noEffortDefined=Line %s\: You must precise effort wao.import.sampleRow.failure.sampleMonthWithIllegalExpectedTidesValue=Line %s\: Effort must be positive for month %s wao.import.sampleRow.failure.unknownFishingGearDcfCode=Unknown fishing gear code\: %s +wao.import.sampleRow.failure.unknownOrganisation=Unknown organisation %s +wao.import.sampleRow.failure.unknownSpecies=Unknown species %s wao.import.sampleRow.failure.unknownTargetSpeciesDcfCode=Unknown target species code\: %s wao.import.sampleRow.failure.wrongFishingZone=There is no fishing zone with the code '%s' wao.import.sampleRow.failure.wrongSampleRowCodeFormat=The sample row code '%s' is not compliant with the format "YYYY_PIIII" diff --git a/wao-services/src/main/resources/i18n/wao-services_fr_FR.properties b/wao-services/src/main/resources/i18n/wao-services_fr_FR.properties index a4dc317..01f18dd 100644 --- a/wao-services/src/main/resources/i18n/wao-services_fr_FR.properties +++ b/wao-services/src/main/resources/i18n/wao-services_fr_FR.properties @@ -84,14 +84,19 @@ wao.import.sampleRow.failure.codeMustBeUnique=Ligne %s \: Le code ligne doit êt wao.import.sampleRow.failure.fishingZoneMissing=Ligne %s \: Il faut préciser au moins une zone de pêche wao.import.sampleRow.failure.missingDcf5Codes=Ligne %s \: Il faut préciser au moins un code DCF5 wao.import.sampleRow.failure.missingFishingZones=Ligne %s \: Il faut préciser au moins une zone de pêche +wao.import.sampleRow.failure.missingIndividualMeasurementStrategy=Ligne %s \: il faut préciser l'ensemble de caractéristiques à mesurer wao.import.sampleRow.failure.missingPeriodBegin=Ligne %s \: Il faut préciser le débat de la période wao.import.sampleRow.failure.missingPeriodEnd=Ligne %s \: Il faut préciser la fin de la période wao.import.sampleRow.failure.missingProfessionSpecies=Ligne %s \: Il faut préciser les espèces cibles pour cette stratégie d'échantillonage wao.import.sampleRow.failure.missingProgramName=Ligne %s \: Il faut préciser le programme wao.import.sampleRow.failure.missingSampleRowCode=Ligne %s \: Il faut préciser un code pour a ligne du plan +wao.import.sampleRow.failure.missingSclerochronologySamplingContext=Ligne %s \: Il faut préciser le contexte dans lequel se fera l'échantillonnage +wao.import.sampleRow.failure.missingSpecies=Ligne %s \: Il faut préciser l'espèce cible wao.import.sampleRow.failure.noEffortDefined=Ligne %s \: Il faut préciser un effort sur au moins un mois wao.import.sampleRow.failure.sampleMonthWithIllegalExpectedTidesValue=Ligne %s \: l'effort d'observation doit être positif pour le mois %s wao.import.sampleRow.failure.unknownFishingGearDcfCode=Le code engin %s est inconnu du référentiel +wao.import.sampleRow.failure.unknownOrganisation=L'organisation %s n'est pas connue +wao.import.sampleRow.failure.unknownSpecies=L'espèce %s n'est pas connue wao.import.sampleRow.failure.unknownTargetSpeciesDcfCode=Le code espèce cible %s est inconnu du référentiel wao.import.sampleRow.failure.wrongFishingZone=Le code '%s' ne correspond à aucune zone de pêche connue du référentiel wao.import.sampleRow.failure.wrongSampleRowCodeFormat=Le code '%s' n'est pas un code de ligne valide selon le format "AAAA_PIIII" diff --git a/wao-services/src/test/java/fr/ifremer/wao/services/service/BoatsServiceTest.java b/wao-services/src/test/java/fr/ifremer/wao/services/service/BoatsServiceTest.java index 58eaf29..6ec77b0 100644 --- a/wao-services/src/test/java/fr/ifremer/wao/services/service/BoatsServiceTest.java +++ b/wao-services/src/test/java/fr/ifremer/wao/services/service/BoatsServiceTest.java @@ -23,7 +23,6 @@ package fr.ifremer.wao.services.service; import fr.ifremer.wao.BoatsFilter; import fr.ifremer.wao.services.AbstractWaoServiceTest; -import fr.ifremer.wao.services.ObsMerFixtures; import org.junit.Before; import org.junit.Test; import org.nuiton.util.pagination.PaginationParameter; diff --git a/wao-services/src/test/java/fr/ifremer/wao/services/service/ContactsServiceTest.java b/wao-services/src/test/java/fr/ifremer/wao/services/service/ContactsServiceTest.java index ff213a8..ed7f169 100644 --- a/wao-services/src/test/java/fr/ifremer/wao/services/service/ContactsServiceTest.java +++ b/wao-services/src/test/java/fr/ifremer/wao/services/service/ContactsServiceTest.java @@ -23,7 +23,6 @@ package fr.ifremer.wao.services.service; import fr.ifremer.wao.ContactsFilter; import fr.ifremer.wao.services.AbstractWaoServiceTest; -import fr.ifremer.wao.services.ObsMerFixtures; import org.apache.commons.io.IOUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; diff --git a/wao-services/src/test/java/fr/ifremer/wao/services/service/ObsMerFixtures.java b/wao-services/src/test/java/fr/ifremer/wao/services/service/ObsMerFixtures.java new file mode 100644 index 0000000..e3c1806 --- /dev/null +++ b/wao-services/src/test/java/fr/ifremer/wao/services/service/ObsMerFixtures.java @@ -0,0 +1,93 @@ +package fr.ifremer.wao.services.service; + +/* + * #%L + * Wao :: Services + * %% + * Copyright (C) 2009 - 2014 Ifremer + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ + +import fr.ifremer.wao.WaoTechnicalException; +import fr.ifremer.wao.entity.FishingGearDcf; +import fr.ifremer.wao.entity.FishingGearDcfTopiaDao; +import fr.ifremer.wao.entity.ObsProgram; +import fr.ifremer.wao.entity.TargetSpeciesDcf; +import fr.ifremer.wao.entity.TargetSpeciesDcfTopiaDao; +import fr.ifremer.wao.entity.UserRole; +import fr.ifremer.wao.services.AuthenticatedWaoUser; +import fr.ifremer.wao.services.WaoServiceContext; +import org.apache.commons.io.IOUtils; + +import java.io.InputStream; + +public class ObsMerFixtures extends WaoFixtures { + + public ObsMerFixtures(WaoServiceContext serviceContext) { + super(serviceContext); + } + + public AuthenticatedWaoUser admin() { + return newAuthenticatedWaoUser("admin", ObsProgram.OBSMER, UserRole.ADMIN); + } + + public AuthenticatedWaoUser jmichmuche() { + return newAuthenticatedWaoUser("jmichmuche", ObsProgram.OBSMER, UserRole.COORDINATOR); + } + + public void samplingPlan() { + ifremer(); + oceanet(); + fishingZones(); + InputStream input = null; + try { + input = getClass().getResourceAsStream("/import/echantillonnage.csv"); + serviceContext.newService(ObsMerSamplingPlanService.class).importSamplingPlan(admin(), input); + } catch (ImportErrorException e) { + throw new WaoTechnicalException(e); + } finally { + IOUtils.closeQuietly(input); + } + } + + public void contacts() { + samplingPlan(); + jmichmuche(); + navires(); + InputStream input = null; + try { + input = getClass().getResourceAsStream("/import/contacts.csv"); + serviceContext.newService(ContactsService.class).importContacts(admin(), input); + } catch (ImportErrorException e) { + throw new WaoTechnicalException(e); + } finally { + IOUtils.closeQuietly(input); + } + } + + public FishingGearDcf ptb() { + FishingGearDcfTopiaDao fishingGearDcfDao = serviceContext.getPersistenceContext().getFishingGearDcfDao(); + FishingGearDcf ptb = fishingGearDcfDao.forCodeEquals("PTB").findUnique(); + return ptb; + } + + public TargetSpeciesDcf def() { + TargetSpeciesDcfTopiaDao fishingGearDcfDao = serviceContext.getPersistenceContext().getTargetSpeciesDcfDao(); + TargetSpeciesDcf def = fishingGearDcfDao.forCodeEquals("DEF").findUnique(); + return def; + } + +} diff --git a/wao-services/src/test/java/fr/ifremer/wao/services/service/ObsMerSamplingPlanServiceTest.java b/wao-services/src/test/java/fr/ifremer/wao/services/service/ObsMerSamplingPlanServiceTest.java index 61c6d5b..76f8f4f 100644 --- a/wao-services/src/test/java/fr/ifremer/wao/services/service/ObsMerSamplingPlanServiceTest.java +++ b/wao-services/src/test/java/fr/ifremer/wao/services/service/ObsMerSamplingPlanServiceTest.java @@ -27,7 +27,6 @@ import fr.ifremer.wao.entity.SampleMonth; import fr.ifremer.wao.entity.SampleRow; import fr.ifremer.wao.services.AbstractWaoServiceTest; import fr.ifremer.wao.services.FakeWaoServiceContext; -import fr.ifremer.wao.services.ObsMerFixtures; import org.apache.commons.io.IOUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; diff --git a/wao-services/src/test/java/fr/ifremer/wao/services/service/SclerochronologyFixtures.java b/wao-services/src/test/java/fr/ifremer/wao/services/service/SclerochronologyFixtures.java new file mode 100644 index 0000000..0310d5e --- /dev/null +++ b/wao-services/src/test/java/fr/ifremer/wao/services/service/SclerochronologyFixtures.java @@ -0,0 +1,50 @@ +package fr.ifremer.wao.services.service; + +import fr.ifremer.wao.WaoTechnicalException; +import fr.ifremer.wao.entity.Laboratory; +import fr.ifremer.wao.entity.ObsProgram; +import fr.ifremer.wao.entity.UserRole; +import fr.ifremer.wao.services.AuthenticatedWaoUser; +import fr.ifremer.wao.services.WaoServiceContext; +import fr.ifremer.wao.services.service.administration.LaboratoriesService; +import fr.ifremer.wao.services.service.administration.ReferentialService; +import org.apache.commons.io.IOUtils; + +import java.io.InputStream; + +public class SclerochronologyFixtures extends WaoFixtures { + + public SclerochronologyFixtures(WaoServiceContext serviceContext) { + super(serviceContext); + } + + public AuthenticatedWaoUser admin() { + return newAuthenticatedWaoUser("admin", ObsProgram.SCLEROCHRONOLOGY, UserRole.ADMIN); + } + + public void species() { + InputStream input = null; + try { + input = getClass().getResourceAsStream("/import/especes.csv"); + serviceContext.newService(ReferentialService.class).importSpecies(input); + } catch (ImportErrorException e) { + throw new WaoTechnicalException(e); + } finally { + IOUtils.closeQuietly(input); + } + } + + protected boolean emhLaboratoryCreated; + + public void emhLaboratory() { + if ( ! emhLaboratoryCreated) { + ifremer(); + LaboratoriesService service = serviceContext.newService(LaboratoriesService.class); + Laboratory laboratory = service.newLaboratory(); + laboratory.setName("EMH"); + service.save(laboratory); + emhLaboratoryCreated = true; + } + } + +} diff --git a/wao-services/src/test/java/fr/ifremer/wao/services/service/SclerochronologySamplingPlanServiceTest.java b/wao-services/src/test/java/fr/ifremer/wao/services/service/SclerochronologySamplingPlanServiceTest.java new file mode 100644 index 0000000..b959dab --- /dev/null +++ b/wao-services/src/test/java/fr/ifremer/wao/services/service/SclerochronologySamplingPlanServiceTest.java @@ -0,0 +1,51 @@ +package fr.ifremer.wao.services.service; + +import fr.ifremer.wao.services.AbstractWaoServiceTest; +import org.apache.commons.io.IOUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +import java.io.InputStream; + +public class SclerochronologySamplingPlanServiceTest extends AbstractWaoServiceTest { + + private static final Log log = LogFactory.getLog(SclerochronologySamplingPlanServiceTest.class); + + protected SclerochronologySamplingPlanService service; + + protected SclerochronologyFixtures fixtures; + + protected boolean isDatabaseWithReferential() { + return true; + } + + @Before + public void setUp() { + service = newService(SclerochronologySamplingPlanService.class); + fixtures = new SclerochronologyFixtures(newServiceContext()); + } + + @Test + public void testImportSamplingPlan() { + fixtures.fishingZones(); + fixtures.species(); + fixtures.oceanet(); + fixtures.emhLaboratory(); + InputStream input = null; + try { + input = getClass().getResourceAsStream("/import/plan-sclerochronologie.csv"); + service.importSamplingPlan(fixtures.admin(), input); + } catch (ImportErrorException e) { + if (log.isDebugEnabled()) { + log.debug("unexpected exception raised", e); + } + Assert.fail("exception should not be raised"); + } finally { + IOUtils.closeQuietly(input); + } + + } +} \ No newline at end of file diff --git a/wao-services/src/test/java/fr/ifremer/wao/services/service/WaoFixtures.java b/wao-services/src/test/java/fr/ifremer/wao/services/service/WaoFixtures.java new file mode 100644 index 0000000..63e1885 --- /dev/null +++ b/wao-services/src/test/java/fr/ifremer/wao/services/service/WaoFixtures.java @@ -0,0 +1,88 @@ +package fr.ifremer.wao.services.service; + +import fr.ifremer.wao.WaoTechnicalException; +import fr.ifremer.wao.entity.Company; +import fr.ifremer.wao.entity.CompanyTopiaDao; +import fr.ifremer.wao.entity.ObsProgram; +import fr.ifremer.wao.entity.UserProfile; +import fr.ifremer.wao.entity.UserProfileImpl; +import fr.ifremer.wao.entity.UserRole; +import fr.ifremer.wao.entity.WaoUser; +import fr.ifremer.wao.entity.WaoUserImpl; +import fr.ifremer.wao.services.AuthenticatedWaoUser; +import fr.ifremer.wao.services.WaoServiceContext; +import fr.ifremer.wao.services.service.administration.ReferentialService; +import org.apache.commons.io.IOUtils; + +import java.io.InputStream; +import java.util.HashMap; +import java.util.Map; + +public class WaoFixtures { + + protected WaoServiceContext serviceContext; + + protected Map<String, Company> companies = new HashMap<>(); + + public WaoFixtures(WaoServiceContext serviceContext) { + this.serviceContext = serviceContext; + } + + protected Company getCompany(String companyName) { + Company company = companies.get(companyName); + if (company == null) { + CompanyTopiaDao companyDao = serviceContext.getPersistenceContext().getCompanyDao(); + company = companyDao.create( + Company.PROPERTY_NAME, companyName, + Company.PROPERTY_ACTIVE, true); + companies.put(companyName, company); + serviceContext.getPersistenceContext().commit(); + } + return company; + } + + protected AuthenticatedWaoUser newAuthenticatedWaoUser(String login, ObsProgram obsProgram, UserRole userRole) { + WaoUser waoUser = new WaoUserImpl(); + waoUser.setOrganisation(ifremer()); + waoUser.setLogin(login); + waoUser.setActive(true); + UserProfile userProfile = new UserProfileImpl(); + userProfile.setUserRole(userRole); + userProfile.setObsProgram(obsProgram); + userProfile.setCanWrite(true); + waoUser.addUserProfile(userProfile); + return new AuthenticatedWaoUser(waoUser, userProfile); + } + + public Company ifremer() { + return getCompany("IFREMER"); + } + + public Company oceanet() { + return getCompany("OCEANET"); + } + + public void fishingZones() { + InputStream input = null; + try { + input = getClass().getResourceAsStream("/import/zonesPeche.csv"); + serviceContext.newService(ReferentialService.class).importFishingZones(input); + } catch (ImportErrorException e) { + throw new WaoTechnicalException(e); + } finally { + IOUtils.closeQuietly(input); + } + } + + public void navires() { + InputStream input = null; + try { + input = getClass().getResourceAsStream("/import/navires.csv"); + serviceContext.newService(ReferentialService.class).importBoats(input); + } catch (ImportErrorException e) { + throw new WaoTechnicalException(e); + } finally { + IOUtils.closeQuietly(input); + } + } +} diff --git a/wao-services/src/test/resources/import/echantillonnage.csv b/wao-services/src/test/resources/import/echantillonnage.csv index beda484..0073eab 100644 --- a/wao-services/src/test/resources/import/echantillonnage.csv +++ b/wao-services/src/test/resources/import/echantillonnage.csv @@ -1,14 +1,14 @@ "PLAN_CODE";"SOCIETE_NOM";"PECHE_DIVISION";"PECHE_AUTRE";"METIER_CODE_DCF5";"METIER_MAILLAGE";"METIER_TAILLE";"METIER_AUTRE";"METIER_LIBELLE";"METIER_ESPECES";"PROGRAMME_CODE";"PROGRAMME_DEBUT";"PROGRAMME_FIN";"12/2009";"01/2010";"02/2010";"03/2010";"04/2010";"05/2010";"06/2010";"07/2010";"08/2010";"09/2010";"10/2010";"11/2010";"12/2010";"01/2011";"02/2011";"03/2011";"PLAN_DUREE_MOY";"PLAN_NB_OBSERV";"PLAN_COMMENT";"TAUX_COUVERTURE_APPLIQUE" -"2010_M0001";"Ifremer";"IId,I";;"DRB_ALG";;;;;;"MA-2009";"03/2010";"01/2011";;;;0;0;0;0;0;0;0;2;0;0;4;;;"1.5";1;"Un petit commentaire";5 -"2010_M0002";"Ifremer";"IId";;"DRH_CAT,DRH_CRU";;;;"Fileyage";"poissons tubes";"MANY";"01/2008";"12/2008";;20;0;0;21;0;0;21;0;0;21;0;0;;;;1;1;;5 -"2010_M0003";"Ifremer";"IId,IV";;"DRH";;;;"balottage en plein air";"divers choses visqueuses";"MA-2009";"03/2010";"01/2011";;;;0;22;0;0;25;0;0;21;0;0;25;;;2;1;;5 -"2009_M0001";"Ifremer";"IId,IV";;"GTR_DEF,GNS_DEF";"110-119";;;"Fileyage à poissons tubes";"poissons plats";"PPP2010";"12/2009";"10/2010";0;1;1;1;2;1;1;1;1;1;2;;;;;;1;1;;5 -"2009_M0002";"Ifremer";"IId";;"GTR_DEF,GNS_DEF";"9888-99";;;"Fileyage à sirènes ";"nymphes";"PPP2010";"12/2009";"10/2010";1;1;1;2;3;4;4;4;4;3;3;;;;;;1;1;;10 -"2009_M0003";"Ifremer";"IV";;"GTR_MOL,GNS";;;;"Fileyages à baleines à bosse";"chameaux";"PPP2010";"12/2009";"10/2010";2;2;2;2;2;2;2;2;2;2;4;;;;;;1;1;;10 -"2009_M0004";"Ifremer";"IId";;"PTB_ALG";">=190";">18";;"Chalutage de fond machiavélique";"gadidés; divers";"PPP2010";"12/2009";"10/2010";1;1;1;1;1;1;1;1;1;1;2;;;;;;3;2;;10 -"2009_M0005";"Ifremer";"IId";;"PTB_ALG";"70-1100";">1140";;"Plongeur de fond sous-marin";"gadidés; divers";"PPP2010";"12/2009";"10/2010";1;1;1;1;1;1;1;1;1;1;2;;;;;;3;2;;10 +"2010_M0001";"IFREMER";"IId,I";;"DRB_ALG";;;;;;"MA-2009";"03/2010";"01/2011";;;;0;0;0;0;0;0;0;2;0;0;4;;;"1.5";1;"Un petit commentaire";5 +"2010_M0002";"IFREMER";"IId";;"DRH_CAT,DRH_CRU";;;;"Fileyage";"poissons tubes";"MANY";"01/2008";"12/2008";;20;0;0;21;0;0;21;0;0;21;0;0;;;;1;1;;5 +"2010_M0003";"IFREMER";"IId,IV";;"DRH";;;;"balottage en plein air";"divers choses visqueuses";"MA-2009";"03/2010";"01/2011";;;;0;22;0;0;25;0;0;21;0;0;25;;;2;1;;5 +"2009_M0001";"IFREMER";"IId,IV";;"GTR_DEF,GNS_DEF";"110-119";;;"Fileyage à poissons tubes";"poissons plats";"PPP2010";"12/2009";"10/2010";0;1;1;1;2;1;1;1;1;1;2;;;;;;1;1;;5 +"2009_M0002";"IFREMER";"IId";;"GTR_DEF,GNS_DEF";"9888-99";;;"Fileyage à sirènes ";"nymphes";"PPP2010";"12/2009";"10/2010";1;1;1;2;3;4;4;4;4;3;3;;;;;;1;1;;10 +"2009_M0003";"IFREMER";"IV";;"GTR_MOL,GNS";;;;"Fileyages à baleines à bosse";"chameaux";"PPP2010";"12/2009";"10/2010";2;2;2;2;2;2;2;2;2;2;4;;;;;;1;1;;10 +"2009_M0004";"IFREMER";"IId";;"PTB_ALG";">=190";">18";;"Chalutage de fond machiavélique";"gadidés; divers";"PPP2010";"12/2009";"10/2010";1;1;1;1;1;1;1;1;1;1;2;;;;;;3;2;;10 +"2009_M0005";"IFREMER";"IId";;"PTB_ALG";"70-1100";">1140";;"Plongeur de fond sous-marin";"gadidés; divers";"PPP2010";"12/2009";"10/2010";1;1;1;1;1;1;1;1;1;1;2;;;;;;3;2;;10 "2009_M0006";"OCEANET";"I,IV";;"DRB_DEF";"70-1100";">1140";;"Leon";"poissons plats";"PPP2010";"12/2009";"10/2010";0;1;0;1;0;1;2;2;2;2;1;;;;;;3;2;; -"2010_M0004";"Ifremer";"IId,IV";;"PTB_DEF,PTB_ALG,DRH";;;;"Chalutage de fond";"gadidés; poissons plats; divers";"BLOB";"01/2010";"12/2010";;3;0;0;3;0;0;3;0;0;3;0;0;;;;3;1;; +"2010_M0004";"IFREMER";"IId,IV";;"PTB_DEF,PTB_ALG,DRH";;;;"Chalutage de fond";"gadidés; poissons plats; divers";"BLOB";"01/2010";"12/2010";;3;0;0;3;0;0;3;0;0;3;0;0;;;;3;1;; "2010_M0005";"OCEANET";"IId";;"DRB";;;;"Kamoulox";"merlu; poissons cerises; divers";"MA-2009";"03/2010";"01/2011";;;;0;5;0;0;5;0;0;6;0;0;3;;;3;1;;15 "2010_M0010";"OCEANET";"I,IV";;"DRB";"70-1100";;;"Kamoulox";"merlu; poissons pommes; divers";"MA-2009";"03/2010";"01/2011";;;;0;5;0;0;5;0;0;6;0;0;3;;;3;1;;15 "2010_M0011";"OCEANET";"I,IV";;"DRB_ANA";"70-1100";;;"Troubidou";"merlu; poissons cerises";"MA-2009";"03/2010";"01/2011";;;;0;5;0;0;5;0;0;6;0;0;3;;;3;1;; diff --git a/wao-services/src/test/resources/import/plan-sclerochronologie.csv b/wao-services/src/test/resources/import/plan-sclerochronologie.csv new file mode 100644 index 0000000..e2cdf2c --- /dev/null +++ b/wao-services/src/test/resources/import/plan-sclerochronologie.csv @@ -0,0 +1,6 @@ +PLAN_CODE;ORGANISATION_NOM;PECHE_DIVISION;PECHE_AUTRE;PROGRAMME_CODE;PROGRAMME_DEBUT;PROGRAMME_FIN;PLAN_COMMENT;ESPECE_CIBLE;CONTEXTE;CONTEXTE_COMPLEMENT;MESURES;01/2015;02/2015;03/2015;04/2015;05/2015;06/2015;07/2015;08/2015;09/2015;10/2015;11/2015;12/2015 +2015_S0001;OCEANET;X;;CAMPAGNE_22;01/2015;12/2015;;1644;Échantillonnage en mer;;Poids/Taille/Sexe;200;;100;0;50;;;;;;;12 +2015_S0002;OCEANET;X;;CAMPAGNE_22;01/2015;12/2015;;1644;Échantillonnage en mer;;Poids/Taille/Sexe;;;;0;;;300;300;;;; +2015_S0003;EMH;X;;CAMPAGNE_22;01/2015;12/2015;;1543;Échantillonnage à terre;;Poids/Taille/Sexe/Maturité/Âge;;200;;100;0;50;;100;0;50;; +2015_S0004;EMH;IV;;RECHERCHE;01/2015;12/2015;;1543;Campagne scientifique;;Poids/Taille/Sexe;;;;200;;100;0;50;;;; +2015_S0005;EMH;IV;;RECHERCHE;01/2015;12/2015;;1543;Campagne scientifique;;Poids/Taille;;200;;100;0;50;;;200;;100;0 diff --git a/wao-web/src/main/java/fr/ifremer/wao/web/action/EditSampleRowAction.java b/wao-web/src/main/java/fr/ifremer/wao/web/action/EditSampleRowAction.java index faee62f..814f729 100644 --- a/wao-web/src/main/java/fr/ifremer/wao/web/action/EditSampleRowAction.java +++ b/wao-web/src/main/java/fr/ifremer/wao/web/action/EditSampleRowAction.java @@ -29,11 +29,14 @@ import fr.ifremer.wao.entity.SampleMonth; import fr.ifremer.wao.entity.SampleRow; import fr.ifremer.wao.services.service.MissingDcf5CodesException; import fr.ifremer.wao.services.service.MissingFishingZonesException; +import fr.ifremer.wao.services.service.MissingIndividualMeasurementStrategyException; import fr.ifremer.wao.services.service.MissingPeriodBeginException; import fr.ifremer.wao.services.service.MissingPeriodEndException; import fr.ifremer.wao.services.service.MissingProfessionSpeciesException; import fr.ifremer.wao.services.service.MissingProgramNameException; import fr.ifremer.wao.services.service.MissingSampleRowLogCommentException; +import fr.ifremer.wao.services.service.MissingSclerochronologySamplingContextException; +import fr.ifremer.wao.services.service.MissingSpeciesException; import fr.ifremer.wao.services.service.NoEffortDefinedException; import fr.ifremer.wao.services.service.ObsMerSamplingPlanService; import fr.ifremer.wao.services.service.SampleMonthWithIllegalExpectedTidesValueException; @@ -126,6 +129,15 @@ public class EditSampleRowAction extends WaoJspActionSupport implements Preparab addFieldError("updateSampleRowCommand.dcf5Codes", t("wao.ui.form.SampleRow.error.noEffortDefined")); } + // TODO brendan 18/12/14 + catch (MissingIndividualMeasurementStrategyException e) { + throw new UnsupportedOperationException(); + } catch (MissingSclerochronologySamplingContextException e) { + throw new UnsupportedOperationException(); + } catch (MissingSpeciesException e) { + throw new UnsupportedOperationException(); + } + } @Override diff --git a/wao-web/src/main/java/fr/ifremer/wao/web/action/administration/ImportSpeciesAction.java b/wao-web/src/main/java/fr/ifremer/wao/web/action/administration/ImportSpeciesAction.java index 88f2b4c..d21b8cc 100644 --- a/wao-web/src/main/java/fr/ifremer/wao/web/action/administration/ImportSpeciesAction.java +++ b/wao-web/src/main/java/fr/ifremer/wao/web/action/administration/ImportSpeciesAction.java @@ -4,6 +4,8 @@ import fr.ifremer.wao.services.service.ImportErrorException; import java.io.InputStream; +import static org.nuiton.i18n.I18n.n; + public class ImportSpeciesAction extends AbstractImportReferentialAction { @Override @@ -13,6 +15,6 @@ public class ImportSpeciesAction extends AbstractImportReferentialAction { @Override protected String getSuccessMessage() { - return t("wao.import.species.success"); + return t(n("wao.import.species.success")); } } -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository wao. See http://git.codelutin.com/wao.git commit fde3c645ee6d1671b268b802f58d3fa5e3833fa8 Author: Brendan Le Ny <bleny@codelutin.com> Date: Thu Dec 18 15:09:42 2014 +0100 On gère les filtres dans le plan scléro --- .../main/java/fr/ifremer/wao/SampleRowsFilter.java | 18 ++--- .../java/fr/ifremer/wao/entity/BoatTopiaDao.java | 2 +- .../fr/ifremer/wao/entity/SampleRowTopiaDao.java | 4 +- .../ifremer/wao/services/service/BoatsService.java | 6 +- .../wao/services/service/ContactsService.java | 2 +- .../services/service/SampleRowsFilterValues.java | 88 ++++++++++++++++------ .../wao/services/service/SamplingPlanService.java | 4 +- .../service/SclerochronologySamplingPlan.java | 11 +++ .../resources/i18n/wao-services_en_GB.properties | 2 +- .../services/service/SclerochronologyFixtures.java | 15 ++++ .../SclerochronologySamplingPlanServiceTest.java | 24 ++++++ .../action/SampleRowsFilterValuesJsonAction.java | 34 +++++++-- .../main/webapp/WEB-INF/content/boat-details.jsp | 2 +- .../src/main/webapp/WEB-INF/content/contacts.jsp | 2 +- .../WEB-INF/content/obsmer/sampling-plan.jsp | 6 +- .../WEB-INF/content/obsvente/sampling-plan.jsp | 6 +- .../content/sclerochronology/sampling-plan.jsp | 12 +-- .../src/main/webapp/WEB-INF/content/synthesis.jsp | 4 +- 18 files changed, 178 insertions(+), 64 deletions(-) diff --git a/wao-persistence/src/main/java/fr/ifremer/wao/SampleRowsFilter.java b/wao-persistence/src/main/java/fr/ifremer/wao/SampleRowsFilter.java index 1bd98e0..6fc1321 100644 --- a/wao-persistence/src/main/java/fr/ifremer/wao/SampleRowsFilter.java +++ b/wao-persistence/src/main/java/fr/ifremer/wao/SampleRowsFilter.java @@ -67,7 +67,7 @@ public class SampleRowsFilter extends AbstractWaoFilter { protected Set<String> terrestrialDistrictIds; - protected Set<String> companyIds; + protected Set<String> organisationIds; protected LinkedHashSet<String> orderByArguments; @@ -159,12 +159,12 @@ public class SampleRowsFilter extends AbstractWaoFilter { this.terrestrialDistrictIds = terrestrialDistrictIds; } - public Set<String> getCompanyIds() { - return companyIds; + public Set<String> getOrganisationIds() { + return organisationIds; } - public void setCompanyIds(Set<String> companyIds) { - this.companyIds = companyIds; + public void setOrganisationIds(Set<String> organisationIds) { + this.organisationIds = organisationIds; } public LinkedHashSet<String> getOrderByArguments() { @@ -197,7 +197,7 @@ public class SampleRowsFilter extends AbstractWaoFilter { || CollectionUtils.isNotEmpty(targetSpeciesDcfIds) || CollectionUtils.isNotEmpty(samplingStrategies) || CollectionUtils.isNotEmpty(terrestrialDistrictIds) - || CollectionUtils.isNotEmpty(companyIds); + || CollectionUtils.isNotEmpty(organisationIds); return filled; } @@ -221,7 +221,7 @@ public class SampleRowsFilter extends AbstractWaoFilter { && WaoUtils.isEqualCollection(targetSpeciesDcfIds, that.targetSpeciesDcfIds) && WaoUtils.isEqualCollection(samplingStrategies, that.samplingStrategies) && WaoUtils.isEqualCollection(terrestrialDistrictIds, that.terrestrialDistrictIds) - && WaoUtils.isEqualCollection(companyIds, that.companyIds) + && WaoUtils.isEqualCollection(organisationIds, that.organisationIds) && WaoUtils.isEqualCollection(orderByArguments, that.orderByArguments); return equals; @@ -247,7 +247,7 @@ public class SampleRowsFilter extends AbstractWaoFilter { hashCode = 31 * hashCode + WaoUtils.collectionHashCode(targetSpeciesDcfIds); hashCode = 31 * hashCode + WaoUtils.collectionHashCode(samplingStrategies); hashCode = 31 * hashCode + WaoUtils.collectionHashCode(terrestrialDistrictIds); - hashCode = 31 * hashCode + WaoUtils.collectionHashCode(companyIds); + hashCode = 31 * hashCode + WaoUtils.collectionHashCode(organisationIds); hashCode = 31 * hashCode + WaoUtils.collectionHashCode(orderByArguments); return hashCode; } @@ -267,7 +267,7 @@ public class SampleRowsFilter extends AbstractWaoFilter { clone.targetSpeciesDcfIds = targetSpeciesDcfIds == null ? null : new HashSet<>(targetSpeciesDcfIds); clone.samplingStrategies = samplingStrategies == null ? null : new HashSet<>(samplingStrategies); clone.terrestrialDistrictIds = terrestrialDistrictIds == null ? null : new HashSet<>(terrestrialDistrictIds); - clone.companyIds = companyIds == null ? null : new HashSet<>(companyIds); + clone.organisationIds = organisationIds == null ? null : new HashSet<>(organisationIds); clone.orderByArguments = orderByArguments == null ? null : new LinkedHashSet<>(orderByArguments); return clone; } diff --git a/wao-persistence/src/main/java/fr/ifremer/wao/entity/BoatTopiaDao.java b/wao-persistence/src/main/java/fr/ifremer/wao/entity/BoatTopiaDao.java index d63e993..ab7c231 100644 --- a/wao-persistence/src/main/java/fr/ifremer/wao/entity/BoatTopiaDao.java +++ b/wao-persistence/src/main/java/fr/ifremer/wao/entity/BoatTopiaDao.java @@ -149,7 +149,7 @@ public class BoatTopiaDao extends AbstractBoatTopiaDao<Boat> { || CollectionUtils.isNotEmpty(filter.getElligibleForSampleRowsFilter().getTargetSpeciesDcfIds()) || CollectionUtils.isNotEmpty(filter.getElligibleForSampleRowsFilter().getSamplingStrategies()) || CollectionUtils.isNotEmpty(filter.getElligibleForSampleRowsFilter().getTerrestrialDistrictIds()) - || CollectionUtils.isNotEmpty(filter.getElligibleForSampleRowsFilter().getCompanyIds()); + || CollectionUtils.isNotEmpty(filter.getElligibleForSampleRowsFilter().getOrganisationIds()); return filled; } } diff --git a/wao-persistence/src/main/java/fr/ifremer/wao/entity/SampleRowTopiaDao.java b/wao-persistence/src/main/java/fr/ifremer/wao/entity/SampleRowTopiaDao.java index 8506a89..950fe8e 100644 --- a/wao-persistence/src/main/java/fr/ifremer/wao/entity/SampleRowTopiaDao.java +++ b/wao-persistence/src/main/java/fr/ifremer/wao/entity/SampleRowTopiaDao.java @@ -99,8 +99,8 @@ public class SampleRowTopiaDao extends AbstractSampleRowTopiaDao<SampleRow> { query.addIn(SampleRow.PROPERTY_PROGRAM_NAME, filter.getProgramNames()); } - if (CollectionUtils.isNotEmpty(filter.getCompanyIds())) { - query.addTopiaIdIn(SampleRow.PROPERTY_ORGANISATION, filter.getCompanyIds()); + if (CollectionUtils.isNotEmpty(filter.getOrganisationIds())) { + query.addTopiaIdIn(SampleRow.PROPERTY_ORGANISATION, filter.getOrganisationIds()); } if (CollectionUtils.isNotEmpty(filter.getSamplingStrategies())) { diff --git a/wao-services/src/main/java/fr/ifremer/wao/services/service/BoatsService.java b/wao-services/src/main/java/fr/ifremer/wao/services/service/BoatsService.java index 027b80d..da286422a 100644 --- a/wao-services/src/main/java/fr/ifremer/wao/services/service/BoatsService.java +++ b/wao-services/src/main/java/fr/ifremer/wao/services/service/BoatsService.java @@ -204,7 +204,7 @@ public class BoatsService extends WaoServiceSupport { ContactsFilter filter = new ContactsFilter(); filter.getSampleRowFilter().setObsProgram(obsProgram); filter.getBoatFilter().setBoatIds(ImmutableSet.of(boatId)); - filter.getSampleRowFilter().setCompanyIds(ImmutableSet.of(companyId)); + filter.getSampleRowFilter().setOrganisationIds(ImmutableSet.of(companyId)); long contactsCount = getContactDao().forFilter(filter, false).count(); Date now = serviceContext.getNow(); @@ -267,13 +267,13 @@ public class BoatsService extends WaoServiceSupport { long contactsCount = dao.forFilter(filter, false).count(); - filter.getSampleRowFilter().setCompanyIds(ImmutableSet.of(companyId)); + filter.getSampleRowFilter().setOrganisationIds(ImmutableSet.of(companyId)); long contactsCompanyCount = dao.forFilter(filter, false).count(); filter.setContactStates(ImmutableSet.of(ContactState.OBSERVATION_DONE)); long observationsCompanyCount = dao.forFilter(filter, false).count(); - filter.getSampleRowFilter().setCompanyIds(null); + filter.getSampleRowFilter().setOrganisationIds(null); long observationsCount = dao.forFilter(filter, false).count(); Preconditions.checkState(contactsCompanyCount <= contactsCount); diff --git a/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactsService.java b/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactsService.java index ebef067..b2d5cd5 100644 --- a/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactsService.java +++ b/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactsService.java @@ -107,7 +107,7 @@ public class ContactsService extends WaoServiceSupport { // DO NOT REMOVE THIS if (authenticatedWaoUser.isCoordinatorOrObserver()) { String authenticatedWaoUserCompanyTopiaId = authenticatedWaoUser.getWaoUser().getCompany().getTopiaId(); - newContactsFilter.getSampleRowFilter().setCompanyIds(ImmutableSet.of(authenticatedWaoUserCompanyTopiaId)); + newContactsFilter.getSampleRowFilter().setOrganisationIds(ImmutableSet.of(authenticatedWaoUserCompanyTopiaId)); } if (authenticatedWaoUser.isProfessional()) { diff --git a/wao-services/src/main/java/fr/ifremer/wao/services/service/SampleRowsFilterValues.java b/wao-services/src/main/java/fr/ifremer/wao/services/service/SampleRowsFilterValues.java index c9c430b..4184fc4 100644 --- a/wao-services/src/main/java/fr/ifremer/wao/services/service/SampleRowsFilterValues.java +++ b/wao-services/src/main/java/fr/ifremer/wao/services/service/SampleRowsFilterValues.java @@ -22,11 +22,11 @@ package fr.ifremer.wao.services.service; */ import com.google.common.base.Optional; -import fr.ifremer.wao.entity.Company; import fr.ifremer.wao.entity.Dcf5Code; import fr.ifremer.wao.entity.FishingGearDcf; import fr.ifremer.wao.entity.FishingZone; import fr.ifremer.wao.entity.ObsProgram; +import fr.ifremer.wao.entity.Organisation; import fr.ifremer.wao.entity.SampleRow; import fr.ifremer.wao.entity.TargetSpeciesDcf; import fr.ifremer.wao.entity.TerrestrialLocation; @@ -52,7 +52,7 @@ public class SampleRowsFilterValues extends AbstractFilterValues { protected SortedSet<FilterOption> programNames = new TreeSet<>(); - protected SortedSet<FilterOption> companies = new TreeSet<>(); + protected SortedSet<FilterOption> organisations = new TreeSet<>(); protected SortedSet<FilterOption> samplingStrategies = new TreeSet<>(); @@ -64,6 +64,12 @@ public class SampleRowsFilterValues extends AbstractFilterValues { /** Values are the code and the label i18n key. */ protected SortedSet<FilterOption> targetSpeciesDcfs = new TreeSet<>(); + protected SortedSet<FilterOption> individualMeasurementStrategies = new TreeSet<>(); + + protected SortedSet<FilterOption> sclerochronologySamplingContexts = new TreeSet<>(); + + protected SortedSet<FilterOption> species = new TreeSet<>(); + public SampleRowsFilterValues(Locale locale, ObsProgram obsProgram, Optional<String> optionalCompanyId) { super(locale, obsProgram, optionalCompanyId); } @@ -99,11 +105,11 @@ public class SampleRowsFilterValues extends AbstractFilterValues { // XXX brendan 07/07/14 dans le calcul des filter values, on évite tout ça pour les perfs programNames.add(FilterOption.forString(sampleRow.getProgramName())); - Company company = sampleRow.getCompany(); - if (company != null) { - companies.add(FilterOption.forValueAndLabel(company.getTopiaId(), company.getName())); + Organisation organisation = sampleRow.getOrganisation(); + if (organisation != null) { + organisations.add(FilterOption.forValueAndLabel(organisation.getTopiaId(), organisation.getFullName())); } - if (sampleRow.getObsProgram().isObsVente()) { + if (obsProgram.isObsVente()) { samplingStrategies.add(FilterOption.forEnum(locale, sampleRow.getSamplingStrategy())); if (sampleRow.isTerrestrialLocationsNotEmpty()) { for (TerrestrialLocation terrestrialDistrict : sampleRow.getTerrestrialLocations()) { @@ -116,24 +122,34 @@ public class SampleRowsFilterValues extends AbstractFilterValues { } } } - for (Dcf5Code dcf5Code : sampleRow.getDcf5Code()) { - FishingGearDcf fishingGearDcf = dcf5Code.getFishingGearDcf(); - String fishingGearLabel = fishingGearDcf.getCode() + " - " + l(locale, fishingGearDcf.getI18nKey()); - fishingGearDcfs.add( - FilterOption.forValueAndLabel( - fishingGearDcf.getTopiaId(), - fishingGearLabel) - ); - TargetSpeciesDcf targetSpeciesDcf = dcf5Code.getTargetSpeciesDcf(); - if (targetSpeciesDcf != null) { - String targetspeciesLabel = targetSpeciesDcf.getCode() + " - " + l(locale, targetSpeciesDcf.getI18nKey()); - targetSpeciesDcfs.add( + if (obsProgram.isObsMer() || obsProgram.isObsVente()) { + for (Dcf5Code dcf5Code : sampleRow.getDcf5Code()) { + FishingGearDcf fishingGearDcf = dcf5Code.getFishingGearDcf(); + String fishingGearLabel = fishingGearDcf.getCode() + " - " + l(locale, fishingGearDcf.getI18nKey()); + fishingGearDcfs.add( FilterOption.forValueAndLabel( - targetSpeciesDcf.getTopiaId(), - targetspeciesLabel) + fishingGearDcf.getTopiaId(), + fishingGearLabel) ); + TargetSpeciesDcf targetSpeciesDcf = dcf5Code.getTargetSpeciesDcf(); + if (targetSpeciesDcf != null) { + String targetSpeciesLabel = targetSpeciesDcf.getCode() + " - " + l(locale, targetSpeciesDcf.getI18nKey()); + targetSpeciesDcfs.add( + FilterOption.forValueAndLabel( + targetSpeciesDcf.getTopiaId(), + targetSpeciesLabel) + ); + } } } + if (obsProgram.isSclerochronology()) { + individualMeasurementStrategies.add( + FilterOption.forEnum(locale, sampleRow.getIndividualMeasurementStrategy())); + sclerochronologySamplingContexts.add( + FilterOption.forEnum(locale, sampleRow.getSclerochronologySamplingContext())); + species.add( + FilterOption.forValueAndLabel(sampleRow.getSpecies().getTopiaId(), sampleRow.getSpecies().getVernacularName())); + } } } } @@ -154,8 +170,8 @@ public class SampleRowsFilterValues extends AbstractFilterValues { return programNames; } - public SortedSet<FilterOption> getCompanies() { - return companies; + public SortedSet<FilterOption> getOrganisations() { + return organisations; } public SortedSet<FilterOption> getSamplingStrategies() { @@ -174,6 +190,18 @@ public class SampleRowsFilterValues extends AbstractFilterValues { return targetSpeciesDcfs; } + public SortedSet<FilterOption> getIndividualMeasurementStrategies() { + return individualMeasurementStrategies; + } + + public SortedSet<FilterOption> getSclerochronologySamplingContexts() { + return sclerochronologySamplingContexts; + } + + public SortedSet<FilterOption> getSpecies() { + return species; + } + public void setFishingZoneFacadeNames(SortedSet<FilterOption> fishingZoneFacadeNames) { this.fishingZoneFacadeNames = fishingZoneFacadeNames; } @@ -190,8 +218,8 @@ public class SampleRowsFilterValues extends AbstractFilterValues { this.programNames = programNames; } - public void setCompanies(SortedSet<FilterOption> companies) { - this.companies = companies; + public void setOrganisations(SortedSet<FilterOption> organisations) { + this.organisations = organisations; } public void setSamplingStrategies(SortedSet<FilterOption> samplingStrategies) { @@ -210,6 +238,18 @@ public class SampleRowsFilterValues extends AbstractFilterValues { this.targetSpeciesDcfs = targetSpeciesDcfs; } + public void setIndividualMeasurementStrategies(SortedSet<FilterOption> individualMeasurementStrategies) { + this.individualMeasurementStrategies = individualMeasurementStrategies; + } + + public void setSclerochronologySamplingContexts(SortedSet<FilterOption> sclerochronologySamplingContexts) { + this.sclerochronologySamplingContexts = sclerochronologySamplingContexts; + } + + public void setSpecies(SortedSet<FilterOption> species) { + this.species = species; + } + public SampleRowsFilterValues getCopyWithSingleProperty(String propertyName) { SampleRowsFilterValues copy = new SampleRowsFilterValues(locale, obsProgram, optionalCompanyId); copyProperty(copy, propertyName); diff --git a/wao-services/src/main/java/fr/ifremer/wao/services/service/SamplingPlanService.java b/wao-services/src/main/java/fr/ifremer/wao/services/service/SamplingPlanService.java index 6df485f..90e934b 100644 --- a/wao-services/src/main/java/fr/ifremer/wao/services/service/SamplingPlanService.java +++ b/wao-services/src/main/java/fr/ifremer/wao/services/service/SamplingPlanService.java @@ -196,7 +196,7 @@ public class SamplingPlanService extends WaoServiceSupport { // Very very important to do that at beginning // Evo #2227 : Guest user has no default company filter if (authenticatedWaoUser.isCoordinatorOrObserver()) { - newFilter.setCompanyIds(Sets.newHashSet(authenticatedWaoUser.getCompany().getTopiaId())); + newFilter.setOrganisationIds(Sets.newHashSet(authenticatedWaoUser.getCompany().getTopiaId())); } return newFilter; @@ -207,7 +207,7 @@ public class SamplingPlanService extends WaoServiceSupport { SampleRowsFilter sampleRowsFilter = newSampleRowsFilter(authenticatedWaoUser); - sampleRowsFilter.setCompanyIds(ImmutableSet.of(companyId)); + sampleRowsFilter.setOrganisationIds(ImmutableSet.of(companyId)); Date now = getNow(); sampleRowsFilter.setPeriodFrom(now); diff --git a/wao-services/src/main/java/fr/ifremer/wao/services/service/SclerochronologySamplingPlan.java b/wao-services/src/main/java/fr/ifremer/wao/services/service/SclerochronologySamplingPlan.java index d23fefd..9fccaff 100644 --- a/wao-services/src/main/java/fr/ifremer/wao/services/service/SclerochronologySamplingPlan.java +++ b/wao-services/src/main/java/fr/ifremer/wao/services/service/SclerochronologySamplingPlan.java @@ -40,6 +40,8 @@ public class SclerochronologySamplingPlan extends SamplingPlan implements Iterab public static class SclerochronologySamplingPlanSampleRowPart extends SamplingPlanSampleRowPart { + protected final String organisationFullName; + protected String samplingContext; protected String samplingContextInfo; @@ -54,6 +56,11 @@ public class SclerochronologySamplingPlan extends SamplingPlan implements Iterab samplingContext = WaoUtils.l(locale, sampleRow.getSclerochronologySamplingContext()); samplingContextInfo = sampleRow.getSclerochronologySamplingContextInfo(); individualMeasurementStrategy = WaoUtils.l(locale, sampleRow.getIndividualMeasurementStrategy()); + organisationFullName = sampleRow.getOrganisation().getFullName(); + } + + public String getOrganisationFullName() { + return organisationFullName; } public String getSamplingContextInfo() { @@ -102,6 +109,10 @@ public class SclerochronologySamplingPlan extends SamplingPlan implements Iterab throw new UnsupportedOperationException("not in " + ObsProgram.SCLEROCHRONOLOGY); } + @Override + public String getCompanyName() { + throw new UnsupportedOperationException("not in " + ObsProgram.SCLEROCHRONOLOGY); + } } } \ No newline at end of file diff --git a/wao-services/src/main/resources/i18n/wao-services_en_GB.properties b/wao-services/src/main/resources/i18n/wao-services_en_GB.properties index a8a104a..77607c5 100644 --- a/wao-services/src/main/resources/i18n/wao-services_en_GB.properties +++ b/wao-services/src/main/resources/i18n/wao-services_en_GB.properties @@ -86,7 +86,7 @@ wao.import.sampleRow.failure.codeMustBeUnique=Line %s\: The sample row code must wao.import.sampleRow.failure.fishingZoneMissing=Line %s\: You must precise at least one fishing zone wao.import.sampleRow.failure.missingDcf5Codes=Line %s\: You must precise at least one DCF5 code wao.import.sampleRow.failure.missingFishingZones=Line %s\: You must precise at least one fishing zone -wao.import.sampleRow.failure.missingIndividualMeasurementStrategy= Line %s\: You myst precise measurement strategy +wao.import.sampleRow.failure.missingIndividualMeasurementStrategy=Line %s\: You myst precise measurement strategy wao.import.sampleRow.failure.missingPeriodBegin=Line %s\: You must precise the period beginning wao.import.sampleRow.failure.missingPeriodEnd=Line %s\: You must precise the period end wao.import.sampleRow.failure.missingProfessionSpecies=Line %s\: For this sampling strategy, you must provide the species diff --git a/wao-services/src/test/java/fr/ifremer/wao/services/service/SclerochronologyFixtures.java b/wao-services/src/test/java/fr/ifremer/wao/services/service/SclerochronologyFixtures.java index 0310d5e..431bcb7 100644 --- a/wao-services/src/test/java/fr/ifremer/wao/services/service/SclerochronologyFixtures.java +++ b/wao-services/src/test/java/fr/ifremer/wao/services/service/SclerochronologyFixtures.java @@ -47,4 +47,19 @@ public class SclerochronologyFixtures extends WaoFixtures { } } + public void samplingPlan() { + fishingZones(); + species(); + oceanet(); + emhLaboratory(); + InputStream input = null; + try { + input = getClass().getResourceAsStream("/import/plan-sclerochronologie.csv"); + serviceContext.newService(SclerochronologySamplingPlanService.class).importSamplingPlan(admin(), input); + } catch (ImportErrorException e) { + throw new WaoTechnicalException(e); + } finally { + IOUtils.closeQuietly(input); + } + } } diff --git a/wao-services/src/test/java/fr/ifremer/wao/services/service/SclerochronologySamplingPlanServiceTest.java b/wao-services/src/test/java/fr/ifremer/wao/services/service/SclerochronologySamplingPlanServiceTest.java index b959dab..24b9d68 100644 --- a/wao-services/src/test/java/fr/ifremer/wao/services/service/SclerochronologySamplingPlanServiceTest.java +++ b/wao-services/src/test/java/fr/ifremer/wao/services/service/SclerochronologySamplingPlanServiceTest.java @@ -1,12 +1,15 @@ package fr.ifremer.wao.services.service; +import fr.ifremer.wao.SampleRowsFilter; import fr.ifremer.wao.services.AbstractWaoServiceTest; +import fr.ifremer.wao.services.AuthenticatedWaoUser; import org.apache.commons.io.IOUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.junit.Assert; import org.junit.Before; import org.junit.Test; +import org.nuiton.util.DateUtil; import java.io.InputStream; @@ -46,6 +49,27 @@ public class SclerochronologySamplingPlanServiceTest extends AbstractWaoServiceT } finally { IOUtils.closeQuietly(input); } + } + @Test + public void newSampleRowsFilterPeriodMustBeOnJanuaryToDecemberOfTheCurrentYear() { + applicationContext.setDate(DateUtil.createDate(15, 1, 2015)); + fixtures.samplingPlan(); + SampleRowsFilter filter = service.newSampleRowsFilter(fixtures.admin()); + Assert.assertEquals(DateUtil.createDate(1, 1, 2015), filter.getPeriodFrom()); + Assert.assertEquals(DateUtil.createDate(1, 12, 2015), filter.getPeriodTo()); + } + + @Test + public void samplingPlan() { + applicationContext.setDate(DateUtil.createDate(15, 1, 2015)); + fixtures.samplingPlan(); + AuthenticatedWaoUser admin = fixtures.admin(); + SampleRowsFilter filter = service.newSampleRowsFilter(admin); + SclerochronologySamplingPlan samplingPlan = service.getSamplingPlan(admin, filter); + Assert.assertEquals(2, samplingPlan.getFilterValues().getSpecies().size()); + Assert.assertEquals(3, samplingPlan.getFilterValues().getIndividualMeasurementStrategies().size()); + Assert.assertEquals(3, samplingPlan.getFilterValues().getSclerochronologySamplingContexts().size()); + Assert.assertEquals(2, samplingPlan.getFilterValues().getOrganisations().size()); } } \ No newline at end of file diff --git a/wao-web/src/main/java/fr/ifremer/wao/web/action/SampleRowsFilterValuesJsonAction.java b/wao-web/src/main/java/fr/ifremer/wao/web/action/SampleRowsFilterValuesJsonAction.java index af44cc4..e9ebef9 100644 --- a/wao-web/src/main/java/fr/ifremer/wao/web/action/SampleRowsFilterValuesJsonAction.java +++ b/wao-web/src/main/java/fr/ifremer/wao/web/action/SampleRowsFilterValuesJsonAction.java @@ -23,10 +23,13 @@ package fr.ifremer.wao.web.action; import com.opensymphony.xwork2.Preparable; import fr.ifremer.wao.SampleRowsFilter; +import fr.ifremer.wao.entity.ObsProgram; +import fr.ifremer.wao.services.AuthenticatedWaoUser; import fr.ifremer.wao.services.service.ObsMerSamplingPlanService; import fr.ifremer.wao.services.service.ObsVenteSamplingPlanService; import fr.ifremer.wao.services.service.SampleRowsFilterValues; import fr.ifremer.wao.services.service.SamplingPlan; +import fr.ifremer.wao.services.service.SclerochronologySamplingPlanService; import fr.ifremer.wao.web.WaoJsonActionSupport; import org.apache.commons.lang3.StringUtils; @@ -34,9 +37,11 @@ public class SampleRowsFilterValuesJsonAction extends WaoJsonActionSupport imple private static final long serialVersionUID = 1L; - protected transient ObsMerSamplingPlanService obsMerSamplingPlanService; + protected ObsMerSamplingPlanService obsMerSamplingPlanService; - protected transient ObsVenteSamplingPlanService obsVenteSamplingPlanService; + protected ObsVenteSamplingPlanService obsVenteSamplingPlanService; + + protected SclerochronologySamplingPlanService sclerochronologySamplingPlanService; protected SampleRowsFilter filter; @@ -52,6 +57,10 @@ public class SampleRowsFilterValuesJsonAction extends WaoJsonActionSupport imple this.obsVenteSamplingPlanService = obsVenteSamplingPlanService; } + public void setSclerochronologySamplingPlanService(SclerochronologySamplingPlanService sclerochronologySamplingPlanService) { + this.sclerochronologySamplingPlanService = sclerochronologySamplingPlanService; + } + public SampleRowsFilter getFilter() { if (filter == null) { prepare(); @@ -66,7 +75,18 @@ public class SampleRowsFilterValuesJsonAction extends WaoJsonActionSupport imple @Override public void prepare() { - filter = obsMerSamplingPlanService.newSampleRowsFilter(session.getAuthenticatedWaoUser()); + AuthenticatedWaoUser authenticatedWaoUser = session.getAuthenticatedWaoUser(); + ObsProgram obsProgram = authenticatedWaoUser.getObsProgram(); + + if (obsProgram.isObsMer()) { + filter = obsMerSamplingPlanService.newSampleRowsFilter(authenticatedWaoUser); + } else if (obsProgram.isObsVente()) { + filter = obsVenteSamplingPlanService.newSampleRowsFilter(authenticatedWaoUser); + } else if (obsProgram.isSclerochronology()) { + filter = sclerochronologySamplingPlanService.newSampleRowsFilter(authenticatedWaoUser); + } else { + throw new UnsupportedOperationException(); + } } @@ -74,13 +94,17 @@ public class SampleRowsFilterValuesJsonAction extends WaoJsonActionSupport imple public String execute() { SamplingPlan samplingPlan; - if (filter.getObsProgram().isObsMer()) { + ObsProgram obsProgram = filter.getObsProgram(); + if (obsProgram.isObsMer()) { samplingPlan = obsMerSamplingPlanService.getSamplingPlan(session.getAuthenticatedWaoUser(), filter); - } else if (filter.getObsProgram().isObsVente()) { + } else if (obsProgram.isObsVente()) { samplingPlan = obsVenteSamplingPlanService.getSamplingPlan(session.getAuthenticatedWaoUser(), filter); + } else if (obsProgram.isSclerochronology()) { + samplingPlan = sclerochronologySamplingPlanService.getSamplingPlan(session.getAuthenticatedWaoUser(), filter); } else { throw new UnsupportedOperationException(); } + filterValues = samplingPlan.getFilterValues(); if (StringUtils.isNotBlank(filterValuesField)) { diff --git a/wao-web/src/main/webapp/WEB-INF/content/boat-details.jsp b/wao-web/src/main/webapp/WEB-INF/content/boat-details.jsp index 8348778..622afb5 100644 --- a/wao-web/src/main/webapp/WEB-INF/content/boat-details.jsp +++ b/wao-web/src/main/webapp/WEB-INF/content/boat-details.jsp @@ -171,7 +171,7 @@ <s:url action="contacts!applyFilter" id="viewAssociatedContactsForBoatUrl"> <s:param name="filter.boatFilter.registrationCode" value="boatDetails.boatInfos.boat.registrationCode"/> - <s:param name="filter.sampleRowFilter.companyIds" value="boatDetails.boatInfos.company.topiaId"/> + <s:param name="filter.sampleRowFilter.organisationIds" value="boatDetails.boatInfos.company.topiaId"/> <s:param name="filter.periodFrom"/> <s:param name="filter.periodTo"/> </s:url> diff --git a/wao-web/src/main/webapp/WEB-INF/content/contacts.jsp b/wao-web/src/main/webapp/WEB-INF/content/contacts.jsp index a644fea..0181289 100644 --- a/wao-web/src/main/webapp/WEB-INF/content/contacts.jsp +++ b/wao-web/src/main/webapp/WEB-INF/content/contacts.jsp @@ -35,7 +35,7 @@ var contactsFilterMappings = [ <s:if test="authenticatedWaoUser.authorizedToViewOtherCompanies"> { - filterName: 'sampleRowFilter.companyIds', + filterName: 'sampleRowFilter.organisationIds', filterLabel: "<s:text name="wao.ui.entity.Company"/>", filterValuesField: 'sampleRowsFilterValues.companies', }, diff --git a/wao-web/src/main/webapp/WEB-INF/content/obsmer/sampling-plan.jsp b/wao-web/src/main/webapp/WEB-INF/content/obsmer/sampling-plan.jsp index 3a6e28b..08138b8 100644 --- a/wao-web/src/main/webapp/WEB-INF/content/obsmer/sampling-plan.jsp +++ b/wao-web/src/main/webapp/WEB-INF/content/obsmer/sampling-plan.jsp @@ -37,9 +37,9 @@ var sampleRowsFilterMappings = [ <s:if test="authenticatedWaoUser.authorizedToViewOtherCompanies"> { - filterName: 'companyIds', + filterName: 'organisationIds', filterLabel: "<s:text name="wao.ui.entity.Company"/>", - filterValuesField: 'companies', + filterValuesField: 'organisations', }, </s:if> { @@ -458,7 +458,7 @@ <s:url action="sampling-plan!applyFilter" id="sampleRowZoomUrl"> <s:param name="filter.periodFrom" value="%{formatMonth(firstSampleMonthDate)}"/> <s:param name="filter.periodTo" value="%{formatMonth(lastSampleMonthDate)}"/> - <s:param name="filter.companyIds" value="%{filter.companyIds}"/> + <s:param name="filter.organisationIds" value="%{filter.organisationIds}"/> <s:param name="filter.programNames" value="%{filter.programNames}"/> <s:param name="filter.sampleRowCodes" value="%{filter.sampleRowCodes}"/> <s:param name="filter.fishingZoneFacadeNames" value="%{filter.targetSpeciesDcfIds}"/> diff --git a/wao-web/src/main/webapp/WEB-INF/content/obsvente/sampling-plan.jsp b/wao-web/src/main/webapp/WEB-INF/content/obsvente/sampling-plan.jsp index cd1417c..c785096 100644 --- a/wao-web/src/main/webapp/WEB-INF/content/obsvente/sampling-plan.jsp +++ b/wao-web/src/main/webapp/WEB-INF/content/obsvente/sampling-plan.jsp @@ -38,9 +38,9 @@ var sampleRowsFilterMappings = [ <s:if test="authenticatedWaoUser.authorizedToViewOtherCompanies"> { - filterName: 'companyIds', + filterName: 'organisationIds', filterLabel: "<s:text name="wao.ui.entity.Company"/>", - filterValuesField: 'companies', + filterValuesField: 'organisations', }, </s:if> { @@ -417,7 +417,7 @@ <s:url action="sampling-plan!applyFilter" id="sampleRowZoomUrl"> <s:param name="filter.periodFrom" value="%{formatMonth(firstSampleMonthDate)}"/> <s:param name="filter.periodTo" value="%{formatMonth(lastSampleMonthDate)}"/> - <s:param name="filter.companyIds" value="%{filter.companyIds}"/> + <s:param name="filter.organisationIds" value="%{filter.organisationIds}"/> <s:param name="filter.programNames" value="%{filter.programNames}"/> <s:param name="filter.sampleRowCodes" value="%{filter.sampleRowCodes}"/> <s:param name="filter.fishingZoneFacadeNames" value="%{filter.targetSpeciesDcfIds}"/> diff --git a/wao-web/src/main/webapp/WEB-INF/content/sclerochronology/sampling-plan.jsp b/wao-web/src/main/webapp/WEB-INF/content/sclerochronology/sampling-plan.jsp index 30dd0c5..b9c4b7b 100644 --- a/wao-web/src/main/webapp/WEB-INF/content/sclerochronology/sampling-plan.jsp +++ b/wao-web/src/main/webapp/WEB-INF/content/sclerochronology/sampling-plan.jsp @@ -38,9 +38,9 @@ var sampleRowsFilterMappings = [ <s:if test="authenticatedWaoUser.authorizedToViewOtherCompanies"> { - filterName: 'companyIds', - filterLabel: "<s:text name="wao.ui.entity.Company"/>", - filterValuesField: 'companies', + filterName: 'organisationIds', + filterLabel: "<s:text name="wao.ui.entity.Organisation"/>", + filterValuesField: 'organisations', }, </s:if> { @@ -66,7 +66,7 @@ { filterName: 'samplingContext', filterLabel: "<s:text name="wao.ui.field.SampleRow.sclerochronologySamplingContext"/>", - filterValuesField: 'samplingContexts', + filterValuesField: 'sclerochronologySamplingContexts', }, { filterName: 'individualMeasurementStrategy', @@ -288,7 +288,7 @@ <td><s:property value="programName" /></td> <s:if test="authenticatedWaoUser.authorizedToViewOtherCompanies"> <td class="only-in-full-view"> - <s:property value="companyName" /> + <s:property value="organisationFullName" /> </td> </s:if> <td class="only-in-full-view"><s:property value="fishingZones" /></td> @@ -366,7 +366,7 @@ <s:url action="sampling-plan!applyFilter" id="sampleRowZoomUrl"> <s:param name="filter.periodFrom" value="%{formatMonth(firstSampleMonthDate)}"/> <s:param name="filter.periodTo" value="%{formatMonth(lastSampleMonthDate)}"/> - <s:param name="filter.companyIds" value="%{filter.companyIds}"/> + <s:param name="filter.organisationIds" value="%{filter.organisationIds}"/> <s:param name="filter.programNames" value="%{filter.programNames}"/> <s:param name="filter.sampleRowCodes" value="%{filter.sampleRowCodes}"/> <s:param name="filter.fishingZoneFacadeNames" value="%{filter.targetSpeciesDcfIds}"/> diff --git a/wao-web/src/main/webapp/WEB-INF/content/synthesis.jsp b/wao-web/src/main/webapp/WEB-INF/content/synthesis.jsp index 0f1d4ac..c7a8be8 100644 --- a/wao-web/src/main/webapp/WEB-INF/content/synthesis.jsp +++ b/wao-web/src/main/webapp/WEB-INF/content/synthesis.jsp @@ -37,9 +37,9 @@ var contactsFilterMappings = [ <s:if test="authenticatedWaoUser.authorizedToViewOtherCompanies"> { - filterName: 'sampleRowFilter.companyIds', + filterName: 'sampleRowFilter.organisationIds', filterLabel: "<s:text name="wao.ui.entity.Company"/>", - filterValuesField: 'sampleRowsFilterValues.companies', + filterValuesField: 'sampleRowsFilterValues.organisations', }, </s:if> { -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository wao. See http://git.codelutin.com/wao.git commit 321824f7e06ca6331d81be51c38b135eed7962a6 Author: Brendan Le Ny <bleny@codelutin.com> Date: Thu Dec 18 16:37:42 2014 +0100 Ajout des champs scléro dans le formulaire de modification d'une ligne du plan --- .../wao/services/service/SamplingPlanService.java | 18 +++- .../services/service/UpdateSampleRowCommand.java | 51 ++++++++++ .../wao/web/action/EditSampleRowAction.java | 17 +--- .../WEB-INF/content/edit-sample-row-input.jsp | 108 ++++++++++++++------- 4 files changed, 144 insertions(+), 50 deletions(-) diff --git a/wao-services/src/main/java/fr/ifremer/wao/services/service/SamplingPlanService.java b/wao-services/src/main/java/fr/ifremer/wao/services/service/SamplingPlanService.java index 90e934b..f2c72a1 100644 --- a/wao-services/src/main/java/fr/ifremer/wao/services/service/SamplingPlanService.java +++ b/wao-services/src/main/java/fr/ifremer/wao/services/service/SamplingPlanService.java @@ -59,6 +59,7 @@ import fr.ifremer.wao.entity.SampleRowLog; import fr.ifremer.wao.entity.SampleRowLogImpl; import fr.ifremer.wao.entity.SampleRowLogTopiaDao; import fr.ifremer.wao.entity.SampleRowTopiaDao; +import fr.ifremer.wao.entity.Species; import fr.ifremer.wao.entity.TerrestrialLocation; import fr.ifremer.wao.entity.TerrestrialLocationTopiaDao; import fr.ifremer.wao.services.AuthenticatedWaoUser; @@ -288,7 +289,7 @@ public class SamplingPlanService extends WaoServiceSupport { ObsProgram obsProgram = authenticatedWaoUser.getObsProgram(); - UpdateSampleRowCommand updateSampleRowCommand = new UpdateSampleRowCommand(); + UpdateSampleRowCommand updateSampleRowCommand = new UpdateSampleRowCommand(serviceContext.getLocale()); if (optionalSampleRowId.isPresent()) { @@ -341,9 +342,11 @@ public class SamplingPlanService extends WaoServiceSupport { updateSampleRowCommand.setSampleRowLog(newSampleRowLog); updateSampleRowCommand.getSampleRow().addSampleRowLog(newSampleRowLog); + ReferentialService referentialService = getReferentialService(); + ImmutableMap<String, FishingZone> allFishingZones = Maps.uniqueIndex( - getReferentialService().getAllFishingZones(), + referentialService.getAllFishingZones(), TopiaEntities.getTopiaIdFunction() ); updateSampleRowCommand.setAllFishingZones(allFishingZones); @@ -358,18 +361,25 @@ public class SamplingPlanService extends WaoServiceSupport { ImmutableMap<String, Dcf5Code> allDcf5Codes = Maps.uniqueIndex( - getReferentialService().getAllDcf5Codes(), + referentialService.getAllDcf5Codes(), TopiaEntities.getTopiaIdFunction() ); updateSampleRowCommand.setAllDcf5Codes(allDcf5Codes); ImmutableMap<String, TerrestrialLocation> allTerrestrialDistricts = Maps.uniqueIndex( - getReferentialService().getAllTerrestrialDistricts(), + referentialService.getAllTerrestrialDistricts(), TopiaEntities.getTopiaIdFunction() ); updateSampleRowCommand.setAllTerrestrialDistricts(allTerrestrialDistricts); + ImmutableMap<String, Species> allSpecies = + Maps.uniqueIndex( + referentialService.getAllSpecies(), + TopiaEntities.getTopiaIdFunction() + ); + updateSampleRowCommand.setAllSpecies(allSpecies); + return updateSampleRowCommand; } diff --git a/wao-services/src/main/java/fr/ifremer/wao/services/service/UpdateSampleRowCommand.java b/wao-services/src/main/java/fr/ifremer/wao/services/service/UpdateSampleRowCommand.java index 2087a68..cf233e9 100644 --- a/wao-services/src/main/java/fr/ifremer/wao/services/service/UpdateSampleRowCommand.java +++ b/wao-services/src/main/java/fr/ifremer/wao/services/service/UpdateSampleRowCommand.java @@ -27,12 +27,16 @@ import com.google.common.collect.Collections2; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Iterables; import com.google.common.collect.Sets; +import fr.ifremer.wao.WaoUtils; import fr.ifremer.wao.entity.Company; import fr.ifremer.wao.entity.Dcf5Code; import fr.ifremer.wao.entity.FishingZone; +import fr.ifremer.wao.entity.IndividualMeasurementStrategy; import fr.ifremer.wao.entity.SampleMonth; import fr.ifremer.wao.entity.SampleRow; import fr.ifremer.wao.entity.SampleRowLog; +import fr.ifremer.wao.entity.SclerochronologySamplingContext; +import fr.ifremer.wao.entity.Species; import fr.ifremer.wao.entity.TerrestrialLocation; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; @@ -44,7 +48,9 @@ import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Collection; import java.util.Date; +import java.util.EnumMap; import java.util.LinkedHashMap; +import java.util.Locale; import java.util.Map; import java.util.Set; @@ -52,6 +58,8 @@ public class UpdateSampleRowCommand implements Serializable{ private static final long serialVersionUID = 1L; + protected Locale locale; + protected DateFormat monthFormat = new SimpleDateFormat("yyyyMM"); protected boolean creation; @@ -72,11 +80,17 @@ public class UpdateSampleRowCommand implements Serializable{ protected ImmutableMap<String, TerrestrialLocation> allTerrestrialDistricts; + protected ImmutableMap<String, Species> allSpecies; + /** * La clé est un mois au format YYYY-MM */ protected Map<String, Integer> expectedObservationsByMonths; + public UpdateSampleRowCommand(Locale locale) { + this.locale = locale; + } + public Map<String, Integer> getExpectedObservationsByMonths() { if (expectedObservationsByMonths == null) { expectedObservationsByMonths = new LinkedHashMap<>(); @@ -245,4 +259,41 @@ public class UpdateSampleRowCommand implements Serializable{ public void setSampleRowMemento(SampleRow sampleRowMemento) { this.sampleRowMemento = sampleRowMemento; } + + public ImmutableMap<SclerochronologySamplingContext, String> getAllSclerochronologySamplingContexts() { + EnumMap<SclerochronologySamplingContext, String> allSclerochronologySamplingContexts = new EnumMap<>(SclerochronologySamplingContext.class); + for (SclerochronologySamplingContext sclerochronologySamplingContext : SclerochronologySamplingContext.values()) { + allSclerochronologySamplingContexts.put(sclerochronologySamplingContext, WaoUtils.l(locale, sclerochronologySamplingContext)); + } + return ImmutableMap.copyOf(allSclerochronologySamplingContexts); + } + + public ImmutableMap<IndividualMeasurementStrategy, String> getAllIndividualMeasurementStrategies() { + EnumMap<IndividualMeasurementStrategy, String> allIndividualMeasurementStrategies = new EnumMap<>(IndividualMeasurementStrategy.class); + for (IndividualMeasurementStrategy individualMeasurementStrategy : IndividualMeasurementStrategy.values()) { + allIndividualMeasurementStrategies.put(individualMeasurementStrategy, WaoUtils.l(locale, individualMeasurementStrategy)); + } + return ImmutableMap.copyOf(allIndividualMeasurementStrategies); + } + + public ImmutableMap<String, Species> getAllSpecies() { + return allSpecies; + } + + public void setAllSpecies(ImmutableMap<String, Species> allSpecies) { + this.allSpecies = allSpecies; + } + + public String getSpeciesId() { + String speciesId = null; + if (sampleRow.getSpecies() != null) { + speciesId = sampleRow.getSpecies().getTopiaId(); + } + return speciesId; + } + + public void setSpeciesId(String speciesId) { + Species species = allSpecies.get(speciesId); + sampleRow.setSpecies(species); + } } diff --git a/wao-web/src/main/java/fr/ifremer/wao/web/action/EditSampleRowAction.java b/wao-web/src/main/java/fr/ifremer/wao/web/action/EditSampleRowAction.java index 814f729..a03b8f9 100644 --- a/wao-web/src/main/java/fr/ifremer/wao/web/action/EditSampleRowAction.java +++ b/wao-web/src/main/java/fr/ifremer/wao/web/action/EditSampleRowAction.java @@ -98,10 +98,6 @@ public class EditSampleRowAction extends WaoJspActionSupport implements Preparab service.validate(getAuthenticatedWaoUser(), updateSampleRowCommand); - if (sampleRow.isDcf5CodeEmpty()) { - addFieldError("updateSampleRowCommand.dcf5Codes", t("wao.ui.form.SampleRow.error.missingDcf5Codes")); - } - } catch (UnknownBoatRegistrationCodesException e) { addFieldError("updateSampleRowCommand.elligibleBoatRegistrationCodes", t("wao.ui.unknownBoatRegistrationCodes", Joiner.on(", ").join(e.getRegistrationCodes()))); } catch (SampleRowCodeMustBeUniqueException e) { @@ -126,16 +122,13 @@ public class EditSampleRowAction extends WaoJspActionSupport implements Preparab } catch (MissingDcf5CodesException e) { addFieldError("updateSampleRowCommand.dcf5Codes", t("wao.ui.form.SampleRow.error.missingDcf5Codes")); } catch (NoEffortDefinedException e) { - addFieldError("updateSampleRowCommand.dcf5Codes", t("wao.ui.form.SampleRow.error.noEffortDefined")); - } - - // TODO brendan 18/12/14 - catch (MissingIndividualMeasurementStrategyException e) { - throw new UnsupportedOperationException(); + addActionError(t("wao.ui.form.SampleRow.error.noEffortDefined")); + } catch (MissingIndividualMeasurementStrategyException e) { + addFieldError("updateSampleRowCommand.sampleRow.individualMeasurementStrategy", t("wao.ui.form.SampleRow.error.noIndividualMeasurementStrategyDefined")); } catch (MissingSclerochronologySamplingContextException e) { - throw new UnsupportedOperationException(); + addFieldError("updateSampleRowCommand.sampleRow.sclerochronologySamplingContext", t("wao.ui.form.SampleRow.error.noSclerochronologySamplingContextDefined")); } catch (MissingSpeciesException e) { - throw new UnsupportedOperationException(); + addFieldError("updateSampleRowCommand.sampleRow.species", t("wao.ui.form.SampleRow.error.noSpeciesDefined")); } } diff --git a/wao-web/src/main/webapp/WEB-INF/content/edit-sample-row-input.jsp b/wao-web/src/main/webapp/WEB-INF/content/edit-sample-row-input.jsp index ba792c8..ab8ccd4 100644 --- a/wao-web/src/main/webapp/WEB-INF/content/edit-sample-row-input.jsp +++ b/wao-web/src/main/webapp/WEB-INF/content/edit-sample-row-input.jsp @@ -118,47 +118,85 @@ <s:hidden name="sampleRowId" value="%{sampleRowId}" /> - <fieldset> + <s:if test="updateSampleRowCommand.sampleRow.obsProgram.obsMer || updateSampleRowCommand.sampleRow.obsProgram.obsVente"> - <legend><s:text name="wao.ui.field.SampleRow.profession" /></legend> + <fieldset> - <s:textfield name="updateSampleRowCommand.sampleRow.profession.libelle" - label="%{getText('wao.ui.field.SampleRow.libelle')}" - disabled="updateSampleRowCommand.observationAlreadyStarted" - cssClass="input-xxlarge" /> + <legend><s:text name="wao.ui.field.SampleRow.profession" /></legend> - <s:textfield name="updateSampleRowCommand.sampleRow.profession.size" - label="%{getText('wao.ui.field.SampleRow.size')}" - disabled="updateSampleRowCommand.observationAlreadyStarted" - inputAppend="m" - cssClass="input-small" /> + <s:textfield name="updateSampleRowCommand.sampleRow.profession.libelle" + label="%{getText('wao.ui.field.SampleRow.libelle')}" + disabled="updateSampleRowCommand.observationAlreadyStarted" + cssClass="input-xxlarge" /> - <s:textfield name="updateSampleRowCommand.sampleRow.profession.meshSize" - label="%{getText('wao.ui.field.SampleRow.meshSize')}" - disabled="updateSampleRowCommand.observationAlreadyStarted" - inputAppend="mm" - cssClass="input-small" /> + <s:textfield name="updateSampleRowCommand.sampleRow.profession.size" + label="%{getText('wao.ui.field.SampleRow.size')}" + disabled="updateSampleRowCommand.observationAlreadyStarted" + inputAppend="m" + cssClass="input-small" /> - <s:textfield name="updateSampleRowCommand.sampleRow.profession.species" - label="%{getText('wao.ui.field.SampleRow.species')}" - disabled="updateSampleRowCommand.observationAlreadyStarted" - cssClass="input-xxlarge" /> + <s:textfield name="updateSampleRowCommand.sampleRow.profession.meshSize" + label="%{getText('wao.ui.field.SampleRow.meshSize')}" + disabled="updateSampleRowCommand.observationAlreadyStarted" + inputAppend="mm" + cssClass="input-small" /> - <s:textfield name="updateSampleRowCommand.sampleRow.profession.other" - label="%{getText('wao.ui.field.SampleRow.other')}" - disabled="updateSampleRowCommand.observationAlreadyStarted" - cssClass="input-xxlarge" /> + <s:textfield name="updateSampleRowCommand.sampleRow.profession.species" + label="%{getText('wao.ui.field.SampleRow.species')}" + disabled="updateSampleRowCommand.observationAlreadyStarted" + cssClass="input-xxlarge" /> - <s:select name="updateSampleRowCommand.dcf5CodesIds" - label="%{getText('wao.ui.field.SampleRow.dcf5Codes')}" - disabled="updateSampleRowCommand.observationAlreadyStarted" - list="updateSampleRowCommand.allDcf5Codes" - listValue="%{value.code}" - cssClass="input-xxlarge select2" - multiple="true" - /> + <s:textfield name="updateSampleRowCommand.sampleRow.profession.other" + label="%{getText('wao.ui.field.SampleRow.other')}" + disabled="updateSampleRowCommand.observationAlreadyStarted" + cssClass="input-xxlarge" /> - </fieldset> + <s:select name="updateSampleRowCommand.dcf5CodesIds" + label="%{getText('wao.ui.field.SampleRow.dcf5Codes')}" + disabled="updateSampleRowCommand.observationAlreadyStarted" + list="updateSampleRowCommand.allDcf5Codes" + listValue="%{value.code}" + cssClass="input-xxlarge select2" + multiple="true" + /> + + </fieldset> + + </s:if> + + <s:if test="updateSampleRowCommand.sampleRow.obsProgram.sclerochronology"> + + <fieldset> + + <legend><s:text name="wao.ui.field.SampleRow.profession" /></legend> + + <s:select name="updateSampleRowCommand.sampleRow.sclerochronologySamplingContext" + label="%{getText('wao.ui.field.SampleRow.sclerochronologySamplingContext')}" + list="updateSampleRowCommand.allSclerochronologySamplingContexts" + disabled="updateSampleRowCommand.observationAlreadyStarted" /> + + <s:textfield name="updateSampleRowCommand.sampleRow.sclerochronologySamplingContextInfo" + label="%{getText('wao.ui.field.SampleRow.sclerochronologySamplingContextInfo')}" + cssClass="input-xxlarge" + disabled="updateSampleRowCommand.observationAlreadyStarted" /> + + <s:select name="updateSampleRowCommand.sampleRow.individualMeasurementStrategy" + label="%{getText('wao.ui.field.SampleRow.individualMeasurementStrategy')}" + list="updateSampleRowCommand.allIndividualMeasurementStrategies" + cssClass="input-xlarge" + disabled="updateSampleRowCommand.observationAlreadyStarted" /> + + <s:select name="updateSampleRowCommand.speciesId" + label="%{getText('wao.ui.field.SampleRow.species')}" + disabled="updateSampleRowCommand.observationAlreadyStarted" + list="updateSampleRowCommand.allSpecies" + listValue="%{value.permanentCode + ' ' + value.vernacularName}" + cssClass="input-xxlarge select2" + /> + + </fieldset> + + </s:if> <fieldset> @@ -257,7 +295,9 @@ </s:if> - <s:textarea name="updateSampleRowCommand.elligibleBoatRegistrationCodes" label="%{getText('wao.ui.field.SampleRow.elligibleBoat')}" /> + <s:if test="updateSampleRowCommand.sampleRow.obsProgram.obsMer || updateSampleRowCommand.sampleRow.obsProgram.obsVente"> + <s:textarea name="updateSampleRowCommand.elligibleBoatRegistrationCodes" label="%{getText('wao.ui.field.SampleRow.elligibleBoat')}" /> + </s:if> <s:textarea name="updateSampleRowCommand.sampleRow.comment" label="%{getText('wao.ui.field.SampleRow.comment')}" /> -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository wao. See http://git.codelutin.com/wao.git commit 626b064a5985fa0ac36176bfc71e7091e7271220 Author: Brendan Le Ny <bleny@codelutin.com> Date: Thu Dec 18 16:56:26 2014 +0100 Les filtres du plan sont désormais effectifs --- .../main/java/fr/ifremer/wao/SampleRowsFilter.java | 52 ++++++++++++++++++++-- .../fr/ifremer/wao/entity/SampleRowTopiaDao.java | 12 +++++ .../content/sclerochronology/sampling-plan.jsp | 4 +- 3 files changed, 63 insertions(+), 5 deletions(-) diff --git a/wao-persistence/src/main/java/fr/ifremer/wao/SampleRowsFilter.java b/wao-persistence/src/main/java/fr/ifremer/wao/SampleRowsFilter.java index 6fc1321..dab068b 100644 --- a/wao-persistence/src/main/java/fr/ifremer/wao/SampleRowsFilter.java +++ b/wao-persistence/src/main/java/fr/ifremer/wao/SampleRowsFilter.java @@ -21,8 +21,10 @@ package fr.ifremer.wao; * #L% */ +import fr.ifremer.wao.entity.IndividualMeasurementStrategy; import fr.ifremer.wao.entity.ObsProgram; import fr.ifremer.wao.entity.SamplingStrategy; +import fr.ifremer.wao.entity.SclerochronologySamplingContext; import org.apache.commons.collections4.CollectionUtils; import java.util.Date; @@ -33,7 +35,7 @@ import java.util.Set; public class SampleRowsFilter extends AbstractWaoFilter { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 2L; protected ObsProgram obsProgram; @@ -69,6 +71,12 @@ public class SampleRowsFilter extends AbstractWaoFilter { protected Set<String> organisationIds; + protected Set<String> species; + + protected Set<IndividualMeasurementStrategy> individualMeasurementStrategies; + + protected Set<SclerochronologySamplingContext> sclerochronologySamplingContexts; + protected LinkedHashSet<String> orderByArguments; public ObsProgram getObsProgram() { @@ -167,6 +175,30 @@ public class SampleRowsFilter extends AbstractWaoFilter { this.organisationIds = organisationIds; } + public Set<String> getSpecies() { + return species; + } + + public void setSpecies(Set<String> species) { + this.species = species; + } + + public Set<IndividualMeasurementStrategy> getIndividualMeasurementStrategies() { + return individualMeasurementStrategies; + } + + public void setIndividualMeasurementStrategies(Set<IndividualMeasurementStrategy> individualMeasurementStrategies) { + this.individualMeasurementStrategies = individualMeasurementStrategies; + } + + public Set<SclerochronologySamplingContext> getSclerochronologySamplingContexts() { + return sclerochronologySamplingContexts; + } + + public void setSclerochronologySamplingContexts(Set<SclerochronologySamplingContext> sclerochronologySamplingContexts) { + this.sclerochronologySamplingContexts = sclerochronologySamplingContexts; + } + public LinkedHashSet<String> getOrderByArguments() { return orderByArguments; } @@ -197,7 +229,11 @@ public class SampleRowsFilter extends AbstractWaoFilter { || CollectionUtils.isNotEmpty(targetSpeciesDcfIds) || CollectionUtils.isNotEmpty(samplingStrategies) || CollectionUtils.isNotEmpty(terrestrialDistrictIds) - || CollectionUtils.isNotEmpty(organisationIds); + || CollectionUtils.isNotEmpty(organisationIds) + || CollectionUtils.isNotEmpty(species) + || CollectionUtils.isNotEmpty(sclerochronologySamplingContexts) + || CollectionUtils.isNotEmpty(individualMeasurementStrategies) + ; return filled; } @@ -222,7 +258,11 @@ public class SampleRowsFilter extends AbstractWaoFilter { && WaoUtils.isEqualCollection(samplingStrategies, that.samplingStrategies) && WaoUtils.isEqualCollection(terrestrialDistrictIds, that.terrestrialDistrictIds) && WaoUtils.isEqualCollection(organisationIds, that.organisationIds) - && WaoUtils.isEqualCollection(orderByArguments, that.orderByArguments); + && WaoUtils.isEqualCollection(species, that.species) + && WaoUtils.isEqualCollection(sclerochronologySamplingContexts, that.sclerochronologySamplingContexts) + && WaoUtils.isEqualCollection(individualMeasurementStrategies, that.individualMeasurementStrategies) + && WaoUtils.isEqualCollection(orderByArguments, that.orderByArguments) + ; return equals; @@ -248,6 +288,9 @@ public class SampleRowsFilter extends AbstractWaoFilter { hashCode = 31 * hashCode + WaoUtils.collectionHashCode(samplingStrategies); hashCode = 31 * hashCode + WaoUtils.collectionHashCode(terrestrialDistrictIds); hashCode = 31 * hashCode + WaoUtils.collectionHashCode(organisationIds); + hashCode = 31 * hashCode + WaoUtils.collectionHashCode(species); + hashCode = 31 * hashCode + WaoUtils.collectionHashCode(sclerochronologySamplingContexts); + hashCode = 31 * hashCode + WaoUtils.collectionHashCode(individualMeasurementStrategies); hashCode = 31 * hashCode + WaoUtils.collectionHashCode(orderByArguments); return hashCode; } @@ -268,6 +311,9 @@ public class SampleRowsFilter extends AbstractWaoFilter { clone.samplingStrategies = samplingStrategies == null ? null : new HashSet<>(samplingStrategies); clone.terrestrialDistrictIds = terrestrialDistrictIds == null ? null : new HashSet<>(terrestrialDistrictIds); clone.organisationIds = organisationIds == null ? null : new HashSet<>(organisationIds); + clone.species = species == null ? null : new HashSet<>(species); + clone.sclerochronologySamplingContexts = sclerochronologySamplingContexts == null ? null : new HashSet<>(sclerochronologySamplingContexts); + clone.individualMeasurementStrategies = individualMeasurementStrategies == null ? null : new HashSet<>(individualMeasurementStrategies); clone.orderByArguments = orderByArguments == null ? null : new LinkedHashSet<>(orderByArguments); return clone; } diff --git a/wao-persistence/src/main/java/fr/ifremer/wao/entity/SampleRowTopiaDao.java b/wao-persistence/src/main/java/fr/ifremer/wao/entity/SampleRowTopiaDao.java index 950fe8e..1fedec7 100644 --- a/wao-persistence/src/main/java/fr/ifremer/wao/entity/SampleRowTopiaDao.java +++ b/wao-persistence/src/main/java/fr/ifremer/wao/entity/SampleRowTopiaDao.java @@ -137,6 +137,18 @@ public class SampleRowTopiaDao extends AbstractSampleRowTopiaDao<SampleRow> { ImmutableMap.of("targetSpeciesDcfIds", (Object) filter.getTargetSpeciesDcfIds())); } + if (CollectionUtils.isNotEmpty(filter.getSpecies())) { + query.addTopiaIdIn(SampleRow.PROPERTY_SPECIES, filter.getSpecies()); + } + + if (CollectionUtils.isNotEmpty(filter.getIndividualMeasurementStrategies())) { + query.addIn(SampleRow.PROPERTY_INDIVIDUAL_MEASUREMENT_STRATEGY, filter.getIndividualMeasurementStrategies()); + } + + if (CollectionUtils.isNotEmpty(filter.getSclerochronologySamplingContexts())) { + query.addIn(SampleRow.PROPERTY_SCLEROCHRONOLOGY_SAMPLING_CONTEXT, filter.getSclerochronologySamplingContexts()); + } + if (log.isTraceEnabled()) { log.trace("query to filter sample rows for " + filter + " is " + query.getHql() + " " + query.getHqlParameters()); } diff --git a/wao-web/src/main/webapp/WEB-INF/content/sclerochronology/sampling-plan.jsp b/wao-web/src/main/webapp/WEB-INF/content/sclerochronology/sampling-plan.jsp index b9c4b7b..bb7a9d9 100644 --- a/wao-web/src/main/webapp/WEB-INF/content/sclerochronology/sampling-plan.jsp +++ b/wao-web/src/main/webapp/WEB-INF/content/sclerochronology/sampling-plan.jsp @@ -64,12 +64,12 @@ filterValuesField: 'fishingZoneSectorNames', }, { - filterName: 'samplingContext', + filterName: 'sclerochronologySamplingContexts', filterLabel: "<s:text name="wao.ui.field.SampleRow.sclerochronologySamplingContext"/>", filterValuesField: 'sclerochronologySamplingContexts', }, { - filterName: 'individualMeasurementStrategy', + filterName: 'individualMeasurementStrategies', filterLabel: "<s:text name="wao.ui.field.SampleRow.individualMeasurementStrategy"/>", filterValuesField: 'individualMeasurementStrategies', }, -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository wao. See http://git.codelutin.com/wao.git commit 5bcc4c289cf3ff8473efda00a0a1af960f537de5 Author: Brendan Le Ny <bleny@codelutin.com> Date: Thu Dec 18 16:59:10 2014 +0100 Dans le plan scléro, on ajoute une colonne pour l'espèce --- .../webapp/WEB-INF/content/sclerochronology/sampling-plan.jsp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/wao-web/src/main/webapp/WEB-INF/content/sclerochronology/sampling-plan.jsp b/wao-web/src/main/webapp/WEB-INF/content/sclerochronology/sampling-plan.jsp index bb7a9d9..3511394 100644 --- a/wao-web/src/main/webapp/WEB-INF/content/sclerochronology/sampling-plan.jsp +++ b/wao-web/src/main/webapp/WEB-INF/content/sclerochronology/sampling-plan.jsp @@ -182,12 +182,12 @@ </div> <s:if test="authenticatedWaoUser.authorizedToViewOtherCompanies"> - <s:set var="nbColumnsForProfessionInFullView" value="10" /> + <s:set var="nbColumnsForProfessionInFullView" value="11" /> </s:if> <s:else> - <s:set var="nbColumnsForProfessionInFullView" value="9" /> + <s:set var="nbColumnsForProfessionInFullView" value="10" /> </s:else> -<s:set var="nbColumnsForProfessionInCompactView" value="6" /> +<s:set var="nbColumnsForProfessionInCompactView" value="7" /> <s:set var="nbColumnsForMonths" value="%{samplingPlan.months.size() + 1}" /> <s:set var="nbColumnsForOther" value="2" /> <s:set var="nbColumnsTotalInFullView" value="%{#nbColumnsForProfessionInFullView + #nbColumnsForMonths + #nbColumnsForOther}" /> @@ -234,6 +234,7 @@ <th><s:text name="wao.ui.field.SampleRow.sclerochronologySamplingContext"/></th> <th><s:text name="wao.ui.field.SampleRow.sclerochronologySamplingContextInfo"/></th> <th><s:text name="wao.ui.field.SampleRow.individualMeasurementStrategy"/></th> + <th><s:text name="wao.ui.field.SampleRow.species"/></th> <th class="only-in-full-view"><s:text name="wao.ui.field.SampleRow.periodBegin"/></th> <th class="only-in-full-view"><s:text name="wao.ui.field.SampleRow.periodEnd"/></th> @@ -314,6 +315,9 @@ <td> <s:property value="individualMeasurementStrategy"/> </td> + <td> + <s:property value="species"/> + </td> <td class="only-in-full-view"><s:property value="%{formatMonth(periodBegin)}" /></td> <td class="only-in-full-view"><s:property value="%{formatMonth(periodEnd)}" /></td> <!-- Months columns --> -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository wao. See http://git.codelutin.com/wao.git commit 50588e180aed02fe197bbb2242e5f0e771e6afb6 Author: Brendan Le Ny <bleny@codelutin.com> Date: Fri Dec 19 11:44:13 2014 +0100 On adapte la génération de la liste des modifications pour considérer les changements sur une ligne scléro --- .../fr/ifremer/wao/entity/SampleRowLogImpl.java | 94 ++++++++++++++++++---- .../SclerochronologySamplingPlanServiceTest.java | 53 +++++++++++- .../ifremer/wao/services/service/WaoFixtures.java | 28 ++++--- 3 files changed, 149 insertions(+), 26 deletions(-) diff --git a/wao-persistence/src/main/java/fr/ifremer/wao/entity/SampleRowLogImpl.java b/wao-persistence/src/main/java/fr/ifremer/wao/entity/SampleRowLogImpl.java index 3253b65..bd39c1b 100644 --- a/wao-persistence/src/main/java/fr/ifremer/wao/entity/SampleRowLogImpl.java +++ b/wao-persistence/src/main/java/fr/ifremer/wao/entity/SampleRowLogImpl.java @@ -25,6 +25,8 @@ package fr.ifremer.wao.entity; import com.google.common.collect.Maps; +import fr.ifremer.wao.WaoUtils; +import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.StringUtils; import org.nuiton.topia.persistence.TopiaEntities; import org.nuiton.util.DateUtil; @@ -36,6 +38,7 @@ import java.util.Collection; import java.util.Collections; import java.util.Date; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.Set; @@ -48,6 +51,8 @@ import java.util.Set; */ public class SampleRowLogImpl extends SampleRowLogAbstract { + protected Locale locale = Locale.FRANCE; + // TODO brendan 29/04/14 i18n, i18n everywhere ! protected void addChange(String text) { String log = getLogText(); @@ -188,18 +193,18 @@ public class SampleRowLogImpl extends SampleRowLogAbstract { } } - protected void compareCompanies() { - Organisation oldCompany = oldRow == null ? null : oldRow.getOrganisation(); - Organisation newCompany = newRow.getOrganisation(); - if (oldCompany != null) { - String msg = "La ligne n'est plus associée à la société " + oldCompany.getName(); - if (newCompany != null && !newCompany.equals(oldCompany)) { - addChange(msg + " mais à la société " + newCompany.getName()); - } else if (newCompany == null) { + protected void compareOrganisations() { + Organisation oldOrganisation = oldRow == null ? null : oldRow.getOrganisation(); + Organisation newOrganisation = newRow.getOrganisation(); + if (oldOrganisation != null) { + String msg = "La ligne n'est plus associée à " + oldOrganisation.getFullName(); + if (newOrganisation != null && !newOrganisation.equals(oldOrganisation)) { + addChange(msg + " mais à la société " + newOrganisation.getName()); + } else if (newOrganisation == null) { addChange(msg); } - } else if (newCompany != null) { - addChange("La ligne est désormais associée à la société " + newCompany.getName()); + } else if (newOrganisation != null) { + addChange("La ligne est désormais associée à " + newOrganisation.getFullName()); } } @@ -397,6 +402,18 @@ public class SampleRowLogImpl extends SampleRowLogAbstract { } } + protected void compareSclerochronologySamplingContextInfos() { + String oldSclerochronologySamplingContextInfo = oldRow == null ? null : oldRow.getSclerochronologySamplingContextInfo(); + String newSclerochronologySamplingContextInfo = newRow.getSclerochronologySamplingContextInfo(); + if (!StringUtils.isEmpty(oldSclerochronologySamplingContextInfo)) { + if (!oldSclerochronologySamplingContextInfo.equals(newSclerochronologySamplingContextInfo)) { + addChange("Le complément d'information sur le contexte est passé de « " + oldSclerochronologySamplingContextInfo + " » à « " + newSclerochronologySamplingContextInfo + " »"); + } + } else if (!StringUtils.isEmpty(newSclerochronologySamplingContextInfo)) { + addChange("Le complément d'information sur le contexte est désormais « " + newSclerochronologySamplingContextInfo + " »"); + } + } + /** Compare a sample row before and after its modifications and generate * a differences summary and save it by setting log text. */ @@ -421,7 +438,7 @@ public class SampleRowLogImpl extends SampleRowLogAbstract { this.newRow = newRow; ObsProgram obsProgram = newRow.getObsProgram(); - if (ObsProgram.OBSMER.equals(obsProgram)) { + if (obsProgram.isObsMer()) { compareNbObservers(); compareAverageTidesTimes(); comparePrograms(); @@ -430,8 +447,7 @@ public class SampleRowLogImpl extends SampleRowLogAbstract { compareSampleMonths(); compareEligibleBoats(); compareFishingZones(); - } - if (ObsProgram.OBSVENTE.equals(obsProgram)) { + } else if (obsProgram.isObsVente()) { compareTerrestrialDistricts(); comparePrograms(); comparePeriods(); @@ -440,10 +456,60 @@ public class SampleRowLogImpl extends SampleRowLogAbstract { compareEligibleBoats(); compareFishingZones(); compareAverageObservationsCount(); + } else if (obsProgram.isSclerochronology()) { + comparePrograms(); + comparePeriods(); + compareSampleMonths(); + compareFishingZones(); + compareIndividualMeasurementStrategies(); + compareSclerochronologySamplingContexts(); + compareSclerochronologySamplingContextInfos(); + compareSpecies(); + } else { + throw new UnsupportedOperationException("not for " + obsProgram); } - compareCompanies(); + compareOrganisations(); this.oldRow = null; this.newRow = null; } + + protected void compareSclerochronologySamplingContexts() { + SclerochronologySamplingContext oldSclerochronologySamplingContext = oldRow.getSclerochronologySamplingContext(); + SclerochronologySamplingContext newSclerochronologySamplingContext = newRow.getSclerochronologySamplingContext(); + if (ObjectUtils.notEqual(oldSclerochronologySamplingContext, newSclerochronologySamplingContext)) { + String change = String.format( + "Le contexte est passé de %s à %s", + WaoUtils.l(locale, oldSclerochronologySamplingContext), + WaoUtils.l(locale, newSclerochronologySamplingContext) + ); + addChange(change); + } + } + + protected void compareIndividualMeasurementStrategies() { + IndividualMeasurementStrategy oldIndividualMeasurementStrategy = oldRow.getIndividualMeasurementStrategy(); + IndividualMeasurementStrategy newIndividualMeasurementStrategy = newRow.getIndividualMeasurementStrategy(); + if (ObjectUtils.notEqual(oldIndividualMeasurementStrategy, newIndividualMeasurementStrategy)) { + String change = String.format( + "Les caractéristiques à mesurer sont passées de %s à %s", + WaoUtils.l(locale, oldIndividualMeasurementStrategy), + WaoUtils.l(locale, newIndividualMeasurementStrategy) + ); + addChange(change); + } + } + + protected void compareSpecies() { + Species oldSpecies = oldRow.getSpecies(); + Species newSpecies = newRow.getSpecies(); + if (ObjectUtils.notEqual(oldSpecies, newSpecies)) { + String change = String.format( + "L'espèce est passée de %s à %s", + oldSpecies.getVernacularName(), + newSpecies.getVernacularName() + ); + addChange(change); + } + } } diff --git a/wao-services/src/test/java/fr/ifremer/wao/services/service/SclerochronologySamplingPlanServiceTest.java b/wao-services/src/test/java/fr/ifremer/wao/services/service/SclerochronologySamplingPlanServiceTest.java index 24b9d68..a729ace 100644 --- a/wao-services/src/test/java/fr/ifremer/wao/services/service/SclerochronologySamplingPlanServiceTest.java +++ b/wao-services/src/test/java/fr/ifremer/wao/services/service/SclerochronologySamplingPlanServiceTest.java @@ -1,8 +1,13 @@ package fr.ifremer.wao.services.service; +import com.google.common.base.Optional; +import com.google.common.collect.Iterables; import fr.ifremer.wao.SampleRowsFilter; +import fr.ifremer.wao.entity.SampleRow; +import fr.ifremer.wao.entity.SampleRowLog; import fr.ifremer.wao.services.AbstractWaoServiceTest; import fr.ifremer.wao.services.AuthenticatedWaoUser; +import fr.ifremer.wao.services.service.administration.UnknownBoatRegistrationCodesException; import org.apache.commons.io.IOUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -27,6 +32,7 @@ public class SclerochronologySamplingPlanServiceTest extends AbstractWaoServiceT @Before public void setUp() { + getApplicationContext().setDate(DateUtil.createDate(0, 30, 12, 15, 6, 2015)); service = newService(SclerochronologySamplingPlanService.class); fixtures = new SclerochronologyFixtures(newServiceContext()); } @@ -53,7 +59,6 @@ public class SclerochronologySamplingPlanServiceTest extends AbstractWaoServiceT @Test public void newSampleRowsFilterPeriodMustBeOnJanuaryToDecemberOfTheCurrentYear() { - applicationContext.setDate(DateUtil.createDate(15, 1, 2015)); fixtures.samplingPlan(); SampleRowsFilter filter = service.newSampleRowsFilter(fixtures.admin()); Assert.assertEquals(DateUtil.createDate(1, 1, 2015), filter.getPeriodFrom()); @@ -62,7 +67,6 @@ public class SclerochronologySamplingPlanServiceTest extends AbstractWaoServiceT @Test public void samplingPlan() { - applicationContext.setDate(DateUtil.createDate(15, 1, 2015)); fixtures.samplingPlan(); AuthenticatedWaoUser admin = fixtures.admin(); SampleRowsFilter filter = service.newSampleRowsFilter(admin); @@ -72,4 +76,49 @@ public class SclerochronologySamplingPlanServiceTest extends AbstractWaoServiceT Assert.assertEquals(3, samplingPlan.getFilterValues().getSclerochronologySamplingContexts().size()); Assert.assertEquals(2, samplingPlan.getFilterValues().getOrganisations().size()); } + + @Test + public void sampleRowModificationsAreLogged() { + + // dans le plan, on prend une ligne du plan + fixtures.samplingPlan(); + String sampleRowCode = "2015_S0001"; + String sampleRowId = service.getSampleRowDao().forCodeEquals(sampleRowCode).findUnique().getTopiaId(); + + // on la modifie en changeant diverses propriétés + UpdateSampleRowCommand updateSampleRowCommand = service.newUpdateSampleRowCommand(fixtures.admin(), Optional.of(sampleRowId)); + updateSampleRowCommand.getSampleRow().setSpecies( + Iterables.get(updateSampleRowCommand.getAllSpecies().values(), 2)); + updateSampleRowCommand.getSampleRow().setIndividualMeasurementStrategy( + Iterables.get(updateSampleRowCommand.getAllIndividualMeasurementStrategies().keySet(), 0)); + updateSampleRowCommand.getSampleRow().setSclerochronologySamplingContext( + Iterables.get(updateSampleRowCommand.getAllSclerochronologySamplingContexts().keySet(), 2)); + updateSampleRowCommand.getSampleRow().setSclerochronologySamplingContextInfo("note"); + updateSampleRowCommand.getSampleRowLog().setComment("test de modification"); + + try { + service.preValidate(fixtures.admin(), updateSampleRowCommand); + service.validate(fixtures.admin(), updateSampleRowCommand); + service.save(updateSampleRowCommand); + } catch (UnknownBoatRegistrationCodesException | SampleRowCodeMustBeUniqueException | SampleRowValidationException e) { + if (log.isDebugEnabled()) { + log.debug("unexpected exception", e); + } + Assert.fail("unexpected exception"); + } + + // on vérifie que les différentes modifications sont bien journalisées + SampleRow sampleRow = service.getSampleRowDao().forCodeEquals(sampleRowCode).findUnique(); + SampleRowLog sampleRowLog = Iterables.getOnlyElement(sampleRow.getSampleRowLog()); + + if (log.isDebugEnabled()) { + log.debug("log text is " + sampleRowLog.getLogText()); + } + + Assert.assertTrue(sampleRowLog.getLogText().contains("note")); + Assert.assertTrue(sampleRowLog.getLogText().contains("Échantillonnage à terre")); + Assert.assertTrue(sampleRowLog.getLogText().contains("Poids/Taille")); + Assert.assertTrue(sampleRowLog.getLogText().contains("Merlu")); + + } } \ No newline at end of file diff --git a/wao-services/src/test/java/fr/ifremer/wao/services/service/WaoFixtures.java b/wao-services/src/test/java/fr/ifremer/wao/services/service/WaoFixtures.java index 63e1885..7279bd3 100644 --- a/wao-services/src/test/java/fr/ifremer/wao/services/service/WaoFixtures.java +++ b/wao-services/src/test/java/fr/ifremer/wao/services/service/WaoFixtures.java @@ -1,5 +1,6 @@ package fr.ifremer.wao.services.service; +import com.google.common.collect.Iterables; import fr.ifremer.wao.WaoTechnicalException; import fr.ifremer.wao.entity.Company; import fr.ifremer.wao.entity.CompanyTopiaDao; @@ -9,6 +10,7 @@ import fr.ifremer.wao.entity.UserProfileImpl; import fr.ifremer.wao.entity.UserRole; import fr.ifremer.wao.entity.WaoUser; import fr.ifremer.wao.entity.WaoUserImpl; +import fr.ifremer.wao.entity.WaoUserTopiaDao; import fr.ifremer.wao.services.AuthenticatedWaoUser; import fr.ifremer.wao.services.WaoServiceContext; import fr.ifremer.wao.services.service.administration.ReferentialService; @@ -42,16 +44,22 @@ public class WaoFixtures { } protected AuthenticatedWaoUser newAuthenticatedWaoUser(String login, ObsProgram obsProgram, UserRole userRole) { - WaoUser waoUser = new WaoUserImpl(); - waoUser.setOrganisation(ifremer()); - waoUser.setLogin(login); - waoUser.setActive(true); - UserProfile userProfile = new UserProfileImpl(); - userProfile.setUserRole(userRole); - userProfile.setObsProgram(obsProgram); - userProfile.setCanWrite(true); - waoUser.addUserProfile(userProfile); - return new AuthenticatedWaoUser(waoUser, userProfile); + WaoUserTopiaDao waoUserDao = serviceContext.getPersistenceContext().getWaoUserDao(); + WaoUser waoUser = waoUserDao.forLoginEquals(login).findUniqueOrNull(); + if (waoUser == null) { + waoUser = new WaoUserImpl(); + waoUser.setOrganisation(ifremer()); + waoUser.setLogin(login); + waoUser.setActive(true); + UserProfile userProfile = new UserProfileImpl(); + userProfile.setUserRole(userRole); + userProfile.setObsProgram(obsProgram); + userProfile.setCanWrite(true); + waoUser.addUserProfile(userProfile); + waoUserDao.create(waoUser); + serviceContext.getPersistenceContext().commit(); + } + return new AuthenticatedWaoUser(waoUser, Iterables.getOnlyElement(waoUser.getUserProfile())); } public Company ifremer() { -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository wao. See http://git.codelutin.com/wao.git commit a182c8a6bb2769f803bc54491143330e4cb9b2a3 Author: Brendan Le Ny <bleny@codelutin.com> Date: Fri Dec 19 11:48:38 2014 +0100 Impact des données de test suite à changement de modèle CSV --- wao-services/src/test/resources/import/echantillonnage.csv | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wao-services/src/test/resources/import/echantillonnage.csv b/wao-services/src/test/resources/import/echantillonnage.csv index 0073eab..cfddb59 100644 --- a/wao-services/src/test/resources/import/echantillonnage.csv +++ b/wao-services/src/test/resources/import/echantillonnage.csv @@ -1,4 +1,4 @@ -"PLAN_CODE";"SOCIETE_NOM";"PECHE_DIVISION";"PECHE_AUTRE";"METIER_CODE_DCF5";"METIER_MAILLAGE";"METIER_TAILLE";"METIER_AUTRE";"METIER_LIBELLE";"METIER_ESPECES";"PROGRAMME_CODE";"PROGRAMME_DEBUT";"PROGRAMME_FIN";"12/2009";"01/2010";"02/2010";"03/2010";"04/2010";"05/2010";"06/2010";"07/2010";"08/2010";"09/2010";"10/2010";"11/2010";"12/2010";"01/2011";"02/2011";"03/2011";"PLAN_DUREE_MOY";"PLAN_NB_OBSERV";"PLAN_COMMENT";"TAUX_COUVERTURE_APPLIQUE" +"PLAN_CODE";"ORGANISATION_NOM";"PECHE_DIVISION";"PECHE_AUTRE";"METIER_CODE_DCF5";"METIER_MAILLAGE";"METIER_TAILLE";"METIER_AUTRE";"METIER_LIBELLE";"METIER_ESPECES";"PROGRAMME_CODE";"PROGRAMME_DEBUT";"PROGRAMME_FIN";"12/2009";"01/2010";"02/2010";"03/2010";"04/2010";"05/2010";"06/2010";"07/2010";"08/2010";"09/2010";"10/2010";"11/2010";"12/2010";"01/2011";"02/2011";"03/2011";"PLAN_DUREE_MOY";"PLAN_NB_OBSERV";"PLAN_COMMENT";"TAUX_COUVERTURE_APPLIQUE" "2010_M0001";"IFREMER";"IId,I";;"DRB_ALG";;;;;;"MA-2009";"03/2010";"01/2011";;;;0;0;0;0;0;0;0;2;0;0;4;;;"1.5";1;"Un petit commentaire";5 "2010_M0002";"IFREMER";"IId";;"DRH_CAT,DRH_CRU";;;;"Fileyage";"poissons tubes";"MANY";"01/2008";"12/2008";;20;0;0;21;0;0;21;0;0;21;0;0;;;;1;1;;5 "2010_M0003";"IFREMER";"IId,IV";;"DRH";;;;"balottage en plein air";"divers choses visqueuses";"MA-2009";"03/2010";"01/2011";;;;0;22;0;0;25;0;0;21;0;0;25;;;2;1;;5 -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository wao. See http://git.codelutin.com/wao.git commit 1a11c491eb88690a423def59c6a278948ad0a43b Author: Brendan Le Ny <bleny@codelutin.com> Date: Fri Dec 19 12:04:50 2014 +0100 Correction du message généré quand on compare les organisations (qui ne sont plus forcément des sociétés) --- .../src/main/java/fr/ifremer/wao/entity/SampleRowLogImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wao-persistence/src/main/java/fr/ifremer/wao/entity/SampleRowLogImpl.java b/wao-persistence/src/main/java/fr/ifremer/wao/entity/SampleRowLogImpl.java index bd39c1b..f0fad49 100644 --- a/wao-persistence/src/main/java/fr/ifremer/wao/entity/SampleRowLogImpl.java +++ b/wao-persistence/src/main/java/fr/ifremer/wao/entity/SampleRowLogImpl.java @@ -199,7 +199,7 @@ public class SampleRowLogImpl extends SampleRowLogAbstract { if (oldOrganisation != null) { String msg = "La ligne n'est plus associée à " + oldOrganisation.getFullName(); if (newOrganisation != null && !newOrganisation.equals(oldOrganisation)) { - addChange(msg + " mais à la société " + newOrganisation.getName()); + addChange(msg + " mais à " + newOrganisation.getFullName()); } else if (newOrganisation == null) { addChange(msg); } -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository wao. See http://git.codelutin.com/wao.git commit 44b82321eb517d338f8e5d1faa327e6523b60bb6 Author: Brendan Le Ny <bleny@codelutin.com> Date: Fri Dec 19 14:58:17 2014 +0100 Pour les coordinateurs et les observateurs, on affiche que les lignes du plan d'échantillonnage de l'organisation --- .../ifremer/wao/services/AuthenticatedWaoUser.java | 5 +++ .../wao/services/service/SamplingPlanService.java | 37 ++++++++++++++-------- .../services/service/UpdateSampleRowCommand.java | 28 ++++++++-------- .../wao/services/service/ObsMerFixtures.java | 4 +-- .../services/service/SclerochronologyFixtures.java | 10 +++++- .../SclerochronologySamplingPlanServiceTest.java | 11 +++++++ .../ifremer/wao/services/service/WaoFixtures.java | 27 ++++++++++++++-- .../main/resources/i18n/wao-web_en_GB.properties | 1 + .../main/resources/i18n/wao-web_fr_FR.properties | 1 + .../WEB-INF/content/edit-sample-row-input.jsp | 8 ++--- 10 files changed, 95 insertions(+), 37 deletions(-) diff --git a/wao-services/src/main/java/fr/ifremer/wao/services/AuthenticatedWaoUser.java b/wao-services/src/main/java/fr/ifremer/wao/services/AuthenticatedWaoUser.java index a3fab0b..214d21a 100644 --- a/wao-services/src/main/java/fr/ifremer/wao/services/AuthenticatedWaoUser.java +++ b/wao-services/src/main/java/fr/ifremer/wao/services/AuthenticatedWaoUser.java @@ -27,6 +27,7 @@ import fr.ifremer.wao.entity.Company; import fr.ifremer.wao.entity.Contact; import fr.ifremer.wao.entity.News; import fr.ifremer.wao.entity.ObsProgram; +import fr.ifremer.wao.entity.Organisation; import fr.ifremer.wao.entity.UserProfile; import fr.ifremer.wao.entity.UserRole; import fr.ifremer.wao.entity.WaoUser; @@ -103,6 +104,10 @@ public class AuthenticatedWaoUser implements Serializable{ return waoUser.getCompany(); } + public Organisation getOrganisation() { + return waoUser.getOrganisation(); + } + public boolean isAuthorizedToChangeUserRights() { boolean authorizedToChangeUserRights = isAuthorizedToSetAdmin() || isAuthorizedToSetCoordinator() diff --git a/wao-services/src/main/java/fr/ifremer/wao/services/service/SamplingPlanService.java b/wao-services/src/main/java/fr/ifremer/wao/services/service/SamplingPlanService.java index f2c72a1..2376fb1 100644 --- a/wao-services/src/main/java/fr/ifremer/wao/services/service/SamplingPlanService.java +++ b/wao-services/src/main/java/fr/ifremer/wao/services/service/SamplingPlanService.java @@ -35,7 +35,6 @@ import fr.ifremer.wao.WaoTechnicalException; import fr.ifremer.wao.WaoUtils; import fr.ifremer.wao.entity.Boat; import fr.ifremer.wao.entity.Boats; -import fr.ifremer.wao.entity.Company; import fr.ifremer.wao.entity.Contact; import fr.ifremer.wao.entity.ContactState; import fr.ifremer.wao.entity.Dcf5Code; @@ -154,9 +153,11 @@ public class SamplingPlanService extends WaoServiceSupport { public SampleRowsFilter newSampleRowsFilter(AuthenticatedWaoUser authenticatedWaoUser) { + ObsProgram obsProgram = authenticatedWaoUser.getObsProgram(); + // all users can see only rows for the program they are logged for SampleRowsFilter newFilter = new SampleRowsFilter(); - newFilter.setObsProgram(authenticatedWaoUser.getObsProgram()); + newFilter.setObsProgram(obsProgram); // We don't want to see all rows but the ones important for today Date fromDate = serviceContext.getNow(); @@ -164,11 +165,7 @@ public class SamplingPlanService extends WaoServiceSupport { // Dans ObsMer et ObsVente, le plan est mensualisé fromDate = DateUtils.truncate(fromDate, Calendar.MONTH); - if (authenticatedWaoUser.getObsProgram().isSclerochronology()) { - // on est sur un plan de janvier à décembre - fromDate = DateUtils.setMonths(fromDate, 0); - - } else { + if (obsProgram.isObsMer() || obsProgram.isObsVente()) { // la période initiale doit toujours aller d'avril à mars (contractuel). // on prend la période dans laquelle on se trouve actuellement @@ -185,6 +182,12 @@ public class SamplingPlanService extends WaoServiceSupport { // l'année prochaine fromDate = DateUtils.setMonths(fromDate, 3); } + } else if (obsProgram.isSclerochronology()) { + // on est sur un plan de janvier à décembre + fromDate = DateUtils.setMonths(fromDate, 0); + + } else { + throw new UnsupportedOperationException("program " + obsProgram); } // on a fromDate sur le premier avril de la bonne année, on va @@ -194,10 +197,17 @@ public class SamplingPlanService extends WaoServiceSupport { newFilter.setPeriodFrom(fromDate); newFilter.setPeriodTo(toDate); - // Very very important to do that at beginning - // Evo #2227 : Guest user has no default company filter + // ATTENTION, il s'agit de sécu if (authenticatedWaoUser.isCoordinatorOrObserver()) { - newFilter.setOrganisationIds(Sets.newHashSet(authenticatedWaoUser.getCompany().getTopiaId())); + // quand on appartient à une organisation (société ou labo), par défaut on ne peut voir + // que les lignes de cette même organisation + Organisation organisationToFilterOn = authenticatedWaoUser.getOrganisation(); + if (obsProgram.isObsMer() || obsProgram.isObsVente()) { + // dans ce cas, on est plus souple : si on appartient à des labos différents mais à + // la même société, on peut voir tout ce qui concerne la société tous labos confondus + organisationToFilterOn = authenticatedWaoUser.getOrganisation().getCompany(); + } + newFilter.setOrganisationIds(ImmutableSet.of(organisationToFilterOn.getTopiaId())); } return newFilter; @@ -351,13 +361,12 @@ public class SamplingPlanService extends WaoServiceSupport { ); updateSampleRowCommand.setAllFishingZones(allFishingZones); - ImmutableMap<String, Company> allCompanies = + ImmutableMap<String, Organisation> allOrganisations = Maps.uniqueIndex( - // TODO brendan 15/12/14 getOrganisationsService().getOrganisationsToWorkOnSampleRow(obsProgram); - getCompaniesService().getAllCompanies(), + getOrganisationsService().getOrganisationsToWorkOnSampleRow(obsProgram), TopiaEntities.getTopiaIdFunction() ); - updateSampleRowCommand.setAllCompanies(allCompanies); + updateSampleRowCommand.setAllOrganisations(allOrganisations); ImmutableMap<String, Dcf5Code> allDcf5Codes = Maps.uniqueIndex( diff --git a/wao-services/src/main/java/fr/ifremer/wao/services/service/UpdateSampleRowCommand.java b/wao-services/src/main/java/fr/ifremer/wao/services/service/UpdateSampleRowCommand.java index cf233e9..3641d36 100644 --- a/wao-services/src/main/java/fr/ifremer/wao/services/service/UpdateSampleRowCommand.java +++ b/wao-services/src/main/java/fr/ifremer/wao/services/service/UpdateSampleRowCommand.java @@ -28,10 +28,10 @@ import com.google.common.collect.ImmutableMap; import com.google.common.collect.Iterables; import com.google.common.collect.Sets; import fr.ifremer.wao.WaoUtils; -import fr.ifremer.wao.entity.Company; import fr.ifremer.wao.entity.Dcf5Code; import fr.ifremer.wao.entity.FishingZone; import fr.ifremer.wao.entity.IndividualMeasurementStrategy; +import fr.ifremer.wao.entity.Organisation; import fr.ifremer.wao.entity.SampleMonth; import fr.ifremer.wao.entity.SampleRow; import fr.ifremer.wao.entity.SampleRowLog; @@ -72,7 +72,7 @@ public class UpdateSampleRowCommand implements Serializable{ protected ImmutableMap<String, FishingZone> allFishingZones; - protected ImmutableMap<String, Company> allCompanies; + protected ImmutableMap<String, Organisation> allOrganisations; protected ImmutableMap<String, Dcf5Code> allDcf5Codes; @@ -112,20 +112,20 @@ public class UpdateSampleRowCommand implements Serializable{ this.expectedObservationsByMonths = expectedObservationsByMonths; } - public String getCompanyId() { - String companyId = null; + public String getOrganisationId() { + String organisationId = null; if (sampleRow.getCompany() != null) { - companyId = sampleRow.getCompany().getTopiaId(); + organisationId = sampleRow.getOrganisation().getTopiaId(); } - return companyId; + return organisationId; } - public void setCompanyId(String companyId) { - Company company = null; + public void setOrganisationId(String companyId) { + Organisation organisation = null; if (StringUtils.isNotBlank(companyId)) { - company = allCompanies.get(companyId); + organisation = allOrganisations.get(companyId); } - sampleRow.setCompany(company); + sampleRow.setOrganisation(organisation); } public Set<String> getDcf5CodesIds() { @@ -216,12 +216,12 @@ public class UpdateSampleRowCommand implements Serializable{ this.allFishingZones = allFishingZones; } - public ImmutableMap<String, Company> getAllCompanies() { - return allCompanies; + public ImmutableMap<String, Organisation> getAllOrganisations() { + return allOrganisations; } - public void setAllCompanies(ImmutableMap<String, Company> allCompanies) { - this.allCompanies = allCompanies; + public void setAllOrganisations(ImmutableMap<String, Organisation> allOrganisations) { + this.allOrganisations = allOrganisations; } public ImmutableMap<String, Dcf5Code> getAllDcf5Codes() { diff --git a/wao-services/src/test/java/fr/ifremer/wao/services/service/ObsMerFixtures.java b/wao-services/src/test/java/fr/ifremer/wao/services/service/ObsMerFixtures.java index e3c1806..fa8a3bf 100644 --- a/wao-services/src/test/java/fr/ifremer/wao/services/service/ObsMerFixtures.java +++ b/wao-services/src/test/java/fr/ifremer/wao/services/service/ObsMerFixtures.java @@ -41,11 +41,11 @@ public class ObsMerFixtures extends WaoFixtures { } public AuthenticatedWaoUser admin() { - return newAuthenticatedWaoUser("admin", ObsProgram.OBSMER, UserRole.ADMIN); + return newAuthenticatedWaoUser("admin", ObsProgram.OBSMER, UserRole.ADMIN, ifremer()); } public AuthenticatedWaoUser jmichmuche() { - return newAuthenticatedWaoUser("jmichmuche", ObsProgram.OBSMER, UserRole.COORDINATOR); + return newAuthenticatedWaoUser("jmichmuche", ObsProgram.OBSMER, UserRole.COORDINATOR, ifremer()); } public void samplingPlan() { diff --git a/wao-services/src/test/java/fr/ifremer/wao/services/service/SclerochronologyFixtures.java b/wao-services/src/test/java/fr/ifremer/wao/services/service/SclerochronologyFixtures.java index 431bcb7..5c97dd3 100644 --- a/wao-services/src/test/java/fr/ifremer/wao/services/service/SclerochronologyFixtures.java +++ b/wao-services/src/test/java/fr/ifremer/wao/services/service/SclerochronologyFixtures.java @@ -19,7 +19,15 @@ public class SclerochronologyFixtures extends WaoFixtures { } public AuthenticatedWaoUser admin() { - return newAuthenticatedWaoUser("admin", ObsProgram.SCLEROCHRONOLOGY, UserRole.ADMIN); + return newAuthenticatedWaoUser("admin", ObsProgram.SCLEROCHRONOLOGY, UserRole.ADMIN, ifremer()); + } + + public AuthenticatedWaoUser coordinator() { + return newAuthenticatedWaoUser("coordinator", ObsProgram.SCLEROCHRONOLOGY, UserRole.COORDINATOR, emh()); + } + + public AuthenticatedWaoUser observer() { + return newAuthenticatedWaoUser("observer", ObsProgram.SCLEROCHRONOLOGY, UserRole.OBSERVER, ifremer()); } public void species() { diff --git a/wao-services/src/test/java/fr/ifremer/wao/services/service/SclerochronologySamplingPlanServiceTest.java b/wao-services/src/test/java/fr/ifremer/wao/services/service/SclerochronologySamplingPlanServiceTest.java index a729ace..b1b0c0b 100644 --- a/wao-services/src/test/java/fr/ifremer/wao/services/service/SclerochronologySamplingPlanServiceTest.java +++ b/wao-services/src/test/java/fr/ifremer/wao/services/service/SclerochronologySamplingPlanServiceTest.java @@ -8,6 +8,7 @@ import fr.ifremer.wao.entity.SampleRowLog; import fr.ifremer.wao.services.AbstractWaoServiceTest; import fr.ifremer.wao.services.AuthenticatedWaoUser; import fr.ifremer.wao.services.service.administration.UnknownBoatRegistrationCodesException; +import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.io.IOUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -66,6 +67,16 @@ public class SclerochronologySamplingPlanServiceTest extends AbstractWaoServiceT } @Test + public void newSampleRowsFilterMustEnsureSecurity() { + SampleRowsFilter adminFilter = service.newSampleRowsFilter(fixtures.admin()); + Assert.assertTrue(CollectionUtils.isEmpty(adminFilter.getOrganisationIds())); + + SampleRowsFilter coordinatorFilter = service.newSampleRowsFilter(fixtures.coordinator()); + Assert.assertFalse(coordinatorFilter.getOrganisationIds().isEmpty()); + Assert.assertTrue(coordinatorFilter.getOrganisationIds().contains(fixtures.coordinator().getOrganisation().getTopiaId())); + } + + @Test public void samplingPlan() { fixtures.samplingPlan(); AuthenticatedWaoUser admin = fixtures.admin(); diff --git a/wao-services/src/test/java/fr/ifremer/wao/services/service/WaoFixtures.java b/wao-services/src/test/java/fr/ifremer/wao/services/service/WaoFixtures.java index 7279bd3..f85e3a7 100644 --- a/wao-services/src/test/java/fr/ifremer/wao/services/service/WaoFixtures.java +++ b/wao-services/src/test/java/fr/ifremer/wao/services/service/WaoFixtures.java @@ -4,7 +4,10 @@ import com.google.common.collect.Iterables; import fr.ifremer.wao.WaoTechnicalException; import fr.ifremer.wao.entity.Company; import fr.ifremer.wao.entity.CompanyTopiaDao; +import fr.ifremer.wao.entity.Laboratory; +import fr.ifremer.wao.entity.LaboratoryTopiaDao; import fr.ifremer.wao.entity.ObsProgram; +import fr.ifremer.wao.entity.Organisation; import fr.ifremer.wao.entity.UserProfile; import fr.ifremer.wao.entity.UserProfileImpl; import fr.ifremer.wao.entity.UserRole; @@ -26,6 +29,8 @@ public class WaoFixtures { protected Map<String, Company> companies = new HashMap<>(); + protected Map<String, Laboratory> laboratories = new HashMap<>(); + public WaoFixtures(WaoServiceContext serviceContext) { this.serviceContext = serviceContext; } @@ -43,12 +48,26 @@ public class WaoFixtures { return company; } - protected AuthenticatedWaoUser newAuthenticatedWaoUser(String login, ObsProgram obsProgram, UserRole userRole) { + protected Laboratory getLaboratory(String laboratoryName) { + Laboratory laboratory = laboratories.get(laboratoryName); + if (laboratory == null) { + LaboratoryTopiaDao laboratoryDao = serviceContext.getPersistenceContext().getLaboratoryDao(); + laboratory = laboratoryDao.create( + Laboratory.PROPERTY_NAME, laboratoryName, + Laboratory.PROPERTY_COMPANY, ifremer(), + Laboratory.PROPERTY_ACTIVE, true); + laboratories.put(laboratoryName, laboratory); + serviceContext.getPersistenceContext().commit(); + } + return laboratory; + } + + protected AuthenticatedWaoUser newAuthenticatedWaoUser(String login, ObsProgram obsProgram, UserRole userRole, Organisation organisation) { WaoUserTopiaDao waoUserDao = serviceContext.getPersistenceContext().getWaoUserDao(); WaoUser waoUser = waoUserDao.forLoginEquals(login).findUniqueOrNull(); if (waoUser == null) { waoUser = new WaoUserImpl(); - waoUser.setOrganisation(ifremer()); + waoUser.setOrganisation(organisation); waoUser.setLogin(login); waoUser.setActive(true); UserProfile userProfile = new UserProfileImpl(); @@ -70,6 +89,10 @@ public class WaoFixtures { return getCompany("OCEANET"); } + public Laboratory emh() { + return getLaboratory("EMH"); + } + public void fishingZones() { InputStream input = null; try { diff --git a/wao-web/src/main/resources/i18n/wao-web_en_GB.properties b/wao-web/src/main/resources/i18n/wao-web_en_GB.properties index e540698..b17a646 100644 --- a/wao-web/src/main/resources/i18n/wao-web_en_GB.properties +++ b/wao-web/src/main/resources/i18n/wao-web_en_GB.properties @@ -260,6 +260,7 @@ wao.ui.field.SampleRow.nbObservants=Number of observers wao.ui.field.SampleRow.observationType=Observation type wao.ui.field.SampleRow.observationUnit=Observation unit wao.ui.field.SampleRow.observers=Observers +wao.ui.field.SampleRow.organisation=Organisation wao.ui.field.SampleRow.other=Other wao.ui.field.SampleRow.periodBegin=Begin wao.ui.field.SampleRow.periodEnd=End diff --git a/wao-web/src/main/resources/i18n/wao-web_fr_FR.properties b/wao-web/src/main/resources/i18n/wao-web_fr_FR.properties index 0726cc6..e7d66ba 100644 --- a/wao-web/src/main/resources/i18n/wao-web_fr_FR.properties +++ b/wao-web/src/main/resources/i18n/wao-web_fr_FR.properties @@ -261,6 +261,7 @@ wao.ui.field.SampleRow.nbObservants=Nombre d'observateurs wao.ui.field.SampleRow.observationType=Type d'observation wao.ui.field.SampleRow.observationUnit=Unité d'observation wao.ui.field.SampleRow.observers=Observateurs +wao.ui.field.SampleRow.organisation=Organisation wao.ui.field.SampleRow.other=Autre wao.ui.field.SampleRow.periodBegin=Début wao.ui.field.SampleRow.periodEnd=Fin diff --git a/wao-web/src/main/webapp/WEB-INF/content/edit-sample-row-input.jsp b/wao-web/src/main/webapp/WEB-INF/content/edit-sample-row-input.jsp index ab8ccd4..0b3bc70 100644 --- a/wao-web/src/main/webapp/WEB-INF/content/edit-sample-row-input.jsp +++ b/wao-web/src/main/webapp/WEB-INF/content/edit-sample-row-input.jsp @@ -260,11 +260,11 @@ cssClass="input-small" /> </s:if> - <s:select name="updateSampleRowCommand.companyId" - label="%{getText('wao.ui.field.SampleRow.company')}" + <s:select name="updateSampleRowCommand.organisationId" + label="%{getText('wao.ui.field.SampleRow.organisation')}" disabled="updateSampleRowCommand.observationAlreadyStarted" - list="updateSampleRowCommand.allCompanies" - listValue="%{value.name}" + list="updateSampleRowCommand.allOrganisations" + listValue="%{value.fullName}" cssClass="input-xxlarge" /> -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository wao. See http://git.codelutin.com/wao.git commit e2e361a595fc675c909553ec5aea137a804a2eb7 Author: Brendan Le Ny <bleny@codelutin.com> Date: Mon Dec 22 11:15:09 2014 +0100 Dans la scléro, on utilise pas la notion de Profession --- .../main/java/fr/ifremer/wao/entity/SampleRowImpl.java | 15 ++++++++------- .../fr/ifremer/wao/services/service/SamplingPlan.java | 14 +++++++++----- .../ifremer/wao/services/service/SamplingPlanService.java | 11 +++++------ .../csv/ObsMerObsVenteSamplingPlanImportExportModel.java | 4 +++- 4 files changed, 25 insertions(+), 19 deletions(-) diff --git a/wao-persistence/src/main/java/fr/ifremer/wao/entity/SampleRowImpl.java b/wao-persistence/src/main/java/fr/ifremer/wao/entity/SampleRowImpl.java index e5d10c9..ce002fc 100644 --- a/wao-persistence/src/main/java/fr/ifremer/wao/entity/SampleRowImpl.java +++ b/wao-persistence/src/main/java/fr/ifremer/wao/entity/SampleRowImpl.java @@ -155,15 +155,16 @@ public class SampleRowImpl extends SampleRowAbstract { @Override public String getProfessionDescriptionWithoutDcf5() { String code = ""; - if (getProfession() != null) { - if (!StringUtils.isEmpty(getProfession().getMeshSize())) { - code += " " + getProfession().getMeshSize(); + Profession profession = getProfession(); + if (profession != null) { + if (!StringUtils.isEmpty(profession.getMeshSize())) { + code += " " + profession.getMeshSize(); } - if (!StringUtils.isEmpty(getProfession().getSize())) { - code += " " + getProfession().getSize(); + if (!StringUtils.isEmpty(profession.getSize())) { + code += " " + profession.getSize(); } - if (!StringUtils.isEmpty(getProfession().getOther())) { - code += " " + getProfession().getOther(); + if (!StringUtils.isEmpty(profession.getOther())) { + code += " " + profession.getOther(); } } return code; diff --git a/wao-services/src/main/java/fr/ifremer/wao/services/service/SamplingPlan.java b/wao-services/src/main/java/fr/ifremer/wao/services/service/SamplingPlan.java index 47eb232..d2f7b41 100644 --- a/wao-services/src/main/java/fr/ifremer/wao/services/service/SamplingPlan.java +++ b/wao-services/src/main/java/fr/ifremer/wao/services/service/SamplingPlan.java @@ -24,6 +24,7 @@ package fr.ifremer.wao.services.service; import fr.ifremer.wao.WaoUtils; import fr.ifremer.wao.entity.Dcf5Code; import fr.ifremer.wao.entity.FishingZone; +import fr.ifremer.wao.entity.Profession; import fr.ifremer.wao.entity.SampleMonth; import fr.ifremer.wao.entity.SampleRow; import fr.ifremer.wao.entity.SampleRowLog; @@ -394,11 +395,14 @@ public abstract class SamplingPlan implements Iterable<SamplingPlan.SamplingPlan periodEnd = sampleRow.getPeriodEnd(); companyName = sampleRow.getCompany().getName(); code = sampleRow.getCode(); - professionMeshSize = sampleRow.getProfession().getMeshSize(); - professionSize = sampleRow.getProfession().getSize(); - professionOther = sampleRow.getProfession().getOther(); - professionLibelle = sampleRow.getProfession().getLibelle(); - professionSpecies = sampleRow.getProfession().getSpecies(); + Profession profession = sampleRow.getProfession(); + if (profession != null) { + professionMeshSize = profession.getMeshSize(); + professionSize = profession.getSize(); + professionOther = profession.getOther(); + professionLibelle = profession.getLibelle(); + professionSpecies = profession.getSpecies(); + } dcf5CodesAndDescriptions = new LinkedHashMap<>(); for (Dcf5Code dcf5Code : sampleRow.getDcf5Code()) { String key = dcf5Code.getCode(); diff --git a/wao-services/src/main/java/fr/ifremer/wao/services/service/SamplingPlanService.java b/wao-services/src/main/java/fr/ifremer/wao/services/service/SamplingPlanService.java index 2376fb1..87495c6 100644 --- a/wao-services/src/main/java/fr/ifremer/wao/services/service/SamplingPlanService.java +++ b/wao-services/src/main/java/fr/ifremer/wao/services/service/SamplingPlanService.java @@ -333,7 +333,9 @@ public class SamplingPlanService extends WaoServiceSupport { SampleRow newSampleRow = new SampleRowImpl(); newSampleRow.setObsProgram(obsProgram); - newSampleRow.setProfession(new ProfessionImpl()); + if (obsProgram.isObsMer() || obsProgram.isObsVente()) { + newSampleRow.setProfession(new ProfessionImpl()); + } newSampleRow.setFishingZone(new HashSet<FishingZone>()); newSampleRow.setSampleMonth(new HashSet<SampleMonth>()); @@ -508,12 +510,9 @@ public class SamplingPlanService extends WaoServiceSupport { } } - ProfessionTopiaDao professionDao = getProfessionDao(); Profession profession = sampleRow.getProfession(); - if (profession.isPersisted()) { - professionDao.update(profession); - } else { - professionDao.create(profession); + if (profession != null) { + getProfessionDao().save(profession); } SampleRowTopiaDao dao = getSampleRowDao(); diff --git a/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/ObsMerObsVenteSamplingPlanImportExportModel.java b/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/ObsMerObsVenteSamplingPlanImportExportModel.java index 54204a6..5723088 100644 --- a/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/ObsMerObsVenteSamplingPlanImportExportModel.java +++ b/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/ObsMerObsVenteSamplingPlanImportExportModel.java @@ -189,7 +189,9 @@ public class ObsMerObsVenteSamplingPlanImportExportModel implements ImportExport public SampleRow newEmptyInstance() { SampleRow newSampleRow = new SampleRowImpl(); newSampleRow.setObsProgram(obsProgram); - newSampleRow.setProfession(new ProfessionImpl()); + if (obsProgram.isObsMer() || obsProgram.isObsVente()) { + newSampleRow.setProfession(new ProfessionImpl()); + } return newSampleRow; } -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository wao. See http://git.codelutin.com/wao.git commit ddc9f4ef1d0a4ca7258ee1e143b03415822f5743 Merge: 12328c6 e2e361a Author: Brendan Le Ny <bleny@codelutin.com> Date: Mon Dec 22 14:36:19 2014 +0100 Ajout du plan d'échantillonnage pour le programme sclérochronologie (fixes #2263) .../main/java/fr/ifremer/wao/SampleRowsFilter.java | 68 ++++- .../java/fr/ifremer/wao/entity/BoatTopiaDao.java | 2 +- .../main/java/fr/ifremer/wao/entity/Companies.java | 9 +- .../wao/entity/IndividualMeasurementStrategy.java | 39 +++ .../java/fr/ifremer/wao/entity/Organisations.java | 23 ++ .../java/fr/ifremer/wao/entity/SampleRowImpl.java | 15 +- .../fr/ifremer/wao/entity/SampleRowLogImpl.java | 94 +++++- .../fr/ifremer/wao/entity/SampleRowTopiaDao.java | 16 +- .../entity/SclerochronologySamplingContext.java | 38 +++ .../main/java/fr/ifremer/wao/entity/Specieses.java | 19 ++ .../db/migration/V5_0__sclerochronology.sql | 18 ++ .../i18n/wao-persistence_en_GB.properties | 7 + .../i18n/wao-persistence_fr_FR.properties | 7 + wao-persistence/src/main/xmi/wao-model.properties | 2 +- wao-persistence/src/main/xmi/wao-model.zargo | Bin 61366 -> 61993 bytes .../ifremer/wao/services/AuthenticatedWaoUser.java | 5 + .../fr/ifremer/wao/services/ObsMerFixtures.java | 222 -------------- .../ifremer/wao/services/service/BoatsService.java | 6 +- .../wao/services/service/ContactsService.java | 2 +- ...singIndividualMeasurementStrategyException.java | 10 + ...ngSclerochronologySamplingContextException.java | 10 + .../services/service/MissingSpeciesException.java | 10 + .../services/service/SampleRowsFilterValues.java | 88 ++++-- .../ifremer/wao/services/service/SamplingPlan.java | 14 +- .../wao/services/service/SamplingPlanService.java | 135 ++++++--- .../service/SclerochronologySamplingPlan.java | 118 ++++++++ .../SclerochronologySamplingPlanBuilder.java | 326 +++++++++++++++++++++ .../SclerochronologySamplingPlanService.java | 89 ++++++ .../services/service/UpdateSampleRowCommand.java | 79 ++++- .../wao/services/service/WaoServiceSupport.java | 5 + .../administration/OrganisationsService.java | 18 ++ .../service/administration/ReferentialService.java | 9 + .../administration/UpdateWaoUserCommand.java | 9 + .../service/csv/ContactImportExportModel.java | 12 +- ...bsMerObsVenteSamplingPlanImportExportModel.java | 46 ++- ...atter.java => OrganisationParserFormatter.java} | 48 +-- .../csv/operations/SpeciesParserFormatter.java | 51 ++++ .../resources/i18n/wao-services_en_GB.properties | 5 + .../resources/i18n/wao-services_fr_FR.properties | 5 + .../wao/services/service/BoatsServiceTest.java | 1 - .../wao/services/service/ContactsServiceTest.java | 1 - .../wao/services/service/ObsMerFixtures.java | 93 ++++++ .../service/ObsMerSamplingPlanServiceTest.java | 1 - .../services/service/SclerochronologyFixtures.java | 73 +++++ .../SclerochronologySamplingPlanServiceTest.java | 135 +++++++++ .../ifremer/wao/services/service/WaoFixtures.java | 119 ++++++++ .../src/test/resources/import/echantillonnage.csv | 20 +- .../resources/import/plan-sclerochronologie.csv | 6 + .../test/resources/import/samplingPlan-obsdeb.csv | 3 - .../wao/web/action/EditSampleRowAction.java | 15 +- .../action/SampleRowsFilterValuesJsonAction.java | 34 ++- .../action/administration/ImportSpeciesAction.java | 4 +- .../sclerochronology/SamplingPlanAction.java | 26 +- .../SamplingPlanAction-conversion.properties | 1 + .../main/resources/i18n/wao-web_en_GB.properties | 5 + .../main/resources/i18n/wao-web_fr_FR.properties | 5 + .../content/administration/edit-wao-user.jsp | 4 +- .../administration/referential-management.jsp | 94 +++--- .../main/webapp/WEB-INF/content/boat-details.jsp | 2 +- .../src/main/webapp/WEB-INF/content/contacts.jsp | 2 +- .../WEB-INF/content/edit-sample-row-input.jsp | 116 +++++--- .../WEB-INF/content/obsmer/sampling-plan.jsp | 6 +- .../WEB-INF/content/obsvente/sampling-plan.jsp | 6 +- .../sampling-plan.jsp | 107 ++----- .../src/main/webapp/WEB-INF/content/synthesis.jsp | 4 +- .../src/main/webapp/WEB-INF/decorators/layout.jsp | 50 ++-- 66 files changed, 1980 insertions(+), 632 deletions(-) -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
participants (1)
-
codelutin.com scm