Author: fdesbois Date: 2010-02-01 10:43:47 +0000 (Mon, 01 Feb 2010) New Revision: 303 Modified: trunk/changelog.txt trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/BoatImpl.java trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/impl/ServiceBoatImpl.java trunk/suiviobsmer-ui/src/main/resources/fr/ifremer/suiviobsmer/ui/components/Layout.tml trunk/suiviobsmer-ui/src/main/webapp/Boats.tml trunk/suiviobsmer-ui/src/main/webapp/SamplingPlan.tml Log: Evo #2070 : Test activation of boat for contact creation Modified: trunk/changelog.txt =================================================================== --- trunk/changelog.txt 2010-02-01 09:49:29 UTC (rev 302) +++ trunk/changelog.txt 2010-02-01 10:43:47 UTC (rev 303) @@ -7,6 +7,7 @@ Evolutions ++++++++++ +- [fdesbois] Evo #2070 : Gestion de l'inactivité du navire (bloquer la création d'un contact) - [fdesbois] Evo #2046 : Lien vers le site dans les mail concernant les login - [fdesbois] Evo #2045 : Enlever le mot de passe du mail lors de la modification du compte utilisateur - [fdesbois] Evo #1987 : Synthèse : Graphe sollicitation des navires Modified: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/BoatImpl.java =================================================================== --- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/BoatImpl.java 2010-02-01 09:49:29 UTC (rev 302) +++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/BoatImpl.java 2010-02-01 10:43:47 UTC (rev 303) @@ -58,26 +58,30 @@ * @see fr.ifremer.suiviobsmer.bean.ContactState#isFinalState() */ @Override - public boolean canCreateContact(Company company) throws SuiviObsmerException { - TopiaContext transaction = null; + public boolean canCreateContact(Company company) throws SuiviObsmerException { boolean result = true; - try { - transaction = SuiviObsmerContext.getTopiaRootContext().beginTransaction(); + if (!getActive()) { + result = false; + } else { + TopiaContext transaction = null; + try { + transaction = SuiviObsmerContext.getTopiaRootContext().beginTransaction(); - ContactDAO dao = SuiviObsmerModelDAOHelper.getContactDAO(transaction); - Contact contact = dao.createQueryLastContactForBoat(this, company).executeToEntity(); + ContactDAO dao = SuiviObsmerModelDAOHelper.getContactDAO(transaction); + Contact contact = dao.createQueryLastContactForBoat(this, company).executeToEntity(); - if (contact != null) { - ContactState state = ContactState.createContactStateEnum(contact.getState()); - result = state.isFinalState(); + if (contact != null) { + ContactState state = ContactState.createContactStateEnum(contact.getState()); + result = state.isFinalState(); + } + + transaction.closeContext(); + } catch (Exception eee) { + SuiviObsmerContext.serviceException(transaction, + "Impossible de récupérer les informations privées du navire lié à la société " + + "'" + company.getName() + "'", + eee); } - - transaction.closeContext(); - } catch (Exception eee) { - SuiviObsmerContext.serviceException(transaction, - "Impossible de récupérer les informations privées du navire lié à la société " + - "'" + company.getName() + "'", - eee); } return result; } Modified: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/impl/ServiceBoatImpl.java =================================================================== --- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/impl/ServiceBoatImpl.java 2010-02-01 09:49:29 UTC (rev 302) +++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/impl/ServiceBoatImpl.java 2010-02-01 10:43:47 UTC (rev 303) @@ -385,17 +385,22 @@ // } - int immatriculation = Integer.parseInt(reader.get(BOAT.NAVS_COD.name()).trim()); - String boatName = reader.get(BOAT.CARN_NOM.name()).trim(); - int boatLength = Integer.parseInt(reader.get(BOAT.CARN_LONGUEUR_HT.name()).trim()); - int buildYear = Integer.parseInt(reader.get(BOAT.CARN_ANNEE.name()).trim()); - String districtCode = reader.get(BOAT.QUARTIER_IMMA.name()).trim(); - String shipOwnerCode = reader.get(BOAT.PER_COD.name()).trim(); - String shipOwnerLastName = reader.get(BOAT.PER_NOM.name()).trim(); - String shipOwnerFirstName = reader.get(BOAT.PER_PRENOM.name()).trim(); - String activeStr = reader.get(BOAT.NAVS_ACTIVE.name()).trim(); + int immatriculation = ImportHelper.readInt(reader, BOAT.NAVS_COD); + String boatName = ImportHelper.read(reader, BOAT.CARN_NOM); + int boatLength = ImportHelper.readInt(reader, BOAT.CARN_LONGUEUR_HT); + int buildYear = ImportHelper.readInt(reader, BOAT.CARN_ANNEE); + String districtCode = ImportHelper.read(reader, BOAT.QUARTIER_IMMA); + String shipOwnerCode = ImportHelper.read(reader, BOAT.PER_COD); + String shipOwnerLastName = ImportHelper.read(reader, BOAT.PER_NOM); + String shipOwnerFirstName = ImportHelper.read(reader, BOAT.PER_PRENOM); + //String activeStr = reader.get(BOAT.NAVS_ACTIVE.name()).trim(); + String activeStr = ImportHelper.read(reader, BOAT.NAVS_ACTIVE); boolean active = !activeStr.equals("I"); + if (log.isDebugEnabled()) { + log.debug("Active : " + active + " (" + activeStr + ")"); + } + // Find existing boat with immatriculation Boat boat = boatDAO.findByImmatriculation(immatriculation); Modified: trunk/suiviobsmer-ui/src/main/resources/fr/ifremer/suiviobsmer/ui/components/Layout.tml =================================================================== --- trunk/suiviobsmer-ui/src/main/resources/fr/ifremer/suiviobsmer/ui/components/Layout.tml 2010-02-01 09:49:29 UTC (rev 302) +++ trunk/suiviobsmer-ui/src/main/resources/fr/ifremer/suiviobsmer/ui/components/Layout.tml 2010-02-01 10:43:47 UTC (rev 303) @@ -27,11 +27,11 @@ <a t:type="pagelink" t:page="index" title="Page d'accueil"> <img src="${asset:context:}/img/home.png" alt="Accueil" title="Page d'accueil" /> </a> - <a t:type="pagelink" t:page="userProfile" title="Gestion profile"> - <img src="${asset:context:}/img/user.png" alt="Preferences" title="Gestion profile"/> + <a t:type="pagelink" t:page="userProfile" title="Gestion profil"> + <img src="${asset:context:}/img/user.png" alt="Preferences" title="Gestion profil"/> </a> - <a t:type="actionlink" t:id="exit" title="Déconnection"> - <img src="${asset:context:}/img/exit.png" alt="Exit" title="Déconnection"/> + <a t:type="actionlink" t:id="exit" title="Déconnexion"> + <img src="${asset:context:}/img/exit.png" alt="Exit" title="Déconnexion"/> </a> </div> </div> Modified: trunk/suiviobsmer-ui/src/main/webapp/Boats.tml =================================================================== --- trunk/suiviobsmer-ui/src/main/webapp/Boats.tml 2010-02-01 09:49:29 UTC (rev 302) +++ trunk/suiviobsmer-ui/src/main/webapp/Boats.tml 2010-02-01 10:43:47 UTC (rev 303) @@ -258,7 +258,7 @@ </a> <p:else> <t:unless t:test="user.admin"> - <img src="${asset:context:}/img/contact-unavailable-22px.png" title="Création d'un nouveau contact indisponible"/> + <img src="${asset:context:}/img/contact-unavailable-22px.png" title="Création d'un nouveau contact impossible"/> </t:unless> </p:else> </t:if> Modified: trunk/suiviobsmer-ui/src/main/webapp/SamplingPlan.tml =================================================================== --- trunk/suiviobsmer-ui/src/main/webapp/SamplingPlan.tml 2010-02-01 09:49:29 UTC (rev 302) +++ trunk/suiviobsmer-ui/src/main/webapp/SamplingPlan.tml 2010-02-01 10:43:47 UTC (rev 303) @@ -21,7 +21,7 @@ <form t:type="form" t:id="periodForm"> <t:label t:for="periodBegin" /> : <input t:type="datefield" t:id="periodBegin" /> <t:label t:for="periodEnd" /> : <input t:type="datefield" t:id="periodEnd" /> - <input t:type="submit" class="ico search" value="Search" t:title="Affichage des lignes du plan couverte par la période sélectionnée" /> + <input t:type="submit" class="ico search" value="Search" t:title="Affichage des lignes du plan couvertes par la période sélectionnée" /> </form> </div> <t:if t:test="user.admin">