branch feature/2263 updated (f4a83c2 -> 5bcc4c2)
This is an automated email from the git hooks/post-receive script. New change to branch feature/2263 in repository wao. See http://git.codelutin.com/wao.git from f4a83c2 Import du plan d'échantillonnage scléro new fde3c64 On gère les filtres dans le plan scléro new 321824f Ajout des champs scléro dans le formulaire de modification d'une ligne du plan new 626b064 Les filtres du plan sont désormais effectifs new 5bcc4c2 Dans le plan scléro, on ajoute une colonne pour l'espèce The 4 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Detailed log of new commits: commit 5bcc4c289cf3ff8473efda00a0a1af960f537de5 Author: Brendan Le Ny <bleny@codelutin.com> Date: Thu Dec 18 16:59:10 2014 +0100 Dans le plan scléro, on ajoute une colonne pour l'espèce commit 626b064a5985fa0ac36176bfc71e7091e7271220 Author: Brendan Le Ny <bleny@codelutin.com> Date: Thu Dec 18 16:56:26 2014 +0100 Les filtres du plan sont désormais effectifs commit 321824f7e06ca6331d81be51c38b135eed7962a6 Author: Brendan Le Ny <bleny@codelutin.com> Date: Thu Dec 18 16:37:42 2014 +0100 Ajout des champs scléro dans le formulaire de modification d'une ligne du plan commit fde3c645ee6d1671b268b802f58d3fa5e3833fa8 Author: Brendan Le Ny <bleny@codelutin.com> Date: Thu Dec 18 15:09:42 2014 +0100 On gère les filtres dans le plan scléro Summary of changes: .../main/java/fr/ifremer/wao/SampleRowsFilter.java | 68 ++++++++++--- .../java/fr/ifremer/wao/entity/BoatTopiaDao.java | 2 +- .../fr/ifremer/wao/entity/SampleRowTopiaDao.java | 16 ++- .../ifremer/wao/services/service/BoatsService.java | 6 +- .../wao/services/service/ContactsService.java | 2 +- .../services/service/SampleRowsFilterValues.java | 88 ++++++++++++----- .../wao/services/service/SamplingPlanService.java | 22 +++-- .../service/SclerochronologySamplingPlan.java | 11 +++ .../services/service/UpdateSampleRowCommand.java | 51 ++++++++++ .../resources/i18n/wao-services_en_GB.properties | 2 +- .../services/service/SclerochronologyFixtures.java | 15 +++ .../SclerochronologySamplingPlanServiceTest.java | 24 +++++ .../wao/web/action/EditSampleRowAction.java | 17 +--- .../action/SampleRowsFilterValuesJsonAction.java | 34 ++++++- .../main/webapp/WEB-INF/content/boat-details.jsp | 2 +- .../src/main/webapp/WEB-INF/content/contacts.jsp | 2 +- .../WEB-INF/content/edit-sample-row-input.jsp | 108 ++++++++++++++------- .../WEB-INF/content/obsmer/sampling-plan.jsp | 6 +- .../WEB-INF/content/obsvente/sampling-plan.jsp | 6 +- .../content/sclerochronology/sampling-plan.jsp | 26 ++--- .../src/main/webapp/WEB-INF/content/synthesis.jsp | 4 +- 21 files changed, 391 insertions(+), 121 deletions(-) -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature/2263 in repository wao. See http://git.codelutin.com/wao.git commit fde3c645ee6d1671b268b802f58d3fa5e3833fa8 Author: Brendan Le Ny <bleny@codelutin.com> Date: Thu Dec 18 15:09:42 2014 +0100 On gère les filtres dans le plan scléro --- .../main/java/fr/ifremer/wao/SampleRowsFilter.java | 18 ++--- .../java/fr/ifremer/wao/entity/BoatTopiaDao.java | 2 +- .../fr/ifremer/wao/entity/SampleRowTopiaDao.java | 4 +- .../ifremer/wao/services/service/BoatsService.java | 6 +- .../wao/services/service/ContactsService.java | 2 +- .../services/service/SampleRowsFilterValues.java | 88 ++++++++++++++++------ .../wao/services/service/SamplingPlanService.java | 4 +- .../service/SclerochronologySamplingPlan.java | 11 +++ .../resources/i18n/wao-services_en_GB.properties | 2 +- .../services/service/SclerochronologyFixtures.java | 15 ++++ .../SclerochronologySamplingPlanServiceTest.java | 24 ++++++ .../action/SampleRowsFilterValuesJsonAction.java | 34 +++++++-- .../main/webapp/WEB-INF/content/boat-details.jsp | 2 +- .../src/main/webapp/WEB-INF/content/contacts.jsp | 2 +- .../WEB-INF/content/obsmer/sampling-plan.jsp | 6 +- .../WEB-INF/content/obsvente/sampling-plan.jsp | 6 +- .../content/sclerochronology/sampling-plan.jsp | 12 +-- .../src/main/webapp/WEB-INF/content/synthesis.jsp | 4 +- 18 files changed, 178 insertions(+), 64 deletions(-) diff --git a/wao-persistence/src/main/java/fr/ifremer/wao/SampleRowsFilter.java b/wao-persistence/src/main/java/fr/ifremer/wao/SampleRowsFilter.java index 1bd98e0..6fc1321 100644 --- a/wao-persistence/src/main/java/fr/ifremer/wao/SampleRowsFilter.java +++ b/wao-persistence/src/main/java/fr/ifremer/wao/SampleRowsFilter.java @@ -67,7 +67,7 @@ public class SampleRowsFilter extends AbstractWaoFilter { protected Set<String> terrestrialDistrictIds; - protected Set<String> companyIds; + protected Set<String> organisationIds; protected LinkedHashSet<String> orderByArguments; @@ -159,12 +159,12 @@ public class SampleRowsFilter extends AbstractWaoFilter { this.terrestrialDistrictIds = terrestrialDistrictIds; } - public Set<String> getCompanyIds() { - return companyIds; + public Set<String> getOrganisationIds() { + return organisationIds; } - public void setCompanyIds(Set<String> companyIds) { - this.companyIds = companyIds; + public void setOrganisationIds(Set<String> organisationIds) { + this.organisationIds = organisationIds; } public LinkedHashSet<String> getOrderByArguments() { @@ -197,7 +197,7 @@ public class SampleRowsFilter extends AbstractWaoFilter { || CollectionUtils.isNotEmpty(targetSpeciesDcfIds) || CollectionUtils.isNotEmpty(samplingStrategies) || CollectionUtils.isNotEmpty(terrestrialDistrictIds) - || CollectionUtils.isNotEmpty(companyIds); + || CollectionUtils.isNotEmpty(organisationIds); return filled; } @@ -221,7 +221,7 @@ public class SampleRowsFilter extends AbstractWaoFilter { && WaoUtils.isEqualCollection(targetSpeciesDcfIds, that.targetSpeciesDcfIds) && WaoUtils.isEqualCollection(samplingStrategies, that.samplingStrategies) && WaoUtils.isEqualCollection(terrestrialDistrictIds, that.terrestrialDistrictIds) - && WaoUtils.isEqualCollection(companyIds, that.companyIds) + && WaoUtils.isEqualCollection(organisationIds, that.organisationIds) && WaoUtils.isEqualCollection(orderByArguments, that.orderByArguments); return equals; @@ -247,7 +247,7 @@ public class SampleRowsFilter extends AbstractWaoFilter { hashCode = 31 * hashCode + WaoUtils.collectionHashCode(targetSpeciesDcfIds); hashCode = 31 * hashCode + WaoUtils.collectionHashCode(samplingStrategies); hashCode = 31 * hashCode + WaoUtils.collectionHashCode(terrestrialDistrictIds); - hashCode = 31 * hashCode + WaoUtils.collectionHashCode(companyIds); + hashCode = 31 * hashCode + WaoUtils.collectionHashCode(organisationIds); hashCode = 31 * hashCode + WaoUtils.collectionHashCode(orderByArguments); return hashCode; } @@ -267,7 +267,7 @@ public class SampleRowsFilter extends AbstractWaoFilter { clone.targetSpeciesDcfIds = targetSpeciesDcfIds == null ? null : new HashSet<>(targetSpeciesDcfIds); clone.samplingStrategies = samplingStrategies == null ? null : new HashSet<>(samplingStrategies); clone.terrestrialDistrictIds = terrestrialDistrictIds == null ? null : new HashSet<>(terrestrialDistrictIds); - clone.companyIds = companyIds == null ? null : new HashSet<>(companyIds); + clone.organisationIds = organisationIds == null ? null : new HashSet<>(organisationIds); clone.orderByArguments = orderByArguments == null ? null : new LinkedHashSet<>(orderByArguments); return clone; } diff --git a/wao-persistence/src/main/java/fr/ifremer/wao/entity/BoatTopiaDao.java b/wao-persistence/src/main/java/fr/ifremer/wao/entity/BoatTopiaDao.java index d63e993..ab7c231 100644 --- a/wao-persistence/src/main/java/fr/ifremer/wao/entity/BoatTopiaDao.java +++ b/wao-persistence/src/main/java/fr/ifremer/wao/entity/BoatTopiaDao.java @@ -149,7 +149,7 @@ public class BoatTopiaDao extends AbstractBoatTopiaDao<Boat> { || CollectionUtils.isNotEmpty(filter.getElligibleForSampleRowsFilter().getTargetSpeciesDcfIds()) || CollectionUtils.isNotEmpty(filter.getElligibleForSampleRowsFilter().getSamplingStrategies()) || CollectionUtils.isNotEmpty(filter.getElligibleForSampleRowsFilter().getTerrestrialDistrictIds()) - || CollectionUtils.isNotEmpty(filter.getElligibleForSampleRowsFilter().getCompanyIds()); + || CollectionUtils.isNotEmpty(filter.getElligibleForSampleRowsFilter().getOrganisationIds()); return filled; } } diff --git a/wao-persistence/src/main/java/fr/ifremer/wao/entity/SampleRowTopiaDao.java b/wao-persistence/src/main/java/fr/ifremer/wao/entity/SampleRowTopiaDao.java index 8506a89..950fe8e 100644 --- a/wao-persistence/src/main/java/fr/ifremer/wao/entity/SampleRowTopiaDao.java +++ b/wao-persistence/src/main/java/fr/ifremer/wao/entity/SampleRowTopiaDao.java @@ -99,8 +99,8 @@ public class SampleRowTopiaDao extends AbstractSampleRowTopiaDao<SampleRow> { query.addIn(SampleRow.PROPERTY_PROGRAM_NAME, filter.getProgramNames()); } - if (CollectionUtils.isNotEmpty(filter.getCompanyIds())) { - query.addTopiaIdIn(SampleRow.PROPERTY_ORGANISATION, filter.getCompanyIds()); + if (CollectionUtils.isNotEmpty(filter.getOrganisationIds())) { + query.addTopiaIdIn(SampleRow.PROPERTY_ORGANISATION, filter.getOrganisationIds()); } if (CollectionUtils.isNotEmpty(filter.getSamplingStrategies())) { diff --git a/wao-services/src/main/java/fr/ifremer/wao/services/service/BoatsService.java b/wao-services/src/main/java/fr/ifremer/wao/services/service/BoatsService.java index 027b80d..da286422a 100644 --- a/wao-services/src/main/java/fr/ifremer/wao/services/service/BoatsService.java +++ b/wao-services/src/main/java/fr/ifremer/wao/services/service/BoatsService.java @@ -204,7 +204,7 @@ public class BoatsService extends WaoServiceSupport { ContactsFilter filter = new ContactsFilter(); filter.getSampleRowFilter().setObsProgram(obsProgram); filter.getBoatFilter().setBoatIds(ImmutableSet.of(boatId)); - filter.getSampleRowFilter().setCompanyIds(ImmutableSet.of(companyId)); + filter.getSampleRowFilter().setOrganisationIds(ImmutableSet.of(companyId)); long contactsCount = getContactDao().forFilter(filter, false).count(); Date now = serviceContext.getNow(); @@ -267,13 +267,13 @@ public class BoatsService extends WaoServiceSupport { long contactsCount = dao.forFilter(filter, false).count(); - filter.getSampleRowFilter().setCompanyIds(ImmutableSet.of(companyId)); + filter.getSampleRowFilter().setOrganisationIds(ImmutableSet.of(companyId)); long contactsCompanyCount = dao.forFilter(filter, false).count(); filter.setContactStates(ImmutableSet.of(ContactState.OBSERVATION_DONE)); long observationsCompanyCount = dao.forFilter(filter, false).count(); - filter.getSampleRowFilter().setCompanyIds(null); + filter.getSampleRowFilter().setOrganisationIds(null); long observationsCount = dao.forFilter(filter, false).count(); Preconditions.checkState(contactsCompanyCount <= contactsCount); diff --git a/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactsService.java b/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactsService.java index ebef067..b2d5cd5 100644 --- a/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactsService.java +++ b/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactsService.java @@ -107,7 +107,7 @@ public class ContactsService extends WaoServiceSupport { // DO NOT REMOVE THIS if (authenticatedWaoUser.isCoordinatorOrObserver()) { String authenticatedWaoUserCompanyTopiaId = authenticatedWaoUser.getWaoUser().getCompany().getTopiaId(); - newContactsFilter.getSampleRowFilter().setCompanyIds(ImmutableSet.of(authenticatedWaoUserCompanyTopiaId)); + newContactsFilter.getSampleRowFilter().setOrganisationIds(ImmutableSet.of(authenticatedWaoUserCompanyTopiaId)); } if (authenticatedWaoUser.isProfessional()) { diff --git a/wao-services/src/main/java/fr/ifremer/wao/services/service/SampleRowsFilterValues.java b/wao-services/src/main/java/fr/ifremer/wao/services/service/SampleRowsFilterValues.java index c9c430b..4184fc4 100644 --- a/wao-services/src/main/java/fr/ifremer/wao/services/service/SampleRowsFilterValues.java +++ b/wao-services/src/main/java/fr/ifremer/wao/services/service/SampleRowsFilterValues.java @@ -22,11 +22,11 @@ package fr.ifremer.wao.services.service; */ import com.google.common.base.Optional; -import fr.ifremer.wao.entity.Company; import fr.ifremer.wao.entity.Dcf5Code; import fr.ifremer.wao.entity.FishingGearDcf; import fr.ifremer.wao.entity.FishingZone; import fr.ifremer.wao.entity.ObsProgram; +import fr.ifremer.wao.entity.Organisation; import fr.ifremer.wao.entity.SampleRow; import fr.ifremer.wao.entity.TargetSpeciesDcf; import fr.ifremer.wao.entity.TerrestrialLocation; @@ -52,7 +52,7 @@ public class SampleRowsFilterValues extends AbstractFilterValues { protected SortedSet<FilterOption> programNames = new TreeSet<>(); - protected SortedSet<FilterOption> companies = new TreeSet<>(); + protected SortedSet<FilterOption> organisations = new TreeSet<>(); protected SortedSet<FilterOption> samplingStrategies = new TreeSet<>(); @@ -64,6 +64,12 @@ public class SampleRowsFilterValues extends AbstractFilterValues { /** Values are the code and the label i18n key. */ protected SortedSet<FilterOption> targetSpeciesDcfs = new TreeSet<>(); + protected SortedSet<FilterOption> individualMeasurementStrategies = new TreeSet<>(); + + protected SortedSet<FilterOption> sclerochronologySamplingContexts = new TreeSet<>(); + + protected SortedSet<FilterOption> species = new TreeSet<>(); + public SampleRowsFilterValues(Locale locale, ObsProgram obsProgram, Optional<String> optionalCompanyId) { super(locale, obsProgram, optionalCompanyId); } @@ -99,11 +105,11 @@ public class SampleRowsFilterValues extends AbstractFilterValues { // XXX brendan 07/07/14 dans le calcul des filter values, on évite tout ça pour les perfs programNames.add(FilterOption.forString(sampleRow.getProgramName())); - Company company = sampleRow.getCompany(); - if (company != null) { - companies.add(FilterOption.forValueAndLabel(company.getTopiaId(), company.getName())); + Organisation organisation = sampleRow.getOrganisation(); + if (organisation != null) { + organisations.add(FilterOption.forValueAndLabel(organisation.getTopiaId(), organisation.getFullName())); } - if (sampleRow.getObsProgram().isObsVente()) { + if (obsProgram.isObsVente()) { samplingStrategies.add(FilterOption.forEnum(locale, sampleRow.getSamplingStrategy())); if (sampleRow.isTerrestrialLocationsNotEmpty()) { for (TerrestrialLocation terrestrialDistrict : sampleRow.getTerrestrialLocations()) { @@ -116,24 +122,34 @@ public class SampleRowsFilterValues extends AbstractFilterValues { } } } - for (Dcf5Code dcf5Code : sampleRow.getDcf5Code()) { - FishingGearDcf fishingGearDcf = dcf5Code.getFishingGearDcf(); - String fishingGearLabel = fishingGearDcf.getCode() + " - " + l(locale, fishingGearDcf.getI18nKey()); - fishingGearDcfs.add( - FilterOption.forValueAndLabel( - fishingGearDcf.getTopiaId(), - fishingGearLabel) - ); - TargetSpeciesDcf targetSpeciesDcf = dcf5Code.getTargetSpeciesDcf(); - if (targetSpeciesDcf != null) { - String targetspeciesLabel = targetSpeciesDcf.getCode() + " - " + l(locale, targetSpeciesDcf.getI18nKey()); - targetSpeciesDcfs.add( + if (obsProgram.isObsMer() || obsProgram.isObsVente()) { + for (Dcf5Code dcf5Code : sampleRow.getDcf5Code()) { + FishingGearDcf fishingGearDcf = dcf5Code.getFishingGearDcf(); + String fishingGearLabel = fishingGearDcf.getCode() + " - " + l(locale, fishingGearDcf.getI18nKey()); + fishingGearDcfs.add( FilterOption.forValueAndLabel( - targetSpeciesDcf.getTopiaId(), - targetspeciesLabel) + fishingGearDcf.getTopiaId(), + fishingGearLabel) ); + TargetSpeciesDcf targetSpeciesDcf = dcf5Code.getTargetSpeciesDcf(); + if (targetSpeciesDcf != null) { + String targetSpeciesLabel = targetSpeciesDcf.getCode() + " - " + l(locale, targetSpeciesDcf.getI18nKey()); + targetSpeciesDcfs.add( + FilterOption.forValueAndLabel( + targetSpeciesDcf.getTopiaId(), + targetSpeciesLabel) + ); + } } } + if (obsProgram.isSclerochronology()) { + individualMeasurementStrategies.add( + FilterOption.forEnum(locale, sampleRow.getIndividualMeasurementStrategy())); + sclerochronologySamplingContexts.add( + FilterOption.forEnum(locale, sampleRow.getSclerochronologySamplingContext())); + species.add( + FilterOption.forValueAndLabel(sampleRow.getSpecies().getTopiaId(), sampleRow.getSpecies().getVernacularName())); + } } } } @@ -154,8 +170,8 @@ public class SampleRowsFilterValues extends AbstractFilterValues { return programNames; } - public SortedSet<FilterOption> getCompanies() { - return companies; + public SortedSet<FilterOption> getOrganisations() { + return organisations; } public SortedSet<FilterOption> getSamplingStrategies() { @@ -174,6 +190,18 @@ public class SampleRowsFilterValues extends AbstractFilterValues { return targetSpeciesDcfs; } + public SortedSet<FilterOption> getIndividualMeasurementStrategies() { + return individualMeasurementStrategies; + } + + public SortedSet<FilterOption> getSclerochronologySamplingContexts() { + return sclerochronologySamplingContexts; + } + + public SortedSet<FilterOption> getSpecies() { + return species; + } + public void setFishingZoneFacadeNames(SortedSet<FilterOption> fishingZoneFacadeNames) { this.fishingZoneFacadeNames = fishingZoneFacadeNames; } @@ -190,8 +218,8 @@ public class SampleRowsFilterValues extends AbstractFilterValues { this.programNames = programNames; } - public void setCompanies(SortedSet<FilterOption> companies) { - this.companies = companies; + public void setOrganisations(SortedSet<FilterOption> organisations) { + this.organisations = organisations; } public void setSamplingStrategies(SortedSet<FilterOption> samplingStrategies) { @@ -210,6 +238,18 @@ public class SampleRowsFilterValues extends AbstractFilterValues { this.targetSpeciesDcfs = targetSpeciesDcfs; } + public void setIndividualMeasurementStrategies(SortedSet<FilterOption> individualMeasurementStrategies) { + this.individualMeasurementStrategies = individualMeasurementStrategies; + } + + public void setSclerochronologySamplingContexts(SortedSet<FilterOption> sclerochronologySamplingContexts) { + this.sclerochronologySamplingContexts = sclerochronologySamplingContexts; + } + + public void setSpecies(SortedSet<FilterOption> species) { + this.species = species; + } + public SampleRowsFilterValues getCopyWithSingleProperty(String propertyName) { SampleRowsFilterValues copy = new SampleRowsFilterValues(locale, obsProgram, optionalCompanyId); copyProperty(copy, propertyName); diff --git a/wao-services/src/main/java/fr/ifremer/wao/services/service/SamplingPlanService.java b/wao-services/src/main/java/fr/ifremer/wao/services/service/SamplingPlanService.java index 6df485f..90e934b 100644 --- a/wao-services/src/main/java/fr/ifremer/wao/services/service/SamplingPlanService.java +++ b/wao-services/src/main/java/fr/ifremer/wao/services/service/SamplingPlanService.java @@ -196,7 +196,7 @@ public class SamplingPlanService extends WaoServiceSupport { // Very very important to do that at beginning // Evo #2227 : Guest user has no default company filter if (authenticatedWaoUser.isCoordinatorOrObserver()) { - newFilter.setCompanyIds(Sets.newHashSet(authenticatedWaoUser.getCompany().getTopiaId())); + newFilter.setOrganisationIds(Sets.newHashSet(authenticatedWaoUser.getCompany().getTopiaId())); } return newFilter; @@ -207,7 +207,7 @@ public class SamplingPlanService extends WaoServiceSupport { SampleRowsFilter sampleRowsFilter = newSampleRowsFilter(authenticatedWaoUser); - sampleRowsFilter.setCompanyIds(ImmutableSet.of(companyId)); + sampleRowsFilter.setOrganisationIds(ImmutableSet.of(companyId)); Date now = getNow(); sampleRowsFilter.setPeriodFrom(now); diff --git a/wao-services/src/main/java/fr/ifremer/wao/services/service/SclerochronologySamplingPlan.java b/wao-services/src/main/java/fr/ifremer/wao/services/service/SclerochronologySamplingPlan.java index d23fefd..9fccaff 100644 --- a/wao-services/src/main/java/fr/ifremer/wao/services/service/SclerochronologySamplingPlan.java +++ b/wao-services/src/main/java/fr/ifremer/wao/services/service/SclerochronologySamplingPlan.java @@ -40,6 +40,8 @@ public class SclerochronologySamplingPlan extends SamplingPlan implements Iterab public static class SclerochronologySamplingPlanSampleRowPart extends SamplingPlanSampleRowPart { + protected final String organisationFullName; + protected String samplingContext; protected String samplingContextInfo; @@ -54,6 +56,11 @@ public class SclerochronologySamplingPlan extends SamplingPlan implements Iterab samplingContext = WaoUtils.l(locale, sampleRow.getSclerochronologySamplingContext()); samplingContextInfo = sampleRow.getSclerochronologySamplingContextInfo(); individualMeasurementStrategy = WaoUtils.l(locale, sampleRow.getIndividualMeasurementStrategy()); + organisationFullName = sampleRow.getOrganisation().getFullName(); + } + + public String getOrganisationFullName() { + return organisationFullName; } public String getSamplingContextInfo() { @@ -102,6 +109,10 @@ public class SclerochronologySamplingPlan extends SamplingPlan implements Iterab throw new UnsupportedOperationException("not in " + ObsProgram.SCLEROCHRONOLOGY); } + @Override + public String getCompanyName() { + throw new UnsupportedOperationException("not in " + ObsProgram.SCLEROCHRONOLOGY); + } } } \ No newline at end of file diff --git a/wao-services/src/main/resources/i18n/wao-services_en_GB.properties b/wao-services/src/main/resources/i18n/wao-services_en_GB.properties index a8a104a..77607c5 100644 --- a/wao-services/src/main/resources/i18n/wao-services_en_GB.properties +++ b/wao-services/src/main/resources/i18n/wao-services_en_GB.properties @@ -86,7 +86,7 @@ wao.import.sampleRow.failure.codeMustBeUnique=Line %s\: The sample row code must wao.import.sampleRow.failure.fishingZoneMissing=Line %s\: You must precise at least one fishing zone wao.import.sampleRow.failure.missingDcf5Codes=Line %s\: You must precise at least one DCF5 code wao.import.sampleRow.failure.missingFishingZones=Line %s\: You must precise at least one fishing zone -wao.import.sampleRow.failure.missingIndividualMeasurementStrategy= Line %s\: You myst precise measurement strategy +wao.import.sampleRow.failure.missingIndividualMeasurementStrategy=Line %s\: You myst precise measurement strategy wao.import.sampleRow.failure.missingPeriodBegin=Line %s\: You must precise the period beginning wao.import.sampleRow.failure.missingPeriodEnd=Line %s\: You must precise the period end wao.import.sampleRow.failure.missingProfessionSpecies=Line %s\: For this sampling strategy, you must provide the species diff --git a/wao-services/src/test/java/fr/ifremer/wao/services/service/SclerochronologyFixtures.java b/wao-services/src/test/java/fr/ifremer/wao/services/service/SclerochronologyFixtures.java index 0310d5e..431bcb7 100644 --- a/wao-services/src/test/java/fr/ifremer/wao/services/service/SclerochronologyFixtures.java +++ b/wao-services/src/test/java/fr/ifremer/wao/services/service/SclerochronologyFixtures.java @@ -47,4 +47,19 @@ public class SclerochronologyFixtures extends WaoFixtures { } } + public void samplingPlan() { + fishingZones(); + species(); + oceanet(); + emhLaboratory(); + InputStream input = null; + try { + input = getClass().getResourceAsStream("/import/plan-sclerochronologie.csv"); + serviceContext.newService(SclerochronologySamplingPlanService.class).importSamplingPlan(admin(), input); + } catch (ImportErrorException e) { + throw new WaoTechnicalException(e); + } finally { + IOUtils.closeQuietly(input); + } + } } diff --git a/wao-services/src/test/java/fr/ifremer/wao/services/service/SclerochronologySamplingPlanServiceTest.java b/wao-services/src/test/java/fr/ifremer/wao/services/service/SclerochronologySamplingPlanServiceTest.java index b959dab..24b9d68 100644 --- a/wao-services/src/test/java/fr/ifremer/wao/services/service/SclerochronologySamplingPlanServiceTest.java +++ b/wao-services/src/test/java/fr/ifremer/wao/services/service/SclerochronologySamplingPlanServiceTest.java @@ -1,12 +1,15 @@ package fr.ifremer.wao.services.service; +import fr.ifremer.wao.SampleRowsFilter; import fr.ifremer.wao.services.AbstractWaoServiceTest; +import fr.ifremer.wao.services.AuthenticatedWaoUser; import org.apache.commons.io.IOUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.junit.Assert; import org.junit.Before; import org.junit.Test; +import org.nuiton.util.DateUtil; import java.io.InputStream; @@ -46,6 +49,27 @@ public class SclerochronologySamplingPlanServiceTest extends AbstractWaoServiceT } finally { IOUtils.closeQuietly(input); } + } + @Test + public void newSampleRowsFilterPeriodMustBeOnJanuaryToDecemberOfTheCurrentYear() { + applicationContext.setDate(DateUtil.createDate(15, 1, 2015)); + fixtures.samplingPlan(); + SampleRowsFilter filter = service.newSampleRowsFilter(fixtures.admin()); + Assert.assertEquals(DateUtil.createDate(1, 1, 2015), filter.getPeriodFrom()); + Assert.assertEquals(DateUtil.createDate(1, 12, 2015), filter.getPeriodTo()); + } + + @Test + public void samplingPlan() { + applicationContext.setDate(DateUtil.createDate(15, 1, 2015)); + fixtures.samplingPlan(); + AuthenticatedWaoUser admin = fixtures.admin(); + SampleRowsFilter filter = service.newSampleRowsFilter(admin); + SclerochronologySamplingPlan samplingPlan = service.getSamplingPlan(admin, filter); + Assert.assertEquals(2, samplingPlan.getFilterValues().getSpecies().size()); + Assert.assertEquals(3, samplingPlan.getFilterValues().getIndividualMeasurementStrategies().size()); + Assert.assertEquals(3, samplingPlan.getFilterValues().getSclerochronologySamplingContexts().size()); + Assert.assertEquals(2, samplingPlan.getFilterValues().getOrganisations().size()); } } \ No newline at end of file diff --git a/wao-web/src/main/java/fr/ifremer/wao/web/action/SampleRowsFilterValuesJsonAction.java b/wao-web/src/main/java/fr/ifremer/wao/web/action/SampleRowsFilterValuesJsonAction.java index af44cc4..e9ebef9 100644 --- a/wao-web/src/main/java/fr/ifremer/wao/web/action/SampleRowsFilterValuesJsonAction.java +++ b/wao-web/src/main/java/fr/ifremer/wao/web/action/SampleRowsFilterValuesJsonAction.java @@ -23,10 +23,13 @@ package fr.ifremer.wao.web.action; import com.opensymphony.xwork2.Preparable; import fr.ifremer.wao.SampleRowsFilter; +import fr.ifremer.wao.entity.ObsProgram; +import fr.ifremer.wao.services.AuthenticatedWaoUser; import fr.ifremer.wao.services.service.ObsMerSamplingPlanService; import fr.ifremer.wao.services.service.ObsVenteSamplingPlanService; import fr.ifremer.wao.services.service.SampleRowsFilterValues; import fr.ifremer.wao.services.service.SamplingPlan; +import fr.ifremer.wao.services.service.SclerochronologySamplingPlanService; import fr.ifremer.wao.web.WaoJsonActionSupport; import org.apache.commons.lang3.StringUtils; @@ -34,9 +37,11 @@ public class SampleRowsFilterValuesJsonAction extends WaoJsonActionSupport imple private static final long serialVersionUID = 1L; - protected transient ObsMerSamplingPlanService obsMerSamplingPlanService; + protected ObsMerSamplingPlanService obsMerSamplingPlanService; - protected transient ObsVenteSamplingPlanService obsVenteSamplingPlanService; + protected ObsVenteSamplingPlanService obsVenteSamplingPlanService; + + protected SclerochronologySamplingPlanService sclerochronologySamplingPlanService; protected SampleRowsFilter filter; @@ -52,6 +57,10 @@ public class SampleRowsFilterValuesJsonAction extends WaoJsonActionSupport imple this.obsVenteSamplingPlanService = obsVenteSamplingPlanService; } + public void setSclerochronologySamplingPlanService(SclerochronologySamplingPlanService sclerochronologySamplingPlanService) { + this.sclerochronologySamplingPlanService = sclerochronologySamplingPlanService; + } + public SampleRowsFilter getFilter() { if (filter == null) { prepare(); @@ -66,7 +75,18 @@ public class SampleRowsFilterValuesJsonAction extends WaoJsonActionSupport imple @Override public void prepare() { - filter = obsMerSamplingPlanService.newSampleRowsFilter(session.getAuthenticatedWaoUser()); + AuthenticatedWaoUser authenticatedWaoUser = session.getAuthenticatedWaoUser(); + ObsProgram obsProgram = authenticatedWaoUser.getObsProgram(); + + if (obsProgram.isObsMer()) { + filter = obsMerSamplingPlanService.newSampleRowsFilter(authenticatedWaoUser); + } else if (obsProgram.isObsVente()) { + filter = obsVenteSamplingPlanService.newSampleRowsFilter(authenticatedWaoUser); + } else if (obsProgram.isSclerochronology()) { + filter = sclerochronologySamplingPlanService.newSampleRowsFilter(authenticatedWaoUser); + } else { + throw new UnsupportedOperationException(); + } } @@ -74,13 +94,17 @@ public class SampleRowsFilterValuesJsonAction extends WaoJsonActionSupport imple public String execute() { SamplingPlan samplingPlan; - if (filter.getObsProgram().isObsMer()) { + ObsProgram obsProgram = filter.getObsProgram(); + if (obsProgram.isObsMer()) { samplingPlan = obsMerSamplingPlanService.getSamplingPlan(session.getAuthenticatedWaoUser(), filter); - } else if (filter.getObsProgram().isObsVente()) { + } else if (obsProgram.isObsVente()) { samplingPlan = obsVenteSamplingPlanService.getSamplingPlan(session.getAuthenticatedWaoUser(), filter); + } else if (obsProgram.isSclerochronology()) { + samplingPlan = sclerochronologySamplingPlanService.getSamplingPlan(session.getAuthenticatedWaoUser(), filter); } else { throw new UnsupportedOperationException(); } + filterValues = samplingPlan.getFilterValues(); if (StringUtils.isNotBlank(filterValuesField)) { diff --git a/wao-web/src/main/webapp/WEB-INF/content/boat-details.jsp b/wao-web/src/main/webapp/WEB-INF/content/boat-details.jsp index 8348778..622afb5 100644 --- a/wao-web/src/main/webapp/WEB-INF/content/boat-details.jsp +++ b/wao-web/src/main/webapp/WEB-INF/content/boat-details.jsp @@ -171,7 +171,7 @@ <s:url action="contacts!applyFilter" id="viewAssociatedContactsForBoatUrl"> <s:param name="filter.boatFilter.registrationCode" value="boatDetails.boatInfos.boat.registrationCode"/> - <s:param name="filter.sampleRowFilter.companyIds" value="boatDetails.boatInfos.company.topiaId"/> + <s:param name="filter.sampleRowFilter.organisationIds" value="boatDetails.boatInfos.company.topiaId"/> <s:param name="filter.periodFrom"/> <s:param name="filter.periodTo"/> </s:url> diff --git a/wao-web/src/main/webapp/WEB-INF/content/contacts.jsp b/wao-web/src/main/webapp/WEB-INF/content/contacts.jsp index a644fea..0181289 100644 --- a/wao-web/src/main/webapp/WEB-INF/content/contacts.jsp +++ b/wao-web/src/main/webapp/WEB-INF/content/contacts.jsp @@ -35,7 +35,7 @@ var contactsFilterMappings = [ <s:if test="authenticatedWaoUser.authorizedToViewOtherCompanies"> { - filterName: 'sampleRowFilter.companyIds', + filterName: 'sampleRowFilter.organisationIds', filterLabel: "<s:text name="wao.ui.entity.Company"/>", filterValuesField: 'sampleRowsFilterValues.companies', }, diff --git a/wao-web/src/main/webapp/WEB-INF/content/obsmer/sampling-plan.jsp b/wao-web/src/main/webapp/WEB-INF/content/obsmer/sampling-plan.jsp index 3a6e28b..08138b8 100644 --- a/wao-web/src/main/webapp/WEB-INF/content/obsmer/sampling-plan.jsp +++ b/wao-web/src/main/webapp/WEB-INF/content/obsmer/sampling-plan.jsp @@ -37,9 +37,9 @@ var sampleRowsFilterMappings = [ <s:if test="authenticatedWaoUser.authorizedToViewOtherCompanies"> { - filterName: 'companyIds', + filterName: 'organisationIds', filterLabel: "<s:text name="wao.ui.entity.Company"/>", - filterValuesField: 'companies', + filterValuesField: 'organisations', }, </s:if> { @@ -458,7 +458,7 @@ <s:url action="sampling-plan!applyFilter" id="sampleRowZoomUrl"> <s:param name="filter.periodFrom" value="%{formatMonth(firstSampleMonthDate)}"/> <s:param name="filter.periodTo" value="%{formatMonth(lastSampleMonthDate)}"/> - <s:param name="filter.companyIds" value="%{filter.companyIds}"/> + <s:param name="filter.organisationIds" value="%{filter.organisationIds}"/> <s:param name="filter.programNames" value="%{filter.programNames}"/> <s:param name="filter.sampleRowCodes" value="%{filter.sampleRowCodes}"/> <s:param name="filter.fishingZoneFacadeNames" value="%{filter.targetSpeciesDcfIds}"/> diff --git a/wao-web/src/main/webapp/WEB-INF/content/obsvente/sampling-plan.jsp b/wao-web/src/main/webapp/WEB-INF/content/obsvente/sampling-plan.jsp index cd1417c..c785096 100644 --- a/wao-web/src/main/webapp/WEB-INF/content/obsvente/sampling-plan.jsp +++ b/wao-web/src/main/webapp/WEB-INF/content/obsvente/sampling-plan.jsp @@ -38,9 +38,9 @@ var sampleRowsFilterMappings = [ <s:if test="authenticatedWaoUser.authorizedToViewOtherCompanies"> { - filterName: 'companyIds', + filterName: 'organisationIds', filterLabel: "<s:text name="wao.ui.entity.Company"/>", - filterValuesField: 'companies', + filterValuesField: 'organisations', }, </s:if> { @@ -417,7 +417,7 @@ <s:url action="sampling-plan!applyFilter" id="sampleRowZoomUrl"> <s:param name="filter.periodFrom" value="%{formatMonth(firstSampleMonthDate)}"/> <s:param name="filter.periodTo" value="%{formatMonth(lastSampleMonthDate)}"/> - <s:param name="filter.companyIds" value="%{filter.companyIds}"/> + <s:param name="filter.organisationIds" value="%{filter.organisationIds}"/> <s:param name="filter.programNames" value="%{filter.programNames}"/> <s:param name="filter.sampleRowCodes" value="%{filter.sampleRowCodes}"/> <s:param name="filter.fishingZoneFacadeNames" value="%{filter.targetSpeciesDcfIds}"/> diff --git a/wao-web/src/main/webapp/WEB-INF/content/sclerochronology/sampling-plan.jsp b/wao-web/src/main/webapp/WEB-INF/content/sclerochronology/sampling-plan.jsp index 30dd0c5..b9c4b7b 100644 --- a/wao-web/src/main/webapp/WEB-INF/content/sclerochronology/sampling-plan.jsp +++ b/wao-web/src/main/webapp/WEB-INF/content/sclerochronology/sampling-plan.jsp @@ -38,9 +38,9 @@ var sampleRowsFilterMappings = [ <s:if test="authenticatedWaoUser.authorizedToViewOtherCompanies"> { - filterName: 'companyIds', - filterLabel: "<s:text name="wao.ui.entity.Company"/>", - filterValuesField: 'companies', + filterName: 'organisationIds', + filterLabel: "<s:text name="wao.ui.entity.Organisation"/>", + filterValuesField: 'organisations', }, </s:if> { @@ -66,7 +66,7 @@ { filterName: 'samplingContext', filterLabel: "<s:text name="wao.ui.field.SampleRow.sclerochronologySamplingContext"/>", - filterValuesField: 'samplingContexts', + filterValuesField: 'sclerochronologySamplingContexts', }, { filterName: 'individualMeasurementStrategy', @@ -288,7 +288,7 @@ <td><s:property value="programName" /></td> <s:if test="authenticatedWaoUser.authorizedToViewOtherCompanies"> <td class="only-in-full-view"> - <s:property value="companyName" /> + <s:property value="organisationFullName" /> </td> </s:if> <td class="only-in-full-view"><s:property value="fishingZones" /></td> @@ -366,7 +366,7 @@ <s:url action="sampling-plan!applyFilter" id="sampleRowZoomUrl"> <s:param name="filter.periodFrom" value="%{formatMonth(firstSampleMonthDate)}"/> <s:param name="filter.periodTo" value="%{formatMonth(lastSampleMonthDate)}"/> - <s:param name="filter.companyIds" value="%{filter.companyIds}"/> + <s:param name="filter.organisationIds" value="%{filter.organisationIds}"/> <s:param name="filter.programNames" value="%{filter.programNames}"/> <s:param name="filter.sampleRowCodes" value="%{filter.sampleRowCodes}"/> <s:param name="filter.fishingZoneFacadeNames" value="%{filter.targetSpeciesDcfIds}"/> diff --git a/wao-web/src/main/webapp/WEB-INF/content/synthesis.jsp b/wao-web/src/main/webapp/WEB-INF/content/synthesis.jsp index 0f1d4ac..c7a8be8 100644 --- a/wao-web/src/main/webapp/WEB-INF/content/synthesis.jsp +++ b/wao-web/src/main/webapp/WEB-INF/content/synthesis.jsp @@ -37,9 +37,9 @@ var contactsFilterMappings = [ <s:if test="authenticatedWaoUser.authorizedToViewOtherCompanies"> { - filterName: 'sampleRowFilter.companyIds', + filterName: 'sampleRowFilter.organisationIds', filterLabel: "<s:text name="wao.ui.entity.Company"/>", - filterValuesField: 'sampleRowsFilterValues.companies', + filterValuesField: 'sampleRowsFilterValues.organisations', }, </s:if> { -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature/2263 in repository wao. See http://git.codelutin.com/wao.git commit 321824f7e06ca6331d81be51c38b135eed7962a6 Author: Brendan Le Ny <bleny@codelutin.com> Date: Thu Dec 18 16:37:42 2014 +0100 Ajout des champs scléro dans le formulaire de modification d'une ligne du plan --- .../wao/services/service/SamplingPlanService.java | 18 +++- .../services/service/UpdateSampleRowCommand.java | 51 ++++++++++ .../wao/web/action/EditSampleRowAction.java | 17 +--- .../WEB-INF/content/edit-sample-row-input.jsp | 108 ++++++++++++++------- 4 files changed, 144 insertions(+), 50 deletions(-) diff --git a/wao-services/src/main/java/fr/ifremer/wao/services/service/SamplingPlanService.java b/wao-services/src/main/java/fr/ifremer/wao/services/service/SamplingPlanService.java index 90e934b..f2c72a1 100644 --- a/wao-services/src/main/java/fr/ifremer/wao/services/service/SamplingPlanService.java +++ b/wao-services/src/main/java/fr/ifremer/wao/services/service/SamplingPlanService.java @@ -59,6 +59,7 @@ import fr.ifremer.wao.entity.SampleRowLog; import fr.ifremer.wao.entity.SampleRowLogImpl; import fr.ifremer.wao.entity.SampleRowLogTopiaDao; import fr.ifremer.wao.entity.SampleRowTopiaDao; +import fr.ifremer.wao.entity.Species; import fr.ifremer.wao.entity.TerrestrialLocation; import fr.ifremer.wao.entity.TerrestrialLocationTopiaDao; import fr.ifremer.wao.services.AuthenticatedWaoUser; @@ -288,7 +289,7 @@ public class SamplingPlanService extends WaoServiceSupport { ObsProgram obsProgram = authenticatedWaoUser.getObsProgram(); - UpdateSampleRowCommand updateSampleRowCommand = new UpdateSampleRowCommand(); + UpdateSampleRowCommand updateSampleRowCommand = new UpdateSampleRowCommand(serviceContext.getLocale()); if (optionalSampleRowId.isPresent()) { @@ -341,9 +342,11 @@ public class SamplingPlanService extends WaoServiceSupport { updateSampleRowCommand.setSampleRowLog(newSampleRowLog); updateSampleRowCommand.getSampleRow().addSampleRowLog(newSampleRowLog); + ReferentialService referentialService = getReferentialService(); + ImmutableMap<String, FishingZone> allFishingZones = Maps.uniqueIndex( - getReferentialService().getAllFishingZones(), + referentialService.getAllFishingZones(), TopiaEntities.getTopiaIdFunction() ); updateSampleRowCommand.setAllFishingZones(allFishingZones); @@ -358,18 +361,25 @@ public class SamplingPlanService extends WaoServiceSupport { ImmutableMap<String, Dcf5Code> allDcf5Codes = Maps.uniqueIndex( - getReferentialService().getAllDcf5Codes(), + referentialService.getAllDcf5Codes(), TopiaEntities.getTopiaIdFunction() ); updateSampleRowCommand.setAllDcf5Codes(allDcf5Codes); ImmutableMap<String, TerrestrialLocation> allTerrestrialDistricts = Maps.uniqueIndex( - getReferentialService().getAllTerrestrialDistricts(), + referentialService.getAllTerrestrialDistricts(), TopiaEntities.getTopiaIdFunction() ); updateSampleRowCommand.setAllTerrestrialDistricts(allTerrestrialDistricts); + ImmutableMap<String, Species> allSpecies = + Maps.uniqueIndex( + referentialService.getAllSpecies(), + TopiaEntities.getTopiaIdFunction() + ); + updateSampleRowCommand.setAllSpecies(allSpecies); + return updateSampleRowCommand; } diff --git a/wao-services/src/main/java/fr/ifremer/wao/services/service/UpdateSampleRowCommand.java b/wao-services/src/main/java/fr/ifremer/wao/services/service/UpdateSampleRowCommand.java index 2087a68..cf233e9 100644 --- a/wao-services/src/main/java/fr/ifremer/wao/services/service/UpdateSampleRowCommand.java +++ b/wao-services/src/main/java/fr/ifremer/wao/services/service/UpdateSampleRowCommand.java @@ -27,12 +27,16 @@ import com.google.common.collect.Collections2; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Iterables; import com.google.common.collect.Sets; +import fr.ifremer.wao.WaoUtils; import fr.ifremer.wao.entity.Company; import fr.ifremer.wao.entity.Dcf5Code; import fr.ifremer.wao.entity.FishingZone; +import fr.ifremer.wao.entity.IndividualMeasurementStrategy; import fr.ifremer.wao.entity.SampleMonth; import fr.ifremer.wao.entity.SampleRow; import fr.ifremer.wao.entity.SampleRowLog; +import fr.ifremer.wao.entity.SclerochronologySamplingContext; +import fr.ifremer.wao.entity.Species; import fr.ifremer.wao.entity.TerrestrialLocation; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; @@ -44,7 +48,9 @@ import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Collection; import java.util.Date; +import java.util.EnumMap; import java.util.LinkedHashMap; +import java.util.Locale; import java.util.Map; import java.util.Set; @@ -52,6 +58,8 @@ public class UpdateSampleRowCommand implements Serializable{ private static final long serialVersionUID = 1L; + protected Locale locale; + protected DateFormat monthFormat = new SimpleDateFormat("yyyyMM"); protected boolean creation; @@ -72,11 +80,17 @@ public class UpdateSampleRowCommand implements Serializable{ protected ImmutableMap<String, TerrestrialLocation> allTerrestrialDistricts; + protected ImmutableMap<String, Species> allSpecies; + /** * La clé est un mois au format YYYY-MM */ protected Map<String, Integer> expectedObservationsByMonths; + public UpdateSampleRowCommand(Locale locale) { + this.locale = locale; + } + public Map<String, Integer> getExpectedObservationsByMonths() { if (expectedObservationsByMonths == null) { expectedObservationsByMonths = new LinkedHashMap<>(); @@ -245,4 +259,41 @@ public class UpdateSampleRowCommand implements Serializable{ public void setSampleRowMemento(SampleRow sampleRowMemento) { this.sampleRowMemento = sampleRowMemento; } + + public ImmutableMap<SclerochronologySamplingContext, String> getAllSclerochronologySamplingContexts() { + EnumMap<SclerochronologySamplingContext, String> allSclerochronologySamplingContexts = new EnumMap<>(SclerochronologySamplingContext.class); + for (SclerochronologySamplingContext sclerochronologySamplingContext : SclerochronologySamplingContext.values()) { + allSclerochronologySamplingContexts.put(sclerochronologySamplingContext, WaoUtils.l(locale, sclerochronologySamplingContext)); + } + return ImmutableMap.copyOf(allSclerochronologySamplingContexts); + } + + public ImmutableMap<IndividualMeasurementStrategy, String> getAllIndividualMeasurementStrategies() { + EnumMap<IndividualMeasurementStrategy, String> allIndividualMeasurementStrategies = new EnumMap<>(IndividualMeasurementStrategy.class); + for (IndividualMeasurementStrategy individualMeasurementStrategy : IndividualMeasurementStrategy.values()) { + allIndividualMeasurementStrategies.put(individualMeasurementStrategy, WaoUtils.l(locale, individualMeasurementStrategy)); + } + return ImmutableMap.copyOf(allIndividualMeasurementStrategies); + } + + public ImmutableMap<String, Species> getAllSpecies() { + return allSpecies; + } + + public void setAllSpecies(ImmutableMap<String, Species> allSpecies) { + this.allSpecies = allSpecies; + } + + public String getSpeciesId() { + String speciesId = null; + if (sampleRow.getSpecies() != null) { + speciesId = sampleRow.getSpecies().getTopiaId(); + } + return speciesId; + } + + public void setSpeciesId(String speciesId) { + Species species = allSpecies.get(speciesId); + sampleRow.setSpecies(species); + } } diff --git a/wao-web/src/main/java/fr/ifremer/wao/web/action/EditSampleRowAction.java b/wao-web/src/main/java/fr/ifremer/wao/web/action/EditSampleRowAction.java index 814f729..a03b8f9 100644 --- a/wao-web/src/main/java/fr/ifremer/wao/web/action/EditSampleRowAction.java +++ b/wao-web/src/main/java/fr/ifremer/wao/web/action/EditSampleRowAction.java @@ -98,10 +98,6 @@ public class EditSampleRowAction extends WaoJspActionSupport implements Preparab service.validate(getAuthenticatedWaoUser(), updateSampleRowCommand); - if (sampleRow.isDcf5CodeEmpty()) { - addFieldError("updateSampleRowCommand.dcf5Codes", t("wao.ui.form.SampleRow.error.missingDcf5Codes")); - } - } catch (UnknownBoatRegistrationCodesException e) { addFieldError("updateSampleRowCommand.elligibleBoatRegistrationCodes", t("wao.ui.unknownBoatRegistrationCodes", Joiner.on(", ").join(e.getRegistrationCodes()))); } catch (SampleRowCodeMustBeUniqueException e) { @@ -126,16 +122,13 @@ public class EditSampleRowAction extends WaoJspActionSupport implements Preparab } catch (MissingDcf5CodesException e) { addFieldError("updateSampleRowCommand.dcf5Codes", t("wao.ui.form.SampleRow.error.missingDcf5Codes")); } catch (NoEffortDefinedException e) { - addFieldError("updateSampleRowCommand.dcf5Codes", t("wao.ui.form.SampleRow.error.noEffortDefined")); - } - - // TODO brendan 18/12/14 - catch (MissingIndividualMeasurementStrategyException e) { - throw new UnsupportedOperationException(); + addActionError(t("wao.ui.form.SampleRow.error.noEffortDefined")); + } catch (MissingIndividualMeasurementStrategyException e) { + addFieldError("updateSampleRowCommand.sampleRow.individualMeasurementStrategy", t("wao.ui.form.SampleRow.error.noIndividualMeasurementStrategyDefined")); } catch (MissingSclerochronologySamplingContextException e) { - throw new UnsupportedOperationException(); + addFieldError("updateSampleRowCommand.sampleRow.sclerochronologySamplingContext", t("wao.ui.form.SampleRow.error.noSclerochronologySamplingContextDefined")); } catch (MissingSpeciesException e) { - throw new UnsupportedOperationException(); + addFieldError("updateSampleRowCommand.sampleRow.species", t("wao.ui.form.SampleRow.error.noSpeciesDefined")); } } diff --git a/wao-web/src/main/webapp/WEB-INF/content/edit-sample-row-input.jsp b/wao-web/src/main/webapp/WEB-INF/content/edit-sample-row-input.jsp index ba792c8..ab8ccd4 100644 --- a/wao-web/src/main/webapp/WEB-INF/content/edit-sample-row-input.jsp +++ b/wao-web/src/main/webapp/WEB-INF/content/edit-sample-row-input.jsp @@ -118,47 +118,85 @@ <s:hidden name="sampleRowId" value="%{sampleRowId}" /> - <fieldset> + <s:if test="updateSampleRowCommand.sampleRow.obsProgram.obsMer || updateSampleRowCommand.sampleRow.obsProgram.obsVente"> - <legend><s:text name="wao.ui.field.SampleRow.profession" /></legend> + <fieldset> - <s:textfield name="updateSampleRowCommand.sampleRow.profession.libelle" - label="%{getText('wao.ui.field.SampleRow.libelle')}" - disabled="updateSampleRowCommand.observationAlreadyStarted" - cssClass="input-xxlarge" /> + <legend><s:text name="wao.ui.field.SampleRow.profession" /></legend> - <s:textfield name="updateSampleRowCommand.sampleRow.profession.size" - label="%{getText('wao.ui.field.SampleRow.size')}" - disabled="updateSampleRowCommand.observationAlreadyStarted" - inputAppend="m" - cssClass="input-small" /> + <s:textfield name="updateSampleRowCommand.sampleRow.profession.libelle" + label="%{getText('wao.ui.field.SampleRow.libelle')}" + disabled="updateSampleRowCommand.observationAlreadyStarted" + cssClass="input-xxlarge" /> - <s:textfield name="updateSampleRowCommand.sampleRow.profession.meshSize" - label="%{getText('wao.ui.field.SampleRow.meshSize')}" - disabled="updateSampleRowCommand.observationAlreadyStarted" - inputAppend="mm" - cssClass="input-small" /> + <s:textfield name="updateSampleRowCommand.sampleRow.profession.size" + label="%{getText('wao.ui.field.SampleRow.size')}" + disabled="updateSampleRowCommand.observationAlreadyStarted" + inputAppend="m" + cssClass="input-small" /> - <s:textfield name="updateSampleRowCommand.sampleRow.profession.species" - label="%{getText('wao.ui.field.SampleRow.species')}" - disabled="updateSampleRowCommand.observationAlreadyStarted" - cssClass="input-xxlarge" /> + <s:textfield name="updateSampleRowCommand.sampleRow.profession.meshSize" + label="%{getText('wao.ui.field.SampleRow.meshSize')}" + disabled="updateSampleRowCommand.observationAlreadyStarted" + inputAppend="mm" + cssClass="input-small" /> - <s:textfield name="updateSampleRowCommand.sampleRow.profession.other" - label="%{getText('wao.ui.field.SampleRow.other')}" - disabled="updateSampleRowCommand.observationAlreadyStarted" - cssClass="input-xxlarge" /> + <s:textfield name="updateSampleRowCommand.sampleRow.profession.species" + label="%{getText('wao.ui.field.SampleRow.species')}" + disabled="updateSampleRowCommand.observationAlreadyStarted" + cssClass="input-xxlarge" /> - <s:select name="updateSampleRowCommand.dcf5CodesIds" - label="%{getText('wao.ui.field.SampleRow.dcf5Codes')}" - disabled="updateSampleRowCommand.observationAlreadyStarted" - list="updateSampleRowCommand.allDcf5Codes" - listValue="%{value.code}" - cssClass="input-xxlarge select2" - multiple="true" - /> + <s:textfield name="updateSampleRowCommand.sampleRow.profession.other" + label="%{getText('wao.ui.field.SampleRow.other')}" + disabled="updateSampleRowCommand.observationAlreadyStarted" + cssClass="input-xxlarge" /> - </fieldset> + <s:select name="updateSampleRowCommand.dcf5CodesIds" + label="%{getText('wao.ui.field.SampleRow.dcf5Codes')}" + disabled="updateSampleRowCommand.observationAlreadyStarted" + list="updateSampleRowCommand.allDcf5Codes" + listValue="%{value.code}" + cssClass="input-xxlarge select2" + multiple="true" + /> + + </fieldset> + + </s:if> + + <s:if test="updateSampleRowCommand.sampleRow.obsProgram.sclerochronology"> + + <fieldset> + + <legend><s:text name="wao.ui.field.SampleRow.profession" /></legend> + + <s:select name="updateSampleRowCommand.sampleRow.sclerochronologySamplingContext" + label="%{getText('wao.ui.field.SampleRow.sclerochronologySamplingContext')}" + list="updateSampleRowCommand.allSclerochronologySamplingContexts" + disabled="updateSampleRowCommand.observationAlreadyStarted" /> + + <s:textfield name="updateSampleRowCommand.sampleRow.sclerochronologySamplingContextInfo" + label="%{getText('wao.ui.field.SampleRow.sclerochronologySamplingContextInfo')}" + cssClass="input-xxlarge" + disabled="updateSampleRowCommand.observationAlreadyStarted" /> + + <s:select name="updateSampleRowCommand.sampleRow.individualMeasurementStrategy" + label="%{getText('wao.ui.field.SampleRow.individualMeasurementStrategy')}" + list="updateSampleRowCommand.allIndividualMeasurementStrategies" + cssClass="input-xlarge" + disabled="updateSampleRowCommand.observationAlreadyStarted" /> + + <s:select name="updateSampleRowCommand.speciesId" + label="%{getText('wao.ui.field.SampleRow.species')}" + disabled="updateSampleRowCommand.observationAlreadyStarted" + list="updateSampleRowCommand.allSpecies" + listValue="%{value.permanentCode + ' ' + value.vernacularName}" + cssClass="input-xxlarge select2" + /> + + </fieldset> + + </s:if> <fieldset> @@ -257,7 +295,9 @@ </s:if> - <s:textarea name="updateSampleRowCommand.elligibleBoatRegistrationCodes" label="%{getText('wao.ui.field.SampleRow.elligibleBoat')}" /> + <s:if test="updateSampleRowCommand.sampleRow.obsProgram.obsMer || updateSampleRowCommand.sampleRow.obsProgram.obsVente"> + <s:textarea name="updateSampleRowCommand.elligibleBoatRegistrationCodes" label="%{getText('wao.ui.field.SampleRow.elligibleBoat')}" /> + </s:if> <s:textarea name="updateSampleRowCommand.sampleRow.comment" label="%{getText('wao.ui.field.SampleRow.comment')}" /> -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature/2263 in repository wao. See http://git.codelutin.com/wao.git commit 626b064a5985fa0ac36176bfc71e7091e7271220 Author: Brendan Le Ny <bleny@codelutin.com> Date: Thu Dec 18 16:56:26 2014 +0100 Les filtres du plan sont désormais effectifs --- .../main/java/fr/ifremer/wao/SampleRowsFilter.java | 52 ++++++++++++++++++++-- .../fr/ifremer/wao/entity/SampleRowTopiaDao.java | 12 +++++ .../content/sclerochronology/sampling-plan.jsp | 4 +- 3 files changed, 63 insertions(+), 5 deletions(-) diff --git a/wao-persistence/src/main/java/fr/ifremer/wao/SampleRowsFilter.java b/wao-persistence/src/main/java/fr/ifremer/wao/SampleRowsFilter.java index 6fc1321..dab068b 100644 --- a/wao-persistence/src/main/java/fr/ifremer/wao/SampleRowsFilter.java +++ b/wao-persistence/src/main/java/fr/ifremer/wao/SampleRowsFilter.java @@ -21,8 +21,10 @@ package fr.ifremer.wao; * #L% */ +import fr.ifremer.wao.entity.IndividualMeasurementStrategy; import fr.ifremer.wao.entity.ObsProgram; import fr.ifremer.wao.entity.SamplingStrategy; +import fr.ifremer.wao.entity.SclerochronologySamplingContext; import org.apache.commons.collections4.CollectionUtils; import java.util.Date; @@ -33,7 +35,7 @@ import java.util.Set; public class SampleRowsFilter extends AbstractWaoFilter { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 2L; protected ObsProgram obsProgram; @@ -69,6 +71,12 @@ public class SampleRowsFilter extends AbstractWaoFilter { protected Set<String> organisationIds; + protected Set<String> species; + + protected Set<IndividualMeasurementStrategy> individualMeasurementStrategies; + + protected Set<SclerochronologySamplingContext> sclerochronologySamplingContexts; + protected LinkedHashSet<String> orderByArguments; public ObsProgram getObsProgram() { @@ -167,6 +175,30 @@ public class SampleRowsFilter extends AbstractWaoFilter { this.organisationIds = organisationIds; } + public Set<String> getSpecies() { + return species; + } + + public void setSpecies(Set<String> species) { + this.species = species; + } + + public Set<IndividualMeasurementStrategy> getIndividualMeasurementStrategies() { + return individualMeasurementStrategies; + } + + public void setIndividualMeasurementStrategies(Set<IndividualMeasurementStrategy> individualMeasurementStrategies) { + this.individualMeasurementStrategies = individualMeasurementStrategies; + } + + public Set<SclerochronologySamplingContext> getSclerochronologySamplingContexts() { + return sclerochronologySamplingContexts; + } + + public void setSclerochronologySamplingContexts(Set<SclerochronologySamplingContext> sclerochronologySamplingContexts) { + this.sclerochronologySamplingContexts = sclerochronologySamplingContexts; + } + public LinkedHashSet<String> getOrderByArguments() { return orderByArguments; } @@ -197,7 +229,11 @@ public class SampleRowsFilter extends AbstractWaoFilter { || CollectionUtils.isNotEmpty(targetSpeciesDcfIds) || CollectionUtils.isNotEmpty(samplingStrategies) || CollectionUtils.isNotEmpty(terrestrialDistrictIds) - || CollectionUtils.isNotEmpty(organisationIds); + || CollectionUtils.isNotEmpty(organisationIds) + || CollectionUtils.isNotEmpty(species) + || CollectionUtils.isNotEmpty(sclerochronologySamplingContexts) + || CollectionUtils.isNotEmpty(individualMeasurementStrategies) + ; return filled; } @@ -222,7 +258,11 @@ public class SampleRowsFilter extends AbstractWaoFilter { && WaoUtils.isEqualCollection(samplingStrategies, that.samplingStrategies) && WaoUtils.isEqualCollection(terrestrialDistrictIds, that.terrestrialDistrictIds) && WaoUtils.isEqualCollection(organisationIds, that.organisationIds) - && WaoUtils.isEqualCollection(orderByArguments, that.orderByArguments); + && WaoUtils.isEqualCollection(species, that.species) + && WaoUtils.isEqualCollection(sclerochronologySamplingContexts, that.sclerochronologySamplingContexts) + && WaoUtils.isEqualCollection(individualMeasurementStrategies, that.individualMeasurementStrategies) + && WaoUtils.isEqualCollection(orderByArguments, that.orderByArguments) + ; return equals; @@ -248,6 +288,9 @@ public class SampleRowsFilter extends AbstractWaoFilter { hashCode = 31 * hashCode + WaoUtils.collectionHashCode(samplingStrategies); hashCode = 31 * hashCode + WaoUtils.collectionHashCode(terrestrialDistrictIds); hashCode = 31 * hashCode + WaoUtils.collectionHashCode(organisationIds); + hashCode = 31 * hashCode + WaoUtils.collectionHashCode(species); + hashCode = 31 * hashCode + WaoUtils.collectionHashCode(sclerochronologySamplingContexts); + hashCode = 31 * hashCode + WaoUtils.collectionHashCode(individualMeasurementStrategies); hashCode = 31 * hashCode + WaoUtils.collectionHashCode(orderByArguments); return hashCode; } @@ -268,6 +311,9 @@ public class SampleRowsFilter extends AbstractWaoFilter { clone.samplingStrategies = samplingStrategies == null ? null : new HashSet<>(samplingStrategies); clone.terrestrialDistrictIds = terrestrialDistrictIds == null ? null : new HashSet<>(terrestrialDistrictIds); clone.organisationIds = organisationIds == null ? null : new HashSet<>(organisationIds); + clone.species = species == null ? null : new HashSet<>(species); + clone.sclerochronologySamplingContexts = sclerochronologySamplingContexts == null ? null : new HashSet<>(sclerochronologySamplingContexts); + clone.individualMeasurementStrategies = individualMeasurementStrategies == null ? null : new HashSet<>(individualMeasurementStrategies); clone.orderByArguments = orderByArguments == null ? null : new LinkedHashSet<>(orderByArguments); return clone; } diff --git a/wao-persistence/src/main/java/fr/ifremer/wao/entity/SampleRowTopiaDao.java b/wao-persistence/src/main/java/fr/ifremer/wao/entity/SampleRowTopiaDao.java index 950fe8e..1fedec7 100644 --- a/wao-persistence/src/main/java/fr/ifremer/wao/entity/SampleRowTopiaDao.java +++ b/wao-persistence/src/main/java/fr/ifremer/wao/entity/SampleRowTopiaDao.java @@ -137,6 +137,18 @@ public class SampleRowTopiaDao extends AbstractSampleRowTopiaDao<SampleRow> { ImmutableMap.of("targetSpeciesDcfIds", (Object) filter.getTargetSpeciesDcfIds())); } + if (CollectionUtils.isNotEmpty(filter.getSpecies())) { + query.addTopiaIdIn(SampleRow.PROPERTY_SPECIES, filter.getSpecies()); + } + + if (CollectionUtils.isNotEmpty(filter.getIndividualMeasurementStrategies())) { + query.addIn(SampleRow.PROPERTY_INDIVIDUAL_MEASUREMENT_STRATEGY, filter.getIndividualMeasurementStrategies()); + } + + if (CollectionUtils.isNotEmpty(filter.getSclerochronologySamplingContexts())) { + query.addIn(SampleRow.PROPERTY_SCLEROCHRONOLOGY_SAMPLING_CONTEXT, filter.getSclerochronologySamplingContexts()); + } + if (log.isTraceEnabled()) { log.trace("query to filter sample rows for " + filter + " is " + query.getHql() + " " + query.getHqlParameters()); } diff --git a/wao-web/src/main/webapp/WEB-INF/content/sclerochronology/sampling-plan.jsp b/wao-web/src/main/webapp/WEB-INF/content/sclerochronology/sampling-plan.jsp index b9c4b7b..bb7a9d9 100644 --- a/wao-web/src/main/webapp/WEB-INF/content/sclerochronology/sampling-plan.jsp +++ b/wao-web/src/main/webapp/WEB-INF/content/sclerochronology/sampling-plan.jsp @@ -64,12 +64,12 @@ filterValuesField: 'fishingZoneSectorNames', }, { - filterName: 'samplingContext', + filterName: 'sclerochronologySamplingContexts', filterLabel: "<s:text name="wao.ui.field.SampleRow.sclerochronologySamplingContext"/>", filterValuesField: 'sclerochronologySamplingContexts', }, { - filterName: 'individualMeasurementStrategy', + filterName: 'individualMeasurementStrategies', filterLabel: "<s:text name="wao.ui.field.SampleRow.individualMeasurementStrategy"/>", filterValuesField: 'individualMeasurementStrategies', }, -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature/2263 in repository wao. See http://git.codelutin.com/wao.git commit 5bcc4c289cf3ff8473efda00a0a1af960f537de5 Author: Brendan Le Ny <bleny@codelutin.com> Date: Thu Dec 18 16:59:10 2014 +0100 Dans le plan scléro, on ajoute une colonne pour l'espèce --- .../webapp/WEB-INF/content/sclerochronology/sampling-plan.jsp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/wao-web/src/main/webapp/WEB-INF/content/sclerochronology/sampling-plan.jsp b/wao-web/src/main/webapp/WEB-INF/content/sclerochronology/sampling-plan.jsp index bb7a9d9..3511394 100644 --- a/wao-web/src/main/webapp/WEB-INF/content/sclerochronology/sampling-plan.jsp +++ b/wao-web/src/main/webapp/WEB-INF/content/sclerochronology/sampling-plan.jsp @@ -182,12 +182,12 @@ </div> <s:if test="authenticatedWaoUser.authorizedToViewOtherCompanies"> - <s:set var="nbColumnsForProfessionInFullView" value="10" /> + <s:set var="nbColumnsForProfessionInFullView" value="11" /> </s:if> <s:else> - <s:set var="nbColumnsForProfessionInFullView" value="9" /> + <s:set var="nbColumnsForProfessionInFullView" value="10" /> </s:else> -<s:set var="nbColumnsForProfessionInCompactView" value="6" /> +<s:set var="nbColumnsForProfessionInCompactView" value="7" /> <s:set var="nbColumnsForMonths" value="%{samplingPlan.months.size() + 1}" /> <s:set var="nbColumnsForOther" value="2" /> <s:set var="nbColumnsTotalInFullView" value="%{#nbColumnsForProfessionInFullView + #nbColumnsForMonths + #nbColumnsForOther}" /> @@ -234,6 +234,7 @@ <th><s:text name="wao.ui.field.SampleRow.sclerochronologySamplingContext"/></th> <th><s:text name="wao.ui.field.SampleRow.sclerochronologySamplingContextInfo"/></th> <th><s:text name="wao.ui.field.SampleRow.individualMeasurementStrategy"/></th> + <th><s:text name="wao.ui.field.SampleRow.species"/></th> <th class="only-in-full-view"><s:text name="wao.ui.field.SampleRow.periodBegin"/></th> <th class="only-in-full-view"><s:text name="wao.ui.field.SampleRow.periodEnd"/></th> @@ -314,6 +315,9 @@ <td> <s:property value="individualMeasurementStrategy"/> </td> + <td> + <s:property value="species"/> + </td> <td class="only-in-full-view"><s:property value="%{formatMonth(periodBegin)}" /></td> <td class="only-in-full-view"><s:property value="%{formatMonth(periodEnd)}" /></td> <!-- Months columns --> -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
participants (1)
-
codelutin.com scm