[Suiviobsmer-commits] r464 - in trunk: . wao-business/src/main/java/fr/ifremer/wao/bean wao-business/src/main/java/fr/ifremer/wao/service wao-business/src/test/java/fr/ifremer/wao/service wao-ui/src/main/java/fr/ifremer/wao/ui/components wao-ui/src/main/java/fr/ifremer/wao/ui/pages wao-ui/src/main/webapp
Author: fdesbois Date: 2010-04-20 09:34:10 +0000 (Tue, 20 Apr 2010) New Revision: 464 Log: - Missing some contactState libelle call to display contact state - Change some message managment from exceptions - Catch NullSampleMonthException if old sampleMonth is not found - Add constraint on contact state for validations update - Resolve issue on tideBeginDate when the new one is set to null after changing state ('non abouti' for example) Modified: trunk/changelog.txt trunk/pom.xml trunk/wao-business/src/main/java/fr/ifremer/wao/bean/ContactStatus.java trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceContactImpl.java trunk/wao-business/src/test/java/fr/ifremer/wao/service/ServiceContactImplTest.java trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/components/Layout.java trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Boats.java trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Contacts.java trunk/wao-ui/src/main/webapp/Boats.tml trunk/wao-ui/src/main/webapp/Contacts.tml Modified: trunk/changelog.txt =================================================================== --- trunk/changelog.txt 2010-04-20 00:37:48 UTC (rev 463) +++ trunk/changelog.txt 2010-04-20 09:34:10 UTC (rev 464) @@ -23,6 +23,8 @@ Anomalies +++++++++ +- [fdesbois] Ano #2246 : Erreur calendrier d'activité lors du retour sur + les informations du navire. - [fdesbois] Ano #2242 : Changement du nom de l'observateur lors de l'édition d'une ligne de contact. - [fdesbois] Ano #2245 : Erreur création ligne du plan : le chargement des Modified: trunk/pom.xml =================================================================== --- trunk/pom.xml 2010-04-20 00:37:48 UTC (rev 463) +++ trunk/pom.xml 2010-04-20 09:34:10 UTC (rev 464) @@ -236,7 +236,7 @@ <i18n.version>1.2.1</i18n.version> <nuitonutils.version>1.2.2</nuitonutils.version> <topia.version>2.3.3-SNAPSHOT</topia.version> - <eugene.version>2.0.1-SNAPSHOT</eugene.version> + <eugene.version>2.0.1</eugene.version> <tapestry.version>5.1.0.5</tapestry.version> </properties> Modified: trunk/wao-business/src/main/java/fr/ifremer/wao/bean/ContactStatus.java =================================================================== --- trunk/wao-business/src/main/java/fr/ifremer/wao/bean/ContactStatus.java 2010-04-20 00:37:48 UTC (rev 463) +++ trunk/wao-business/src/main/java/fr/ifremer/wao/bean/ContactStatus.java 2010-04-20 09:34:10 UTC (rev 464) @@ -215,8 +215,13 @@ case OLD: tideBeginDate = oldContact.getTideBeginDate(); break; // newContact may be null in CREATE case, so we use the previous // one - case NEW: tideBeginDate = newContact != null ? - newContact.getTideBeginDate() : oldContact.getTideBeginDate(); + case NEW: + if (newContact != null && + newContact.getTideBeginDate() != null) { + tideBeginDate = newContact.getTideBeginDate(); + } else { + tideBeginDate = oldContact.getTideBeginDate(); + } } SampleMonthDAO monthDAO = WaoDAOHelper.getSampleMonthDAO(transaction); Modified: trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceContactImpl.java =================================================================== --- trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceContactImpl.java 2010-04-20 00:37:48 UTC (rev 463) +++ trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceContactImpl.java 2010-04-20 09:34:10 UTC (rev 464) @@ -630,26 +630,39 @@ tideBeginDateChanged = status.isTideBeginDateMonthChanged(); // Retrieve oldMonth from status - // Must exists otherwise the oldContact couln't have been saved - SampleMonth oldMonth = status.getOldSampleMonth(transaction); + try { + SampleMonth oldMonth = status.getOldSampleMonth(transaction); - // Apply changes on oldMonth - if (status.isOldContactValidate()) { - // decrement real tides - oldMonth.addRealTideTime(-1); + // Apply changes on oldMonth + if (status.isOldContactValidate()) { + // decrement real tides + oldMonth.addRealTideTime(-1); + } + // Decrement estimated only if old state is BOARDING_DONE + // and old validationProgram is NOT FALSE + // the estimated value has already been decremented during + // refused + if (status.isOldContactDone() && BooleanUtils.isNotFalse( + oldContact.getValidationProgram())) { + // decrement estimated tides + oldMonth.addEstimatedTideTime(-1); + } + + // Catch the null exception, only a warning if the oldSampleMonth is + // not found + } catch (NullSampleMonthException eee) { + if (log.isWarnEnabled()) { + log.warn("Error on retrieve old sampleMonth", eee); + } } - // Decrement estimated only if old state is BOARDING_DONE - // and old validationProgram is NOT FALSE - // the estimated value has already been decremented during refused - if (status.isOldContactDone() && - BooleanUtils.isNotFalse(oldContact.getValidationProgram())) { - // decrement estimated tides - oldMonth.addEstimatedTideTime(-1); - } } + ContactState currentState = contact != null ? + contact.getContactState() : oldContact.getContactState(); + // Validation of contact has changed in status, modify realTides - if (calculateReal && + // Only calculate real for a currentState equals to BOARDING_DONE + if (calculateReal && ContactState.BOARDING_DONE.equals(currentState) && (status.isContactValidateChanged() || tideBeginDateChanged)) { SampleMonth sampleMonth = status.getSampleMonth(transaction); Modified: trunk/wao-business/src/test/java/fr/ifremer/wao/service/ServiceContactImplTest.java =================================================================== --- trunk/wao-business/src/test/java/fr/ifremer/wao/service/ServiceContactImplTest.java 2010-04-20 00:37:48 UTC (rev 463) +++ trunk/wao-business/src/test/java/fr/ifremer/wao/service/ServiceContactImplTest.java 2010-04-20 09:34:10 UTC (rev 464) @@ -349,11 +349,11 @@ when(contactReference.getValidationCompany()).thenReturn(Boolean.TRUE); logger.info("test 6 : Delete contact (new contact is null) -> " + - "decrement realTides, estimatedTides doesn't change"); + "decrement realTides and estimatedTides"); transaction = manager.getContext().beginTransaction(); try { - // ContactReference as a state != BOARDING_DONE, don't decrement - // estimatedTides + when(contactReference.getContactState()). + thenReturn(ContactState.BOARDING_DONE); service.updateSampleMonthTidesValue(transaction, contactReference, null, true); @@ -363,9 +363,9 @@ } logger.info("test 6 : verification sampleMonth real tides = 0" + - "and estimated tides = 1"); + "and estimated tides = 0"); checkTidesValue(0, true); - checkTidesValue(1, false); + checkTidesValue(0, false); logger.info("test 7 : SampleMonth will change from 03/2010 to 04/2010" + " -> decrement estimated tides from oldMonth"); Modified: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/components/Layout.java =================================================================== --- trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/components/Layout.java 2010-04-20 00:37:48 UTC (rev 463) +++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/components/Layout.java 2010-04-20 09:34:10 UTC (rev 464) @@ -44,6 +44,7 @@ import org.apache.tapestry5.annotations.Persist; import org.apache.tapestry5.annotations.Property; import org.apache.tapestry5.annotations.SessionState; +import org.apache.tapestry5.ioc.Messages; import org.apache.tapestry5.ioc.annotations.Inject; import org.apache.tapestry5.services.Request; import org.slf4j.Logger; @@ -97,6 +98,9 @@ @Inject private Logger logger; + @Inject + private Messages messages; + private boolean fatal = false; void setupRender() { Modified: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Boats.java =================================================================== --- trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Boats.java 2010-04-20 00:37:48 UTC (rev 463) +++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Boats.java 2010-04-20 09:34:10 UTC (rev 464) @@ -225,9 +225,7 @@ layout.addInfo(result[0] + " navires importés dont " + result[1] + " nouveaux"); } catch (WaoBusinessException eee) { - String error = - manager.getErrorMessage(eee, messages, log); - layout.addError(error); + layout.addError(eee.getMessage()); } } } Modified: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Contacts.java =================================================================== --- trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Contacts.java 2010-04-20 00:37:48 UTC (rev 463) +++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/Contacts.java 2010-04-20 09:34:10 UTC (rev 464) @@ -70,6 +70,7 @@ import org.apache.tapestry5.beaneditor.BeanModel; import org.apache.tapestry5.corelib.components.Form; import org.apache.tapestry5.corelib.components.Zone; +import org.apache.tapestry5.ioc.Messages; import org.apache.tapestry5.ioc.annotations.Inject; import org.apache.tapestry5.ioc.services.PropertyAccess; import org.apache.tapestry5.services.BeanModelSource; @@ -591,6 +592,9 @@ @Inject private WaoManager manager; + @Inject + private Messages messages; + @Log void onValidateFormFromContactsForm() { contactsForm.clearErrors(); @@ -598,8 +602,8 @@ // form) if (!edited && contactEdited != null) { ContactState contactState = contactEdited.getContactState(); - if (log.isInfoEnabled()) { - log.info("For state : " + contactState); + if (log.isDebugEnabled()) { + log.debug("For state : " + contactState); } Date begin = contactEdited.getTideBeginDate(); @@ -653,24 +657,24 @@ } else { contactsForm.recordError(comment, "Vous devez ajouter" + " un commentaire pour l'état" + - " '" + contactState + "'"); + " '" + contactState.libelle() + "'"); } // Embarquement Réalisé } else if (contactState.equals(ContactState.BOARDING_DONE)) { if (begin == null) { contactsForm.recordError(beginDate, "La date de début de" + " marée est obligatoire pour l'état" + - " '" + contactState + "'"); + " '" + contactState.libelle() + "'"); } if (end == null) { contactsForm.recordError(endDate, "La date de fin de" + " marée est obligatoire pour l'état" + - " '" + contactState + "'"); + " '" + contactState.libelle() + "'"); } if (contactEdited.getNbObservants() == 0) { contactsForm.recordError(nbObservants, "Il ne peut y" + " avoir aucun observateur pour l'état" + - " '" + contactState + "'"); + " '" + contactState.libelle() + "'"); } } } @@ -688,7 +692,9 @@ oldComment = null; contactEdited = null; } catch (WaoException eee) { - layout.addError(eee.getMessage()); + for (String msg : manager.getErrorMessages(eee, messages, log)) { + layout.addError(msg); + } } } return this; Modified: trunk/wao-ui/src/main/webapp/Boats.tml =================================================================== --- trunk/wao-ui/src/main/webapp/Boats.tml 2010-04-20 00:37:48 UTC (rev 463) +++ trunk/wao-ui/src/main/webapp/Boats.tml 2010-04-20 09:34:10 UTC (rev 464) @@ -241,6 +241,9 @@ <div class="${lastContactStyle}"> <dl t:type="beandisplay" t:id="boatInfosLastContact" t:object="companyBoatInfos.lastContact" t:include="referenceDate, state" t:add="createdBy, sampleRowCode"> + <p:state> + ${companyBoatInfos.lastContact.contactState.libelle()} + </p:state> <p:createdBy> ${companyBoatInfos.lastContact.observer.fullName} </p:createdBy> Modified: trunk/wao-ui/src/main/webapp/Contacts.tml =================================================================== --- trunk/wao-ui/src/main/webapp/Contacts.tml 2010-04-20 00:37:48 UTC (rev 463) +++ trunk/wao-ui/src/main/webapp/Contacts.tml 2010-04-20 09:34:10 UTC (rev 464) @@ -275,9 +275,9 @@ </p> <p> </p> <p class="aright"> -<!-- <a onclick="closeCommentWindow(windowComment, 'commentPopup', 'contact-comment', ${contact.contactState.isUnfinishedState()}, 'commentImg', '${asset:context:}')" class="save"> + <a onclick="closeCommentWindow(windowComment, 'commentPopup', 'contact-comment', ${contact.contactState.isUnfinishedState()}, 'commentImg', '${asset:context:}')" class="save"> <img src="${asset:context:img/save-22px.png}" alt="Save comment" title="Enregistrer le commentaire"/> - </a>--> + </a> </p> </div>
participants (1)
-
fdesbois@users.labs.libre-entreprise.org