Author: fdesbois Date: 2010-01-23 17:59:23 +0000 (Sat, 23 Jan 2010) New Revision: 262 Modified: trunk/changelog.txt trunk/pom.xml trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/ImportHelper.java trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/bean/ContactFilterImpl.java trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/bean/SamplingFilterImpl.java trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/bean/states/ContactState.java trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/BoatImpl.java trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/SampleRowImpl.java trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/impl/ActivityCalendarImport.java trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/impl/ServiceBoatImpl.java trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/impl/ServiceContactImpl.java trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/impl/ServiceReferentialImpl.java trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/impl/ServiceSamplingImpl.java trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/impl/ServiceSynthesisImpl.java trunk/suiviobsmer-business/src/main/xmi/suiviobsmer.zargo trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/impl/ServiceReferentialImplTest.java trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/base/AbstractFilteredPage.java trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/data/AbstractMappedGridDataSource.java trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/BoatActivityCalendar.java trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/Boats.java trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/Contacts.java trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/Synthesis.java trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/services/ContactModelFactory.java trunk/suiviobsmer-ui/src/main/resources/fr/ifremer/suiviobsmer/ui/pages/Boats.properties trunk/suiviobsmer-ui/src/main/resources/fr/ifremer/suiviobsmer/ui/pages/Contacts.properties trunk/suiviobsmer-ui/src/main/webapp/BoatActivityCalendar.tml trunk/suiviobsmer-ui/src/main/webapp/Boats.tml trunk/suiviobsmer-ui/src/main/webapp/Contacts.tml trunk/suiviobsmer-ui/src/main/webapp/Synthesis.tml trunk/suiviobsmer-ui/src/main/webapp/css/boats.css trunk/suiviobsmer-ui/src/main/webapp/css/contacts.css Log: - Clean filters managment (replace js onChange event on selects by submit buttons) - Clean imports + resolve issues on "INA" in ActivityCalendar and missing PLAN_COMMENT header - Add back link from ActivityCalendar page - Use ContactDataSource to refresh contacts grid Modified: trunk/changelog.txt =================================================================== --- trunk/changelog.txt 2010-01-22 18:48:46 UTC (rev 261) +++ trunk/changelog.txt 2010-01-23 17:59:23 UTC (rev 262) @@ -4,12 +4,12 @@ 0.1.2 ----- -- [fdesbois] Ano #2033 : Problème avec le filtre sur un code de ligne dans les synthèses +- [fdesbois] Ano #2037 : Le retour depuis les calendriers d'activité ne ramène pas sur le navire sélectionnée (ajout d'un lien retour) +- [fdesbois] Evol #2036 : Optimiser la pagination des contacts (suppression des tris sur les colonnes du tableau) +- [fdesbois] Evol #2030, #2038, Ano #2033, #2042 : Revoir la gestion des filtres sur les pages navires, contacts et synthèse - [fdesbois] Ano #2034 : Mauvais calcul des marées réels -- [fdesbois] Ano #2042 : Problème sur les filtres de la page contacts (une validation les enlève) - [fdesbois] Evol #2017 : Permettre la suppression d'un utilisateur non utilisé dans l'application - [fdesbois] Evol #1959 : Contacts : Popup pour la sasie d'un commentaire sur une ligne -- [fdesbois] Evol #2030 : Refactoré filtres des navires pour utiliser la partie commune a ceux des contacts et des syntheses - [fdesbois] Ano #2019 : L'affichage des zones sur le plan d'échantillonnage n'est pas cohérent avec les lignes. 0.1.1 Modified: trunk/pom.xml =================================================================== --- trunk/pom.xml 2010-01-22 18:48:46 UTC (rev 261) +++ trunk/pom.xml 2010-01-23 17:59:23 UTC (rev 262) @@ -207,7 +207,7 @@ <!-- libraries version --> <nuitonutils.version>1.1.3</nuitonutils.version> - <topia.version>2.3.0-beta-5</topia.version> + <topia.version>2.3.0-beta-6-SNAPSHOT</topia.version> <eugene.version>2.0.0-beta-3</eugene.version> <tapestry.version>5.1.0.5</tapestry.version> Modified: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/ImportHelper.java =================================================================== --- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/ImportHelper.java 2010-01-22 18:48:46 UTC (rev 261) +++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/ImportHelper.java 2010-01-23 17:59:23 UTC (rev 262) @@ -72,19 +72,19 @@ /** Boat name **/ CARN_NOM(21), /** Boat length **/ - CARN_LONGUEUR_HT(-1), + CARN_LONGUEUR_HT, /** Boat build year **/ - CARN_ANNEE(-1), + CARN_ANNEE, /** Boat district code **/ QUARTIER_IMMA(22), /** ShipOwner code **/ - PER_COD(-1), + PER_COD, /** ShipOwner last name **/ - PER_NOM(-1), + PER_NOM, /** ShipOwner first name **/ - PER_PRENOM(-1), + PER_PRENOM, /** Boat active **/ - NAVS_ACTIVE(-1); + NAVS_ACTIVE; int contactHeader; @@ -92,6 +92,10 @@ this.contactHeader = index; } + BOAT() { + this.contactHeader = -1; + } + @Override public int forContactCsv() { return contactHeader; @@ -132,9 +136,11 @@ /** Profession species **/ METIER_ESPECES(19), /** SampleRow nb observants **/ - PLAN_NB_OBSERV(-1), + PLAN_NB_OBSERV, /** SampleRow average tide time **/ - PLAN_DUREE_MOY(-1); + PLAN_DUREE_MOY, + /** SampleRow comment **/ + PLAN_COMMENT; int contactHeader; @@ -142,6 +148,10 @@ this.contactHeader = index; } + SAMPLING() { + this.contactHeader = -1; + } + @Override public int forContactCsv() { return contactHeader; Modified: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/bean/ContactFilterImpl.java =================================================================== --- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/bean/ContactFilterImpl.java 2010-01-22 18:48:46 UTC (rev 261) +++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/bean/ContactFilterImpl.java 2010-01-23 17:59:23 UTC (rev 262) @@ -22,10 +22,12 @@ package fr.ifremer.suiviobsmer.bean; import fr.ifremer.suiviobsmer.entity.Contact; +import fr.ifremer.suiviobsmer.entity.SampleRow; import fr.ifremer.suiviobsmer.entity.User; import java.util.ArrayList; import java.util.List; import org.nuiton.topia.framework.TopiaQuery; +import org.nuiton.topia.persistence.TopiaEntity; /** * ContactFilterImpl @@ -47,12 +49,21 @@ if (getObserver() != null) { query.add(contact + "." + Contact.USER, getObserver()); - } else if (getCompany() != null) { - query.add(contact + "." + Contact.USER + "." + User.COMPANY, getCompany()); } + // Company filter is managed by SamplingFilter cause the company is linked with the sampleRow instead of contact user +// else if (getCompany() != null) { +// query.add(contact + "." + Contact.USER + "." + User.COMPANY, getCompany()); +// } - query = prepareQueryForSampling(query, query.getMainAlias() + "." + Contact.SAMPLE_ROW); - query = prepareQueryForBoat(query, query.getMainAlias() + "." + Contact.BOAT); + if (isSamplingFiltered() || getFromDate() != null) { + // Seems to be necessary to have distinct on sampleRows in case of + // fishingZone join. Otherwise multiple contacts for sames sampleRow + // will be returned (Bad count). + TopiaQuery<SampleRow> subquery = TopiaQuery.createQuery(SampleRow.class, "S").setSelect("S").addDistinct(); + subquery = prepareQueryForSampling(subquery, "S"); + query.add(contact + "." + Contact.SAMPLE_ROW + " IN (" + subquery.fullQuery() + ")").addParams(subquery.getParams()); + } + query = prepareQueryForBoat(query, contact + "." + Contact.BOAT); if (getMammalsObservation() && getMammalsCapture()) { query.add(contact + ".mammalsObservation = :mammals OR " + contact + ".mammalsCapture = :mammals"). @@ -85,6 +96,14 @@ query.add(contact + "." + Contact.STATE, getState().toString()); } + if (getFromDate() != null) { + String tideBeginDate = contact + "." + Contact.TIDE_BEGIN_DATE; + String createDate = contact + "." + TopiaEntity.TOPIA_CREATE_DATE; + query.add("(" + tideBeginDate + " IS NOT NULL AND " + tideBeginDate + " >= :fromDate)" + + " OR (" + tideBeginDate + " IS NULL AND " + createDate + " >= :fromDate)"); + query.addParam("fromDate", getFromDate()); + } + return query; } Modified: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/bean/SamplingFilterImpl.java =================================================================== --- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/bean/SamplingFilterImpl.java 2010-01-22 18:48:46 UTC (rev 261) +++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/bean/SamplingFilterImpl.java 2010-01-23 17:59:23 UTC (rev 262) @@ -52,10 +52,10 @@ query.add(main, getSampleRow()); } else if (StringUtils.isNotEmpty(getSectorName())) { query.addFrom(FishingZone.class.getName() + " F"); - query.add("F." + FishingZone.SECTOR_NAME, getSectorName()).add(main + " IN elements(F." + FishingZone.SAMPLE_ROW + ")"); + query.add("F." + FishingZone.SECTOR_NAME, getSectorName()).add("F IN elements(" + main + "." + SampleRow.FISHING_ZONE + ")"); } else if (StringUtils.isNotEmpty(getFacadeName())) { query.addFrom(FishingZone.class.getName() + " F"); - query.add("F." + FishingZone.FACADE_NAME, getFacadeName()).add(main + " IN elements(F." + FishingZone.SAMPLE_ROW + ")"); + query.add("F." + FishingZone.FACADE_NAME, getFacadeName()).add("F IN elements(" + main + "." + SampleRow.FISHING_ZONE + ")"); } // Profession filter @@ -68,10 +68,16 @@ getPeriod().initDayOfMonthExtremities(); query.add(main + "." + SampleRow.PERIOD_BEGIN, Op.LT, getPeriod().getThruDate()). add(main + "." + SampleRow.PERIOD_END, Op.GT, getPeriod().getFromDate()); + } else if (getFromDate() != null) { + query.add(main + "." + SampleRow.PERIOD_END, Op.GE, getFromDate()); } - /** Finished rows constraint only needed if an other filter is set **/ - if (isSamplingFiltered() && getNbMonthFinishedFromToday() != null) { + // Company + if (getCompany() != null) { + query.add(main + "." + SampleRow.COMPANY, getCompany()); + } + + if (getNbMonthFinishedFromToday() != null) { // Only rows which are not finished will be kept // Date current = SuiviObsmerContext.getCurrentDate(); Calendar calendar = new GregorianCalendar(); @@ -85,6 +91,7 @@ @Override public boolean isSamplingFiltered() { + // all field except fromDate return getSampleRow() != null || StringUtils.isNotEmpty(getSectorName()) || StringUtils.isNotEmpty(getFacadeName()) || getPeriod() != null || getProfession() != null; } Modified: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/bean/states/ContactState.java =================================================================== --- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/bean/states/ContactState.java 2010-01-22 18:48:46 UTC (rev 261) +++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/bean/states/ContactState.java 2010-01-23 17:59:23 UTC (rev 262) @@ -91,7 +91,7 @@ * changing state. * @param context Context to manipulate for validation * @param transitionNum Number of the transaction to validate - * @return true if the transition is validate, false either + * @return true if the transition is validate, false otherwise * @throws ContactStateException */ protected boolean validate(ContactContext context, int transitionNum) throws ContactStateException { 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-01-22 18:48:46 UTC (rev 261) +++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/BoatImpl.java 2010-01-23 17:59:23 UTC (rev 262) @@ -52,7 +52,7 @@ * The state is tested for the last created contact. * A new contact can be created only if the last state is final and is not 'Refus définitif'. * @param company which is the creator of the contact - * @return true if the contact can be created, false either + * @return true if the contact can be created, false otherwise * @throws SuiviObsmerException */ @Override Modified: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/SampleRowImpl.java =================================================================== --- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/SampleRowImpl.java 2010-01-22 18:48:46 UTC (rev 261) +++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/entity/SampleRowImpl.java 2010-01-23 17:59:23 UTC (rev 262) @@ -55,7 +55,7 @@ /** * Get a SampleMonth from a date. The month and year of the date must correspond to the SampleMonth to get. * @param date a Date - * @return the SampleMonth if it exists in the SampleMonth list or null either + * @return the SampleMonth if it exists in the SampleMonth list or null otherwise */ @Override public SampleMonth getSampleMonth(Date date) { @@ -124,7 +124,7 @@ * Check if the sampleRow has an ElligibleBoat corresponding to the boat in argument. * The test return true only if it's a global ElligbleBoat set by an admin and not by a user (companyActive). * @param boat Boat to test - * @return true if the ElligibleBoat is find, false either + * @return true if the ElligibleBoat is find, false otherwise */ @Override public boolean hasElligibleBoat(Boat boat) { @@ -188,7 +188,7 @@ /** * Check if SampleMonth of the SampleRow has already realTidesValue set (different from 0). * It means the SampleRow could'nt be deleted and have some modification constraints. - * @return true if a SampleMonth have realTidesValue, false either + * @return true if a SampleMonth have realTidesValue, false otherwise */ @Override public boolean hasSampleMonthRealTideTime() { @@ -253,7 +253,7 @@ * Check if a SampleMonth is valid for the date in argument. * * @param begin date for testing SampleMonth existence - * @return true if a SampleMonth exist for this begin date, false either + * @return true if a SampleMonth exist for this begin date, false otherwise */ @Override public boolean isValid(Date begin) { Modified: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/impl/ActivityCalendarImport.java =================================================================== --- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/impl/ActivityCalendarImport.java 2010-01-22 18:48:46 UTC (rev 261) +++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/impl/ActivityCalendarImport.java 2010-01-23 17:59:23 UTC (rev 262) @@ -216,9 +216,8 @@ } //String harbourCode = reader.get("SYNA_POR_COD").trim(); - String harbourCode = ImportHelper.read(reader, ACTIVITY_CALENDAR.SYNA_POR_COD); - boolean active = harbourCode != null && !harbourCode.equals("INA"); - // FIXME-FD20100122 : INA a tester sur le code du métier : YOUPI ONE + String professionCode = ImportHelper.read(reader, ACTIVITY_CALENDAR.MET_COD); + boolean active = professionCode != null && !professionCode.equals("INA"); ActivityMonth month = calendar.getActivityMonth(monthNum); @@ -258,6 +257,7 @@ Integer nbBoardingPersons = ImportHelper.readInteger(reader, ACTIVITY_CALENDAR.SYNA_NOMHE); int harbourId = ImportHelper.readInt(reader, ACTIVITY_CALENDAR.SYNA_TPOR_COD); + String harbourCode = ImportHelper.read(reader, ACTIVITY_CALENDAR.SYNA_POR_COD); String harbourLibelle = ImportHelper.read(reader, ACTIVITY_CALENDAR.SYNA_POR_LIB); month.setHarbourId(harbourId); @@ -274,7 +274,6 @@ // Can be equals to -1 if set to NA in Csv File (not a problem for ordering Profession) int professionOrder = ImportHelper.readInt(reader, ACTIVITY_CALENDAR.META_ORDRE); - String professionCode = ImportHelper.read(reader, ACTIVITY_CALENDAR.MET_COD); int professionId = ImportHelper.readInt(reader, ACTIVITY_CALENDAR.MET_ID); String professionLibelle = ImportHelper.read(reader, ACTIVITY_CALENDAR.MET_LIB); @@ -334,6 +333,8 @@ transaction.commitTransaction(); availableCalendars.clear(); + // Force garbage collector + System.gc(); tic2 = System.currentTimeMillis(); if (log.isDebugEnabled()) { @@ -348,9 +349,6 @@ long stopTime = System.currentTimeMillis(); - // Force garbage collector - System.gc(); - String execTime = DurationFormatUtils.formatDurationHMS(stopTime - startTime); info("Nombre de ligne ajouté : " + result, -1); 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-01-22 18:48:46 UTC (rev 261) +++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/impl/ServiceBoatImpl.java 2010-01-23 17:59:23 UTC (rev 262) @@ -109,13 +109,8 @@ protected TopiaQuery<Boat> createQueryForBoatFilter(TopiaQuery<Boat> query, BoatFilter filter) { String main = query.getMainAlias(); - query = filter.prepareQueryForBoat(query, main); + query = filter.prepareQueryForBoat(query, main).addDistinct(); -// boolean sampleRowCodeFiltered = !StringUtils.isEmpty(filter.getSampleRowCode()); -// boolean professionFiltered = filter.getProfession() != null; -// boolean fishingZoneFiltered = filter.getFishingZone() != null; -// boolean sampleRowFiltered = sampleRowCodeFiltered || professionFiltered || fishingZoneFiltered; - // Sampling filter if (filter.isSamplingFiltered()) { // Add join for ElligibleBoat @@ -125,21 +120,13 @@ // Company if (filter.getCompany() != null) { - query.add("E." + ElligibleBoat.SAMPLE_ROW + "." + SampleRow.COMPANY, filter.getCompany()); + //query.add("E." + ElligibleBoat.SAMPLE_ROW + "." + SampleRow.COMPANY, filter.getCompany()); // Test only valid ElligibleBoat for that company query.add("E." + ElligibleBoat.COMPANY_ACTIVE + " = :booleanTrue " + "OR (E." + ElligibleBoat.COMPANY_ACTIVE + " IS NULL AND E." + ElligibleBoat.GLOBAL_ACTIVE + " = :booleanTrue)"); query.addParam("booleanTrue", Boolean.TRUE); } } -// // SampleRowCode -// if (sampleRowCodeFiltered) { -// query.add("E.sampleRow.code", filter.getSampleRowCode()); -// } -// // Profession -// if (professionFiltered) { -// query.add("E.sampleRow.profession", filter.getProfession()); -// } return query; } Modified: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/impl/ServiceContactImpl.java =================================================================== --- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/impl/ServiceContactImpl.java 2010-01-22 18:48:46 UTC (rev 261) +++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/impl/ServiceContactImpl.java 2010-01-23 17:59:23 UTC (rev 262) @@ -100,7 +100,7 @@ ContactDAO dao = SuiviObsmerModelDAOHelper.getContactDAO(transaction); - TopiaQuery<Contact> query = dao.createQuery("C"); + TopiaQuery<Contact> query = dao.createQuery("C").addDistinct(); query = filter.prepareQueryForContact(query); Modified: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/impl/ServiceReferentialImpl.java =================================================================== --- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/impl/ServiceReferentialImpl.java 2010-01-22 18:48:46 UTC (rev 261) +++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/impl/ServiceReferentialImpl.java 2010-01-23 17:59:23 UTC (rev 262) @@ -30,6 +30,8 @@ import fr.ifremer.suiviobsmer.entity.FishingZoneDAO; import fr.ifremer.suiviobsmer.entity.Profession; import fr.ifremer.suiviobsmer.entity.ProfessionDAO; +import fr.ifremer.suiviobsmer.entity.SampleRow; +import fr.ifremer.suiviobsmer.entity.User; import fr.ifremer.suiviobsmer.services.ServiceReferential; import java.io.InputStream; import java.nio.charset.Charset; @@ -64,15 +66,23 @@ } @Override - public List<String> getFacades() throws SuiviObsmerException { + public List<String> getFacadesByUser(User user) throws SuiviObsmerException { TopiaContext transaction = null; List<String> results = new ArrayList<String>(); try { transaction = rootContext.beginTransaction(); FishingZoneDAO dao = SuiviObsmerModelDAOHelper.getFishingZoneDAO(transaction); - results = (List<String>)dao.createQuery().setSelect("DISTINCT " + FishingZone.FACADE_NAME).execute(); + TopiaQuery<FishingZone> query = dao.createQuery("F"); + if (!user.getAdmin()) { + query.addFrom(SampleRow.class.getName() + " S"). + add("S IN elements(F." + FishingZone.SAMPLE_ROW + ")"). + add("S." + SampleRow.COMPANY, user.getCompany()); + } + + results = (List<String>)query.setSelect("DISTINCT F." + FishingZone.FACADE_NAME).execute(); + transaction.closeContext(); } catch (Exception eee) { SuiviObsmerContext.serviceException(transaction, "Impossible de charger la liste des facades", eee); @@ -81,20 +91,26 @@ } @Override - public List<String> getSectors(String facadeName) throws SuiviObsmerException { + public List<String> getSectorsByUser(User user, String facadeName) throws SuiviObsmerException { TopiaContext transaction = null; List<String> results = new ArrayList<String>(); try { transaction = rootContext.beginTransaction(); FishingZoneDAO dao = SuiviObsmerModelDAOHelper.getFishingZoneDAO(transaction); - TopiaQuery<FishingZone> query = dao.createQuery(); + TopiaQuery<FishingZone> query = dao.createQuery("F"); + if (!user.getAdmin()) { + query.addFrom(SampleRow.class.getName() + " S"). + add("S IN elements(F." + FishingZone.SAMPLE_ROW + ")"). + add("S." + SampleRow.COMPANY, user.getCompany()); + } + if (!StringUtils.isEmpty(facadeName)) { - query.add(FishingZone.FACADE_NAME, facadeName); + query.add("F." + FishingZone.FACADE_NAME, facadeName); } - results = (List<String>)query.setSelect("DISTINCT " + FishingZone.SECTOR_NAME).execute(); + results = (List<String>)query.setSelect("DISTINCT F." + FishingZone.SECTOR_NAME).execute(); transaction.closeContext(); } catch (Exception eee) { Modified: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/impl/ServiceSamplingImpl.java =================================================================== --- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/impl/ServiceSamplingImpl.java 2010-01-22 18:48:46 UTC (rev 261) +++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/impl/ServiceSamplingImpl.java 2010-01-23 17:59:23 UTC (rev 262) @@ -341,19 +341,23 @@ SampleRowDAO dao = SuiviObsmerModelDAOHelper.getSampleRowDAO(transaction); - TopiaQuery<SampleRow> query = dao.createQuery("S"); + TopiaQuery<SampleRow> query = dao.createQuery("S").addDistinct().addOrder("S." + SampleRow.CODE); query = filter.prepareQueryForSampling(query, "S"); + if (log.isDebugEnabled()) { + log.debug("Query : " + query); + } + // if (finished) { // // Only rows which are not finished will be kept // Date current = SuiviObsmerContext.getCurrentDate(); // query.add(SampleRow.PERIOD_END, Op.GE, current); // } - if (filter.getCompany() != null) { - query.add("S." + SampleRow.COMPANY, filter.getCompany()); - } +// if (filter.getCompany() != null) { +// query.add("S." + SampleRow.COMPANY, filter.getCompany()); +// } results = query.executeToEntityList(); @@ -683,21 +687,22 @@ protected void updateRow(TopiaContext transaction, SampleRow sampleRow, CsvReader reader) throws IOException, TopiaException, ParseException { - String fishingZoneInfos = reader.get(SAMPLING.PECHE_AUTRE.name()).trim(); - int nbObservants = Integer.parseInt(reader.get(SAMPLING.PLAN_NB_OBSERV.name()).trim()); - String averageStr = reader.get(SAMPLING.PLAN_DUREE_MOY.name()).trim(); + String fishingZoneInfos = ImportHelper.read(reader, SAMPLING.PECHE_AUTRE); + int nbObservants = ImportHelper.readInt(reader, SAMPLING.PLAN_NB_OBSERV); + String averageStr = ImportHelper.read(reader, SAMPLING.PLAN_DUREE_MOY); averageStr = averageStr.replaceAll(",", "."); double averageTideTime = Double.parseDouble(averageStr); - String programName = reader.get(SAMPLING.PROGRAMME_CODE.name()).trim(); + String programName = ImportHelper.read(reader, SAMPLING.PROGRAMME_CODE); + String comment = ImportHelper.read(reader, SAMPLING.PLAN_COMMENT); PeriodDates period = ImportHelper.readPeriod(reader, SAMPLING.PROGRAMME_DEBUT, SAMPLING.PROGRAMME_FIN); - // Problem : not imported yet ?? sampleRow.setFishingZonesInfos(fishingZoneInfos); sampleRow.setNbObservants(nbObservants); sampleRow.setAverageTideTime(averageTideTime); sampleRow.setProgramName(programName); sampleRow.setPeriodBegin(period.getFromDate()); sampleRow.setPeriodEnd(period.getThruDate()); + sampleRow.setComment(comment); // 16 fixed columns : 13 before months and 3 after final int nbFixedColumns = 16; Modified: trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/impl/ServiceSynthesisImpl.java =================================================================== --- trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/impl/ServiceSynthesisImpl.java 2010-01-22 18:48:46 UTC (rev 261) +++ trunk/suiviobsmer-business/src/main/java/fr/ifremer/suiviobsmer/impl/ServiceSynthesisImpl.java 2010-01-23 17:59:23 UTC (rev 262) @@ -111,9 +111,9 @@ // } // } - if (filter.getCompany() != null) { - query.add("M." + SampleMonth.SAMPLE_ROW + "." + SampleRow.COMPANY, filter.getCompany()); - } +// if (filter.getCompany() != null) { +// query.add("M." + SampleMonth.SAMPLE_ROW + "." + SampleRow.COMPANY, filter.getCompany()); +// } if (log.isTraceEnabled()) { log.trace("Exec query : " + query); Modified: trunk/suiviobsmer-business/src/main/xmi/suiviobsmer.zargo =================================================================== (Binary files differ) Modified: trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/impl/ServiceReferentialImplTest.java =================================================================== --- trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/impl/ServiceReferentialImplTest.java 2010-01-22 18:48:46 UTC (rev 261) +++ trunk/suiviobsmer-business/src/test/java/fr/ifremer/suiviobsmer/impl/ServiceReferentialImplTest.java 2010-01-23 17:59:23 UTC (rev 262) @@ -25,6 +25,8 @@ import fr.ifremer.suiviobsmer.SuiviObsmerRunner; import fr.ifremer.suiviobsmer.business.SuiviObsmerRunnerTest; import fr.ifremer.suiviobsmer.entity.FishingZone; +import fr.ifremer.suiviobsmer.entity.User; +import fr.ifremer.suiviobsmer.entity.UserImpl; import java.io.InputStream; import java.util.List; import org.junit.After; @@ -80,8 +82,10 @@ InputStream input = getClass().getResourceAsStream("/import/zonesPeche.csv"); service.importFishingZoneCsv(input); + User user = new UserImpl(); + user.setAdmin(true); - List<String> facades = service.getFacades(); + List<String> facades = service.getFacadesByUser(user); assertEquals(3, facades.size()); assertTrue(facades.contains("Atlantique")); assertTrue(facades.contains("Mer du Nord")); @@ -94,8 +98,10 @@ InputStream input = getClass().getResourceAsStream("/import/zonesPeche.csv"); service.importFishingZoneCsv(input); + User user = new UserImpl(); + user.setAdmin(true); - List<String> sectors = service.getSectors(null); + List<String> sectors = service.getSectorsByUser(user, null); assertEquals(5, sectors.size()); assertTrue(sectors.contains("Manche")); assertTrue(sectors.contains("Mer du Nord")); @@ -103,7 +109,7 @@ assertTrue(sectors.contains("Golfe de Gascogne")); assertTrue(sectors.contains("Méditerranée")); - sectors = service.getSectors("Atlantique"); + sectors = service.getSectorsByUser(user, "Atlantique"); assertEquals(2, sectors.size()); assertTrue(sectors.contains("Manche Ouest")); assertTrue(sectors.contains("Golfe de Gascogne")); Modified: trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/base/AbstractFilteredPage.java =================================================================== --- trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/base/AbstractFilteredPage.java 2010-01-22 18:48:46 UTC (rev 261) +++ trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/base/AbstractFilteredPage.java 2010-01-23 17:59:23 UTC (rev 262) @@ -34,11 +34,9 @@ import java.util.List; import org.apache.tapestry5.OptionModel; import org.apache.tapestry5.SelectModel; -import org.apache.tapestry5.annotations.Log; import org.apache.tapestry5.annotations.Persist; import org.apache.tapestry5.annotations.Property; import org.apache.tapestry5.annotations.SessionState; -import org.apache.tapestry5.corelib.components.Zone; import org.apache.tapestry5.internal.OptionModelImpl; import org.apache.tapestry5.internal.SelectModelImpl; import org.apache.tapestry5.ioc.annotations.Inject; @@ -134,17 +132,6 @@ */ protected void initSelectFilters(boolean companySelect, boolean observerSelect) throws SuiviObsmerException { - if (log.isDebugEnabled()) { - log.debug("Filters : " + getFilter()); - } - - facadeSelectModel = null; - getFacadeSelectModel(); - sectorSelectModel = null; - getSectorSelectModel(); - sampleRowSelectModel = null; - getSampleRowSelectModel(); - if (getFilter().getSampleRow() != null) { if (log.isDebugEnabled()) { log.debug("SampleRow filtered : " + getFilter().getSampleRow()); @@ -173,15 +160,34 @@ observerId = getFilter().getObserver().getTopiaId(); } } + + resetFacadeSelect(); + resetSectorSelect(); + resetSampleRowSelect(); } + protected void resetFacadeSelect() throws SuiviObsmerException { + facadeSelectModel = null; + getFacadeSelectModel(); + } + + protected void resetSectorSelect() throws SuiviObsmerException { + sectorSelectModel = null; + getSectorSelectModel(); + } + + protected void resetSampleRowSelect() throws SuiviObsmerException { + sampleRowSelectModel = null; + getSampleRowSelectModel(); + } + public SelectModel getFacadeSelectModel() throws SuiviObsmerException { if (facadeSelectModel == null) { if (log.isInfoEnabled()) { log.info("BUSINESS REQUEST [getFacades]"); } List<OptionModel> options = new ArrayList<OptionModel>(); - for (String facadeName : serviceReferential.getFacades()) { + for (String facadeName : serviceReferential.getFacadesByUser(user)) { options.add(new OptionModelImpl(facadeName,facadeName)); } facadeSelectModel = new SelectModelImpl(null, options); @@ -195,7 +201,7 @@ log.info("BUSINESS REQUEST [getSectors]"); } List<OptionModel> options = new ArrayList<OptionModel>(); - for (String sectorName : serviceReferential.getSectors(getFilter().getFacadeName())) { + for (String sectorName : serviceReferential.getSectorsByUser(user, getFilter().getFacadeName())) { options.add(new OptionModelImpl(sectorName,sectorName)); } sectorSelectModel = new SelectModelImpl(null, options); @@ -259,7 +265,7 @@ /** * Used to show only active company and observers. * - * @return true if only active users will be showed, false either + * @return true if only active users will be showed, false otherwise */ protected abstract boolean getAvailableDataForFiltersOnly(); @@ -314,10 +320,39 @@ if (user.getAdmin()) { Company company = getCompanySelectModel().findObject(companyId); getFilter().setCompany(company); + } else { + getFilter().setCompany(user.getCompany()); } User observer = getObserverSelectModel().findObject(observerId); getFilter().setObserver(observer); } + + private boolean edited; + + public void onSelectedFromRefreshByFacade() throws SuiviObsmerException { + getFilter().setSectorName(null); + onSelectedFromRefreshBySector(); + resetSectorSelect(); + } + + public void onSelectedFromRefreshBySector() throws SuiviObsmerException { + onSelectedFromSearch(); + getFilter().setSampleRow(null); + resetSampleRowSelect(); + edited = true; + } + + public void onSelectedFromRefreshByCompany() throws SuiviObsmerException { + onSelectedFromSearch(); + getFilter().setObserver(null); + observerSelectModel = null; + getObserverSelectModel(); + edited = true; + } + + protected boolean isEdited() { + return edited; + } } Modified: trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/data/AbstractMappedGridDataSource.java =================================================================== --- trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/data/AbstractMappedGridDataSource.java 2010-01-22 18:48:46 UTC (rev 261) +++ trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/data/AbstractMappedGridDataSource.java 2010-01-23 17:59:23 UTC (rev 262) @@ -56,8 +56,8 @@ if (nbRows < 0) { try { nbRows = count(); - if (log.isDebugEnabled()) { - log.debug("Count : " + nbRows); + if (log.isTraceEnabled()) { + log.trace("Count : " + nbRows); } } catch (SuiviObsmerException eee) { throw new TapestryException("", eee); @@ -68,8 +68,8 @@ @Override public void prepare(int startIndex, int endIndex, List<SortConstraint> sortConstraints) { - if (log.isDebugEnabled()) { - log.debug("Prepare results : " + startIndex + ", " + endIndex); + if (log.isTraceEnabled()) { + log.trace("Prepare results : " + startIndex + ", " + endIndex); } nbRowsPerPage = endIndex - startIndex + 1; try { Modified: trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/BoatActivityCalendar.java =================================================================== --- trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/BoatActivityCalendar.java 2010-01-22 18:48:46 UTC (rev 261) +++ trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/BoatActivityCalendar.java 2010-01-23 17:59:23 UTC (rev 262) @@ -156,6 +156,14 @@ return result-1; } + /** Hack for pagelink to Boats page + * + * @return null + */ + public String getNorow() { + return null; + } + // public boolean hasZones() { // return getZoneIndexMax() != -1; // } Modified: trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/Boats.java =================================================================== --- trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/Boats.java 2010-01-22 18:48:46 UTC (rev 261) +++ trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/Boats.java 2010-01-23 17:59:23 UTC (rev 262) @@ -31,14 +31,12 @@ import fr.ifremer.suiviobsmer.entity.Company; import fr.ifremer.suiviobsmer.entity.Contact; import fr.ifremer.suiviobsmer.entity.ElligibleBoat; -import fr.ifremer.suiviobsmer.entity.FishingZone; import fr.ifremer.suiviobsmer.entity.Profession; import fr.ifremer.suiviobsmer.entity.SampleRow; import fr.ifremer.suiviobsmer.entity.User; import fr.ifremer.suiviobsmer.services.ServiceBoat; import fr.ifremer.suiviobsmer.services.ServiceReferential; import fr.ifremer.suiviobsmer.services.ServiceSampling; -import fr.ifremer.suiviobsmer.services.ServiceUser; import fr.ifremer.suiviobsmer.ui.base.AbstractFilteredPage; import fr.ifremer.suiviobsmer.ui.data.BusinessUtils; import fr.ifremer.suiviobsmer.ui.base.GenericSelectModel; @@ -68,7 +66,6 @@ import org.apache.tapestry5.annotations.Persist; import org.apache.tapestry5.annotations.Property; import org.apache.tapestry5.annotations.SessionState; -import org.apache.tapestry5.corelib.components.Form; import org.apache.tapestry5.corelib.components.Zone; import org.apache.tapestry5.ioc.annotations.Inject; import org.apache.tapestry5.ioc.services.PropertyAccess; @@ -120,6 +117,10 @@ @Property private String sampleRowContextId; + /** Selected boat immatriculation for showing boatInfos */ + @Property + private Integer boatSelectedImmatriculation; + @InjectComponent private FeedBack filterFeedback; @@ -142,21 +143,22 @@ // Initialize filters using AbstractFilteredPage superclass initSelectFilters(true, false); - // Only rows which are not finished nearly one month - getFilter().setNbMonthFinishedFromToday(-1); companyBoatInfos = null; - boatSelectedImmatriculation = null; + //boatSelectedImmatriculation = null; } void onActivate(EventContext ec) { if (ec.getCount() > 0) { sampleRowContextId = ec.get(String.class, 0); + if (ec.getCount() > 1) { + boatSelectedImmatriculation = ec.get(Integer.class, 1); + } } } - String onPassivate() { - return sampleRowContextId; + Object[] onPassivate() { + return new Object[] { sampleRowContextId, boatSelectedImmatriculation }; } /**************************** Import Forms ********************************/ @@ -277,7 +279,12 @@ @Override public BoatFilter getFilter() throws SuiviObsmerException { if (boatFilter == null) { + if (log.isDebugEnabled()) { + log.debug("Create filter"); + } boatFilter = new BoatFilterImpl(); + // Only rows which are not finished nearly one month + boatFilter.setNbMonthFinishedFromToday(-1); } return boatFilter; } @@ -374,15 +381,20 @@ /** * EVENT_SUCCESS :: for filtersForm. Reset persitant data to have new data using filters selected. * + * @return the filtersZone if it's a refresh data for select, or the page otherwise * @throws SuiviObsmerException for business errors */ - void onSuccessFromFiltersForm() throws SuiviObsmerException { + Object onSuccessFromFiltersForm() throws SuiviObsmerException { + if (isEdited()) { + return filtersZone.getBody(); + } // Suppress persistant boats list to get new one with filter boats = null; // Suppress persistant immatriculation for boat selected boatSelectedImmatriculation = null; // Suppress persistant boat informations for boat selected companyBoatInfos = null; + return this; } /**************************** Boats List *****************************************/ @@ -392,9 +404,9 @@ private BoatDataSource boats; /** Selected boat immatriculation for showing boatInfos */ - @Property - @Persist - private Integer boatSelectedImmatriculation; +// @Property +// @Persist +// private Integer boatSelectedImmatriculation; /** Current boat in the Grid */ @Property @@ -477,7 +489,7 @@ private ElligibleBoat elligibleBoat; @Property - private String boatInfosSampleRowCode; + private String boatInfosSampleRowId; private boolean boatInfosEditable; @@ -603,8 +615,13 @@ return boatInfosZone.getBody(); } - Block onActionFromEditBoatInfos() { + Block onActionFromEditBoatInfos() throws SuiviObsmerException { boatInfosEditable = true; + // WARNING :: Reset sampleRow select for edition mode, no limit for + // showing sampleRows instead of filters + getFilter().setNbMonthFinishedFromToday(null); + resetSampleRowSelect(); + getFilter().setNbMonthFinishedFromToday(-1); return boatInfosZone.getBody(); } @@ -625,8 +642,8 @@ void onSelectedFromAddBoatInfosSampleRow() throws SuiviObsmerException { // We stay in edition mode boatInfosEditable = true; - if (!StringUtils.isEmpty(boatInfosSampleRowCode)) { - SampleRow row = getSampleRowSelectModel().findObject(boatInfosSampleRowCode); + if (StringUtils.isNotEmpty(boatInfosSampleRowId)) { + SampleRow row = getSampleRowSelectModel().findObject(boatInfosSampleRowId); companyBoatInfos.setNewElligibleBoat(row); } } @@ -671,7 +688,8 @@ // Get selected boat from BoatInfos boat = getBoatInfos().getBoat(); // Get sampleRow from elligibleBoat list - sampleRow = getSampleRowSelectModel().findObject(sampleRowCode); + ElligibleBoat elligible = getCompanyBoatInfos().getElligibleBoat(sampleRowCode); + sampleRow = elligible.getSampleRow(); contacts.createNewContact(boat, sampleRow); return contacts; } Modified: trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/Contacts.java =================================================================== --- trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/Contacts.java 2010-01-22 18:48:46 UTC (rev 261) +++ trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/Contacts.java 2010-01-23 17:59:23 UTC (rev 262) @@ -49,7 +49,6 @@ import java.text.SimpleDateFormat; import java.util.Date; import java.util.List; -import java.util.Map; import org.apache.commons.lang.BooleanUtils; import org.apache.commons.lang.StringUtils; import org.apache.tapestry5.ComponentResources; @@ -70,6 +69,7 @@ import org.apache.tapestry5.services.BeanModelSource; import org.apache.tapestry5.services.Response; import org.apache.tapestry5.upload.services.UploadedFile; +import org.nuiton.util.DateUtils; import org.slf4j.Logger; /** @@ -150,9 +150,15 @@ private boolean reset; + @Property + private ContactState stateFilter; + public ContactFilter getContactFilter() throws SuiviObsmerException { if (contactFilter == null) { contactFilter = new ContactFilterImpl(); + // Initialized to 12 months before the current day + Date fromDate = DateUtils.createDateAfterToday(0, -12, 0); + contactFilter.setFromDate(fromDate); } return contactFilter; } @@ -162,25 +168,11 @@ return getContactFilter(); } -// @Override -// protected Zone getSampleRowFilterZone() { -// return filtersZone; -// } -// -// @Override -// protected Zone getObserverFilterZone() { -// return filtersZone; -// } - @Override protected boolean getAvailableDataForFiltersOnly() { return true; } - void onSuccessFromSearchBoat() { - - } - Object onActionFromShowFilters() { contactFilter = null; return filtersZone.getBody(); @@ -195,13 +187,14 @@ } @Log - void onSuccessFromFiltersForm() throws SuiviObsmerException { + Object onSuccessFromFiltersForm() throws SuiviObsmerException { + if (isEdited()) { + return filtersZone.getBody(); + } if (reset) { contactFilter = null; - filtersVisible = false; - } else { - filtersVisible = true; } + return this; } /**************************** CONTACT IMPORT/EXPORT ***********************/ @@ -264,8 +257,8 @@ private ContactModelFactory contactModelFactory; @Persist -// private ContactDataSource contacts; - private Map<String, Contact> contacts; + private ContactDataSource contacts; +// private Map<String, Contact> contacts; @Property private Contact contact; @@ -285,26 +278,26 @@ private boolean even = true; -// public ContactDataSource getContacts() throws SuiviObsmerException { -// if (contacts == null) { -// if (log.isInfoEnabled()) { -// log.info("Create DataSource"); -// } -// contacts = new ContactDataSource(getContactFilter(), serviceContact); -// } -// return contacts; -// } - - public Map<String, Contact> getContacts() throws SuiviObsmerException { + public ContactDataSource getContacts() throws SuiviObsmerException { if (contacts == null) { if (log.isInfoEnabled()) { - log.info("BUSINESS REQUEST [getContactsByFilter]"); + log.info("Create DataSource"); } - contacts = serviceContact.getContactsByFilter(getContactFilter()); + contacts = new ContactDataSource(getContactFilter(), serviceContact); } return contacts; } +// public Map<String, Contact> getContacts() throws SuiviObsmerException { +// if (contacts == null) { +// if (log.isInfoEnabled()) { +// log.info("BUSINESS REQUEST [getContactsByFilter]"); +// } +// contacts = serviceContact.getContactsByFilter(getContactFilter()); +// } +// return contacts; +// } + public BeanModel<Contact> getContactModel() { if (contactModel == null) { contactModel = user.getAdmin() ? Modified: trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/Synthesis.java =================================================================== --- trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/Synthesis.java 2010-01-22 18:48:46 UTC (rev 261) +++ trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/pages/Synthesis.java 2010-01-23 17:59:23 UTC (rev 262) @@ -87,11 +87,8 @@ private BoatFilter dataSamplingFilter; @InjectComponent - private Zone sampleRowZone; + private Zone filtersZone; - @InjectComponent - private Zone observerZone; - @Persist private ChartType dataSamplingChartType; @@ -113,16 +110,6 @@ return dataSamplingFilter; } -// @Override -// protected Zone getSampleRowFilterZone() { -// return sampleRowZone; -// } -// -// @Override -// protected Zone getObserverFilterZone() { -// return observerZone; -// } - @Override protected boolean getAvailableDataForFiltersOnly() { return false; @@ -167,10 +154,14 @@ reset = true; } - void onSuccessFromFiltersForm() { + Object onSuccessFromFiltersForm() { + if (isEdited()) { + return filtersZone.getBody(); + } if (reset) { dataSamplingFilter = null; } + return this; } } Modified: trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/services/ContactModelFactory.java =================================================================== --- trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/services/ContactModelFactory.java 2010-01-22 18:48:46 UTC (rev 261) +++ trunk/suiviobsmer-ui/src/main/java/fr/ifremer/suiviobsmer/ui/services/ContactModelFactory.java 2010-01-23 17:59:23 UTC (rev 262) @@ -55,8 +55,10 @@ // New properties for contactModel contactModel.add("createdBy", null); - contactModel.add(Contact.SAMPLE_ROW, getSampleRowPropertyConduit()); - contactModel.add(Contact.BOAT, getBoatPropertyConduit()); +// contactModel.add(Contact.SAMPLE_ROW, getSampleRowPropertyConduit()); +// contactModel.add(Contact.BOAT, getBoatPropertyConduit()); + contactModel.add(Contact.SAMPLE_ROW, null); + contactModel.add(Contact.BOAT, null); contactModel.add("mammals", null); contactModel.add("validation", null); contactModel.add("actions", null); @@ -75,6 +77,14 @@ Contact.COMMENT, "validation", "actions"); + + contactModel.get(TopiaEntity.TOPIA_CREATE_DATE).sortable(false); + contactModel.get(Contact.STATE).sortable(false); + contactModel.get(Contact.TIDE_BEGIN_DATE).sortable(false); + contactModel.get(Contact.TIDE_END_DATE).sortable(false); + contactModel.get(Contact.NB_OBSERVANTS).sortable(false); + contactModel.get(Contact.DATA_INPUT_DATE).sortable(false); + contactModel.get(Contact.COMMENT).sortable(false); return contactModel; } @@ -93,6 +103,30 @@ contactModel.add(RelativePosition.AFTER, "fishingZoneSector", "fishingZoneDivision", getFishingZoneDivisionPropertyConduit()); contactModel.add(RelativePosition.AFTER, Contact.BOAT, "boatImmatriculation", getBoatImmatriculationPropertyConduit()); contactModel.add(RelativePosition.AFTER, "boatImmatriculation", "boatDistrictCode", getBoatDistrictCodePropertyConduit()); + + contactModel.get("observer").sortable(false); + contactModel.get(User.COMPANY).sortable(false); + contactModel.get("program").sortable(false); + contactModel.get("professionCode").sortable(false); + contactModel.get("professionLibelle").sortable(false); + contactModel.get("professionSpecies").sortable(false); + contactModel.get("fishingZoneFacade").sortable(false); + contactModel.get("fishingZoneSector").sortable(false); + contactModel.get("fishingZoneDivision").sortable(false); + contactModel.get("boatImmatriculation").sortable(false); + contactModel.get("boatDistrictCode").sortable(false); + +// contactModel.add(RelativePosition.AFTER, TopiaEntity.TOPIA_CREATE_DATE, "observer", null); +// contactModel.add(RelativePosition.AFTER, "observer", User.COMPANY, null); +// contactModel.add(RelativePosition.AFTER, Contact.SAMPLE_ROW, "program", null); +// contactModel.add(RelativePosition.AFTER, "program", "professionCode", null); +// contactModel.add(RelativePosition.AFTER, "professionCode", "professionLibelle", null); +// contactModel.add(RelativePosition.AFTER, "professionLibelle", "professionSpecies", null); +// contactModel.add(RelativePosition.AFTER, "professionSpecies", "fishingZoneFacade", null); +// contactModel.add(RelativePosition.AFTER, "fishingZoneFacade", "fishingZoneSector", null); +// contactModel.add(RelativePosition.AFTER, "fishingZoneSector", "fishingZoneDivision", null); +// contactModel.add(RelativePosition.AFTER, Contact.BOAT, "boatImmatriculation", null); +// contactModel.add(RelativePosition.AFTER, "boatImmatriculation", "boatDistrictCode", null); return contactModel; } Modified: trunk/suiviobsmer-ui/src/main/resources/fr/ifremer/suiviobsmer/ui/pages/Boats.properties =================================================================== --- trunk/suiviobsmer-ui/src/main/resources/fr/ifremer/suiviobsmer/ui/pages/Boats.properties 2010-01-22 18:48:46 UTC (rev 261) +++ trunk/suiviobsmer-ui/src/main/resources/fr/ifremer/suiviobsmer/ui/pages/Boats.properties 2010-01-23 17:59:23 UTC (rev 262) @@ -2,8 +2,9 @@ activityCalendarsCsvFile-label: Fichier CSV des calendriers d'activit\u00E9 # FILTERS -sampleRow-label: Ligne du plan +sampleRow-label: M\u00E9tier facadeName-label: Fa\u00E7ade +sectorName-label: Zone profession-label: M\u00E9tier du plan boatName-label: Navire districtCode-label: Quartier Modified: trunk/suiviobsmer-ui/src/main/resources/fr/ifremer/suiviobsmer/ui/pages/Contacts.properties =================================================================== --- trunk/suiviobsmer-ui/src/main/resources/fr/ifremer/suiviobsmer/ui/pages/Contacts.properties 2010-01-22 18:48:46 UTC (rev 261) +++ trunk/suiviobsmer-ui/src/main/resources/fr/ifremer/suiviobsmer/ui/pages/Contacts.properties 2010-01-23 17:59:23 UTC (rev 262) @@ -3,6 +3,7 @@ sectorName-label: Secteur observer-label: Observateur contactsCsvFile-label: Fichier des contacts +fromDate-label: Depuis le # Grid labels createdBy-label: Observateur Modified: trunk/suiviobsmer-ui/src/main/webapp/BoatActivityCalendar.tml =================================================================== --- trunk/suiviobsmer-ui/src/main/webapp/BoatActivityCalendar.tml 2010-01-22 18:48:46 UTC (rev 261) +++ trunk/suiviobsmer-ui/src/main/webapp/BoatActivityCalendar.tml 2010-01-23 17:59:23 UTC (rev 262) @@ -4,6 +4,13 @@ <t:if t:test="activityCalendar"> <h1>Calendrier d'activité ${activityCalendar.year}</h1> + <p class="acenter"> + <a t:type="pagelink" class="return" t:context="[norow,activityCalendar.boat.immatriculation]" t:page="boats" title="Revenir sur les informations du navire"> + <img src="${asset:context:}/img/boat.png" alt="Navire"/> + Retour sur ${activityCalendar.boat.name} + <img src="${asset:context:}/img/boat.png" alt="Navire"/> + </a> + </p> <table t:type="grid" id="so-activity-calendar-boat" t:source="boats" t:row="boat" t:include="immatriculation, districtCode, name, boatLength, buildYear" /> Modified: trunk/suiviobsmer-ui/src/main/webapp/Boats.tml =================================================================== --- trunk/suiviobsmer-ui/src/main/webapp/Boats.tml 2010-01-22 18:48:46 UTC (rev 261) +++ trunk/suiviobsmer-ui/src/main/webapp/Boats.tml 2010-01-23 17:59:23 UTC (rev 262) @@ -65,35 +65,32 @@ </div> <t:feedback t:id="filterFeedback" /> <div class="so-filters-form ${hiddenStyle}"> - <form t:type="form" t:id="filtersForm"> + <form t:type="form" t:id="filtersForm" t:zone="so-boats-filters"> <t:errors /> <div class="t-beaneditor"> - <t:beaneditor t:id="filtersEditor" t:object="filter" - t:include="boatName" t:add="facade, sampleRow, profession" t:reorder="facade, sampleRow, profession, boatName"> - <p:facade> - <t:label t:for="facadeName" /> - <select t:type="select" t:id="facadeName" t:model="facadeSelectModel" value="filter.facadeName" /> - <span> zone </span> - <select t:type="select" t:id="sectorName" t:model="sectorSelectModel" value="filter.sectorName" /> - </p:facade> - <p:sampleRow> - <t:label t:for="sampleRow" /> - <select t:type="select" t:id="sampleRow" t:disabled="sampleRowExists" t:model="sampleRowSelectModel" value="sampleRowId" /> - </p:sampleRow> - <p:profession> - <t:label t:for="profession" /> - <select t:type="select" t:id="profession" t:disabled="sampleRowExists" t:model="professionSelectModel" value="professionId" /> - </p:profession> - <p:boatName> - <t:label t:for="boatName" /> - <span> nom </span> - <input t:type="textfield" t:id="boatName" class="width150" t:value="filter.boatName" t:mixins="Autocomplete" /> - <span> immatriculation </span> - <input t:type="textfield" t:id="boatImmatriculation" class="width50" t:value="filter.boatImmatriculation" /> - <span> code quartier </span> - <input t:type="textfield" t:id="boatDistrictCode" class="width50" t:value="filter.boatDistrictCode" /> - </p:boatName> - </t:beaneditor> + <div> + <!-- Sampling filter --> + <t:label t:for="facadeName" />: + <select t:type="select" t:id="facadeName" t:model="facadeSelectModel" value="filter.facadeName" /> + <input t:type="submit" class="ico22px refresh" t:id="refreshByFacade" value="Refresh" + title="Rafraîchir les zones et les métiers en fonction de la façade sélectionnée"/> + <t:label t:for="sectorName" />: + <select t:type="select" t:id="sectorName" t:model="sectorSelectModel" value="filter.sectorName" /> + <input t:type="submit" class="ico22px refresh" t:id="refreshBySector" value="Refresh" + title="Rafraîchir les métiers en fonction de la zone sélectionnée"/> + <t:label t:for="sampleRow" />: + <select t:type="select" t:id="sampleRow" t:disabled="sampleRowExists" t:model="sampleRowSelectModel" value="sampleRowId" /> + </div><p> </p> + <div> + <!-- Boat filter --> + <t:label t:for="boatName" /> + <span> nom </span> + <input t:type="textfield" t:id="boatName" class="width150" t:value="filter.boatName" t:mixins="Autocomplete" /> + <span> immatriculation </span> + <input t:type="textfield" t:id="boatImmatriculation" class="width50" t:value="filter.boatImmatriculation" /> + <span> code quartier </span> + <input t:type="textfield" t:id="boatDistrictCode" class="width50" t:value="filter.boatDistrictCode" /> + </div> <div class="t-beaneditor-row aright"> <input t:type="submit" class="ico search-32px" t:id="search" value="Search" /> <input t:type="submit" class="ico undo" t:id="reset" value="Reset" /> @@ -347,7 +344,7 @@ </ul> <p> <input t:type="select" t:id="sampleRowSelect" t:model="sampleRowSelectModel" - t:value="boatInfosSampleRowCode"/> + t:value="boatInfosSampleRowId"/> <input t:type="submit" t:id="addBoatInfosSampleRow" class="ico add" value="Add" t:title="Associer à une ligne du plan" /> </p> @@ -361,9 +358,4 @@ </t:if> </div> - <!-- Script for filters change --> - <script type="text/javascript"> - Event.observe('facadeName', 'change', function() { $('filtersForm').submit(); } ); - Event.observe('sectorName', 'change', function() { $('filtersForm').submit(); } ); - </script> </t:layout> Modified: trunk/suiviobsmer-ui/src/main/webapp/Contacts.tml =================================================================== --- trunk/suiviobsmer-ui/src/main/webapp/Contacts.tml 2010-01-22 18:48:46 UTC (rev 261) +++ trunk/suiviobsmer-ui/src/main/webapp/Contacts.tml 2010-01-23 17:59:23 UTC (rev 262) @@ -23,21 +23,28 @@ <fieldset> <legend>Recherche avancée</legend> <div class="so-filters-form"> - <form t:type="form" t:id="filtersForm"> + <form t:type="form" t:id="filtersForm" t:zone="so-contacts-filters"> <t:errors /> <div class="t-beaneditor"> <div> + <!-- Boat filter --> <label>Navire </label> <t:label t:for="boatImmatriculation" />: <input t:type="textfield" t:id="boatImmatriculation" class="width50" t:value="contactFilter.boatImmatriculation" /> <t:label t:for="boatDistrictCode" />: <input t:type="textfield" t:id="boatDistrictCode" class="width50" t:value="contactFilter.boatDistrictCode" /> + <!-- Sampling filter --> <t:label t:for="facadeName" />: <select t:type="select" t:id="facadeName" t:model="facadeSelectModel" value="contactFilter.facadeName" /> + <input t:type="submit" class="ico22px refresh" t:id="refreshByFacade" value="Refresh" + title="Rafraîchir les zones et les métiers en fonction de la façade sélectionnée"/> <t:label t:for="sectorName" />: <select t:type="select" t:id="sectorName" t:model="sectorSelectModel" value="contactFilter.sectorName" /> + <input t:type="submit" class="ico22px refresh" t:id="refreshBySector" value="Refresh" + title="Rafraîchir les métiers en fonction de la zone sélectionnée"/> <t:label t:for="sampleRow" />: <input t:type="select" t:id="sampleRow" t:model="sampleRowSelectModel" value="sampleRowId" /> + <!-- Contact filter --> <label>Mammifères: </label> <input t:type="checkbox" t:id="mammalsObservation1" value="contactFilter.mammalsObservation" /> <t:label t:for="mammalsObservation1"> @@ -49,12 +56,20 @@ </t:label> </div><p> </p> <div> + <t:label t:for="fromDate" />: + <input t:type="datefield" class="width70" t:id="fromDate" value="contactFilter.fromDate" /> <t:if t:test="user.admin"> <t:label t:for="company" />: <input t:type="select" t:id="company" t:model="companySelectModel" value="companyId"/> + <input t:type="submit" class="ico22px refresh" t:id="refreshByCompany" value="Refresh" + title="Rafraîchir les observateurs en fonction de la société sélectionnée"/> </t:if> <t:label t:for="observer" />: - <input t:type="select" t:id="observer" t:model="observerSelectModel" value="observerId" /> + <select t:type="select" t:id="observer" t:model="observerSelectModel" value="observerId" /> + </div><p> </p> + <div> + <t:label t:for="state" />: + <select t:type="select" t:id="state" value="contactFilter.state"/> <label>Validation société: </label> <input t:type="checkbox" t:id="companyAccepted" value="contactFilter.companyAccepted" /> <t:label t:for="companyAccepted"> @@ -112,7 +127,7 @@ <t:zone t:id="gridZone" t:update="show"> <form t:type="form" t:id="contactsForm" t:zone="gridZone"> <t:errors id="so-contact-form-errors" t:banner="message:contactsForm-errors-banner"/> - <div t:type="grid" t:source="contacts.values()" t:row="contact" class="t-data-grid ${gridClass}" t:model="contactModel" t:rowClass="prop:rowClass" + <div t:type="grid" t:source="contacts" t:row="contact" class="t-data-grid ${gridClass}" t:model="contactModel" t:rowClass="prop:rowClass" t:rowsPerPage="20"> <p:createdByCell> <t:if t:test="editionMode"> @@ -215,7 +230,7 @@ <img src="${asset:context:}/img/comment-22px.png" alt="Add comment" /> </a> </span> - <textarea t:type="textarea" t:id="comment" class="hidden-textarea" cols="0" rows="0" value="contact.comment" /> + <textarea t:type="textarea" t:id="comment" class="hidden" value="contact.comment" /> <div t:type="ck/Window" t:id="windowComment" show="false" modal="true" title="literal:Ajouter un commentaire" width="488" height="210"> @@ -279,14 +294,5 @@ </div> </form> </t:zone> -<script type="text/javascript"> - Event.observe('facadeName', 'change', function() { $('filtersForm').submit(); } ); - Event.observe('sectorName', 'change', function() { $('filtersForm').submit(); } ); -</script> -<t:if t:test="user.admin"> - <script type="text/javascript"> - Event.observe('company', 'change', function() { $('filtersForm').submit(); } ); - </script> - </t:if> </t:layout> Modified: trunk/suiviobsmer-ui/src/main/webapp/Synthesis.tml =================================================================== --- trunk/suiviobsmer-ui/src/main/webapp/Synthesis.tml 2010-01-22 18:48:46 UTC (rev 261) +++ trunk/suiviobsmer-ui/src/main/webapp/Synthesis.tml 2010-01-23 17:59:23 UTC (rev 262) @@ -46,9 +46,9 @@ <div class="acenter" id="so-datasampling"> <fieldset> <legend>Filtres</legend> - <div class="so-filters-form"> + <div t:type="zone" t:id="filtersZone" class="so-filters-form" id="so-datasampling-filters" t:update="show"> <!--<div t:type="zone" t:id="dataSamplingFiltersZone" t:update="show" id="so-datasampling-filters">--> - <form t:type="form" t:id="filtersForm"> + <form t:type="form" t:id="filtersForm" t:zone="so-datasampling-filters"> <t:errors /> <div class="t-beaneditor"> <div class="filterRow"> @@ -60,33 +60,25 @@ </div> <div class="filterRow" t:type="zone" t:id="sampleRowZone" t:update="show"> <t:label t:for="facadeName" />: - <select t:type="select" t:id="facadeName" t:model="facadeSelectModel" value="filter.facadeName" - /> + <select t:type="select" t:id="facadeName" t:model="facadeSelectModel" value="filter.facadeName" /> + <input t:type="submit" class="ico22px refresh" t:id="refreshByFacade" value="Refresh" + title="Rafraîchir les zones et les métiers en fonction de la façade sélectionnée"/> <t:label t:for="sectorName" />: <select t:type="select" t:id="sectorName" t:model="sectorSelectModel" value="filter.sectorName" /> - <t:label t:for="sampleRow" />: - <input t:type="select" t:id="sampleRow" t:model="sampleRowSelectModel" value="sampleRowId" /> + <input t:type="submit" class="ico22px refresh" t:id="refreshBySector" value="Refresh" + title="Rafraîchir les métiers en fonction de la zone sélectionnée"/> + <!--<t:label t:for="program" />: <input t:type="select" t:id="program" t:model="programSelectModel" value="programId" />--> </div> -<!-- <div class="filterRow"> - <label>Navire: </label> - <t:label t:for="boatName" />: - <input t:type="textfield" t:id="boatName" t:value="filter.boatName" t:mixins="Autocomplete" /> - <t:label t:for="boatImmatriculation" />: - <input t:type="textfield" t:id="boatImmatriculation" class="width50" t:value="filter.boatImmatriculation" /> - <t:label t:for="boatDistrictCode" />: - <input t:type="textfield" t:id="boatDistrictCode" class="width50" t:value="filter.boatDistrictCode" /> - </div>--> - <t:if t:test="user.admin"> - <div t:type="zone" t:id="observerZone" t:update="show"> - <!--<t:label t:for="observer" />: - <input t:type="select" t:id="observer" t:model="observerSelectModel" value="observerId" />--> - - <t:label t:for="company" />: + <div> + <t:label t:for="sampleRow" />: + <input t:type="select" t:id="sampleRow" t:model="sampleRowSelectModel" value="sampleRowId" /> + <t:if t:test="user.admin"> + <t:label t:for="company" />: <input t:type="select" t:id="company" t:model="companySelectModel" value="companyId"/> - </div> - </t:if> + </t:if> + </div> <div class="t-beaneditor-row aright"> <input t:type="submit" class="ico search-32px" t:id="search" value="Search" /> <input t:type="submit" class="ico undo" t:id="reset" value="Reset" /> @@ -109,8 +101,4 @@ </p> <t:chart t:width="600" t:height="400" t:chart="dataSamplingChart" /> </div> -<script type="text/javascript"> - Event.observe('facadeName', 'change', function() { $('filtersForm').submit(); } ); - Event.observe('sectorName', 'change', function() { $('filtersForm').submit(); } ); -</script> </t:layout> Modified: trunk/suiviobsmer-ui/src/main/webapp/css/boats.css =================================================================== --- trunk/suiviobsmer-ui/src/main/webapp/css/boats.css 2010-01-22 18:48:46 UTC (rev 261) +++ trunk/suiviobsmer-ui/src/main/webapp/css/boats.css 2010-01-23 17:59:23 UTC (rev 262) @@ -19,6 +19,10 @@ width: 60%; } +div#so-boats-filters { + width: 70%; +} + /*div.so-filters { width: 60%; margin-left: auto; @@ -197,4 +201,15 @@ table#so-activity-calendar-months tr.profession { background-color: silver; +} + +div#so-activity-calendar a.return { + text-decoration: none; + color: #19a28d; + font-weight: bold; +} + +div#so-activity-calendar a.return:hover { + text-decoration: underline; + color: black; } \ No newline at end of file Modified: trunk/suiviobsmer-ui/src/main/webapp/css/contacts.css =================================================================== --- trunk/suiviobsmer-ui/src/main/webapp/css/contacts.css 2010-01-22 18:48:46 UTC (rev 261) +++ trunk/suiviobsmer-ui/src/main/webapp/css/contacts.css 2010-01-23 17:59:23 UTC (rev 262) @@ -168,9 +168,3 @@ input.nbObservants { width: 18px; } - -textarea.hidden-textarea { - border: 0; - width: 0; - height: 0; -}