Author: bleny Date: 2014-09-10 17:53:16 +0200 (Wed, 10 Sep 2014) New Revision: 2250 Url: http://forge.codelutin.com/projects/wao/repository/revisions/2250 Log: Fusion des modifications effectu?\195?\169es dans la branche 4.0.x dans le tronc en 4.1 Added: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/SynthesisCacheKey.java trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/WaoCacheKey.java trunk/wao-services/src/test/java/fr/ifremer/wao/services/service/BoatsFilterValuesCacheKeyTest.java Modified: trunk/ trunk/wao-persistence/src/main/java/fr/ifremer/wao/AbstractWaoFilter.java trunk/wao-persistence/src/main/java/fr/ifremer/wao/BoatsFilter.java 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/entity/ContactTopiaDao.java trunk/wao-services/src/main/java/fr/ifremer/wao/services/DefaultWaoServiceContext.java trunk/wao-services/src/main/java/fr/ifremer/wao/services/WaoApplicationContext.java trunk/wao-services/src/main/java/fr/ifremer/wao/services/WaoServiceContext.java trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/BoatsFilterValuesCacheKey.java trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/BoatsFilterValuesCacheLoader.java trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/BoatsService.java trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactsFilterValuesCacheKey.java trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactsFilterValuesCacheLoader.java trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactsService.java trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/InitWaoService.java trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/NoEffortDefinedException.java trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerSamplingPlanService.java trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsVenteSamplingPlanService.java trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/SamplingPlanCacheKey.java trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/SynthesisService.java trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/operations/DayParserFormatter.java trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/operations/DayTimeParserFormatter.java trunk/wao-services/src/test/java/fr/ifremer/wao/services/FakeWaoApplicationContext.java trunk/wao-web/src/main/java/fr/ifremer/wao/web/CacheInvalidationTopiaEntityListener.java trunk/wao-web/src/main/java/fr/ifremer/wao/web/DefaultWaoApplicationContext.java trunk/wao-web/src/main/java/fr/ifremer/wao/web/WaoActionSupport.java Property changes on: trunk ___________________________________________________________________ Modified: svn:mergeinfo - /branches/wao-4.0-obsvente:2075-2085 /branches/wao-4.0.x:2169-2242 + /branches/wao-4.0-obsvente:2075-2085 /branches/wao-4.0.x:2169-2249 Modified: trunk/wao-persistence/src/main/java/fr/ifremer/wao/AbstractWaoFilter.java =================================================================== --- trunk/wao-persistence/src/main/java/fr/ifremer/wao/AbstractWaoFilter.java 2014-09-10 15:42:18 UTC (rev 2249) +++ trunk/wao-persistence/src/main/java/fr/ifremer/wao/AbstractWaoFilter.java 2014-09-10 15:53:16 UTC (rev 2250) @@ -25,7 +25,7 @@ import java.io.Serializable; -public abstract class AbstractWaoFilter implements Serializable { +public abstract class AbstractWaoFilter implements Serializable, Cloneable { /** Predicate to tell if user actually gave a criteria to filter entities. */ public abstract boolean isFilled(); Modified: trunk/wao-persistence/src/main/java/fr/ifremer/wao/BoatsFilter.java =================================================================== --- trunk/wao-persistence/src/main/java/fr/ifremer/wao/BoatsFilter.java 2014-09-10 15:42:18 UTC (rev 2249) +++ trunk/wao-persistence/src/main/java/fr/ifremer/wao/BoatsFilter.java 2014-09-10 15:53:16 UTC (rev 2250) @@ -24,6 +24,7 @@ import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; +import java.util.HashSet; import java.util.Objects; import java.util.Set; @@ -206,4 +207,19 @@ return filled; } + @Override + public BoatsFilter clone() { + BoatsFilter clone = new BoatsFilter(); + clone.elligibleForSampleRowsFilter = elligibleForSampleRowsFilter.clone(); + clone.boatName = boatName; + clone.registrationCode = registrationCode; + clone.boatNameOrRegistrationCode = boatNameOrRegistrationCode; + clone.boatIds = boatIds == null ? null : new HashSet<>(boatIds); + clone.shipOwnerIds = shipOwnerIds == null ? null : new HashSet<>(shipOwnerIds); + clone.districtIds = districtIds == null ? null : new HashSet<>(districtIds); + clone.portOfRegistryIds = portOfRegistryIds == null ? null : new HashSet<>(portOfRegistryIds); + clone.fleetIds = fleetIds == null ? null : new HashSet<>(fleetIds); + return clone; + } + } Modified: trunk/wao-persistence/src/main/java/fr/ifremer/wao/ContactsFilter.java =================================================================== --- trunk/wao-persistence/src/main/java/fr/ifremer/wao/ContactsFilter.java 2014-09-10 15:42:18 UTC (rev 2249) +++ trunk/wao-persistence/src/main/java/fr/ifremer/wao/ContactsFilter.java 2014-09-10 15:53:16 UTC (rev 2250) @@ -27,8 +27,10 @@ import fr.ifremer.wao.entity.ObservedDataControl; import fr.ifremer.wao.entity.SamplingStrategy; import org.apache.commons.collections4.CollectionUtils; +import org.nuiton.util.DateUtil; import java.util.Date; +import java.util.HashSet; import java.util.Objects; import java.util.Set; @@ -122,7 +124,11 @@ } public void setPeriodFrom(Date periodFrom) { - this.periodFrom = periodFrom; + if (periodFrom == null) { + this.periodFrom = null; + } else { + this.periodFrom = DateUtil.setMinTimeOfDay(periodFrom); + } } public Date getPeriodTo() { @@ -130,7 +136,11 @@ } public void setPeriodTo(Date periodTo) { - this.periodTo = periodTo; + if (periodTo == null) { + this.periodTo = null; + } else { + this.periodTo = DateUtil.setMaxTimeOfDay(periodTo); + } } public Set<ContactState> getContactStates() { @@ -395,4 +405,34 @@ return realVsEstimated; } + @Override + public ContactsFilter clone() { + ContactsFilter clone = new ContactsFilter(); + clone.boatFilter = boatFilter.clone(); + clone.sampleRowFilter = sampleRowFilter.clone(); + clone.periodFrom = periodFrom; + clone.periodTo = periodTo; + clone.periodTo = periodTo; + clone.contactIds = contactIds == null ? null : new HashSet<>(contactIds); + clone.contactStates = contactStates == null ? null : new HashSet<>(contactStates); + clone.dataReliabilities = dataReliabilities == null ? null : new HashSet<>(dataReliabilities); + clone.actualSamplingStrategies = actualSamplingStrategies == null ? null : new HashSet<>(actualSamplingStrategies); + clone.observationTypes = observationTypes == null ? null : new HashSet<>(observationTypes); + clone.observedDataControls = observedDataControls == null ? null : new HashSet<>(observedDataControls); + clone.observerIds = observerIds == null ? null : new HashSet<>(observerIds); + clone.terrestrialLocationIds = terrestrialLocationIds == null ? null : new HashSet<>(terrestrialLocationIds); + clone.contactStateMotiveIds = contactStateMotiveIds == null ? null : new HashSet<>(contactStateMotiveIds); + clone.companyAcceptations = companyAcceptations == null ? null : new HashSet<>(companyAcceptations); + clone.programAcceptations = programAcceptations == null ? null : new HashSet<>(programAcceptations); + clone.completeSamplings = completeSamplings == null ? null : new HashSet<>(completeSamplings); + clone.mammalsCaptureOnly = mammalsCaptureOnly; + clone.mammalsObservationOnly = mammalsObservationOnly; + clone.commentDefinedOnly = commentDefinedOnly; + clone.commentAdminDefinedOnly = commentAdminDefinedOnly; + clone.commentCompanyDefinedOnly = commentCompanyDefinedOnly; + clone.filterOnObservationBeginDate = filterOnObservationBeginDate; + clone.sortedByBoardingDate = sortedByBoardingDate; + return clone; + } + } Modified: trunk/wao-persistence/src/main/java/fr/ifremer/wao/SampleRowsFilter.java =================================================================== --- trunk/wao-persistence/src/main/java/fr/ifremer/wao/SampleRowsFilter.java 2014-09-10 15:42:18 UTC (rev 2249) +++ trunk/wao-persistence/src/main/java/fr/ifremer/wao/SampleRowsFilter.java 2014-09-10 15:53:16 UTC (rev 2250) @@ -26,6 +26,7 @@ import org.apache.commons.collections4.CollectionUtils; import java.util.Date; +import java.util.HashSet; import java.util.Objects; import java.util.Set; @@ -246,7 +247,28 @@ hashCode = 31 * hashCode + WaoUtils.collectionHashcode(samplingStrategies); hashCode = 31 * hashCode + WaoUtils.collectionHashcode(terrestrialDistrictIds); hashCode = 31 * hashCode + WaoUtils.collectionHashcode(companyIds); + hashCode = 31 * hashCode + WaoUtils.collectionHashcode(orderByArguments); return hashCode; } + @Override + public SampleRowsFilter clone() { + SampleRowsFilter clone = new SampleRowsFilter(); + clone.obsProgram = obsProgram; + clone.periodFrom = periodFrom; + clone.periodTo = periodTo; + clone.sampleRowIds = sampleRowIds == null ? null : new HashSet<>(sampleRowIds); + clone.fishingZoneFacadeNames = fishingZoneFacadeNames == null ? null : new HashSet<>(fishingZoneFacadeNames); + clone.fishingZoneSectorNames = fishingZoneSectorNames == null ? null : new HashSet<>(fishingZoneSectorNames); + clone.sampleRowCodes = sampleRowCodes == null ? null : new HashSet<>(sampleRowCodes); + clone.programNames = programNames == null ? null : new HashSet<>(programNames); + clone.fishingGearDcfIds = fishingGearDcfIds == null ? null : new HashSet<>(fishingGearDcfIds); + 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.orderByArguments = orderByArguments == null ? null : new HashSet<>(orderByArguments); + return clone; + } + } 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-09-10 15:42:18 UTC (rev 2249) +++ trunk/wao-persistence/src/main/java/fr/ifremer/wao/entity/ContactTopiaDao.java 2014-09-10 15:53:16 UTC (rev 2250) @@ -37,7 +37,6 @@ import org.nuiton.topia.persistence.TopiaEntity; import org.nuiton.topia.persistence.TopiaQueryBuilderAddCriteriaOrRunQueryStep; import org.nuiton.topia.persistence.TopiaQueryBuilderRunQueryStep; -import org.nuiton.util.DateUtil; import java.util.Arrays; import java.util.Calendar; Modified: trunk/wao-services/src/main/java/fr/ifremer/wao/services/DefaultWaoServiceContext.java =================================================================== --- trunk/wao-services/src/main/java/fr/ifremer/wao/services/DefaultWaoServiceContext.java 2014-09-10 15:42:18 UTC (rev 2249) +++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/DefaultWaoServiceContext.java 2014-09-10 15:53:16 UTC (rev 2250) @@ -22,7 +22,6 @@ */ import com.google.common.cache.Cache; -import fr.ifremer.wao.ContactsFilter; import fr.ifremer.wao.WaoApplicationConfig; import fr.ifremer.wao.WaoTechnicalException; import fr.ifremer.wao.WaoTopiaPersistenceContext; @@ -33,6 +32,7 @@ import fr.ifremer.wao.services.service.SamplingPlan; import fr.ifremer.wao.services.service.SamplingPlanCacheKey; import fr.ifremer.wao.services.service.Synthesis; +import fr.ifremer.wao.services.service.SynthesisCacheKey; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; @@ -127,7 +127,7 @@ } @Override - public Cache<ContactsFilter, Synthesis> getSynthesesCache() { + public Cache<SynthesisCacheKey, Synthesis> getSynthesesCache() { return waoApplicationContext.getSynthesesCache(); } Modified: trunk/wao-services/src/main/java/fr/ifremer/wao/services/WaoApplicationContext.java =================================================================== --- trunk/wao-services/src/main/java/fr/ifremer/wao/services/WaoApplicationContext.java 2014-09-10 15:42:18 UTC (rev 2249) +++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/WaoApplicationContext.java 2014-09-10 15:53:16 UTC (rev 2250) @@ -22,7 +22,6 @@ */ import com.google.common.cache.Cache; -import fr.ifremer.wao.ContactsFilter; import fr.ifremer.wao.WaoApplicationConfig; import fr.ifremer.wao.WaoTopiaPersistenceContext; import fr.ifremer.wao.services.service.BoatsFilterValues; @@ -32,6 +31,7 @@ import fr.ifremer.wao.services.service.SamplingPlan; import fr.ifremer.wao.services.service.SamplingPlanCacheKey; import fr.ifremer.wao.services.service.Synthesis; +import fr.ifremer.wao.services.service.SynthesisCacheKey; import java.util.Date; import java.util.Locale; @@ -64,6 +64,6 @@ Cache<ContactsFilterValuesCacheKey, ContactsFilterValues> getContactsFilterValuesCache(); - Cache<ContactsFilter, Synthesis> getSynthesesCache(); + Cache<SynthesisCacheKey, Synthesis> getSynthesesCache(); } Modified: trunk/wao-services/src/main/java/fr/ifremer/wao/services/WaoServiceContext.java =================================================================== --- trunk/wao-services/src/main/java/fr/ifremer/wao/services/WaoServiceContext.java 2014-09-10 15:42:18 UTC (rev 2249) +++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/WaoServiceContext.java 2014-09-10 15:53:16 UTC (rev 2250) @@ -22,7 +22,6 @@ */ import com.google.common.cache.Cache; -import fr.ifremer.wao.ContactsFilter; import fr.ifremer.wao.WaoApplicationConfig; import fr.ifremer.wao.WaoTopiaPersistenceContext; import fr.ifremer.wao.services.service.BoatsFilterValues; @@ -32,6 +31,7 @@ import fr.ifremer.wao.services.service.SamplingPlan; import fr.ifremer.wao.services.service.SamplingPlanCacheKey; import fr.ifremer.wao.services.service.Synthesis; +import fr.ifremer.wao.services.service.SynthesisCacheKey; import java.util.Date; import java.util.Locale; @@ -64,5 +64,6 @@ Cache<ContactsFilterValuesCacheKey, ContactsFilterValues> getContactsFilterValuesCache(); - Cache<ContactsFilter,Synthesis> getSynthesesCache(); + Cache<SynthesisCacheKey,Synthesis> getSynthesesCache(); + } Modified: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/BoatsFilterValuesCacheKey.java =================================================================== --- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/BoatsFilterValuesCacheKey.java 2014-09-10 15:42:18 UTC (rev 2249) +++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/BoatsFilterValuesCacheKey.java 2014-09-10 15:53:16 UTC (rev 2250) @@ -25,11 +25,11 @@ import com.google.common.base.Optional; import fr.ifremer.wao.BoatsFilter; import fr.ifremer.wao.entity.ObsProgram; +import org.apache.commons.lang3.builder.ReflectionToStringBuilder; -import java.io.Serializable; import java.util.Locale; -public class BoatsFilterValuesCacheKey implements Serializable { +public class BoatsFilterValuesCacheKey implements WaoCacheKey { protected Locale locale; @@ -75,7 +75,19 @@ return optionalCompanyId; } + @Override + public BoatsFilterValuesCacheKey clone() { + BoatsFilter boatsFilterClone = this.boatsFilter.clone(); + BoatsFilterValuesCacheKey clone = new BoatsFilterValuesCacheKey(locale, obsProgram, optionalCompanyId, boatsFilterClone); + return clone; + } + public BoatsFilter getBoatsFilter() { return boatsFilter; } + + @Override + public String toString() { + return ReflectionToStringBuilder.reflectionToString(this); + } } Modified: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/BoatsFilterValuesCacheLoader.java =================================================================== --- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/BoatsFilterValuesCacheLoader.java 2014-09-10 15:42:18 UTC (rev 2249) +++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/BoatsFilterValuesCacheLoader.java 2014-09-10 15:53:16 UTC (rev 2250) @@ -1,5 +1,26 @@ package fr.ifremer.wao.services.service; +/* + * #%L + * Wao :: Services + * %% + * Copyright (C) 2009 - 2014 Ifremer + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ + import com.google.common.cache.CacheLoader; import fr.ifremer.wao.WaoTopiaPersistenceContext; import fr.ifremer.wao.services.WaoApplicationContext; @@ -38,7 +59,7 @@ BoatsService service = waoServiceContext.newService(BoatsService.class); - BoatsFilterValues boatsFilterValues = service.getBoatsFilterValues(key); + BoatsFilterValues boatsFilterValues = service.computeBoatsFilterValues(key); if (log.isTraceEnabled()) { log.trace("will return from refreshing boatFilterValuesCache"); Modified: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/BoatsService.java =================================================================== --- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/BoatsService.java 2014-09-10 15:42:18 UTC (rev 2249) +++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/BoatsService.java 2014-09-10 15:53:16 UTC (rev 2250) @@ -83,27 +83,32 @@ optionalCompanyId, filter); + BoatsFilterValues boatsFilterValues = getBoatsFilterValues(boatsFilterValuesCacheKey); + + return boatsFilterValues; + + } + + public BoatsFilterValues getBoatsFilterValues(BoatsFilterValuesCacheKey boatsFilterValuesCacheKey) { + Cache<BoatsFilterValuesCacheKey, BoatsFilterValues> cache = serviceContext.getBoatsFilterValuesCache(); BoatsFilterValues boatsFilterValues = cache.getIfPresent(boatsFilterValuesCacheKey); if (boatsFilterValues == null) { - if (log.isTraceEnabled()) { log.trace("cache fail, will compute filter values for key " + boatsFilterValuesCacheKey); } - - boatsFilterValues = getBoatsFilterValues(boatsFilterValuesCacheKey); - - cache.put(boatsFilterValuesCacheKey, boatsFilterValues); - + boatsFilterValues = computeBoatsFilterValues(boatsFilterValuesCacheKey); + cache.put(boatsFilterValuesCacheKey.clone(), boatsFilterValues); } return boatsFilterValues; + } - public BoatsFilterValues getBoatsFilterValues(BoatsFilterValuesCacheKey boatsFilterValuesCacheKey) { + public BoatsFilterValues computeBoatsFilterValues(BoatsFilterValuesCacheKey boatsFilterValuesCacheKey) { BoatTopiaDao dao = getBoatDao(); @@ -146,7 +151,7 @@ public BoatsFilter newBoatsFilter(AuthenticatedWaoUser authenticatedWaoUser) { - BoatsFilter boatsFilter = new BoatsFilter(); + BoatsFilter boatsFilter = newEmptyBoatsFilter(); if (authenticatedWaoUser.isProfessional()) { // Pour le profesionnel, on restreint d'office à la liste des bateaux qu'il peut voir @@ -160,6 +165,12 @@ } + public BoatsFilter newEmptyBoatsFilter() { + + return new BoatsFilter(); + + } + public InputStream exportBoats(BoatsFilter filter) { BoatTopiaDao dao = getBoatDao(); Modified: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactsFilterValuesCacheKey.java =================================================================== --- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactsFilterValuesCacheKey.java 2014-09-10 15:42:18 UTC (rev 2249) +++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactsFilterValuesCacheKey.java 2014-09-10 15:53:16 UTC (rev 2250) @@ -25,11 +25,11 @@ import com.google.common.base.Optional; import fr.ifremer.wao.ContactsFilter; import fr.ifremer.wao.entity.ObsProgram; +import org.apache.commons.lang3.builder.ReflectionToStringBuilder; -import java.io.Serializable; import java.util.Locale; -public class ContactsFilterValuesCacheKey implements Serializable { +public class ContactsFilterValuesCacheKey implements WaoCacheKey { protected Locale locale; @@ -78,4 +78,15 @@ public ContactsFilter getContactsFilter() { return contactsFilter; } + + @Override + public String toString() { + return ReflectionToStringBuilder.reflectionToString(this); + } @Override + + public ContactsFilterValuesCacheKey clone() { + ContactsFilter contactsFilterClone = this.contactsFilter.clone(); + ContactsFilterValuesCacheKey clone = new ContactsFilterValuesCacheKey(locale, obsProgram, optionalCompanyId, contactsFilterClone); + return clone; + } } Modified: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactsFilterValuesCacheLoader.java =================================================================== --- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactsFilterValuesCacheLoader.java 2014-09-10 15:42:18 UTC (rev 2249) +++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactsFilterValuesCacheLoader.java 2014-09-10 15:53:16 UTC (rev 2250) @@ -1,5 +1,26 @@ package fr.ifremer.wao.services.service; +/* + * #%L + * Wao :: Services + * %% + * Copyright (C) 2009 - 2014 Ifremer + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ + import com.google.common.cache.CacheLoader; import fr.ifremer.wao.WaoTopiaPersistenceContext; import fr.ifremer.wao.services.WaoApplicationContext; @@ -38,7 +59,7 @@ ContactsService service = waoServiceContext.newService(ContactsService.class); - ContactsFilterValues boatsFilterValues = service.getContactsFilterValues(key); + ContactsFilterValues boatsFilterValues = service.computeContactsFilterValues(key); if (log.isTraceEnabled()) { log.trace("will return from refreshing boatFilterValuesCache"); Modified: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactsService.java =================================================================== --- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactsService.java 2014-09-10 15:42:18 UTC (rev 2249) +++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactsService.java 2014-09-10 15:53:16 UTC (rev 2250) @@ -95,9 +95,9 @@ public ContactsFilter newContactFilter(AuthenticatedWaoUser authenticatedWaoUser) { - ContactsFilter newContactsFilter = new ContactsFilter(); + ObsProgram obsProgram = authenticatedWaoUser.getObsProgram(); - newContactsFilter.getSampleRowFilter().setObsProgram(authenticatedWaoUser.getObsProgram()); + ContactsFilter newContactsFilter = newEmptyContactsFilter(obsProgram); // DO NOT REMOVE THIS if (authenticatedWaoUser.isCoordinatorOrObserver()) { @@ -105,6 +105,24 @@ newContactsFilter.getSampleRowFilter().setCompanyIds(ImmutableSet.of(authenticatedWaoUserCompanyTopiaId)); } + if (authenticatedWaoUser.isProfessional()) { + // Pour le profesionnel, on restreint d'office à la liste des contacts portant sur les bateaux qu'il peut voir + Collection<String> canReadBoatsTopiaIds = authenticatedWaoUser.getWaoUser().getCanReadBoatsTopiaIds(); + if (CollectionUtils.isNotEmpty(canReadBoatsTopiaIds)) { + newContactsFilter.getBoatFilter().setBoatIds(new HashSet<>(canReadBoatsTopiaIds)); + } + } + + return newContactsFilter; + + } + + public ContactsFilter newEmptyContactsFilter(ObsProgram obsProgram) { + + ContactsFilter newContactsFilter = new ContactsFilter(); + + newContactsFilter.getSampleRowFilter().setObsProgram(obsProgram); + Calendar periodFromCalendar = Calendar.getInstance(); periodFromCalendar.setTime(serviceContext.getNow()); @@ -122,14 +140,6 @@ newContactsFilter.setPeriodFrom(periodFrom); newContactsFilter.setPeriodTo(periodTo); - if (authenticatedWaoUser.isProfessional()) { - // Pour le profesionnel, on restreint d'office à la liste des contacts portant sur les bateaux qu'il peut voir - Collection<String> canReadBoatsTopiaIds = authenticatedWaoUser.getWaoUser().getCanReadBoatsTopiaIds(); - if (CollectionUtils.isNotEmpty(canReadBoatsTopiaIds)) { - newContactsFilter.getBoatFilter().setBoatIds(new HashSet<>(canReadBoatsTopiaIds)); - } - } - return newContactsFilter; } @@ -147,20 +157,32 @@ ContactsFilterValuesCacheKey cacheKey = new ContactsFilterValuesCacheKey(locale, obsProgram, optionalCompanyId, filter); + ContactsFilterValues contactsFilterValues = getContactsFilterValues(cacheKey); + + return contactsFilterValues; + + } + + public ContactsFilterValues getContactsFilterValues(ContactsFilterValuesCacheKey cacheKey) { + Cache<ContactsFilterValuesCacheKey, ContactsFilterValues> cache = serviceContext.getContactsFilterValuesCache(); ContactsFilterValues contactsFilterValues = cache.getIfPresent(cacheKey); if (contactsFilterValues == null) { - contactsFilterValues = getContactsFilterValues(cacheKey); - cache.put(cacheKey, contactsFilterValues); + if (log.isTraceEnabled()) { + log.trace("cache fail, will compute filter values for key " + cacheKey); + } + contactsFilterValues = computeContactsFilterValues(cacheKey); + cache.put(cacheKey.clone(), contactsFilterValues); } return contactsFilterValues; + } - public ContactsFilterValues getContactsFilterValues(ContactsFilterValuesCacheKey cacheKey) { + public ContactsFilterValues computeContactsFilterValues(ContactsFilterValuesCacheKey cacheKey) { ContactTopiaDao dao = getContactDao(); Modified: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/InitWaoService.java =================================================================== --- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/InitWaoService.java 2014-09-10 15:42:18 UTC (rev 2249) +++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/InitWaoService.java 2014-09-10 15:53:16 UTC (rev 2250) @@ -21,16 +21,55 @@ * #L% */ +import com.google.common.base.Optional; +import com.google.common.collect.ImmutableSet; +import fr.ifremer.wao.BoatsFilter; +import fr.ifremer.wao.ContactsFilter; +import fr.ifremer.wao.entity.ObsProgram; import fr.ifremer.wao.services.service.administration.ReferentialService; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import java.util.Locale; + public class InitWaoService extends WaoServiceSupport { + private static final Log log = LogFactory.getLog(InitWaoService.class); + public void init() { ReferentialService referentialService = getReferentialService(); referentialService.initialImport(); + // pré-chargement des caches + + if (getApplicationConfig().isCachingEnabled()) { + + if (log.isInfoEnabled()) { + log.info("début du pré-chargement des caches"); + } + + BoatsService boatsService = newService(BoatsService.class); + ContactsService contactsService = newService(ContactsService.class); + for (ObsProgram obsProgram : ImmutableSet.of(ObsProgram.OBSMER, ObsProgram.OBSVENTE)) { + + BoatsFilter boatsFilter = boatsService.newEmptyBoatsFilter(); + Optional<String> absentCompanyId = Optional.absent(); + BoatsFilterValuesCacheKey boatsFilterValuesCacheKey = new BoatsFilterValuesCacheKey(Locale.FRANCE, obsProgram, absentCompanyId, boatsFilter); + boatsService.getBoatsFilterValues(boatsFilterValuesCacheKey); + + ContactsFilter contactsFilter = contactsService.newEmptyContactsFilter(obsProgram); + ContactsFilterValuesCacheKey contactsFilterValuesCacheKey = new ContactsFilterValuesCacheKey(Locale.FRANCE, obsProgram, absentCompanyId, contactsFilter); + contactsService.getContactsFilterValues(contactsFilterValuesCacheKey); + } + + if (log.isInfoEnabled()) { + log.info("pré-chargement des caches terminé"); + } + + } + } } Modified: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/NoEffortDefinedException.java =================================================================== --- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/NoEffortDefinedException.java 2014-09-10 15:42:18 UTC (rev 2249) +++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/NoEffortDefinedException.java 2014-09-10 15:53:16 UTC (rev 2250) @@ -1,5 +1,26 @@ package fr.ifremer.wao.services.service; +/* + * #%L + * Wao :: Services + * %% + * Copyright (C) 2009 - 2014 Ifremer + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ + import fr.ifremer.wao.entity.SampleRow; public class NoEffortDefinedException extends SampleRowValidationException { 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-09-10 15:42:18 UTC (rev 2249) +++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerSamplingPlanService.java 2014-09-10 15:53:16 UTC (rev 2250) @@ -127,7 +127,7 @@ } result = builder.toPlan(); - samplingPlansCache.put(samplingPlanCacheKey, result); + samplingPlansCache.put(samplingPlanCacheKey.clone(), result); } Modified: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsVenteSamplingPlanService.java =================================================================== --- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsVenteSamplingPlanService.java 2014-09-10 15:42:18 UTC (rev 2249) +++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsVenteSamplingPlanService.java 2014-09-10 15:53:16 UTC (rev 2250) @@ -77,7 +77,7 @@ } result = builder.toPlan(); - samplingPlansCache.put(samplingPlanCacheKey, result); + samplingPlansCache.put(samplingPlanCacheKey.clone(), result); } Modified: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/SamplingPlanCacheKey.java =================================================================== --- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/SamplingPlanCacheKey.java 2014-09-10 15:42:18 UTC (rev 2249) +++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/SamplingPlanCacheKey.java 2014-09-10 15:53:16 UTC (rev 2250) @@ -25,10 +25,9 @@ import com.google.common.base.Optional; import fr.ifremer.wao.SampleRowsFilter; -import java.io.Serializable; import java.util.Locale; -public class SamplingPlanCacheKey implements Serializable { +public class SamplingPlanCacheKey implements WaoCacheKey { protected Locale locale; @@ -58,4 +57,10 @@ return Objects.hashCode(locale, optionalCompanyId, sampleRowsFilter); } + @Override + public SamplingPlanCacheKey clone() { + SampleRowsFilter sampleRowsFilterClone = this.sampleRowsFilter.clone(); + SamplingPlanCacheKey clone = new SamplingPlanCacheKey(locale, optionalCompanyId, sampleRowsFilterClone); + return clone; + } } Copied: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/SynthesisCacheKey.java (from rev 2249, branches/wao-4.0.x/wao-services/src/main/java/fr/ifremer/wao/services/service/SynthesisCacheKey.java) =================================================================== --- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/SynthesisCacheKey.java (rev 0) +++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/SynthesisCacheKey.java 2014-09-10 15:53:16 UTC (rev 2250) @@ -0,0 +1,54 @@ +package fr.ifremer.wao.services.service; + +/* + * #%L + * Wao :: Services + * %% + * Copyright (C) 2009 - 2014 Ifremer + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ + +import com.google.common.base.Objects; +import fr.ifremer.wao.ContactsFilter; + +public class SynthesisCacheKey implements WaoCacheKey { + + protected ContactsFilter contactsFilter; + + public SynthesisCacheKey(ContactsFilter contactsFilter) { + this.contactsFilter = contactsFilter; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + SynthesisCacheKey that = (SynthesisCacheKey) o; + boolean equals = Objects.equal(contactsFilter, that.contactsFilter); + return equals; + } + + @Override + public int hashCode() { + return Objects.hashCode(contactsFilter); + } + + @Override + protected SynthesisCacheKey clone() { + return new SynthesisCacheKey(contactsFilter.clone()); + } + +} Modified: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/SynthesisService.java =================================================================== --- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/SynthesisService.java 2014-09-10 15:42:18 UTC (rev 2249) +++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/SynthesisService.java 2014-09-10 15:53:16 UTC (rev 2250) @@ -81,10 +81,12 @@ public Synthesis getSynthesis(ContactsFilter filter) { - Cache<ContactsFilter, Synthesis> cache = serviceContext.getSynthesesCache(); + Cache<SynthesisCacheKey, Synthesis> cache = serviceContext.getSynthesesCache(); - Synthesis synthesis = cache.getIfPresent(filter); + SynthesisCacheKey synthesisCacheKey = new SynthesisCacheKey(filter); + Synthesis synthesis = cache.getIfPresent(synthesisCacheKey); + if (synthesis == null) { ContactTopiaDao dao = getContactDao(); @@ -113,7 +115,7 @@ companySynthesis.setCompanyName(company.getName()); } - cache.put(filter, synthesis); + cache.put(synthesisCacheKey.clone(), synthesis); } Copied: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/WaoCacheKey.java (from rev 2249, branches/wao-4.0.x/wao-services/src/main/java/fr/ifremer/wao/services/service/WaoCacheKey.java) =================================================================== --- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/WaoCacheKey.java (rev 0) +++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/WaoCacheKey.java 2014-09-10 15:53:16 UTC (rev 2250) @@ -0,0 +1,37 @@ +package fr.ifremer.wao.services.service; + +/* + * #%L + * Wao :: Services + * %% + * Copyright (C) 2009 - 2014 Ifremer + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ + +import java.io.Serializable; + +/** + * Ce contrat représente les classes qui peuvent être utilisées comme clé d'un cache dans Wao. + * + * Il est important que les instances soient {@link java.lang.Cloneable} car un même objet filtre + * peut être utiliser pour faire plusieurs requêtes différentes sur le cache. + * + * À l'insertion dans le cache, on clone la clé : ainsi, on est sûr de ne pas pouvoir avoir d'effet + * de bord sur la clé du cache si l'objet qui compose la clé est modifié. + */ +public interface WaoCacheKey extends Serializable, Cloneable { + +} Property changes on: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/csv ___________________________________________________________________ Modified: svn:mergeinfo - /branches/wao-1.5.x/wao-business/src/main/java/fr/ifremer/wao/io/csv2/models:679-733 /branches/wao-4.0-obsvente/wao-services/src/main/java/fr/ifremer/wao/services/service/csv:2075-2085 /branches/wao-4.0.x/wao-services/src/main/java/fr/ifremer/wao/services/service/csv:2169-2227 + /branches/wao-1.5.x/wao-business/src/main/java/fr/ifremer/wao/io/csv2/models:679-733 /branches/wao-4.0-obsvente/wao-services/src/main/java/fr/ifremer/wao/services/service/csv:2075-2085 /branches/wao-4.0.x/wao-services/src/main/java/fr/ifremer/wao/services/service/csv:2169-2249 Modified: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/operations/DayParserFormatter.java =================================================================== --- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/operations/DayParserFormatter.java 2014-09-10 15:42:18 UTC (rev 2249) +++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/operations/DayParserFormatter.java 2014-09-10 15:53:16 UTC (rev 2250) @@ -1,5 +1,26 @@ package fr.ifremer.wao.services.service.csv.operations; +/* + * #%L + * Wao :: Services + * %% + * Copyright (C) 2009 - 2014 Ifremer + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ + import fr.ifremer.wao.WaoUtils; import org.nuiton.csv.Common; import org.nuiton.i18n.I18n; Modified: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/operations/DayTimeParserFormatter.java =================================================================== --- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/operations/DayTimeParserFormatter.java 2014-09-10 15:42:18 UTC (rev 2249) +++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/operations/DayTimeParserFormatter.java 2014-09-10 15:53:16 UTC (rev 2250) @@ -1,5 +1,26 @@ package fr.ifremer.wao.services.service.csv.operations; +/* + * #%L + * Wao :: Services + * %% + * Copyright (C) 2009 - 2014 Ifremer + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ + import fr.ifremer.wao.WaoUtils; import org.nuiton.csv.Common; import org.nuiton.i18n.I18n; Modified: trunk/wao-services/src/test/java/fr/ifremer/wao/services/FakeWaoApplicationContext.java =================================================================== --- trunk/wao-services/src/test/java/fr/ifremer/wao/services/FakeWaoApplicationContext.java 2014-09-10 15:42:18 UTC (rev 2249) +++ trunk/wao-services/src/test/java/fr/ifremer/wao/services/FakeWaoApplicationContext.java 2014-09-10 15:53:16 UTC (rev 2250) @@ -24,7 +24,6 @@ import com.google.common.base.Preconditions; import com.google.common.cache.Cache; import com.google.common.cache.CacheBuilder; -import fr.ifremer.wao.ContactsFilter; import fr.ifremer.wao.WaoApplicationConfig; import fr.ifremer.wao.WaoTechnicalException; import fr.ifremer.wao.WaoTopiaApplicationContext; @@ -37,6 +36,7 @@ import fr.ifremer.wao.services.service.SamplingPlan; import fr.ifremer.wao.services.service.SamplingPlanCacheKey; import fr.ifremer.wao.services.service.Synthesis; +import fr.ifremer.wao.services.service.SynthesisCacheKey; import org.apache.commons.lang3.SystemUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -77,7 +77,7 @@ protected Cache<ContactsFilterValuesCacheKey, ContactsFilterValues> contactsFilterValuesCache; - protected Cache<ContactsFilter, Synthesis> synthesisCache; + protected Cache<SynthesisCacheKey, Synthesis> synthesisCache; public FakeWaoApplicationContext(String context, boolean initWithReferential) { this.context = context; @@ -295,7 +295,7 @@ } @Override - public Cache<ContactsFilter, Synthesis> getSynthesesCache() { + public Cache<SynthesisCacheKey, Synthesis> getSynthesesCache() { if (synthesisCache == null) { synthesisCache = CacheBuilder.newBuilder().build(); } Copied: trunk/wao-services/src/test/java/fr/ifremer/wao/services/service/BoatsFilterValuesCacheKeyTest.java (from rev 2249, branches/wao-4.0.x/wao-services/src/test/java/fr/ifremer/wao/services/service/BoatsFilterValuesCacheKeyTest.java) =================================================================== --- trunk/wao-services/src/test/java/fr/ifremer/wao/services/service/BoatsFilterValuesCacheKeyTest.java (rev 0) +++ trunk/wao-services/src/test/java/fr/ifremer/wao/services/service/BoatsFilterValuesCacheKeyTest.java 2014-09-10 15:53:16 UTC (rev 2250) @@ -0,0 +1,55 @@ +package fr.ifremer.wao.services.service; + +/* + * #%L + * Wao :: Services + * %% + * Copyright (C) 2009 - 2014 Ifremer + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ + +import com.google.common.base.Optional; +import com.google.common.collect.Sets; +import fr.ifremer.wao.BoatsFilter; +import fr.ifremer.wao.entity.ObsProgram; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.junit.Assert; +import org.junit.Test; + +import java.util.Locale; + +public class BoatsFilterValuesCacheKeyTest { + + private static final Log log = LogFactory.getLog(BoatsFilterValuesCacheKeyTest.class); + + @Test + public void testClone() { + + BoatsFilter boatsFilter = new BoatsFilter(); + boatsFilter.setBoatIds(Sets.newHashSet("oneBoatId")); + + BoatsFilterValuesCacheKey cacheKey = new BoatsFilterValuesCacheKey(Locale.FRANCE, ObsProgram.OBSMER, Optional.of("Toto"), boatsFilter); + + BoatsFilterValuesCacheKey clone = cacheKey.clone(); + + boatsFilter.getBoatIds().add("anotherBoatId"); + + Assert.assertFalse(clone.getBoatsFilter().getBoatIds().contains("anotherBoatId")); + + } + +} \ No newline at end of file Modified: trunk/wao-web/src/main/java/fr/ifremer/wao/web/CacheInvalidationTopiaEntityListener.java =================================================================== --- trunk/wao-web/src/main/java/fr/ifremer/wao/web/CacheInvalidationTopiaEntityListener.java 2014-09-10 15:42:18 UTC (rev 2249) +++ trunk/wao-web/src/main/java/fr/ifremer/wao/web/CacheInvalidationTopiaEntityListener.java 2014-09-10 15:53:16 UTC (rev 2250) @@ -22,7 +22,6 @@ */ import com.google.common.cache.Cache; -import fr.ifremer.wao.ContactsFilter; import fr.ifremer.wao.entity.Boat; import fr.ifremer.wao.entity.Contact; import fr.ifremer.wao.entity.ElligibleBoat; @@ -32,6 +31,7 @@ import fr.ifremer.wao.services.service.SamplingPlan; import fr.ifremer.wao.services.service.SamplingPlanCacheKey; import fr.ifremer.wao.services.service.Synthesis; +import fr.ifremer.wao.services.service.SynthesisCacheKey; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -57,7 +57,7 @@ protected Cache<BoatsFilterValuesCacheKey, BoatsFilterValues> boatsFilterValuesCache; - protected Cache<ContactsFilter, Synthesis> synthesesCache; + protected Cache<SynthesisCacheKey, Synthesis> synthesesCache; protected Set<String> dirtySampleRowIds = new HashSet<>(); @@ -81,7 +81,7 @@ public CacheInvalidationTopiaEntityListener( Cache<SamplingPlanCacheKey, SamplingPlan> samplingPlansCache, Cache<BoatsFilterValuesCacheKey, BoatsFilterValues> boatsFilterValuesCache, - Cache<ContactsFilter, Synthesis> synthesesCache) { + Cache<SynthesisCacheKey, Synthesis> synthesesCache) { this.samplingPlansCache = samplingPlansCache; this.boatsFilterValuesCache = boatsFilterValuesCache; this.synthesesCache = synthesesCache; @@ -157,8 +157,8 @@ } } samplingPlansCache.invalidateAll(samplingPlansCacheKeysToInvalidate); - Set<ContactsFilter> synthesesCacheKeysToInvalidate = new HashSet<>(); - for (Map.Entry<ContactsFilter, Synthesis> entry : synthesesCache.asMap().entrySet()) { + Set<SynthesisCacheKey> synthesesCacheKeysToInvalidate = new HashSet<>(); + for (Map.Entry<SynthesisCacheKey, Synthesis> entry : synthesesCache.asMap().entrySet()) { if (CollectionUtils.containsAny(entry.getValue().getSampleRowIds(), dirtySampleRowIds)) { synthesesCacheKeysToInvalidate.add(entry.getKey()); } Modified: trunk/wao-web/src/main/java/fr/ifremer/wao/web/DefaultWaoApplicationContext.java =================================================================== --- trunk/wao-web/src/main/java/fr/ifremer/wao/web/DefaultWaoApplicationContext.java 2014-09-10 15:42:18 UTC (rev 2249) +++ trunk/wao-web/src/main/java/fr/ifremer/wao/web/DefaultWaoApplicationContext.java 2014-09-10 15:53:16 UTC (rev 2250) @@ -42,6 +42,7 @@ import fr.ifremer.wao.services.service.SamplingPlan; import fr.ifremer.wao.services.service.SamplingPlanCacheKey; import fr.ifremer.wao.services.service.Synthesis; +import fr.ifremer.wao.services.service.SynthesisCacheKey; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.log4j.LogManager; @@ -75,7 +76,7 @@ protected Cache<BoatsFilterValuesCacheKey, BoatsFilterValues> boatsFilterValuesCache; - protected Cache<ContactsFilter, Synthesis> synthesesCache; + protected Cache<SynthesisCacheKey, Synthesis> synthesesCache; protected Cache<ContactsFilterValuesCacheKey, ContactsFilterValues> contactsFilterValuesCache; @@ -142,7 +143,7 @@ } @Override - public Cache<ContactsFilter, Synthesis> getSynthesesCache() { + public Cache<SynthesisCacheKey, Synthesis> getSynthesesCache() { if (synthesesCache == null) { synthesesCache = newCacheBuilder(100).expireAfterAccess(30, TimeUnit.DAYS).build(); } Modified: trunk/wao-web/src/main/java/fr/ifremer/wao/web/WaoActionSupport.java =================================================================== --- trunk/wao-web/src/main/java/fr/ifremer/wao/web/WaoActionSupport.java 2014-09-10 15:42:18 UTC (rev 2249) +++ trunk/wao-web/src/main/java/fr/ifremer/wao/web/WaoActionSupport.java 2014-09-10 15:53:16 UTC (rev 2250) @@ -26,8 +26,6 @@ import org.apache.commons.logging.LogFactory; import org.nuiton.web.struts2.BaseAction; -import java.util.Locale; - public class WaoActionSupport extends BaseAction { private static final long serialVersionUID = 1L; @@ -58,12 +56,4 @@ // ignore fragment get parameter: it's managed by sitemesh decorators } - @Override - public Locale getLocale() { - Locale locale = super.getLocale(); - if (log.isDebugEnabled()) { - log.debug("locale is " + locale); - } - return locale; - } }