branch feature/2264 updated (912ef1e -> 8de096c)
This is an automated email from the git hooks/post-receive script. New change to branch feature/2264 in repository wao. See http://git.codelutin.com/wao.git from 912ef1e Ébauche du formulaire de modification d'un contact scléro new 068d1a2 Tableau des contacts pour scléro et forme du formulaire (pas encore de validation adéquat) new 5d6b2f2 Passage du plan scléro en nombre d'individus (totaux manquants) new 8de096c Ajout des totaux en individus dans le plan The 3 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 8de096c5589af53138cfecf4afde0169df650c91 Author: Brendan Le Ny <bleny@codelutin.com> Date: Fri Dec 26 12:05:25 2014 +0100 Ajout des totaux en individus dans le plan commit 5d6b2f229d296dce252cbd15e0b23804eef48fde Author: Brendan Le Ny <bleny@codelutin.com> Date: Fri Dec 26 11:39:06 2014 +0100 Passage du plan scléro en nombre d'individus (totaux manquants) commit 068d1a2dc4068527ec7571f9c0bf819785d19fc4 Author: Brendan Le Ny <bleny@codelutin.com> Date: Fri Dec 26 10:13:42 2014 +0100 Tableau des contacts pour scléro et forme du formulaire (pas encore de validation adéquat) Summary of changes: .../service/ObsMerSamplingPlanService.java | 27 --- .../ifremer/wao/services/service/SamplingPlan.java | 19 +- .../wao/services/service/SamplingPlanService.java | 22 +++ .../service/SclerochronologySamplingPlan.java | 39 +++- .../SclerochronologySamplingPlanBuilder.java | 218 +++++++++++---------- .../SclerochronologySamplingPlanService.java | 6 +- .../SclerochronologySamplingPlanServiceTest.java | 32 +++ .../wao/entity/Contact-conversion.properties | 5 +- .../main/resources/i18n/wao-web_en_GB.properties | 10 +- .../main/resources/i18n/wao-web_fr_FR.properties | 10 +- .../src/main/webapp/WEB-INF/content/contacts.jsp | 155 +++++++++++---- .../webapp/WEB-INF/content/edit-contact-input.jsp | 3 +- .../content/sclerochronology/sampling-plan.jsp | 10 +- 13 files changed, 354 insertions(+), 202 deletions(-) -- 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 feature/2264 in repository wao. See http://git.codelutin.com/wao.git commit 068d1a2dc4068527ec7571f9c0bf819785d19fc4 Author: Brendan Le Ny <bleny@codelutin.com> Date: Fri Dec 26 10:13:42 2014 +0100 Tableau des contacts pour scléro et forme du formulaire (pas encore de validation adéquat) --- .../wao/entity/Contact-conversion.properties | 5 +- .../main/resources/i18n/wao-web_en_GB.properties | 9 +- .../main/resources/i18n/wao-web_fr_FR.properties | 9 +- .../src/main/webapp/WEB-INF/content/contacts.jsp | 155 +++++++++++++++------ .../webapp/WEB-INF/content/edit-contact-input.jsp | 3 +- 5 files changed, 132 insertions(+), 49 deletions(-) diff --git a/wao-web/src/main/resources/fr/ifremer/wao/entity/Contact-conversion.properties b/wao-web/src/main/resources/fr/ifremer/wao/entity/Contact-conversion.properties index 8898264..c3177ab 100644 --- a/wao-web/src/main/resources/fr/ifremer/wao/entity/Contact-conversion.properties +++ b/wao-web/src/main/resources/fr/ifremer/wao/entity/Contact-conversion.properties @@ -22,4 +22,7 @@ observationBeginDate=fr.ifremer.wao.web.converter.DateTimeConverter observationEndDate=fr.ifremer.wao.web.converter.DateTimeConverter creationDate=fr.ifremer.wao.web.converter.DateConverter dataInputDate=fr.ifremer.wao.web.converter.DateConverter -restitution=fr.ifremer.wao.web.converter.DateConverter \ No newline at end of file +restitution=fr.ifremer.wao.web.converter.DateConverter +sampleSubmission=fr.ifremer.wao.web.converter.DateConverter +sampleReception=fr.ifremer.wao.web.converter.DateConverter +sampleTreatment=fr.ifremer.wao.web.converter.DateConverter 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 18dfe5d..5e9770e 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 @@ -228,11 +228,12 @@ wao.ui.field.Contact.observationTimeInDays=Observation time in days wao.ui.field.Contact.observationType=Observation type wao.ui.field.Contact.observedDataControl=Observed Data control wao.ui.field.Contact.restitution=Restitution -wao.ui.field.Contact.sampleReception= +wao.ui.field.Contact.sampleReception=Sample reception wao.ui.field.Contact.sampleRow=Sample row -wao.ui.field.Contact.sampleSize= -wao.ui.field.Contact.sampleSubmission= -wao.ui.field.Contact.sampleTreatment= +wao.ui.field.Contact.sampleSize=Sample size +wao.ui.field.Contact.sampleSize.unit=individuals +wao.ui.field.Contact.sampleSubmission=Sample submission +wao.ui.field.Contact.sampleTreatment=Sample treatment wao.ui.field.Contact.samplingStrategy=Sampling strategy followed wao.ui.field.Contact.secondaryObservers=Secondary observers wao.ui.field.Contact.terrestrialLocation=Observation's place 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 f917979..28c8e87 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 @@ -229,11 +229,12 @@ wao.ui.field.Contact.observationTimeInDays=Jours d'observation wao.ui.field.Contact.observationType=Type d'observation wao.ui.field.Contact.observedDataControl=Contrôle des données observées wao.ui.field.Contact.restitution=Transmission de la restitution -wao.ui.field.Contact.sampleReception= +wao.ui.field.Contact.sampleReception=Réception de l'échantillon wao.ui.field.Contact.sampleRow=Ligne du plan -wao.ui.field.Contact.sampleSize= -wao.ui.field.Contact.sampleSubmission= -wao.ui.field.Contact.sampleTreatment= +wao.ui.field.Contact.sampleSize=Taille de l'échantillon +wao.ui.field.Contact.sampleSize.unit=individus +wao.ui.field.Contact.sampleSubmission=Envoi de l'échantillon +wao.ui.field.Contact.sampleTreatment=Traitement de l'échantillon wao.ui.field.Contact.samplingStrategy=Stratégie d'échantillonnage suivie wao.ui.field.Contact.secondaryObservers=Observateurs secondaires wao.ui.field.Contact.terrestrialLocation=Lieu d'observation 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 0181289..b3df83d 100644 --- a/wao-web/src/main/webapp/WEB-INF/content/contacts.jsp +++ b/wao-web/src/main/webapp/WEB-INF/content/contacts.jsp @@ -348,12 +348,21 @@ <thead> <tr> <th><s:text name="wao.ui.field.Contact.creationDate"/></th> - <th><s:text name="wao.ui.contacts.boatName"/></th> + <s:if test="obsMer || obsVente"> + <th><s:text name="wao.ui.contacts.boatName"/></th> + </s:if> <th><s:text name="wao.ui.field.Contact.sampleRow"/></th> <th class="only-in-full-view"><s:text name="wao.ui.field.SampleRow.programName"/></th> - <th class="only-in-full-view"><s:text name="wao.ui.field.SampleRow.professionCode"/></th> - <th class="only-in-full-view"><s:text name="wao.ui.contacts.Profession.libelle"/></th> - <th class="only-in-full-view"><s:text name="wao.ui.contacts.Profession.species"/></th> + <s:if test="obsMer || obsVente"> + <th class="only-in-full-view"><s:text name="wao.ui.field.SampleRow.professionCode"/></th> + <th class="only-in-full-view"><s:text name="wao.ui.contacts.Profession.libelle"/></th> + <th class="only-in-full-view"><s:text name="wao.ui.contacts.Profession.species"/></th> + </s:if> + <s:if test="sclerochronology"> + <th class="only-in-full-view"><s:text name="wao.ui.field.SampleRow.sclerochronologySamplingContext"/></th> + <th class="only-in-full-view"><s:text name="wao.ui.field.SampleRow.individualMeasurementStrategy"/></th> + <th class="only-in-full-view"><s:text name="wao.ui.field.SampleRow.species"/></th> + </s:if> <th class="only-in-full-view"><s:text name="wao.ui.contacts.FishingZone.facadeName"/></th> <th class="only-in-full-view"><s:text name="wao.ui.contacts.FishingZone.sectorName"/></th> <th class="only-in-full-view"><s:text name="wao.ui.contacts.division"/></th> @@ -361,15 +370,35 @@ <th><s:text name="wao.ui.field.Contact.terrestrialLocation"/></th> <th><s:text name="wao.ui.field.SampleRow.samplingStrategy"/></th> </s:if> - <th class="only-in-full-view"><s:text name="wao.ui.field.SampleRow.company"/></th> + <th class="only-in-full-view"> + <s:if test="obsMer || obsVente"> + <s:text name="wao.ui.field.SampleRow.company"/> + </s:if> + <s:else> + <s:text name="wao.ui.field.SampleRow.organisation"/> + </s:else> + </th> <th><s:text name="wao.ui.contacts.observers"/></th> - <th><s:text name="wao.ui.field.Contact.contactState"/> (<s:text name="wao.ui.field.Contact.contactStateMotif"/>)</th> + <th> + <s:text name="wao.ui.field.Contact.contactState"/> + <s:if test="obsMer"> + (<s:text name="wao.ui.field.Contact.contactStateMotif"/>) + </s:if> + </th> <th class="date-time"><s:text name="wao.ui.field.Contact.beginDate"/></th> <th class="date-time"><s:text name="wao.ui.field.Contact.endDate"/></th> <s:if test="obsMer"> <th><s:text name="wao.ui.field.Contact.observationTimeInDays"/></th> </s:if> - <th class="date"><s:text name="wao.ui.field.Contact.dataInputDate"/></th> + <s:if test="obsMer || obsVente"> + <th class="date"><s:text name="wao.ui.field.Contact.dataInputDate"/></th> + </s:if> + <s:if test="sclerochronology"> + <th><s:text name="wao.ui.field.Contact.sampleSize"/></th> + <th class="date"><s:text name="wao.ui.field.Contact.sampleSubmission"/></th> + <th class="date"><s:text name="wao.ui.field.Contact.sampleReception"/></th> + <th class="date"><s:text name="wao.ui.field.Contact.sampleTreatment"/></th> + </s:if> <s:if test="obsMer"> <th><s:text name="wao.ui.field.Contact.observedDataControl"/></th> <th class="date"><s:text name="wao.ui.field.Contact.restitution"/></th> @@ -399,23 +428,32 @@ <td> <s:property value="creationDate"/> </td> - <td> - <s:set name="boatTooltip"> - <s:text name="wao.ui.boats.registrationCode"/> <s:property value="boat.registrationCode" escapeHtml="false"/> - <s:text name="wao.ui.boats.boatLength"/> <s:property value="boat.boatLength" escapeHtml="false"/> cm - <s:text name="wao.ui.boats.buildYear"/> <s:property value="%{'' + boat.buildYear}" escapeHtml="false"/> - <s:text name="wao.ui.boats.district"/> <s:property value="boat.district.districtName" escapeHtml="false"/> (<s:property value="boat.district.districtCode" escapeHtml="false"/>) - </s:set> - <span data-original-title="<s:property value="#boatTooltip"/>" data-toggle="tooltip" data-placement="right"> - <s:property value="boat.name"/> - </span> - </td> + <s:if test="obsMer || obsVente"> + <td> + <s:set name="boatTooltip"> + <s:text name="wao.ui.boats.registrationCode"/> <s:property value="boat.registrationCode" escapeHtml="false"/> + <s:text name="wao.ui.boats.boatLength"/> <s:property value="boat.boatLength" escapeHtml="false"/> cm + <s:text name="wao.ui.boats.buildYear"/> <s:property value="%{'' + boat.buildYear}" escapeHtml="false"/> + <s:text name="wao.ui.boats.district"/> <s:property value="boat.district.districtName" escapeHtml="false"/> (<s:property value="boat.district.districtCode" escapeHtml="false"/>) + </s:set> + <span data-original-title="<s:property value="#boatTooltip"/>" data-toggle="tooltip" data-placement="right"> + <s:property value="boat.name"/> + </span> + </td> + </s:if> <td class="only-in-compact-view"> <s:set name="sampleRowTooltip"> <s:text name="wao.ui.field.SampleRow.programName"/> <s:property value="sampleRow.programName" escapeHtml="false"/> - <s:text name="wao.ui.field.SampleRow.professionCode"/> <s:property value="sampleRow.professionDescription" escapeHtml="false"/> - <s:text name="wao.ui.contacts.Profession.libelle"/> <s:property value="sampleRow.profession.libelle" escapeHtml="false"/> - <s:text name="wao.ui.contacts.Profession.species"/> <s:property value="sampleRow.profession.species" escapeHtml="false"/> + <s:if test="obsMer || obsVente"> + <s:text name="wao.ui.field.SampleRow.professionCode"/> <s:property value="sampleRow.professionDescription" escapeHtml="false"/> + <s:text name="wao.ui.contacts.Profession.libelle"/> <s:property value="sampleRow.profession.libelle" escapeHtml="false"/> + <s:text name="wao.ui.contacts.Profession.species"/> <s:property value="sampleRow.profession.species" escapeHtml="false"/> + </s:if> + <s:if test="sclerochronology"> + <s:text name="wao.ui.field.SampleRow.sclerochronologySamplingContext"/> <s:property value="getText(sampleRow.sclerochronologySamplingContext)" escapeHtml="false"/> + <s:text name="wao.ui.field.SampleRow.individualMeasurementStrategy"/> <s:property value="getText(sampleRow.individualMeasurementStrategy)" escapeHtml="false"/> + <s:text name="wao.ui.field.SampleRow.species"/> <s:property value="sampleRow.species.vernacularName" escapeHtml="false"/> + </s:if> <s:text name="wao.ui.contacts.FishingZone.facadeName"/> <s:property value="sampleRow.facade" escapeHtml="false"/> <s:text name="wao.ui.contacts.FishingZone.sectorName"/> <s:property value="sampleRow.sectors" escapeHtml="false"/> <s:text name="wao.ui.contacts.division"/> <s:property value="%{getDivision(sampleRow)}" escapeHtml="false"/> @@ -430,18 +468,33 @@ <td class="only-in-full-view"> <s:property value="sampleRow.programName"/> </td> - <td class="only-in-full-view"> - <s:iterator value="getDcf5CodesAndDescriptions(sampleRow)"> - <abbr title="<s:property value="value"/>"><s:property value="key"/></abbr> - </s:iterator> - <s:property value="sampleRow.professionDescriptionWithoutDcf5" /> - </td> - <td class="only-in-full-view"> - <s:property value="sampleRow.profession.libelle"/> - </td> - <td class="only-in-full-view"> - <s:property value="sampleRow.profession.species"/> - </td> + <s:if test="obsMer || obsVente"> + <td class="only-in-full-view"> + <s:iterator value="getDcf5CodesAndDescriptions(sampleRow)"> + <abbr title="<s:property value="value"/>"><s:property value="key"/></abbr> + </s:iterator> + <s:property value="sampleRow.professionDescriptionWithoutDcf5" /> + </td> + <td class="only-in-full-view"> + <s:property value="sampleRow.profession.libelle"/> + </td> + <td class="only-in-full-view"> + <s:property value="sampleRow.profession.species"/> + </td> + </s:if> + <s:if test="sclerochronology"> + <td class="only-in-full-view"> + <span data-original-title="<s:property value="#sampleRow.sclerochronologySamplingContextInfo"/>" data-toggle="tooltip" data-placement="right"> + <s:property value="getText(sampleRow.sclerochronologySamplingContext)"/> + </span> + </td> + <td class="only-in-full-view"> + <s:property value="getText(sampleRow.individualMeasurementStrategy)"/> + </td> + <td class="only-in-full-view"> + <s:property value="sampleRow.species.vernacularName"/> + </td> + </s:if> <td class="only-in-full-view"> <s:property value="sampleRow.facade"/> </td> @@ -462,7 +515,7 @@ </td> </s:if> <td class="only-in-full-view"> - <s:property value="sampleRow.company.name"/> + <s:property value="sampleRow.organisation.fullName"/> </td> <td> <ul> @@ -494,11 +547,35 @@ </s:if> </td> </s:if> - <td class="date"> - <s:if test="dataInputDate != null"> - <s:property value="dataInputDate"/> - </s:if> - </td> + <s:if test="obsMer || obsVente"> + <td class="date"> + <s:if test="dataInputDate != null"> + <s:property value="dataInputDate"/> + </s:if> + </td> + </s:if> + <s:if test="sclerochronology"> + <td> + <s:if test="sampleSize != null"> + <s:property value="sampleSize"/> + </s:if> + </td> + <td class="date"> + <s:if test="sampleSubmission != null"> + <s:property value="sampleSubmission"/> + </s:if> + </td> + <td class="date"> + <s:if test="sampleReception != null"> + <s:property value="sampleReception"/> + </s:if> + </td> + <td class="date"> + <s:if test="sampleTreatment != null"> + <s:property value="sampleTreatment"/> + </s:if> + </td> + </s:if> <s:if test="obsMer"> <td> <s:if test="observedDataControl != null"> diff --git a/wao-web/src/main/webapp/WEB-INF/content/edit-contact-input.jsp b/wao-web/src/main/webapp/WEB-INF/content/edit-contact-input.jsp index 1598c2f..c4d603c 100644 --- a/wao-web/src/main/webapp/WEB-INF/content/edit-contact-input.jsp +++ b/wao-web/src/main/webapp/WEB-INF/content/edit-contact-input.jsp @@ -347,7 +347,8 @@ label="%{getText('wao.ui.field.Contact.sampleSize')}" type="number" disabled="%{!#editObservationReport}" - cssClass="input-small" /> + cssClass="input-small" + inputAppend="%{getText('wao.ui.field.Contact.sampleSize.unit')}"/> <s:textfield name="updateContactCommand.contact.sampleSubmission" label="%{getText('wao.ui.field.Contact.sampleSubmission')}" -- 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 feature/2264 in repository wao. See http://git.codelutin.com/wao.git commit 5d6b2f229d296dce252cbd15e0b23804eef48fde Author: Brendan Le Ny <bleny@codelutin.com> Date: Fri Dec 26 11:39:06 2014 +0100 Passage du plan scléro en nombre d'individus (totaux manquants) --- .../service/ObsMerSamplingPlanService.java | 27 -------- .../wao/services/service/SamplingPlanService.java | 22 +++++++ .../service/SclerochronologySamplingPlan.java | 9 ++- .../SclerochronologySamplingPlanBuilder.java | 77 ++++++++++++++++++++-- .../SclerochronologySamplingPlanService.java | 6 +- .../SclerochronologySamplingPlanServiceTest.java | 20 ++++++ .../main/resources/i18n/wao-web_en_GB.properties | 1 + .../main/resources/i18n/wao-web_fr_FR.properties | 1 + .../content/sclerochronology/sampling-plan.jsp | 10 +-- 9 files changed, 133 insertions(+), 40 deletions(-) diff --git a/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerSamplingPlanService.java b/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerSamplingPlanService.java index 8d447f7..474c825 100644 --- a/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerSamplingPlanService.java +++ b/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerSamplingPlanService.java @@ -24,13 +24,9 @@ package fr.ifremer.wao.services.service; import com.google.common.base.Charsets; import com.google.common.base.Optional; import com.google.common.cache.Cache; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Sets; -import fr.ifremer.wao.ContactsFilter; import fr.ifremer.wao.SampleRowsFilter; import fr.ifremer.wao.WaoTechnicalException; import fr.ifremer.wao.entity.Contact; -import fr.ifremer.wao.entity.ContactState; import fr.ifremer.wao.entity.ContactTopiaDao; import fr.ifremer.wao.entity.SampleRow; import fr.ifremer.wao.entity.SampleRowTopiaDao; @@ -131,29 +127,6 @@ public class ObsMerSamplingPlanService extends SamplingPlanService { } - /** - * Permet d'obtenir pour une période donnée toutes les observations réalisées. Cela forme - * une base de travail pour calculer le réalisé en jours de mers - */ - protected Collection<Contact> getDoneObservations(SampleRow sampleRow) { - - ContactsFilter contactFilter = new ContactsFilter(); - - contactFilter.getSampleRowFilter().setSampleRowIds(ImmutableSet.of(sampleRow.getTopiaId())); - - contactFilter.setContactStates(ImmutableSet.of(ContactState.OBSERVATION_DONE)); - // on exclue les contacts qui sont invalidés par le programme - contactFilter.setProgramAcceptations(Sets.newHashSet(true, null)); - // on exclue les contacts invalidés par la société - contactFilter.setCompanyAcceptations(Sets.newHashSet(true, null)); - - List<Contact> contacts = getContactDao().forFilter(contactFilter, false).findAll(); - - return contacts; - - } - - public InputStream exportSamplingPlanWithStatistics(AuthenticatedWaoUser authenticatedWaoUser, SampleRowsFilter filter) { ObsMerSamplingPlan samplingPlan = getSamplingPlan(authenticatedWaoUser, filter); 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 ce1e214..8c40446 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 @@ -823,4 +823,26 @@ public class SamplingPlanService extends WaoServiceSupport { } } + + /** + * Permet d'obtenir pour une période donnée toutes les observations réalisées. Cela forme + * une base de travail pour calculer le réalisé en jours de mers + */ + protected Collection<Contact> getDoneObservations(SampleRow sampleRow) { + + ContactsFilter contactFilter = new ContactsFilter(); + + contactFilter.getSampleRowFilter().setSampleRowIds(ImmutableSet.of(sampleRow.getTopiaId())); + + contactFilter.setContactStates(ImmutableSet.of(ContactState.OBSERVATION_DONE)); + // on exclue les contacts qui sont invalidés par le programme + contactFilter.setProgramAcceptations(Sets.newHashSet(true, null)); + // on exclue les contacts invalidés par la société + contactFilter.setCompanyAcceptations(Sets.newHashSet(true, null)); + + List<Contact> contacts = getContactDao().forFilter(contactFilter, false).findAll(); + + return contacts; + + } } 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 9fccaff..28dc7ec 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 @@ -50,8 +50,11 @@ public class SclerochronologySamplingPlan extends SamplingPlan implements Iterab protected String species; - public SclerochronologySamplingPlanSampleRowPart(Locale locale, Map<Date, Effort> effortInObservationsPerMonths, SampleRow sampleRow, long sampleRowContactCounts) { + protected Map<Date, Effort> effortInIndividualsPerMonths; + + public SclerochronologySamplingPlanSampleRowPart(Locale locale, Map<Date, Effort> effortInObservationsPerMonths, Map<Date, Effort> effortInIndividualsPerMonths, SampleRow sampleRow, long sampleRowContactCounts) { super(locale, effortInObservationsPerMonths, sampleRow, sampleRowContactCounts); + this.effortInIndividualsPerMonths = effortInIndividualsPerMonths; species = sampleRow.getSpecies().getVernacularName(); samplingContext = WaoUtils.l(locale, sampleRow.getSclerochronologySamplingContext()); samplingContextInfo = sampleRow.getSclerochronologySamplingContextInfo(); @@ -79,6 +82,10 @@ public class SclerochronologySamplingPlan extends SamplingPlan implements Iterab return samplingContext; } + public Map<Date, Effort> getEffortInIndividualsPerMonths() { + return effortInIndividualsPerMonths; + } + @Override public Map<String, String> getDcf5CodesAndDescriptions() { throw new UnsupportedOperationException("not in " + ObsProgram.SCLEROCHRONOLOGY); 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 index aed9964..0c97760 100644 --- 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 @@ -23,15 +23,21 @@ package fr.ifremer.wao.services.service; import com.google.common.base.Function; import com.google.common.base.Optional; +import com.google.common.collect.LinkedListMultimap; import com.google.common.collect.Ordering; import fr.ifremer.wao.SampleRowsFilter; +import fr.ifremer.wao.WaoUtils; +import fr.ifremer.wao.entity.Contact; import fr.ifremer.wao.entity.ObsProgram; import fr.ifremer.wao.entity.SampleRow; import fr.ifremer.wao.entity.SampleRows; +import org.apache.commons.lang3.BooleanUtils; import org.apache.commons.lang3.mutable.MutableInt; +import org.apache.commons.lang3.time.DateUtils; import org.nuiton.util.PeriodDates; import java.util.ArrayList; +import java.util.Calendar; import java.util.Collection; import java.util.Date; import java.util.HashSet; @@ -129,7 +135,7 @@ public class SclerochronologySamplingPlanBuilder { this.months = periodDates.getMonths(); } - public SclerochronologySamplingPlanBuilder addSampleRow(SampleRow sampleRow, long sampleRowContactCounts) { + public SclerochronologySamplingPlanBuilder addSampleRow(SampleRow sampleRow, Collection<Contact> doneObservations, long sampleRowContactCounts) { String facade = sampleRow.getFacade(); FacadeContext facadeContext = facadeMap.get(facade); @@ -146,13 +152,15 @@ public class SclerochronologySamplingPlanBuilder { // get sector context SectorContext sectorPart = facadeContext.getOrAddSectorContext(sectors); - // compute nb tides per month + // calcul de l'effort en nombre d'observations puis en nombre d'individus Map<Date, SamplingPlan.Effort> effortInObservationsPerMonths = getEffortInObservationsPerMonths(sampleRow); + Map<Date, SamplingPlan.Effort> effortInIndividualsPerMonths = getEffortInIndividualsPerMonths(sampleRow, doneObservations); // add sample row sectorPart.addSampleRow(sampleRowsFilterValues.getLocale(), sampleRow, effortInObservationsPerMonths, + effortInIndividualsPerMonths, sampleRowContactCounts); sampleRowsFilterValues.addSampleRow(sampleRow); @@ -242,6 +250,60 @@ public class SclerochronologySamplingPlanBuilder { return result; } + protected Map<Date, SamplingPlan.Effort> getEffortInIndividualsPerMonths(SampleRow sampleRow, Collection<Contact> doneObservations) { + + // Pour chaque observation réalisée, on ajoute dans ces multimaps, une ou plusieurs + // entrées. Une observation a pu avoir lieu sur deux mois. Une entrée indique que pour + // le mois en clé, la valeur est un nombre de jour passé en mer + LinkedListMultimap<Date, Integer> estimatedSampledIndividualsByMonths = LinkedListMultimap.create(); + LinkedListMultimap<Date, Integer> realSampledIndividualsByMonths = LinkedListMultimap.create(); + + for (Contact doneObservation : doneObservations) { + + // on prend l'observation, on regarde combien de jour ça ajoute à chaque mois + Date month = DateUtils.truncate(doneObservation.getObservationBeginDate(), Calendar.MONTH); + + if (BooleanUtils.isTrue(doneObservation.getValidationCompany())) { + realSampledIndividualsByMonths.put(month, doneObservation.getSampleSize()); + } + + estimatedSampledIndividualsByMonths.put(month, doneObservation.getSampleSize()); + + } + + Map<Date, SamplingPlan.Effort> effortInIndividualsPerMonths = new TreeMap<>(); + + for (Date month : months) { + + // calcul du plannifié + Integer expected = null; + Integer expectedObservations = SampleRows.getExpectedTidesValue(sampleRow, month); + if (expectedObservations != null) { + expected = expectedObservations; + } + + // calcul de l'estimé et du réel + Collection<Integer> estimatedDoneObservationDays = estimatedSampledIndividualsByMonths.asMap().get(month); + Integer estimated = 0; // car estimatedDoneObservationDays peut être null si aucune observation sur le mois + if (estimatedDoneObservationDays != null) { + estimated = WaoUtils.sum(estimatedDoneObservationDays); + } + + Collection<Integer> realDoneObservationDays = realSampledIndividualsByMonths.asMap().get(month); + Integer real = 0; // car realDoneObservationDays peut être null si aucune observation sur le mois + if (realDoneObservationDays != null) { + real = WaoUtils.sum(realDoneObservationDays); + } + + SamplingPlan.Effort effortForMonth = new SamplingPlan.Effort(expected, real, estimated); + effortInIndividualsPerMonths.put(month, effortForMonth); + + } + + return effortInIndividualsPerMonths; + + } + protected static class FacadeContext { protected String facade; @@ -295,15 +357,18 @@ public class SclerochronologySamplingPlanBuilder { this.rows = new ArrayList<>(); } - protected ObsMerSamplingPlan.SamplingPlanSampleRowPart addSampleRow(Locale locale, - SampleRow row, - Map<Date, SamplingPlan.Effort> effortInObservationsPerMonths, - long sampleRowContactCounts) { + protected ObsMerSamplingPlan.SamplingPlanSampleRowPart addSampleRow( + Locale locale, + SampleRow row, + Map<Date, SamplingPlan.Effort> effortInObservationsPerMonths, + Map<Date, SamplingPlan.Effort> effortInIndividualsPerMonths, + long sampleRowContactCounts) { SclerochronologySamplingPlan.SclerochronologySamplingPlanSampleRowPart rowPart = new SclerochronologySamplingPlan.SclerochronologySamplingPlanSampleRowPart( locale, effortInObservationsPerMonths, + effortInIndividualsPerMonths, row, sampleRowContactCounts); rows.add(rowPart); 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 index f0cd05f..22666bb 100644 --- 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 @@ -24,11 +24,13 @@ package fr.ifremer.wao.services.service; import com.google.common.base.Optional; import com.google.common.cache.Cache; import fr.ifremer.wao.SampleRowsFilter; +import fr.ifremer.wao.entity.Contact; 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.Collection; import java.util.List; public class SclerochronologySamplingPlanService extends SamplingPlanService { @@ -69,10 +71,12 @@ public class SclerochronologySamplingPlanService extends SamplingPlanService { for (SampleRow sampleRow : sampleRows) { + Collection<Contact> doneObservations = getDoneObservations(sampleRow); + long sampleRowContactCounts = contactDao.forSampleRowEquals(sampleRow).count(); // ajout de la ligne au build de plan - builder.addSampleRow(sampleRow, sampleRowContactCounts); + builder.addSampleRow(sampleRow, doneObservations, sampleRowContactCounts); } 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 b1b0c0b..5aa1aeb 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 @@ -132,4 +132,24 @@ public class SclerochronologySamplingPlanServiceTest extends AbstractWaoServiceT Assert.assertTrue(sampleRowLog.getLogText().contains("Merlu")); } + + @Test + public void testContactsShowsInSamplingPlan() { + fixtures.contacts(); + AuthenticatedWaoUser admin = fixtures.admin(); + SampleRowsFilter filter = service.newSampleRowsFilter(admin); + SclerochronologySamplingPlan samplingPlan = service.getSamplingPlan(admin, filter); + + for (SamplingPlan.SamplingPlanFacadePart facade : samplingPlan) { + for (SamplingPlan.SamplingPlanSectorPart<SclerochronologySamplingPlan.SclerochronologySamplingPlanSampleRowPart> sector : facade) { + for (SclerochronologySamplingPlan.SclerochronologySamplingPlanSampleRowPart row : sector) { + if (row.getCode().equals("2015_S0001")) { + SamplingPlan.Effort effortInIndividualsForJanuary = Iterables.get(row.getEffortInIndividualsPerMonths().values(), 0); + Assert.assertEquals(53, effortInIndividualsForJanuary.getEstimated().intValue()); + Assert.assertEquals(53, effortInIndividualsForJanuary.getReal().intValue()); + } + } + } + } + } } \ No newline at end of file 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 5e9770e..d6f16a6 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 @@ -533,6 +533,7 @@ wao.ui.samplingPlan.averageObservationsCount=Number of observations wao.ui.samplingPlan.averageTideTime=Average tide time (d.) wao.ui.samplingPlan.effort=Observation effort wao.ui.samplingPlan.effort.obsVente=Observation effort +wao.ui.samplingPlan.effort.sclerochronology=Observation effort in number of individuals wao.ui.samplingPlan.effort.tip=There is a difference between "0" as effort and leave it empty. O means that no effort is asked to the observers but they can still create contacts for this month. Leaving the field empty makes impossible for the observers to create contacts for this months. wao.ui.samplingPlan.estimated=estimated wao.ui.samplingPlan.expected=expected 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 28c8e87..01f930b 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 @@ -534,6 +534,7 @@ wao.ui.samplingPlan.averageObservationsCount=Nombre d'observations wao.ui.samplingPlan.averageTideTime=Durée moyenne d'une marée (J.) wao.ui.samplingPlan.effort=Effort d'observation en nombre de marées wao.ui.samplingPlan.effort.obsVente=Effort d'observation en nombre de sorties +wao.ui.samplingPlan.effort.sclerochronology=Effort d'observation en nombre d'individus wao.ui.samplingPlan.effort.tip=Il y a une différence entre saisir « 0 » comme effort mensuel et laisser la case vide. Si vous indiquez un effort de 0, aucun effort n'est demandé aux observateurs mais ils pourront tout de même saisir un contact. Si vous laissez la case vide, les observateurs ne pourront pas créer de contacts pour ce mois. wao.ui.samplingPlan.estimated=estimé wao.ui.samplingPlan.expected=planifié 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 0082bc8..3ae34b5 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 @@ -203,7 +203,7 @@ <s:text name="wao.ui.samplingPlan.sampledProfessions" /> </th> <th colspan="${nbColumnsForMonths}"> - <s:text name="wao.ui.samplingPlan.effort" /> + <s:text name="wao.ui.samplingPlan.effort.sclerochronology" /> <s:if test="authenticatedWaoUser.authorizedToViewSamplingPlanReal"> [ @@ -322,13 +322,13 @@ <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="effort" value="#samplingPlanRow.effortInIndividualsPerMonths.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="effort" value="#samplingPlanRow.totalIndividuals"/> <s:set var="now" value="false"/> <s:set var="showPercentage" value="true"/> <%@include file="../templates/td-effort.jsp" %> @@ -425,13 +425,13 @@ </th> <!-- Months columns --> <s:iterator value="samplingPlan.months" var="month"> - <s:set var="effort" value="samplingPlan.totalEffortInObservationsPerMonths.get(#month)"/> + <s:set var="effort" value="samplingPlan.totalEffortInIndividualsPerMonths.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="effort" value="samplingPlan.highTotalEffortInIndividuals"/> <s:set var="now" value="false"/> <s:set var="showPercentage" value="true"/> <%@include file="../templates/td-effort.jsp" %> -- 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 feature/2264 in repository wao. See http://git.codelutin.com/wao.git commit 8de096c5589af53138cfecf4afde0169df650c91 Author: Brendan Le Ny <bleny@codelutin.com> Date: Fri Dec 26 12:05:25 2014 +0100 Ajout des totaux en individus dans le plan --- .../ifremer/wao/services/service/SamplingPlan.java | 19 +-- .../service/SclerochronologySamplingPlan.java | 30 ++++- .../SclerochronologySamplingPlanBuilder.java | 145 +++++++-------------- .../SclerochronologySamplingPlanServiceTest.java | 12 ++ 4 files changed, 91 insertions(+), 115 deletions(-) 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 d2f7b41..50743a7 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 @@ -362,24 +362,7 @@ public abstract class SamplingPlan implements Iterable<SamplingPlan.SamplingPlan this.sampleRowContactCounts = sampleRowContactCounts; // pour la ligne, on calcul le total en nombre d'observation - int totalTidesExpected = 0; - int totalTidesEstimated = 0; - int totalTidesReal = 0; - for (Effort effort : effortInObservationsPerMonths.values()) { - Integer totalExpected = effort.getExpected(); - if (totalExpected != null) { - totalTidesExpected += totalExpected; - } - Integer totalEstimated = effort.getEstimated(); - if (totalEstimated != null) { - totalTidesEstimated += totalEstimated; - } - Integer totalReal = effort.getReal(); - if (totalReal != null) { - totalTidesReal += totalReal; - } - } - totalObservations = new Effort(totalTidesExpected, totalTidesReal, totalTidesEstimated); + totalObservations = Effort.sum(effortInObservationsPerMonths.values()); facade = sampleRow.getFacade(); sectors = sampleRow.getSectors(); 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 28dc7ec..cc13303 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 @@ -34,8 +34,29 @@ 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) { + protected Map<Date, Effort> totalEffortInIndividualsPerMonths; + + protected Effort highTotalEffortInIndividuals; + + public SclerochronologySamplingPlan(List<Date> months, + Collection<SamplingPlanFacadePart> facadeParts, + Map<Date, Effort> totalEffortInObservationsPerMonths, + Map<Date, Effort> totalEffortInIndividualsPerMonths, + Effort highTotalEffortInObservations, + Effort highTotalEffortInIndividuals, + SampleRowsFilterValues filterValues, + Set<String> sampleRowIds) { super(months, facadeParts, totalEffortInObservationsPerMonths, highTotalEffortInObservations, filterValues, sampleRowIds); + this.totalEffortInIndividualsPerMonths = totalEffortInIndividualsPerMonths; + this.highTotalEffortInIndividuals = highTotalEffortInIndividuals; + } + + public Map<Date, Effort> getTotalEffortInIndividualsPerMonths() { + return totalEffortInIndividualsPerMonths; + } + + public Effort getHighTotalEffortInIndividuals() { + return highTotalEffortInIndividuals; } public static class SclerochronologySamplingPlanSampleRowPart extends SamplingPlanSampleRowPart { @@ -52,6 +73,8 @@ public class SclerochronologySamplingPlan extends SamplingPlan implements Iterab protected Map<Date, Effort> effortInIndividualsPerMonths; + protected Effort totalIndividuals; + public SclerochronologySamplingPlanSampleRowPart(Locale locale, Map<Date, Effort> effortInObservationsPerMonths, Map<Date, Effort> effortInIndividualsPerMonths, SampleRow sampleRow, long sampleRowContactCounts) { super(locale, effortInObservationsPerMonths, sampleRow, sampleRowContactCounts); this.effortInIndividualsPerMonths = effortInIndividualsPerMonths; @@ -60,6 +83,7 @@ public class SclerochronologySamplingPlan extends SamplingPlan implements Iterab samplingContextInfo = sampleRow.getSclerochronologySamplingContextInfo(); individualMeasurementStrategy = WaoUtils.l(locale, sampleRow.getIndividualMeasurementStrategy()); organisationFullName = sampleRow.getOrganisation().getFullName(); + totalIndividuals = Effort.sum(effortInIndividualsPerMonths.values()); } public String getOrganisationFullName() { @@ -120,6 +144,10 @@ public class SclerochronologySamplingPlan extends SamplingPlan implements Iterab public String getCompanyName() { throw new UnsupportedOperationException("not in " + ObsProgram.SCLEROCHRONOLOGY); } + + public Effort getTotalIndividuals() { + return totalIndividuals; + } } } \ 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 index 0c97760..cc99a98 100644 --- 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 @@ -24,6 +24,8 @@ package fr.ifremer.wao.services.service; import com.google.common.base.Function; import com.google.common.base.Optional; import com.google.common.collect.LinkedListMultimap; +import com.google.common.collect.ListMultimap; +import com.google.common.collect.Multimaps; import com.google.common.collect.Ordering; import fr.ifremer.wao.SampleRowsFilter; import fr.ifremer.wao.WaoUtils; @@ -32,7 +34,6 @@ import fr.ifremer.wao.entity.ObsProgram; import fr.ifremer.wao.entity.SampleRow; import fr.ifremer.wao.entity.SampleRows; import org.apache.commons.lang3.BooleanUtils; -import org.apache.commons.lang3.mutable.MutableInt; import org.apache.commons.lang3.time.DateUtils; import org.nuiton.util.PeriodDates; @@ -65,7 +66,7 @@ public class SclerochronologySamplingPlanBuilder { /** * Ids of all the sample rows included in this sampling plan. */ - protected Set<String> sampleRowIds; + protected Set<String> sampleRowIds = new HashSet<>(); /** * List of month computed from the filter. @@ -75,61 +76,17 @@ public class SclerochronologySamplingPlanBuilder { /** * Dictionnary of facades indexed by their facade name. */ - protected Map<String, FacadeContext> facadeMap; + protected Map<String, FacadeContext> facadeMap = new TreeMap<>(); - /** - * 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; + protected ListMultimap<Date, SamplingPlan.Effort> totalObservationsForMonths = LinkedListMultimap.create(); - /** - * 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; + protected ListMultimap<Date, SamplingPlan.Effort> totalIndividualsForMonths = LinkedListMultimap.create(); 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(); @@ -156,6 +113,10 @@ public class SclerochronologySamplingPlanBuilder { Map<Date, SamplingPlan.Effort> effortInObservationsPerMonths = getEffortInObservationsPerMonths(sampleRow); Map<Date, SamplingPlan.Effort> effortInIndividualsPerMonths = getEffortInIndividualsPerMonths(sampleRow, doneObservations); + // ajout dans les totaux par mois + totalObservationsForMonths.putAll(Multimaps.forMap(effortInObservationsPerMonths)); + totalIndividualsForMonths.putAll(Multimaps.forMap(effortInIndividualsPerMonths)); + // add sample row sectorPart.addSampleRow(sampleRowsFilterValues.getLocale(), sampleRow, @@ -186,68 +147,60 @@ public class SclerochronologySamplingPlanBuilder { } }).immutableSortedCopy(facadeParts); - // Get statistics - Map<Date, SamplingPlan.Effort> statisticsMap = new TreeMap<>(); + // On a accumulé les totaux en nombre d'observation / par mois, on fait les calculs finaux + Map<Date, SamplingPlan.Effort> totalEffortInObservationsPerMonths = new TreeMap<>(); + Map<Date, SamplingPlan.Effort> totalEffortInIndividualsPerMonths = 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); + Collection<SamplingPlan.Effort> totalObservationsForMonth = totalObservationsForMonths.asMap().get(month); + SamplingPlan.Effort totalEffortInObservationsForMonth = SamplingPlan.Effort.sum(totalObservationsForMonth); + totalEffortInObservationsPerMonths.put(month, totalEffortInObservationsForMonth); + + Collection<SamplingPlan.Effort> totalIndividualsForMonth = totalIndividualsForMonths.asMap().get(month); + SamplingPlan.Effort totalEffortInIndividualsForMonth = SamplingPlan.Effort.sum(totalIndividualsForMonth); + totalEffortInIndividualsPerMonths.put(month, totalEffortInIndividualsForMonth); + } - SamplingPlan.Effort highTotals = new SamplingPlan.Effort(highTotalExpected, highTotalReal, highTotalEstimated); + // on calcule le grand total en faisant la somme sur tous les mois + SamplingPlan.Effort highTotalEffortInObservations = SamplingPlan.Effort.sum(totalEffortInObservationsPerMonths.values()); + SamplingPlan.Effort highTotalEffortInIndividuals = SamplingPlan.Effort.sum(totalEffortInIndividualsPerMonths.values()); + + SclerochronologySamplingPlan result = new SclerochronologySamplingPlan( + months, + sortedFacades, + totalEffortInObservationsPerMonths, + totalEffortInIndividualsPerMonths, + highTotalEffortInObservations, + highTotalEffortInIndividuals, + sampleRowsFilterValues, + sampleRowIds); - 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<>(); + + Map<Date, SamplingPlan.Effort> effortInObservationsPerMonths = new TreeMap<>(); + for (Date month : months) { + + // FIXME brendan 26/12/14 n'a aucun sens puisqu'on récupère des individus 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 estimatedTidesValue = SampleRows.getEstimatedTidesValue(sampleRow, month); 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)); + SamplingPlan.Effort effortForMonth = + new SamplingPlan.Effort( + expectedTidesValue, + realTidesValue, + estimatedTidesValue); + effortInObservationsPerMonths.put(month, effortForMonth); } - return result; + + return effortInObservationsPerMonths; } protected Map<Date, SamplingPlan.Effort> getEffortInIndividualsPerMonths(SampleRow sampleRow, Collection<Contact> doneObservations) { 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 5aa1aeb..5818302 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 @@ -147,9 +147,21 @@ public class SclerochronologySamplingPlanServiceTest extends AbstractWaoServiceT SamplingPlan.Effort effortInIndividualsForJanuary = Iterables.get(row.getEffortInIndividualsPerMonths().values(), 0); Assert.assertEquals(53, effortInIndividualsForJanuary.getEstimated().intValue()); Assert.assertEquals(53, effortInIndividualsForJanuary.getReal().intValue()); + + Assert.assertEquals(53, row.getTotalIndividuals().getEstimated().intValue()); + Assert.assertEquals(53, row.getTotalIndividuals().getReal().intValue()); } } } } + + SamplingPlan.Effort effortInIndividualsForJanuary = Iterables.get(samplingPlan.getTotalEffortInIndividualsPerMonths().values(), 0); + + Assert.assertEquals(53, effortInIndividualsForJanuary.getEstimated().intValue()); + Assert.assertEquals(53, effortInIndividualsForJanuary.getReal().intValue()); + + Assert.assertEquals(53, samplingPlan.getHighTotalEffortInIndividuals().getEstimated().intValue()); + Assert.assertEquals(53, samplingPlan.getHighTotalEffortInIndividuals().getReal().intValue()); + } } \ No newline at end of file -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
participants (1)
-
codelutin.com scm