Author: bleny Date: 2014-06-10 16:31:39 +0200 (Tue, 10 Jun 2014) New Revision: 2019 Url: http://forge.codelutin.com/projects/wao/repository/revisions/2019 Log: fixes #5049 fixes #5188 add observation time in days in plan and contacts Modified: trunk/wao-persistence/src/main/java/fr/ifremer/wao/entity/ContactImpl.java trunk/wao-persistence/src/main/xmi/wao-model.zargo trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerSamplingPlan.java trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerSamplingPlanService.java trunk/wao-web/src/main/resources/i18n/wao-web_en_GB.properties trunk/wao-web/src/main/resources/i18n/wao-web_fr_FR.properties trunk/wao-web/src/main/webapp/WEB-INF/content/obsmer/contacts.jsp trunk/wao-web/src/main/webapp/WEB-INF/content/obsmer/sampling-plan.jsp Modified: trunk/wao-persistence/src/main/java/fr/ifremer/wao/entity/ContactImpl.java =================================================================== --- trunk/wao-persistence/src/main/java/fr/ifremer/wao/entity/ContactImpl.java 2014-06-10 13:46:37 UTC (rev 2018) +++ trunk/wao-persistence/src/main/java/fr/ifremer/wao/entity/ContactImpl.java 2014-06-10 14:31:39 UTC (rev 2019) @@ -26,6 +26,7 @@ import org.apache.commons.lang3.BooleanUtils; import org.apache.commons.lang3.StringUtils; +import org.nuiton.util.DateUtil; import java.util.Date; import java.util.LinkedList; @@ -226,4 +227,13 @@ return getValidationProgram() != null; } + @Override + public Integer getObservationTimeInDays() { + Integer observationTimeInDays = null; + if (getObservationBeginDate() != null && getObservationEndDate() != null) { + // +1 car demandé par le métier + observationTimeInDays = DateUtil.getDifferenceInDays(getObservationBeginDate(), getObservationEndDate()) + 1; + } + return observationTimeInDays; + } } Modified: trunk/wao-persistence/src/main/xmi/wao-model.zargo =================================================================== (Binary files differ) Modified: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerSamplingPlan.java =================================================================== --- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerSamplingPlan.java 2014-06-10 13:46:37 UTC (rev 2018) +++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerSamplingPlan.java 2014-06-10 14:31:39 UTC (rev 2019) @@ -298,6 +298,10 @@ */ protected Long observationTimesInDaysEstimated; + protected Integer observationTimesInDaysEstimatedPercentage; + + protected Integer observationTimesInDaysRealPercentage; + protected String fishingZones; protected int nbObservants; @@ -400,6 +404,14 @@ } } + if (observationTimesInDaysExpected != null && observationTimesInDaysExpected > 0) { + if (observationTimesInDaysEstimated != null) { + observationTimesInDaysEstimatedPercentage = (int) Math.round((observationTimesInDaysEstimated / observationTimesInDaysExpected) * 100); + } + if (observationTimesInDaysReal != null) { + observationTimesInDaysRealPercentage = (int) Math.round((observationTimesInDaysReal / observationTimesInDaysExpected) * 100); + } + } totalTides = new ObsMerSamplingPlanStatistics(totalTidesExpected, totalTidesReal, totalTidesEstimated); fishingZones = ""; @@ -626,6 +638,14 @@ return observationTimesInDaysEstimated; } + public Integer getObservationTimesInDaysRealPercentage() { + return observationTimesInDaysRealPercentage; + } + + public Integer getObservationTimesInDaysEstimatedPercentage() { + return observationTimesInDaysEstimatedPercentage; + } + public boolean isElligibleBoatsProvided() { return elligibleBoatsProvided; } Modified: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerSamplingPlanService.java =================================================================== --- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerSamplingPlanService.java 2014-06-10 13:46:37 UTC (rev 2018) +++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerSamplingPlanService.java 2014-06-10 14:31:39 UTC (rev 2019) @@ -689,20 +689,22 @@ long real = 0; long estimated = 0; for (Contact contact : contacts) { - double actualInMinutes = DateUtil.getDifferenceInMinutes( - contact.getObservationBeginDate(), - contact.getObservationEndDate()); - Boolean validationCompany = contact.getValidationCompany(); - double contactInDays = Math.ceil(actualInMinutes / minutesPerDay); + Integer observationTimeInDays = contact.getObservationTimeInDays(); - if (BooleanUtils.isTrue(validationCompany)) { - // real observation - real += contactInDays; + if (observationTimeInDays != null) { + + if (BooleanUtils.isTrue(contact.getValidationCompany())) { + // real observation + real += observationTimeInDays; + } + // estimated observation + estimated += observationTimeInDays; + } - // estimated observation - estimated += contactInDays; + } + return Pair.of(real, estimated); } Modified: trunk/wao-web/src/main/resources/i18n/wao-web_en_GB.properties =================================================================== --- trunk/wao-web/src/main/resources/i18n/wao-web_en_GB.properties 2014-06-10 13:46:37 UTC (rev 2018) +++ trunk/wao-web/src/main/resources/i18n/wao-web_en_GB.properties 2014-06-10 14:31:39 UTC (rev 2019) @@ -209,6 +209,7 @@ wao.ui.field.Contact.mammalsObservation=Exceptional observation wao.ui.field.Contact.nbObservants=Nb Observants wao.ui.field.Contact.obsDebCode=Profession +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 Modified: trunk/wao-web/src/main/resources/i18n/wao-web_fr_FR.properties =================================================================== --- trunk/wao-web/src/main/resources/i18n/wao-web_fr_FR.properties 2014-06-10 13:46:37 UTC (rev 2018) +++ trunk/wao-web/src/main/resources/i18n/wao-web_fr_FR.properties 2014-06-10 14:31:39 UTC (rev 2019) @@ -209,6 +209,7 @@ wao.ui.field.Contact.mammalsObservation=Observation exceptionnelle wao.ui.field.Contact.nbObservants=Nb obs. wao.ui.field.Contact.obsDebCode=Métier +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 Modified: trunk/wao-web/src/main/webapp/WEB-INF/content/obsmer/contacts.jsp =================================================================== --- trunk/wao-web/src/main/webapp/WEB-INF/content/obsmer/contacts.jsp 2014-06-10 13:46:37 UTC (rev 2018) +++ trunk/wao-web/src/main/webapp/WEB-INF/content/obsmer/contacts.jsp 2014-06-10 14:31:39 UTC (rev 2019) @@ -316,6 +316,7 @@ <th><s:text name="wao.ui.field.Contact.contactState"/> (<s:text name="wao.ui.field.Contact.contactStateMotif"/>)</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> + <th class="date-time"><s:text name="wao.ui.field.Contact.observationTimeInDays"/></th> <th class="date"><s:text name="wao.ui.field.Contact.dataInputDate"/></th> <th><s:text name="wao.ui.field.Contact.observedDataControl"/></th> <th class="date"><s:text name="wao.ui.field.Contact.restitution"/></th> @@ -414,6 +415,11 @@ <s:property value="observationEndDate"/> </s:if> </td> + <td> + <s:if test="observationTimeInDays != null"> + <s:property value="observationTimeInDays"/> + </s:if> + </td> <td class="date"> <s:if test="dataInputDate != null"> <s:property value="dataInputDate"/> Modified: trunk/wao-web/src/main/webapp/WEB-INF/content/obsmer/sampling-plan.jsp =================================================================== --- trunk/wao-web/src/main/webapp/WEB-INF/content/obsmer/sampling-plan.jsp 2014-06-10 13:46:37 UTC (rev 2018) +++ trunk/wao-web/src/main/webapp/WEB-INF/content/obsmer/sampling-plan.jsp 2014-06-10 14:31:39 UTC (rev 2019) @@ -396,7 +396,6 @@ <span class="real"> (<s:property value="totalRealPercentage" />) </span> - </s:if> </td> <td class="effort"> @@ -413,6 +412,15 @@ <s:property value="observationTimesInDaysExpected" /> <s:text name="wao.ui.misc.day"/> + <s:if test="authenticatedWaoUser.authorizedToViewSamplingPlanReal"> + <span class="estimated<s:if test="observationTimesInDaysEstimated < observationTimesInDaysExpected"> lower-than-expected</s:if><s:if test="observationTimesInDaysEstimated > observationTimesInDaysExpected"> higher-than-expected</s:if>"> + <s:property value="observationTimesInDaysEstimatedPercentage" /> % + </span> + <span class="real<s:if test="observationTimesInDaysReal < observationTimesInDaysExpected"> lower-than-expected</s:if><s:if test="observationTimesInDaysReal > observationTimesInDaysExpected"> higher-than-expected</s:if>"> + <s:property value="observationTimesInDaysRealPercentage" /> % + </span> + </s:if> + </td> <td><s:property value="averageTideTime" /></td> <td><s:property value="nbObservants" /></td>