Author: bleny Date: 2014-03-25 18:22:15 +0100 (Tue, 25 Mar 2014) New Revision: 1750 Url: http://forge.codelutin.com/projects/wao/repository/revisions/1750 Log: refs #4483 introduce SampleRowsFilterValues start filter form ui Added: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/SampleRowsFilterValues.java Modified: trunk/wao-persistence/src/main/java/fr/ifremer/wao/ContactsFilter.java trunk/wao-persistence/src/main/java/fr/ifremer/wao/SampleRowsFilter.java trunk/wao-persistence/src/main/java/fr/ifremer/wao/WaoUtils.java trunk/wao-persistence/src/main/java/fr/ifremer/wao/entity/ContactTopiaDao.java trunk/wao-persistence/src/main/java/fr/ifremer/wao/entity/SampleRowTopiaDao.java trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerSamplingPlan.java trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerSamplingPlanBuilder.java trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerSamplingPlanService.java trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/SamplingPlanAction.java trunk/wao-web/src/main/resources/i18n/wao-web_en_GB.properties trunk/wao-web/src/main/resources/i18n/wao-web_fr_FR.properties trunk/wao-web/src/main/webapp/WEB-INF/content/obsmer/sampling-plan.jsp Modified: trunk/wao-persistence/src/main/java/fr/ifremer/wao/ContactsFilter.java =================================================================== --- trunk/wao-persistence/src/main/java/fr/ifremer/wao/ContactsFilter.java 2014-03-25 17:16:52 UTC (rev 1749) +++ trunk/wao-persistence/src/main/java/fr/ifremer/wao/ContactsFilter.java 2014-03-25 17:22:15 UTC (rev 1750) @@ -5,6 +5,7 @@ import fr.ifremer.wao.entity.ObservationType; import fr.ifremer.wao.entity.ObservedDataControl; import fr.ifremer.wao.entity.SamplingStrategy; +import org.apache.commons.lang3.builder.ReflectionToStringBuilder; import java.util.Date; import java.util.Set; @@ -13,10 +14,22 @@ protected SampleRowsFilter sampleRowFilter; + /** + * Filter contact on {@link fr.ifremer.wao.entity.Contact#getCreationDate()} or on + * {@link fr.ifremer.wao.entity.Contact#getObservationBeginDate()} according to + * {@link #isFilterOnObservationBeginDate()} flag. + */ protected Date periodFrom; + /** + * Filter contact on {@link fr.ifremer.wao.entity.Contact#getCreationDate()} or on + * {@link fr.ifremer.wao.entity.Contact#getObservationBeginDate()} according to + * {@link #isFilterOnObservationBeginDate()} flag. + */ protected Date periodTo; + protected Set<String> contactIds; + protected Set<ContactState> contactStates; protected Set<DataReliability> dataReliabilities; @@ -224,4 +237,18 @@ public void setSortedByBoardingDate(boolean sortedByBoardingDate) { this.sortedByBoardingDate = sortedByBoardingDate; } + + public Set<String> getContactIds() { + return contactIds; + } + + public void setContactIds(Set<String> contactIds) { + this.contactIds = contactIds; + } + + @Override + public String toString() { + return ReflectionToStringBuilder.reflectionToString(this); + } + } Modified: trunk/wao-persistence/src/main/java/fr/ifremer/wao/SampleRowsFilter.java =================================================================== --- trunk/wao-persistence/src/main/java/fr/ifremer/wao/SampleRowsFilter.java 2014-03-25 17:16:52 UTC (rev 1749) +++ trunk/wao-persistence/src/main/java/fr/ifremer/wao/SampleRowsFilter.java 2014-03-25 17:22:15 UTC (rev 1750) @@ -22,20 +22,29 @@ */ import fr.ifremer.wao.entity.ObsProgram; -import fr.ifremer.wao.entity.ObservationType; import fr.ifremer.wao.entity.SamplingStrategy; +import org.apache.commons.lang3.builder.ReflectionToStringBuilder; import java.util.Date; +import java.util.Objects; import java.util.Set; public class SampleRowsFilter { protected ObsProgram obsProgram; - protected ObservationType expectedObservationType; + protected Set<String> sampleRowIds; + /** Filter sample rows on sample month. + * + * To matches the filter, the sample row must have at least one sample month after this date. + */ protected Date periodFrom; + /** Filter sample rows on sample month. + * + * To matches the filter, the sample row must have at least one sample month before this date. + */ protected Date periodTo; protected Set<String> fishingZoneFacadeNames; @@ -54,16 +63,6 @@ protected Set<String> terrestrialDistrictIds; - protected Set<String> observationUnitIds; - - protected Set<String> observerIds; - - protected Set<String> subPopulationCodes; - - protected Set<String> skillZoneCodes; - - protected Set<String> regionIfremerIds; - protected Set<String> companyIds; protected Set<String> orderByArguments; @@ -79,14 +78,6 @@ this.obsProgram = obsProgram; } - public ObservationType getExpectedObservationType() { - return expectedObservationType; - } - - public void setExpectedObservationType(ObservationType expectedObservationType) { - this.expectedObservationType = expectedObservationType; - } - public Date getPeriodFrom() { return periodFrom; } @@ -167,67 +158,84 @@ this.terrestrialDistrictIds = terrestrialDistrictIds; } - public Set<String> getObservationUnitIds() { - return observationUnitIds; + public Set<String> getCompanyIds() { + return companyIds; } - public void setObservationUnitIds(Set<String> observationUnitIds) { - this.observationUnitIds = observationUnitIds; + public void setCompanyIds(Set<String> companyIds) { + this.companyIds = companyIds; } - public Set<String> getObserverIds() { - return observerIds; + public Set<String> getOrderByArguments() { + return orderByArguments; } - public void setObserverIds(Set<String> observerIds) { - this.observerIds = observerIds; + public void setOrderByArguments(Set<String> orderByArguments) { + this.orderByArguments = orderByArguments; } - public Set<String> getSubPopulationCodes() { - return subPopulationCodes; + public boolean isEstimatedTides() { + return estimatedTides; } - public void setSubPopulationCodes(Set<String> subPopulationCodes) { - this.subPopulationCodes = subPopulationCodes; + public void setEstimatedTides(boolean estimatedTides) { + this.estimatedTides = estimatedTides; } - public Set<String> getSkillZoneCodes() { - return skillZoneCodes; + public Set<String> getSampleRowIds() { + return sampleRowIds; } - public void setSkillZoneCodes(Set<String> skillZoneCodes) { - this.skillZoneCodes = skillZoneCodes; + public void setSampleRowIds(Set<String> sampleRowIds) { + this.sampleRowIds = sampleRowIds; } - public Set<String> getRegionIfremerIds() { - return regionIfremerIds; - } + @Override + public boolean equals(Object o) { - public void setRegionIfremerIds(Set<String> regionIfremerIds) { - this.regionIfremerIds = regionIfremerIds; - } + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; - public Set<String> getCompanyIds() { - return companyIds; - } + SampleRowsFilter that = (SampleRowsFilter) o; - public void setCompanyIds(Set<String> companyIds) { - this.companyIds = companyIds; - } + boolean equals = obsProgram.equals(that.obsProgram) + && Objects.equals(periodFrom, that.periodFrom) + && Objects.equals(periodTo, that.periodTo) + && WaoUtils.isEqualCollection(sampleRowIds, that.sampleRowIds) + && WaoUtils.isEqualCollection(fishingZoneFacadeNames, that.fishingZoneFacadeNames) + && WaoUtils.isEqualCollection(fishingZoneSectorNames, that.fishingZoneSectorNames) + && WaoUtils.isEqualCollection(sampleRowCodes, that.sampleRowCodes) + && WaoUtils.isEqualCollection(programNames, that.programNames) + && WaoUtils.isEqualCollection(fishingGearDcfIds, that.fishingGearDcfIds) + && WaoUtils.isEqualCollection(targetSpeciesDcfIds, that.targetSpeciesDcfIds) + && WaoUtils.isEqualCollection(samplingStrategies, that.samplingStrategies) + && WaoUtils.isEqualCollection(terrestrialDistrictIds, that.terrestrialDistrictIds) + && WaoUtils.isEqualCollection(companyIds, that.companyIds) + && WaoUtils.isEqualCollection(orderByArguments, that.orderByArguments); - public Set<String> getOrderByArguments() { - return orderByArguments; + return equals; + } - public void setOrderByArguments(Set<String> orderByArguments) { - this.orderByArguments = orderByArguments; + @Override + public int hashCode() { + int hashCode = obsProgram.hashCode(); + hashCode = 31 * hashCode + (sampleRowIds == null ? 0 : sampleRowIds.size()); + hashCode = 31 * hashCode + (fishingZoneFacadeNames == null ? 0 : fishingZoneFacadeNames.size()); + hashCode = 31 * hashCode + (fishingZoneSectorNames == null ? 0 : fishingZoneSectorNames.size()); + hashCode = 31 * hashCode + (sampleRowCodes == null ? 0 : sampleRowCodes.size()); + hashCode = 31 * hashCode + (programNames == null ? 0 : programNames.size()); + hashCode = 31 * hashCode + (fishingGearDcfIds == null ? 0 : fishingGearDcfIds.size()); + hashCode = 31 * hashCode + (targetSpeciesDcfIds == null ? 0 : targetSpeciesDcfIds.size()); + hashCode = 31 * hashCode + (samplingStrategies == null ? 0 : samplingStrategies.size()); + hashCode = 31 * hashCode + (terrestrialDistrictIds == null ? 0 : terrestrialDistrictIds.size()); + hashCode = 31 * hashCode + (companyIds == null ? 0 : companyIds.size()); + return hashCode; } - public boolean isEstimatedTides() { - return estimatedTides; + @Override + public String toString() { + return ReflectionToStringBuilder.reflectionToString(this); } - public void setEstimatedTides(boolean estimatedTides) { - this.estimatedTides = estimatedTides; - } } Modified: trunk/wao-persistence/src/main/java/fr/ifremer/wao/WaoUtils.java =================================================================== --- trunk/wao-persistence/src/main/java/fr/ifremer/wao/WaoUtils.java 2014-03-25 17:16:52 UTC (rev 1749) +++ trunk/wao-persistence/src/main/java/fr/ifremer/wao/WaoUtils.java 2014-03-25 17:22:15 UTC (rev 1750) @@ -22,6 +22,7 @@ */ import fr.ifremer.wao.entity.ObsProgram; +import org.apache.commons.collections4.CollectionUtils; import java.text.DateFormat; import java.text.ParseException; @@ -80,4 +81,26 @@ return ordinals; } + /** + * Wrapper on {@link org.apache.commons.collections4.CollectionUtils#isEqualCollection(java.util.Collection, java.util.Collection)} + * that handles null values. + */ + public static boolean isEqualCollection(Collection<?> a, Collection<?> b) { + boolean isEqualCollection; + if (a == null) { + if (b == null) { + isEqualCollection = true; + } else { + isEqualCollection = false; + } + } else { + if (b == null) { + isEqualCollection = false; + } else { + isEqualCollection = CollectionUtils.isEqualCollection(a, b); + } + } + return isEqualCollection; + } + } Modified: trunk/wao-persistence/src/main/java/fr/ifremer/wao/entity/ContactTopiaDao.java =================================================================== --- trunk/wao-persistence/src/main/java/fr/ifremer/wao/entity/ContactTopiaDao.java 2014-03-25 17:16:52 UTC (rev 1749) +++ trunk/wao-persistence/src/main/java/fr/ifremer/wao/entity/ContactTopiaDao.java 2014-03-25 17:22:15 UTC (rev 1750) @@ -8,6 +8,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.nuiton.topia.persistence.HqlAndParametersBuilder; +import org.nuiton.topia.persistence.TopiaEntity; import java.util.Collection; import java.util.List; @@ -63,6 +64,10 @@ query.addWhereClause("c." + periodProperty + " <= :periodTo", ImmutableMap.of("periodTo", (Object) filter.getPeriodTo())); } + if (CollectionUtils.isNotEmpty(filter.getContactIds())) { + query.addIn(TopiaEntity.PROPERTY_TOPIA_ID, filter.getContactIds()); + } + if (CollectionUtils.isNotEmpty(filter.getContactStates())) { Collection<Integer> contactStateOrdinals = WaoUtils.toOrdinals(filter.getContactStates()); query.addIn(Contact.PROPERTY_STATE, contactStateOrdinals); @@ -128,7 +133,7 @@ } if (log.isTraceEnabled()) { - log.trace("query to filter contacts " + query.getHql() + " " + query.getHqlParameters()); + log.trace("query to filter contacts for " + filter + " is " + query.getHql() + " " + query.getHqlParameters()); } return query; Modified: trunk/wao-persistence/src/main/java/fr/ifremer/wao/entity/SampleRowTopiaDao.java =================================================================== --- trunk/wao-persistence/src/main/java/fr/ifremer/wao/entity/SampleRowTopiaDao.java 2014-03-25 17:16:52 UTC (rev 1749) +++ trunk/wao-persistence/src/main/java/fr/ifremer/wao/entity/SampleRowTopiaDao.java 2014-03-25 17:22:15 UTC (rev 1750) @@ -31,6 +31,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.nuiton.topia.persistence.HqlAndParametersBuilder; +import org.nuiton.topia.persistence.TopiaEntity; import java.util.Calendar; import java.util.Date; @@ -76,8 +77,8 @@ query.addEquals(SampleRow.PROPERTY_OBS_PROGRAM_ORDINAL, obsProgram.ordinal()); - if (filter.getExpectedObservationType() != null) { - query.addEquals(SampleRow.PROPERTY_OBSERVATION_TYPE_ORDINAL, filter.getExpectedObservationType().ordinal()); + if (CollectionUtils.isNotEmpty(filter.getSampleRowIds())) { + query.addIn(TopiaEntity.PROPERTY_TOPIA_ID, filter.getSampleRowIds()); } if (filter.getPeriodFrom() != null) { @@ -114,47 +115,6 @@ query.addIn(SampleRow.PROPERTY_SAMPLING_STRATEGY_ORDINAL, WaoUtils.toOrdinals(filter.getSamplingStrategies())); } - if (CollectionUtils.isNotEmpty(filter.getObservationUnitIds())) { - query.addTopiaIdIn(SampleRow.PROPERTY_OBSERVATION_UNIT, filter.getObservationUnitIds()); - } - - if (CollectionUtils.isNotEmpty(filter.getSubPopulationCodes())) { - query.addTopiaIdIn( - SampleRow.PROPERTY_OBSERVATION_UNIT + "." + TerrestrialDivision.PROPERTY_SUB_POPULATION_CODE, - filter.getSubPopulationCodes()); - } - - if (CollectionUtils.isNotEmpty(filter.getSkillZoneCodes())) { - query.addTopiaIdIn( - SampleRow.PROPERTY_OBSERVATION_UNIT + "." + TerrestrialDivision.PROPERTY_SKILL_ZONE_CODE, - filter.getSkillZoneCodes()); - } - - if (CollectionUtils.isNotEmpty(filter.getSkillZoneCodes())) { - query.addTopiaIdIn( - SampleRow.PROPERTY_OBSERVATION_UNIT + "." + TerrestrialDivision.PROPERTY_SKILL_ZONE_CODE, - filter.getSkillZoneCodes()); - } - - if (CollectionUtils.isNotEmpty(filter.getRegionIfremerIds())) { - Preconditions.checkNotNull(filter.getExpectedObservationType(), "expected observation type needed"); - if (filter.getExpectedObservationType().isFieldWorkObservation()) { - query.addTopiaIdIn( - SampleRow.PROPERTY_OBSERVATION_UNIT + "." + TerrestrialDivision.PROPERTY_REGION_IFREMER, - filter.getRegionIfremerIds()); - } else { - query.addWhereClause( - "sr.topiaId in (select sr2.topiaId from fr.ifremer.wao.entity.SampleRowImpl as sr2 join sr2.terrestrialLocations as regionIfremer where regionIfremer.topiaId in (:regionIfremerIds))", - ImmutableMap.of("regionIfremerIds", (Object) filter.getRegionIfremerIds())); - } - } - - if (CollectionUtils.isNotEmpty(filter.getObserverIds())) { - query.addWhereClause( - "sr.topiaId in (select sr2.topiaId from fr.ifremer.wao.entity.SampleRowImpl as sr2 join sr2.observers as observer where observer.topiaId in (:observerIds))", - ImmutableMap.<String, Object>of("observerIds", filter.getObserverIds())); - } - if (CollectionUtils.isNotEmpty(filter.getTerrestrialDistrictIds())) { query.addWhereClause( "sr.topiaId in (select sr2.topiaId from fr.ifremer.wao.entity.SampleRowImpl as sr2 join sr2.terrestrialLocations as terrestrialDistrict where terrestrialDistrict.topiaId in (:terrestrialDistrictIds))", @@ -186,7 +146,7 @@ } if (log.isTraceEnabled()) { - log.trace("query to filter sample rows " + query.getHql() + " " + query.getHqlParameters()); + log.trace("query to filter sample rows for " + filter + " is " + query.getHql() + " " + query.getHqlParameters()); } return query; Modified: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerSamplingPlan.java =================================================================== --- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerSamplingPlan.java 2014-03-25 17:16:52 UTC (rev 1749) +++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerSamplingPlan.java 2014-03-25 17:22:15 UTC (rev 1750) @@ -90,6 +90,8 @@ */ protected List<Date> months; + protected SampleRowsFilterValues filterValues; + public ObsMerSamplingPlan(List<Date> months, List<ObsMerSamplingPlanFacadePart> facadeParts, Map<Date, ObsMerSamplingPlanStatistics> statisticsMap, @@ -98,7 +100,8 @@ Integer highTotalEstimated, Double observationTimesInDaysTotalExpected, Long observationTimesInDaysTotalReal, - Long observationTimesInDaysTotalEstimated) { + Long observationTimesInDaysTotalEstimated, + SampleRowsFilterValues filterValues) { this.months = months; this.facades = facadeParts; this.statisticsMap = statisticsMap; @@ -108,6 +111,7 @@ this.highTotalReal = highTotalReal; this.highTotalEstimated = highTotalEstimated; this.observationTimesInDaysTotalEstimated = observationTimesInDaysTotalEstimated; + this.filterValues = filterValues; } //FIXME Remove this @@ -187,6 +191,10 @@ return ratio; } + public SampleRowsFilterValues getFilterValues() { + return filterValues; + } + /** * All sectors part for a given facade. * <p/> Modified: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerSamplingPlanBuilder.java =================================================================== --- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerSamplingPlanBuilder.java 2014-03-25 17:16:52 UTC (rev 1749) +++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerSamplingPlanBuilder.java 2014-03-25 17:22:15 UTC (rev 1750) @@ -52,6 +52,11 @@ protected SampleRowsFilter sampleRowsFilter; /** + * Bean to hold all values that user can select to fill {@link fr.ifremer.wao.SampleRowsFilter}. + */ + protected SampleRowsFilterValues sampleRowsFilterValues; + + /** * List of month computed from the filter. */ protected List<Date> months; @@ -126,6 +131,7 @@ public ObsMerSamplingPlanBuilder(SampleRowsFilter sampleRowsFilter) { this.sampleRowsFilter = sampleRowsFilter; + this.sampleRowsFilterValues = new SampleRowsFilterValues(); this.facadeMap = new LinkedHashMap<>(); this.highTotalExpected = new MutableInt(); this.highTotalReal = new MutableInt(); @@ -177,6 +183,8 @@ observationTimesInDaysTotalReal.add(observationTimesInDaysReal); observationTimesInDaysTotalEstimated.add(observationTimesInDaysEstimated); + sampleRowsFilterValues.addSampleRow(sampleRow); + return this; } @@ -209,7 +217,8 @@ highTotalEstimated.toInteger(), observationTimesInDaysTotalExpected.toDouble(), observationTimesInDaysTotalReal.toLong(), - observationTimesInDaysTotalEstimated.toLong()); + observationTimesInDaysTotalEstimated.toLong(), + sampleRowsFilterValues); return result; } Modified: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerSamplingPlanService.java =================================================================== --- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerSamplingPlanService.java 2014-03-25 17:16:52 UTC (rev 1749) +++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerSamplingPlanService.java 2014-03-25 17:22:15 UTC (rev 1750) @@ -460,11 +460,6 @@ newFilter.setCompanyIds(Sets.newHashSet(authenticatedWaoUser.getCompany().getTopiaId())); } - if (obsProgram.isObsDeb() && authenticatedWaoUser.isObserver()) { - // observer can only see the row he has been associated - newFilter.setObserverIds(Sets.newHashSet(authenticatedWaoUser.getWaoUser().getTopiaId())); - } - return newFilter; } Added: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/SampleRowsFilterValues.java =================================================================== --- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/SampleRowsFilterValues.java (rev 0) +++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/SampleRowsFilterValues.java 2014-03-25 17:22:15 UTC (rev 1750) @@ -0,0 +1,99 @@ +package fr.ifremer.wao.services.service; + +import fr.ifremer.wao.entity.DCF5Code; +import fr.ifremer.wao.entity.FishingZone; +import fr.ifremer.wao.entity.SampleRow; +import fr.ifremer.wao.entity.SamplingStrategy; +import fr.ifremer.wao.entity.TerrestrialLocation; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +/** + * Bean to hold all values that user can select to fill {@link fr.ifremer.wao.SampleRowsFilter}. + */ +public class SampleRowsFilterValues implements Serializable { + + protected Set<String> fishingZoneFacadeNames = new HashSet<>(); + + protected Set<String> fishingZoneSectorNames = new HashSet<>(); + + protected Set<String> sampleRowCodes = new HashSet<>(); + + protected Set<String> programNames = new HashSet<>(); + + protected Map<String, String> companies = new HashMap<>(); + + protected Set<SamplingStrategy> samplingStrategies = new HashSet<>(); + + protected Map<String, String> terrestrialDistricts = new HashMap<>(); + + /** Values are the i18n keys. */ + protected Map<String, String> fishingGearDcfs = new HashMap<>(); + + /** Values are the i18n keys. */ + protected Map<String, String> targetSpeciesDcfs = new HashMap<>(); + + public void addSampleRow(SampleRow sampleRow) { + for (FishingZone fishingZone : sampleRow.getFishingZone()) { + fishingZoneFacadeNames.add(fishingZone.getFacadeName()); + fishingZoneSectorNames.add(fishingZone.getSectorName()); + } + sampleRowCodes.add(sampleRow.getCode()); + programNames.add(sampleRow.getProgramName()); + companies.put(sampleRow.getCompany().getTopiaId(), sampleRow.getCompany().getName()); + samplingStrategies.add(sampleRow.getSamplingStrategy()); + if (sampleRow.getObsProgram().isObsVente()) { + TerrestrialLocation terrestrialDistrict = sampleRow.getTerrestrialLocation(); + terrestrialDistricts.put(terrestrialDistrict.getTopiaId(), terrestrialDistrict.getDescription()); + } + for (DCF5Code dcf5Code : sampleRow.getdCF5Code()) { + String i18nKey = "fr.ifremer.wao.entity.FishingGearDCF." + dcf5Code.getFishingGearDCF().getCode(); + fishingGearDcfs.put(dcf5Code.getFishingGearDCF().getTopiaId(), i18nKey); + if (dcf5Code.getTargetSpeciesDCF() != null) { + i18nKey = "fr.ifremer.wao.entity.TargetSpeciesDCF." + dcf5Code.getTargetSpeciesDCF().getCode(); + targetSpeciesDcfs.put(dcf5Code.getTargetSpeciesDCF().getTopiaId(), i18nKey); + } + } + } + + public Set<String> getFishingZoneFacadeNames() { + return fishingZoneFacadeNames; + } + + public Set<String> getFishingZoneSectorNames() { + return fishingZoneSectorNames; + } + + public Set<String> getSampleRowCodes() { + return sampleRowCodes; + } + + public Set<String> getProgramNames() { + return programNames; + } + + public Map<String, String> getCompanies() { + return companies; + } + + public Set<SamplingStrategy> getSamplingStrategies() { + return samplingStrategies; + } + + public Map<String, String> getTerrestrialDistricts() { + return terrestrialDistricts; + } + + public Map<String, String> getFishingGearDcfs() { + return fishingGearDcfs; + } + + public Map<String, String> getTargetSpeciesDcfs() { + return targetSpeciesDcfs; + } + +} Modified: trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/SamplingPlanAction.java =================================================================== --- trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/SamplingPlanAction.java 2014-03-25 17:16:52 UTC (rev 1749) +++ trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/obsmer/SamplingPlanAction.java 2014-03-25 17:22:15 UTC (rev 1750) @@ -21,29 +21,41 @@ * #L% */ +import com.opensymphony.xwork2.Preparable; import fr.ifremer.wao.SampleRowsFilter; -import fr.ifremer.wao.entity.SampleRow; import fr.ifremer.wao.services.service.ObsMerSamplingPlan; import fr.ifremer.wao.services.service.ObsMerSamplingPlanService; import fr.ifremer.wao.web.WaoJspActionSupport; -import java.util.List; +public class SamplingPlanAction extends WaoJspActionSupport implements Preparable { -public class SamplingPlanAction extends WaoJspActionSupport { - protected ObsMerSamplingPlanService service; + protected SampleRowsFilter filter; + protected ObsMerSamplingPlan samplingPlan; public void setService(ObsMerSamplingPlanService service) { this.service = service; } + public SampleRowsFilter getFilter() { + if (filter == null) { + prepare(); + } + return filter; + } + @Override + public void prepare() { + + filter = service.newSampleRowsFilter(getAuthenticatedWaoUser()); + + } + + @Override public String execute() { - SampleRowsFilter filter = service.newSampleRowsFilter(getAuthenticatedWaoUser()); - samplingPlan = service.getSamplingPlan(filter); return SUCCESS; @@ -53,12 +65,8 @@ return samplingPlan; } - public List<SampleRow> getSamplingPlanRows() { - return samplingPlan.getRows(); - } - - public String getSampleRowToHighlightId() { return getSession().getSampleRowToHighlightId(); } + } Modified: trunk/wao-web/src/main/resources/i18n/wao-web_en_GB.properties =================================================================== --- trunk/wao-web/src/main/resources/i18n/wao-web_en_GB.properties 2014-03-25 17:16:52 UTC (rev 1749) +++ trunk/wao-web/src/main/resources/i18n/wao-web_en_GB.properties 2014-03-25 17:22:15 UTC (rev 1750) @@ -59,6 +59,7 @@ wao.ui.action.refresh=Refresh wao.ui.action.refuseContact=Refuse contact wao.ui.action.remove=Remove +wao.ui.action.reset=Remettre à zéro wao.ui.action.resetFields=Reset form wao.ui.action.revert=Revert wao.ui.action.runExport=Run export Modified: trunk/wao-web/src/main/resources/i18n/wao-web_fr_FR.properties =================================================================== --- trunk/wao-web/src/main/resources/i18n/wao-web_fr_FR.properties 2014-03-25 17:16:52 UTC (rev 1749) +++ trunk/wao-web/src/main/resources/i18n/wao-web_fr_FR.properties 2014-03-25 17:22:15 UTC (rev 1750) @@ -59,6 +59,7 @@ wao.ui.action.refresh=Rafraîchir wao.ui.action.refuseContact=Refuser le contact wao.ui.action.remove=Retirer +wao.ui.action.reset=Reset wao.ui.action.resetFields=Remettre le formulaire à zéro wao.ui.action.revert=Annuler wao.ui.action.runExport=Lancer l'export Modified: trunk/wao-web/src/main/webapp/WEB-INF/content/obsmer/sampling-plan.jsp =================================================================== --- trunk/wao-web/src/main/webapp/WEB-INF/content/obsmer/sampling-plan.jsp 2014-03-25 17:16:52 UTC (rev 1749) +++ trunk/wao-web/src/main/webapp/WEB-INF/content/obsmer/sampling-plan.jsp 2014-03-25 17:22:15 UTC (rev 1750) @@ -33,11 +33,6 @@ <s:text name="wao.ui.page.SamplingPlan.title" /> </h1> - <s:url action="export-sampling-plan" id="exportSamplingPlanUrl" /> - <s:a href="%{exportSamplingPlanUrl}" cssClass="btn"> - <i class="icon-download"></i> <s:text name="wao.ui.action.csvExport" /> - </s:a> - <s:if test="authenticatedWaoUser.authorizedToEditSamplingPlan"> <s:url action="edit-sample-row!input" id="createSampleRow" /> <s:a href="%{createSampleRow}" cssClass="btn"> @@ -45,6 +40,35 @@ </s:a> </s:if> + <s:form method="GET"> + + <s:select name="filter.companyIds" + label="%{getText('wao.ui.entity.Company')}" + list="samplingPlan.filterValues.companies" + multiple="true" + cssClass="input-xxlarge" /> + + <s:select name="filter.programNames" + label="%{getText('wao.ui.field.SampleRow.programName')}" + list="samplingPlan.filterValues.programNames" + multiple="true" + cssClass="input-xxlarge" /> + + <s:url action="sampling-plan" id="samplingPlanUrl" /> + <s:a href="%{samplingPlanUrl}" cssClass="btn"> + <i class="icon-reset"></i> <s:text name="wao.ui.action.reset" /> + </s:a> + + <s:submit type="button" cssClass="btn"> + <i class="icon-filter"></i> <s:text name="wao.ui.action.filter" /> + </s:submit> + + <s:submit action="export-sampling-plan" type="button" cssClass="btn"> + <i class="icon-download"></i> <s:text name="wao.ui.action.csvExport" /> + </s:submit> + + </s:form> + <s:set var="estimatedTides" value="true"/> <s:set var="fullView" value="true"/> <s:set var="displayTidesReal" value="true"/>