Author: bleny Date: 2011-06-07 12:43:43 +0000 (Tue, 07 Jun 2011) New Revision: 1321 Log: add management of estimation in synthesis for ObsDeb ; refactor ServiceContact to ease location management Modified: trunk/wao-business/src/main/java/fr/ifremer/wao/entity/ContactImpl.java trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceContactImpl.java trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceReferentialImpl.java trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceSynthesisImpl.java trunk/wao-business/src/main/resources/i18n/wao-business_en_GB.properties trunk/wao-business/src/main/resources/i18n/wao-business_fr_FR.properties trunk/wao-business/src/main/xmi/wao.zargo trunk/wao-business/src/test/java/fr/ifremer/wao/business/ObsDebFieldWorkTest.java trunk/wao-business/src/test/java/fr/ifremer/wao/service/AbstractServiceTest.java trunk/wao-business/src/test/java/fr/ifremer/wao/service/ServiceContactInternalTest.java trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/components/SamplingFilterComponent.java trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/ContactForm.java trunk/wao-ui/src/main/resources/fr/ifremer/wao/ui/components/SamplingFilterComponent.tml Modified: trunk/wao-business/src/main/java/fr/ifremer/wao/entity/ContactImpl.java =================================================================== --- trunk/wao-business/src/main/java/fr/ifremer/wao/entity/ContactImpl.java 2011-06-06 15:47:32 UTC (rev 1320) +++ trunk/wao-business/src/main/java/fr/ifremer/wao/entity/ContactImpl.java 2011-06-07 12:43:43 UTC (rev 1321) @@ -78,13 +78,13 @@ */ @Override public Date getReferenceDate() { - if (log.isDebugEnabled()) { - log.debug("topia " + getTopiaCreateDate()); + Date referenceDate; + if (getObservationBeginDate() == null) { + referenceDate = getCreationDate(); + } else { + referenceDate = getObservationBeginDate(); } - if (getObservationBeginDate() != null) { - return getObservationBeginDate(); - } - return getTopiaCreateDate(); + return referenceDate; } @Override 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 2011-06-06 15:47:32 UTC (rev 1320) +++ trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceContactImpl.java 2011-06-07 12:43:43 UTC (rev 1321) @@ -175,6 +175,7 @@ } else if (sampleRow.isFieldWorkObservation()) { sampleRow.getObservationUnit().getRegionIfremer(); } + contact.getTerrestrialLocation(); } } @@ -272,19 +273,18 @@ if (contact.getObsProgram() == ObsProgram.OBSDEB) { - if (success && contact.getObservationType() == ObservationType.FIELD_WORK_OBSERVATION && - contact.getContactState() != ContactState.OBSERVATION_DONE) { - success = false; - message = "Pour le type d'observation '" + contact.getObservationType().toString() - + "', l'état est obligatoirement '" + ContactState.OBSERVATION_DONE.toString() + "."; - } + if (contact.getContactState() == ContactState.OBSERVATION_DONE) { - if (success && contact.getSampleRow().isFieldWorkObservation() && - contact.getTerrestrialLocation() == null) { - success = false; - message = "Il faut préciser un lieu d'observation"; + if (success && contact.getTerrestrialLocation() == null) { + success = false; + message = "Il faut préciser un lieu d'observation"; + } + + if (success && contact.getObsDebCode() == null) { + success = false; + message = "Il faut préciser le code métier de la marée"; + } } - } else { // Validation for saving contact depends on contactState @@ -338,12 +338,6 @@ message = "La date de saisie des données ne peut pas être postérieure à la date du jour"; } - if (success && contact.getObsProgram() == ObsProgram.OBSVENTE && - contact.getTerrestrialLocation() == null) { - success = false; - message = "Il faut préciser un lieu d'observation"; - } - // Non abouti, Refus ou Refus Définitif if (success && contactState.isUnfinishedState()) { @@ -396,6 +390,11 @@ success = false; message = "Il ne peut y avoir aucun observateur pour l'état '" + contactState + "'"; } + if (success && contact.getObsProgram() == ObsProgram.OBSVENTE && + contact.getTerrestrialLocation() == null) { + success = false; + message = "Il faut préciser un lieu d'observation"; + } if (log.isDebugEnabled()) { log.debug("validationProgram = " + contact.isValidationProgram()); @@ -470,7 +469,7 @@ if (row.isPhoneCall()) { newContact.setContactState(ContactState.CONTACT_START); } else if (row.isFieldWorkObservation()) { - newContact.setContactState(ContactState.OBSERVATION_DONE); + newContact.setContactState(ContactState.OBSERVATION_EXPECTED); } } @@ -511,10 +510,7 @@ // on the field work, the observer went in the observation unit // given in the row. If this unit contains only one port, we // can suppose he went in this one - ServiceReferential serviceReferential = - context.getServiceFactory().getServiceReferential(); - List<TerrestrialLocation> allPorts = - serviceReferential.getAllPorts(row.getObservationUnit()); + List<TerrestrialLocation> allPorts = executeGetPossibleTerrestrialLocations(transaction, newContact); if (allPorts.size() == 1) { newContact.setTerrestrialLocation(allPorts.get(0)); } @@ -550,7 +546,7 @@ Contact similarContact = null; // to be found among candidates for (Contact candidate : candidates) { - if (DateUtil.getDifferenceInDays(candidate.getTopiaCreateDate(), context.getCurrentDate()) <= 1) { + if (DateUtil.getDifferenceInDays(candidate.getCreationDate(), context.getCurrentDate()) <= 1) { similarContact = candidate; } } @@ -572,6 +568,10 @@ newContact.setTerrestrialLocation(similarContact.getTerrestrialLocation()); newContact.clearSecondaryObservers(); newContact.addAllSecondaryObservers(similarContact.getSecondaryObservers()); + if (similarContact.getBoat().getImmatriculation() == + newContact.getBoat().getImmatriculation()) { + newContact.setObservationType(ObservationType.FIELD_WORK_SURVEY); + } } } @@ -1211,7 +1211,7 @@ ImportHelper.parseContactCreateDate( contactCode, createDateCsv); - contact.setTopiaCreateDate(createDate); + contact.setCreationDate(createDate); contact.setDataReliability(DataReliability.valueOf( ImportHelper.read(reader, CONTACT.CONT_DATA_RELIABILITY))); @@ -1469,4 +1469,30 @@ return possibleObsDebCodes; } + + @Override + protected List<TerrestrialLocation> executeGetPossibleTerrestrialLocations(TopiaContext transaction, Contact contact) { + List<TerrestrialLocation> terrestrialLocations; + ServiceReferential serviceReferential = context.getServiceFactory().getServiceReferential(); + SampleRow sampleRow = contact.getSampleRow(); + if (contact.getObsProgram() == ObsProgram.OBSVENTE) { + // we must choose a port, or an auction in the district + // specified in the sampling plan + terrestrialLocations = serviceReferential.getAllPortsAndAuctions( + sampleRow.getTerrestrialLocation()); + } else if (contact.getObsProgram() == ObsProgram.OBSDEB) { + // me must choose a port (not auction) in the region + // specified in the plan + TerrestrialLocation region; + if (sampleRow.isFieldWorkObservation()) { + region = sampleRow.getObservationUnit().getRegionIfremer(); + } else { + region = sampleRow.getTerrestrialLocation(); + } + terrestrialLocations = serviceReferential.getAllPorts(region); + } else { + throw new IllegalArgumentException(); + } + return terrestrialLocations; + } } Modified: trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceReferentialImpl.java =================================================================== --- trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceReferentialImpl.java 2011-06-06 15:47:32 UTC (rev 1320) +++ trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceReferentialImpl.java 2011-06-07 12:43:43 UTC (rev 1321) @@ -75,6 +75,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import javax.xml.stream.Location; import java.io.IOException; import java.io.InputStream; import java.util.Arrays; @@ -403,12 +404,16 @@ /** Find ports and auctions in a given district */ @Override - protected List<TerrestrialLocation> executeGetAllTerrestrialLocations(TopiaContext transaction, - ContactFilter filter, String districtCode) throws Exception { + protected List<TerrestrialLocation> executeGetAllPortsAndAuctions(TopiaContext transaction, TerrestrialLocation district) throws Exception { + + if ( ! district.isDistrict()) { + throw new IllegalArgumentException(); + } + TerrestrialLocationDAOImpl dao = WaoDAOHelper.getTerrestrialLocationDAO(transaction); Map<String, Object> properties = new HashMap<String, Object>(); - properties.put(TerrestrialLocation.PROPERTY_DISTRICT_CODE, districtCode); + properties.put(TerrestrialLocation.PROPERTY_DISTRICT_CODE, district.getDistrictCode()); properties.put(TerrestrialLocation.PROPERTY_LOCATION_TYPE_ORDINAL, LocationType.PORT.ordinal()); List<TerrestrialLocation> result = dao.findAllByProperties(properties); @@ -624,38 +629,32 @@ return observationUnits; } - /** Returns all the ports that are in a given observation unit - * @param observationUnit may be null, and all ports will be returned + /** Returns all the ports that are in a region + * @param region may be null, and all ports will be returned */ @Override - protected List<TerrestrialLocation> executeGetAllPorts(TopiaContext transaction, TerrestrialDivision observationUnit) throws Exception { + protected List<TerrestrialLocation> executeGetAllPorts + (TopiaContext transaction, TerrestrialLocation region) + throws Exception { + TerrestrialLocationDAO dao = + WaoDAOHelper.getTerrestrialLocationDAO(transaction); + Map<String, Object> properties = new HashMap<String, Object>(); - List<TerrestrialLocation> ports; + // we are looking for ports only + properties.put(TerrestrialLocation.PROPERTY_LOCATION_TYPE_ORDINAL, + LocationType.PORT.ordinal()); - if (observationUnit == null) { - - TerrestrialLocationDAOImpl terrestrialLocationDAO = WaoDAOHelper.getTerrestrialLocationDAO(transaction); - ports = terrestrialLocationDAO.findAllByLocationType(LocationType.PORT); - - } else { - - TerrestrialDivisionDAO terrestrialDivisionDAO = WaoDAOHelper.getTerrestrialDivisionDAO(transaction); - - Map<String, Object> properties = new HashMap<String, Object>(); - properties.put(TerrestrialDivision.PROPERTY_OBSERVATION_UNIT_CODE, observationUnit.getObservationUnitCode()); - properties.put(TerrestrialDivision.PROPERTY_REGION_IFREMER, observationUnit.getRegionIfremer()); - List<TerrestrialDivision> terrestrialDivisions = terrestrialDivisionDAO.findAllByProperties(properties); - - ports = new LinkedList<TerrestrialLocation>(); - for (TerrestrialDivision terrestrialDivision : terrestrialDivisions) { - if ( ! terrestrialDivision.isObservationUnit()) { - TerrestrialLocation port = terrestrialDivision.getPort(); - ports.add(port); - port.getDescription(); - } + // ports in a specific region + if (region != null) { + if ( ! region.isRegion()) { + throw new IllegalArgumentException(); } + properties.put(TerrestrialLocation.PROPERTY_REGION_IFREMER_CODE, + region.getRegionIfremerCode()); } + // run query + List<TerrestrialLocation> ports = dao.findAllByProperties(properties); return ports; } Modified: trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceSynthesisImpl.java =================================================================== --- trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceSynthesisImpl.java 2011-06-06 15:47:32 UTC (rev 1320) +++ trunk/wao-business/src/main/java/fr/ifremer/wao/service/ServiceSynthesisImpl.java 2011-06-07 12:43:43 UTC (rev 1321) @@ -1255,9 +1255,18 @@ @Override protected Map<String, Map<String, Integer>> executeGetObservationHours(TopiaContext transaction, SamplingFilter samplingFilter) throws Exception { + WaoQueryHelper.ContactProperty contactProperty = WaoQueryHelper.newContactProperty(); WaoQueryBuilder builder = context.newQueryBuilder(); builder.initializeForContact(); - TopiaQuery query = builder.applySamplingFilter(samplingFilter); + TopiaQuery query = builder.applySamplingFilter(samplingFilter). + addNullOr(contactProperty.validationProgram(), Op.EQ, Boolean.TRUE); + + if (samplingFilter.getEstimatedTides()) { + query.addNullOr(contactProperty.validationCompany(), Op.EQ, Boolean.TRUE); + } else { + query.addEquals(contactProperty.validationCompany(), Boolean.TRUE); + } + ContactDAO contactDAO = WaoDAOHelper.getContactDAO(transaction); List<Contact> contacts = contactDAO.findAllByQuery(query); if (log.isDebugEnabled()) { @@ -1359,9 +1368,17 @@ @Override protected Map<String, Map<String, Integer>> executeGetDistinctBoatsCounts(TopiaContext transaction, SamplingFilter samplingFilter) throws Exception { + WaoQueryHelper.ContactProperty contactProperty = WaoQueryHelper.newContactProperty(); WaoQueryBuilder builder = context.newQueryBuilder(); builder.initializeForContact(); - TopiaQuery query = builder.applySamplingFilter(samplingFilter); + TopiaQuery query = builder.applySamplingFilter(samplingFilter). + addNullOr(contactProperty.validationProgram(), Op.EQ, Boolean.TRUE); + + if (samplingFilter.getEstimatedTides()) { + query.addNullOr(contactProperty.validationCompany(), Op.EQ, Boolean.TRUE); + } else { + query.addEquals(contactProperty.validationCompany(), Boolean.TRUE); + } ContactDAO contactDAO = WaoDAOHelper.getContactDAO(transaction); List<Contact> contacts = contactDAO.findAllByQuery(query); Modified: trunk/wao-business/src/main/resources/i18n/wao-business_en_GB.properties =================================================================== --- trunk/wao-business/src/main/resources/i18n/wao-business_en_GB.properties 2011-06-06 15:47:32 UTC (rev 1320) +++ trunk/wao-business/src/main/resources/i18n/wao-business_en_GB.properties 2011-06-07 12:43:43 UTC (rev 1321) @@ -176,6 +176,7 @@ wao.error.serviceContact.getNbContacts= wao.error.serviceContact.getNewContact= wao.error.serviceContact.getPossibleObsDebCodes= +wao.error.serviceContact.getPossibleTerrestrialLocations= wao.error.serviceContact.getPossibleValuesForFilter= wao.error.serviceContact.getSubstitutesForBoat= wao.error.serviceContact.importContactCsv= @@ -193,6 +194,7 @@ wao.error.serviceReferential.getAllObsDebCodes= wao.error.serviceReferential.getAllObservationUnits= wao.error.serviceReferential.getAllPorts= +wao.error.serviceReferential.getAllPortsAndAuctions= wao.error.serviceReferential.getAllRegionIfremers= wao.error.serviceReferential.getAllTerrestrialDistricts= wao.error.serviceReferential.getAllTerrestrialLocations= Modified: trunk/wao-business/src/main/resources/i18n/wao-business_fr_FR.properties =================================================================== --- trunk/wao-business/src/main/resources/i18n/wao-business_fr_FR.properties 2011-06-06 15:47:32 UTC (rev 1320) +++ trunk/wao-business/src/main/resources/i18n/wao-business_fr_FR.properties 2011-06-07 12:43:43 UTC (rev 1321) @@ -176,6 +176,7 @@ wao.error.serviceContact.getNbContacts=Impossible de compter le nombre de contacts filtrés wao.error.serviceContact.getNewContact=Impossible d'instancier un nouveau contact wao.error.serviceContact.getPossibleObsDebCodes= +wao.error.serviceContact.getPossibleTerrestrialLocations= wao.error.serviceContact.getPossibleValuesForFilter= wao.error.serviceContact.getSubstitutesForBoat= wao.error.serviceContact.importContactCsv=Impossible d'importer les contacts @@ -193,6 +194,7 @@ wao.error.serviceReferential.getAllObsDebCodes= wao.error.serviceReferential.getAllObservationUnits= wao.error.serviceReferential.getAllPorts= +wao.error.serviceReferential.getAllPortsAndAuctions= wao.error.serviceReferential.getAllRegionIfremers= wao.error.serviceReferential.getAllTerrestrialDistricts= wao.error.serviceReferential.getAllTerrestrialLocations= Modified: trunk/wao-business/src/main/xmi/wao.zargo =================================================================== (Binary files differ) Modified: trunk/wao-business/src/test/java/fr/ifremer/wao/business/ObsDebFieldWorkTest.java =================================================================== --- trunk/wao-business/src/test/java/fr/ifremer/wao/business/ObsDebFieldWorkTest.java 2011-06-06 15:47:32 UTC (rev 1320) +++ trunk/wao-business/src/test/java/fr/ifremer/wao/business/ObsDebFieldWorkTest.java 2011-06-07 12:43:43 UTC (rev 1321) @@ -29,6 +29,7 @@ import fr.ifremer.wao.bean.ContactFilter; import fr.ifremer.wao.bean.ContactState; import fr.ifremer.wao.bean.ContactStateStatistics; +import fr.ifremer.wao.bean.ObsProgram; import fr.ifremer.wao.bean.ObservationType; import fr.ifremer.wao.bean.SamplingFilter; import fr.ifremer.wao.bean.SamplingFilterValues; @@ -360,7 +361,6 @@ Assert.assertEquals(4, boatsForRow.size()); Boat boat = boatsForRow.get(fixtures.moise().getImmatriculation()); - // let's create the contact Contact contact = serviceContact.newContact(fixtures.joshAsObserver(), row, boat); @@ -368,18 +368,31 @@ Assert.assertEquals(ObservationType.FIELD_WORK_OBSERVATION, contact.getObservationType()); // in the observation report, i must tell where i was and when - List<TerrestrialLocation> ports = serviceReferential.getAllPorts(contact.getSampleRow().getObservationUnit()); + List<TerrestrialLocation> ports = + serviceContact.getPossibleTerrestrialLocations(contact); + List<ObsDebCode> possibleObsDebCodes = + serviceContact.getPossibleObsDebCodes(contact); + // and give a contact state + Assert.assertEquals(ContactState.OBSERVATION_EXPECTED, contact.getContactState()); + if (log.isDebugEnabled()) { + StringBuilder logMessage = new StringBuilder(); + logMessage.append("possible ports for this contact contains"); for (TerrestrialLocation port : ports) { - log.debug("possible ports for this contact contains " + port.getDescription()); + logMessage.append(" ").append(port.getDescription()); } + logMessage.append(". contact states that can be used are ") + .append(ContactState.getAllowedStates(ObsProgram.OBSDEB)); + log.debug(logMessage.toString()); } // i was at this port, from 9:15AM to 10:30AM + contact.setContactState(ContactState.OBSERVATION_DONE); contact.setTerrestrialLocation(ports.get(4)); contact.setObservationBeginDate(DateUtil.createDate(0, 15, 9, 13, 2, 2010)); contact.setObservationEndDate(DateUtil.createDate(0, 30, 10, 13, 2, 2010)); + contact.setObsDebCode(possibleObsDebCodes.get(3)); // let's validate ValidationResult validationResult = serviceContact.validateContact(contact); @@ -393,9 +406,9 @@ serviceContact.saveContact(fixtures.joshAsObserver(), contact, false); contact = serviceContact.getContact(contact.getTopiaId()); - Assert.assertNotNull("service must have save the data given by observer", contact.getTerrestrialLocation()); - Assert.assertNotNull("service must have save the data given by observer", contact.getObservationBeginDate()); - Assert.assertNotNull("service must have save the data given by observer", contact.getObservationEndDate()); + Assert.assertNotNull("service must save the data given by observer", contact.getTerrestrialLocation()); + Assert.assertNotNull("service must save the data given by observer", contact.getObservationBeginDate()); + Assert.assertNotNull("service must save the data given by observer", contact.getObservationEndDate()); // now, i want to create another contact because, at the same // day, and the same time, i've seen another boat @@ -403,11 +416,13 @@ Assert.assertNotNull("service must have pre filled field", contact.getObservationEndDate()); Assert.assertNotNull("service must have pre filled field", contact.getTerrestrialLocation()); - // i've made the survey in this last contact, so i can associate an ObsDebCode - List<ObsDebCode> possibleObsDebCodes = - serviceContact.getPossibleObsDebCodes(contact); + contact.setContactState(ContactState.OBSERVATION_DONE); contact.setObsDebCode(possibleObsDebCodes.get(3)); serviceContact.saveContact(fixtures.joshAsObserver(), contact, false); + + // i've made the survey in this last contact + contact = serviceContact.newContact(fixtures.joshAsObserver(), row, fixtures.samourai()); + Assert.assertEquals(ObservationType.FIELD_WORK_SURVEY, contact.getObservationType()); } /** Check that coordinator is able to export the contacts created in {@link #observerCanCreateContact()} Modified: trunk/wao-business/src/test/java/fr/ifremer/wao/service/AbstractServiceTest.java =================================================================== --- trunk/wao-business/src/test/java/fr/ifremer/wao/service/AbstractServiceTest.java 2011-06-06 15:47:32 UTC (rev 1320) +++ trunk/wao-business/src/test/java/fr/ifremer/wao/service/AbstractServiceTest.java 2011-06-07 12:43:43 UTC (rev 1321) @@ -600,7 +600,7 @@ begin = DateUtil.createDate(3, 5, 2010); end = DateUtil.createDate(4, 5, 2010); contact3.setObservationEndDate(end); - contact3.setTopiaCreateDate(begin); + contact3.setCreationDate(begin); serviceContact.saveContact(connectedUser, contact3, false); // Contacts for company BIS @@ -612,7 +612,7 @@ begin = DateUtil.createDate(3, 3, 2010); end = DateUtil.createDate(4, 3, 2010); contact4.setObservationEndDate(end); - contact4.setTopiaCreateDate(begin); + contact4.setCreationDate(begin); serviceContact.saveContact(connectedUser, contact4, false); Contact contact5 = new ContactImpl(); @@ -623,7 +623,7 @@ begin = DateUtil.createDate(3, 5, 2010); end = DateUtil.createDate(4, 5, 2010); contact5.setObservationEndDate(end); - contact5.setTopiaCreateDate(begin); + contact5.setCreationDate(begin); serviceContact.saveContact(connectedUser, contact5, false); // Contact refused by program, will not be in result @@ -633,7 +633,7 @@ contact6.setSampleRow(row2); contact6.setContactState(ContactState.OBSERVATION_CANCELLED); begin = DateUtil.createDate(3, 3, 2010); - contact6.setTopiaCreateDate(begin); + contact6.setCreationDate(begin); end = DateUtil.createDate(4, 3, 2010); contact6.setObservationEndDate(end); contact6.setValidationProgram(Boolean.FALSE); Modified: trunk/wao-business/src/test/java/fr/ifremer/wao/service/ServiceContactInternalTest.java =================================================================== --- trunk/wao-business/src/test/java/fr/ifremer/wao/service/ServiceContactInternalTest.java 2011-06-06 15:47:32 UTC (rev 1320) +++ trunk/wao-business/src/test/java/fr/ifremer/wao/service/ServiceContactInternalTest.java 2011-06-07 12:43:43 UTC (rev 1321) @@ -549,7 +549,7 @@ result.initialize(transaction, creator, 1); service.loadContactCsv(reader, result, false); Date createDate = DateUtil.createDate(18,3,2010); - assertEquals(createDate, result.getTopiaCreateDate()); + assertEquals(createDate, result.getCreationDate()); assertEquals(ContactState.OBSERVATION_DONE, result.getContactState()); assertEquals(observer, result.getMainObserver()); assertEquals(sampleRow, result.getSampleRow()); @@ -641,7 +641,7 @@ // Don't use a mock in this case Contact newContact = service.newContact(connectedUser, sampleRow, boat); - newContact.setTopiaCreateDate(DateUtil.createDate(2, 3, 2010)); + newContact.setCreationDate(DateUtil.createDate(2, 3, 2010)); /** EXEC METHOD **/ Modified: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/components/SamplingFilterComponent.java =================================================================== --- trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/components/SamplingFilterComponent.java 2011-06-06 15:47:32 UTC (rev 1320) +++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/components/SamplingFilterComponent.java 2011-06-07 12:43:43 UTC (rev 1321) @@ -36,7 +36,6 @@ import org.apache.tapestry5.ioc.Messages; import org.apache.tapestry5.ioc.annotations.Inject; import org.apache.tapestry5.util.EnumSelectModel; -import org.nuiton.util.PeriodDates; import java.util.ArrayList; import java.util.List; Modified: trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/ContactForm.java =================================================================== --- trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/ContactForm.java 2011-06-06 15:47:32 UTC (rev 1320) +++ trunk/wao-ui/src/main/java/fr/ifremer/wao/ui/pages/ContactForm.java 2011-06-07 12:43:43 UTC (rev 1321) @@ -263,17 +263,8 @@ private ServiceReferential serviceReferential; public List<TerrestrialLocation> getTerrestrialLocations() { - List<TerrestrialLocation> locations; - if (contact.getObsProgram() == ObsProgram.OBSVENTE) { - // we must choose a port, or an auction in the district - // specified in the sampling plan - locations = serviceReferential.getAllTerrestrialLocations(new ContactFilterImpl(), - contact.getSampleRow().getTerrestrialLocation().getDistrictCode()); - } else { - // me must choose a port (not auction) in the observation unit - // specified in the plan - locations = serviceReferential.getAllPorts(contact.getSampleRow().getObservationUnit()); - } + List<TerrestrialLocation> locations = serviceContact. + getPossibleTerrestrialLocations(getContact()); return locations; } Modified: trunk/wao-ui/src/main/resources/fr/ifremer/wao/ui/components/SamplingFilterComponent.tml =================================================================== --- trunk/wao-ui/src/main/resources/fr/ifremer/wao/ui/components/SamplingFilterComponent.tml 2011-06-06 15:47:32 UTC (rev 1320) +++ trunk/wao-ui/src/main/resources/fr/ifremer/wao/ui/components/SamplingFilterComponent.tml 2011-06-07 12:43:43 UTC (rev 1321) @@ -150,14 +150,14 @@ <input t:type="select" t:id="samplingStrategy" t:value="filter.samplingStrategy"/> </t:if> </div> - <t:if test="showEstimatedTides"> - <div class="filterRow"> - <input t:type="checkbox" t:id="estimatedTides" t:value="filter.estimatedTides" /> - <label for="estimatedTides" title="${message:wao.ui.form.estimatedTides.description}">${message:wao.ui.form.estimatedTides}</label> - </div> - </t:if> </p:else> </t:if> + <t:if test="showEstimatedTides"> + <div class="filterRow"> + <input t:type="checkbox" t:id="estimatedTides" t:value="filter.estimatedTides" /> + <label for="estimatedTides" title="${message:wao.ui.form.estimatedTides.description}">${message:wao.ui.form.estimatedTides}</label> + </div> + </t:if> <div class="t-beaneditor-row aright"> <input t:type="submit" class="ico22px refresh" t:id="refresh" value="${message:wao.ui.filters.refresh}"