Wao-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- 2352 discussions
10 Sep '14
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;
- }
}
1
0
The Wao team is pleased to announce the wao-4.0.11 release!
Application pour le suivi contractuels d'observations scientifiques de la pêche
Documentation of the project can be found here:
http://doc.codelutin.com/wao
Changes
-------
Changes in this version include:
Fixed Bugs:
o Le réalisé affiché dans le plan ne se met pas à jour suite à la suppression d'un contact Issue: 5756. Thanks to Brendan Le Ny. Resolved by bleny.
Downloads
---------
For a manual installation, you can download files here:
http://forge.codelutin.com/projects/wao/files
* wao-4.0.11.war - http://forge.codelutin.com/attachments/download/2254
Maven artifacts
---------------
Artifacts are deployed in nuiton maven repository
http://maven.nuiton.org/other-releases/
Have fun!
-Wao team
1
0
r2249 - in branches/wao-4.0.x: . wao-persistence wao-services wao-web
by maven-release@users.forge.codelutin.com 10 Sep '14
by maven-release@users.forge.codelutin.com 10 Sep '14
10 Sep '14
Author: maven-release
Date: 2014-09-10 17:42:18 +0200 (Wed, 10 Sep 2014)
New Revision: 2249
Url: http://forge.codelutin.com/projects/wao/repository/revisions/2249
Log:
[maven-release-plugin] prepare for next development iteration
Modified:
branches/wao-4.0.x/pom.xml
branches/wao-4.0.x/wao-persistence/pom.xml
branches/wao-4.0.x/wao-services/pom.xml
branches/wao-4.0.x/wao-web/pom.xml
Modified: branches/wao-4.0.x/pom.xml
===================================================================
--- branches/wao-4.0.x/pom.xml 2014-09-10 15:42:13 UTC (rev 2248)
+++ branches/wao-4.0.x/pom.xml 2014-09-10 15:42:18 UTC (rev 2249)
@@ -10,7 +10,7 @@
<groupId>fr.ifremer</groupId>
<artifactId>wao</artifactId>
- <version>4.0.11</version>
+ <version>4.0.12-SNAPSHOT</version>
<packaging>pom</packaging>
<name>Wao</name>
@@ -86,9 +86,9 @@
</modules>
<scm>
- <connection>scm:svn:http://svn.codelutin.com/wao/tags/wao-4.0.11</connection>
- <developerConnection>scm:svn:https://svn.codelutin.com/wao/tags/wao-4.0.11</developerConnection>
- <url>https://forge.codelutin.com/repositories/browse/wao/tags/wao-4.0.11</url>
+ <connection>scm:svn:http://svn.codelutin.com/wao/branches/wao-4.0.x</connection>
+ <developerConnection>scm:svn:https://svn.codelutin.com/wao/branches/wao-4.0.x</developerConnection>
+ <url>https://forge.codelutin.com/repositories/browse/wao/branches/wao-4.0.x</url>
</scm>
<properties>
Modified: branches/wao-4.0.x/wao-persistence/pom.xml
===================================================================
--- branches/wao-4.0.x/wao-persistence/pom.xml 2014-09-10 15:42:13 UTC (rev 2248)
+++ branches/wao-4.0.x/wao-persistence/pom.xml 2014-09-10 15:42:18 UTC (rev 2249)
@@ -5,7 +5,7 @@
<parent>
<groupId>fr.ifremer</groupId>
<artifactId>wao</artifactId>
- <version>4.0.11</version>
+ <version>4.0.12-SNAPSHOT</version>
</parent>
<artifactId>wao-persistence</artifactId>
Modified: branches/wao-4.0.x/wao-services/pom.xml
===================================================================
--- branches/wao-4.0.x/wao-services/pom.xml 2014-09-10 15:42:13 UTC (rev 2248)
+++ branches/wao-4.0.x/wao-services/pom.xml 2014-09-10 15:42:18 UTC (rev 2249)
@@ -5,7 +5,7 @@
<parent>
<groupId>fr.ifremer</groupId>
<artifactId>wao</artifactId>
- <version>4.0.11</version>
+ <version>4.0.12-SNAPSHOT</version>
</parent>
<artifactId>wao-services</artifactId>
Modified: branches/wao-4.0.x/wao-web/pom.xml
===================================================================
--- branches/wao-4.0.x/wao-web/pom.xml 2014-09-10 15:42:13 UTC (rev 2248)
+++ branches/wao-4.0.x/wao-web/pom.xml 2014-09-10 15:42:18 UTC (rev 2249)
@@ -5,7 +5,7 @@
<parent>
<groupId>fr.ifremer</groupId>
<artifactId>wao</artifactId>
- <version>4.0.11</version>
+ <version>4.0.12-SNAPSHOT</version>
</parent>
<artifactId>wao-web</artifactId>
1
0
Author: maven-release
Date: 2014-09-10 17:42:13 +0200 (Wed, 10 Sep 2014)
New Revision: 2248
Url: http://forge.codelutin.com/projects/wao/repository/revisions/2248
Log:
[maven-release-plugin] copy for tag wao-4.0.11
Added:
tags/wao-4.0.11/
Property changes on: tags/wao-4.0.11
___________________________________________________________________
Added: svn:mergeinfo
+ /branches/wao-4.0-obsvente:2075-2085
Added: svn:ignore
+ *.idea
*.iml
target
atlassian-ide-plugin.xml
1
0
r2247 - in branches/wao-4.0.x: . wao-persistence wao-services wao-web
by maven-release@users.forge.codelutin.com 10 Sep '14
by maven-release@users.forge.codelutin.com 10 Sep '14
10 Sep '14
Author: maven-release
Date: 2014-09-10 17:42:07 +0200 (Wed, 10 Sep 2014)
New Revision: 2247
Url: http://forge.codelutin.com/projects/wao/repository/revisions/2247
Log:
[maven-release-plugin] prepare release wao-4.0.11
Modified:
branches/wao-4.0.x/pom.xml
branches/wao-4.0.x/wao-persistence/pom.xml
branches/wao-4.0.x/wao-services/pom.xml
branches/wao-4.0.x/wao-web/pom.xml
Modified: branches/wao-4.0.x/pom.xml
===================================================================
--- branches/wao-4.0.x/pom.xml 2014-09-10 15:38:23 UTC (rev 2246)
+++ branches/wao-4.0.x/pom.xml 2014-09-10 15:42:07 UTC (rev 2247)
@@ -10,7 +10,7 @@
<groupId>fr.ifremer</groupId>
<artifactId>wao</artifactId>
- <version>4.0.11-SNAPSHOT</version>
+ <version>4.0.11</version>
<packaging>pom</packaging>
<name>Wao</name>
@@ -86,9 +86,9 @@
</modules>
<scm>
- <connection>scm:svn:http://svn.codelutin.com/wao/branches/wao-4.0.x</connection>
- <developerConnection>scm:svn:https://svn.codelutin.com/wao/branches/wao-4.0.x</developerConnection>
- <url>https://forge.codelutin.com/repositories/browse/wao/branches/wao-4.0.x</url>
+ <connection>scm:svn:http://svn.codelutin.com/wao/tags/wao-4.0.11</connection>
+ <developerConnection>scm:svn:https://svn.codelutin.com/wao/tags/wao-4.0.11</developerConnection>
+ <url>https://forge.codelutin.com/repositories/browse/wao/tags/wao-4.0.11</url>
</scm>
<properties>
Modified: branches/wao-4.0.x/wao-persistence/pom.xml
===================================================================
--- branches/wao-4.0.x/wao-persistence/pom.xml 2014-09-10 15:38:23 UTC (rev 2246)
+++ branches/wao-4.0.x/wao-persistence/pom.xml 2014-09-10 15:42:07 UTC (rev 2247)
@@ -5,7 +5,7 @@
<parent>
<groupId>fr.ifremer</groupId>
<artifactId>wao</artifactId>
- <version>4.0.11-SNAPSHOT</version>
+ <version>4.0.11</version>
</parent>
<artifactId>wao-persistence</artifactId>
Modified: branches/wao-4.0.x/wao-services/pom.xml
===================================================================
--- branches/wao-4.0.x/wao-services/pom.xml 2014-09-10 15:38:23 UTC (rev 2246)
+++ branches/wao-4.0.x/wao-services/pom.xml 2014-09-10 15:42:07 UTC (rev 2247)
@@ -5,7 +5,7 @@
<parent>
<groupId>fr.ifremer</groupId>
<artifactId>wao</artifactId>
- <version>4.0.11-SNAPSHOT</version>
+ <version>4.0.11</version>
</parent>
<artifactId>wao-services</artifactId>
Modified: branches/wao-4.0.x/wao-web/pom.xml
===================================================================
--- branches/wao-4.0.x/wao-web/pom.xml 2014-09-10 15:38:23 UTC (rev 2246)
+++ branches/wao-4.0.x/wao-web/pom.xml 2014-09-10 15:42:07 UTC (rev 2247)
@@ -5,7 +5,7 @@
<parent>
<groupId>fr.ifremer</groupId>
<artifactId>wao</artifactId>
- <version>4.0.11-SNAPSHOT</version>
+ <version>4.0.11</version>
</parent>
<artifactId>wao-web</artifactId>
1
0
r2246 - in branches/wao-4.0.x/wao-services/src: main/java/fr/ifremer/wao/services/service main/java/fr/ifremer/wao/services/service/csv/operations test/java/fr/ifremer/wao/services test/java/fr/ifremer/wao/services/service
by bleny@users.forge.codelutin.com 10 Sep '14
by bleny@users.forge.codelutin.com 10 Sep '14
10 Sep '14
Author: bleny
Date: 2014-09-10 17:38:23 +0200 (Wed, 10 Sep 2014)
New Revision: 2246
Url: http://forge.codelutin.com/projects/wao/repository/revisions/2246
Log:
Ajout des ent?\195?\170tes de licences manquants en 4.0.x
Modified:
branches/wao-4.0.x/wao-services/src/main/java/fr/ifremer/wao/services/service/BoatsFilterValuesCacheLoader.java
branches/wao-4.0.x/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactsFilterValuesCacheLoader.java
branches/wao-4.0.x/wao-services/src/main/java/fr/ifremer/wao/services/service/NoEffortDefinedException.java
branches/wao-4.0.x/wao-services/src/main/java/fr/ifremer/wao/services/service/SynthesisCacheKey.java
branches/wao-4.0.x/wao-services/src/main/java/fr/ifremer/wao/services/service/WaoCacheKey.java
branches/wao-4.0.x/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/operations/DayParserFormatter.java
branches/wao-4.0.x/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/operations/DayTimeParserFormatter.java
branches/wao-4.0.x/wao-services/src/test/java/fr/ifremer/wao/services/FakeWaoApplicationContext.java
branches/wao-4.0.x/wao-services/src/test/java/fr/ifremer/wao/services/service/BoatsFilterValuesCacheKeyTest.java
Modified: branches/wao-4.0.x/wao-services/src/main/java/fr/ifremer/wao/services/service/BoatsFilterValuesCacheLoader.java
===================================================================
--- branches/wao-4.0.x/wao-services/src/main/java/fr/ifremer/wao/services/service/BoatsFilterValuesCacheLoader.java 2014-09-10 14:27:15 UTC (rev 2245)
+++ branches/wao-4.0.x/wao-services/src/main/java/fr/ifremer/wao/services/service/BoatsFilterValuesCacheLoader.java 2014-09-10 15:38:23 UTC (rev 2246)
@@ -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;
Modified: branches/wao-4.0.x/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactsFilterValuesCacheLoader.java
===================================================================
--- branches/wao-4.0.x/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactsFilterValuesCacheLoader.java 2014-09-10 14:27:15 UTC (rev 2245)
+++ branches/wao-4.0.x/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactsFilterValuesCacheLoader.java 2014-09-10 15:38:23 UTC (rev 2246)
@@ -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;
Modified: branches/wao-4.0.x/wao-services/src/main/java/fr/ifremer/wao/services/service/NoEffortDefinedException.java
===================================================================
--- branches/wao-4.0.x/wao-services/src/main/java/fr/ifremer/wao/services/service/NoEffortDefinedException.java 2014-09-10 14:27:15 UTC (rev 2245)
+++ branches/wao-4.0.x/wao-services/src/main/java/fr/ifremer/wao/services/service/NoEffortDefinedException.java 2014-09-10 15:38:23 UTC (rev 2246)
@@ -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: branches/wao-4.0.x/wao-services/src/main/java/fr/ifremer/wao/services/service/SynthesisCacheKey.java
===================================================================
--- branches/wao-4.0.x/wao-services/src/main/java/fr/ifremer/wao/services/service/SynthesisCacheKey.java 2014-09-10 14:27:15 UTC (rev 2245)
+++ branches/wao-4.0.x/wao-services/src/main/java/fr/ifremer/wao/services/service/SynthesisCacheKey.java 2014-09-10 15:38:23 UTC (rev 2246)
@@ -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.base.Objects;
import fr.ifremer.wao.ContactsFilter;
Modified: branches/wao-4.0.x/wao-services/src/main/java/fr/ifremer/wao/services/service/WaoCacheKey.java
===================================================================
--- branches/wao-4.0.x/wao-services/src/main/java/fr/ifremer/wao/services/service/WaoCacheKey.java 2014-09-10 14:27:15 UTC (rev 2245)
+++ branches/wao-4.0.x/wao-services/src/main/java/fr/ifremer/wao/services/service/WaoCacheKey.java 2014-09-10 15:38:23 UTC (rev 2246)
@@ -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 java.io.Serializable;
/**
Modified: branches/wao-4.0.x/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/operations/DayParserFormatter.java
===================================================================
--- branches/wao-4.0.x/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/operations/DayParserFormatter.java 2014-09-10 14:27:15 UTC (rev 2245)
+++ branches/wao-4.0.x/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/operations/DayParserFormatter.java 2014-09-10 15:38:23 UTC (rev 2246)
@@ -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: branches/wao-4.0.x/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/operations/DayTimeParserFormatter.java
===================================================================
--- branches/wao-4.0.x/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/operations/DayTimeParserFormatter.java 2014-09-10 14:27:15 UTC (rev 2245)
+++ branches/wao-4.0.x/wao-services/src/main/java/fr/ifremer/wao/services/service/csv/operations/DayTimeParserFormatter.java 2014-09-10 15:38:23 UTC (rev 2246)
@@ -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: branches/wao-4.0.x/wao-services/src/test/java/fr/ifremer/wao/services/FakeWaoApplicationContext.java
===================================================================
--- branches/wao-4.0.x/wao-services/src/test/java/fr/ifremer/wao/services/FakeWaoApplicationContext.java 2014-09-10 14:27:15 UTC (rev 2245)
+++ branches/wao-4.0.x/wao-services/src/test/java/fr/ifremer/wao/services/FakeWaoApplicationContext.java 2014-09-10 15:38:23 UTC (rev 2246)
@@ -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();
}
Modified: branches/wao-4.0.x/wao-services/src/test/java/fr/ifremer/wao/services/service/BoatsFilterValuesCacheKeyTest.java
===================================================================
--- branches/wao-4.0.x/wao-services/src/test/java/fr/ifremer/wao/services/service/BoatsFilterValuesCacheKeyTest.java 2014-09-10 14:27:15 UTC (rev 2245)
+++ branches/wao-4.0.x/wao-services/src/test/java/fr/ifremer/wao/services/service/BoatsFilterValuesCacheKeyTest.java 2014-09-10 15:38:23 UTC (rev 2246)
@@ -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.base.Optional;
import com.google.common.collect.Sets;
import fr.ifremer.wao.BoatsFilter;
1
0
r2245 - in branches/wao-4.0.x: wao-persistence/src/main/java/fr/ifremer/wao wao-persistence/src/main/java/fr/ifremer/wao/entity wao-services/src/main/java/fr/ifremer/wao/services wao-services/src/main/java/fr/ifremer/wao/services/service wao-services/src/test/java/fr/ifremer/wao/services/service wao-web/src/main/java/fr/ifremer/wao/web
by bleny@users.forge.codelutin.com 10 Sep '14
by bleny@users.forge.codelutin.com 10 Sep '14
10 Sep '14
Author: bleny
Date: 2014-09-10 16:27:15 +0200 (Wed, 10 Sep 2014)
New Revision: 2245
Url: http://forge.codelutin.com/projects/wao/repository/revisions/2245
Log:
Revue du syst?\195?\168me de cache : on avait des effet de bord car, les filtres ?\195?\169tant stock?\195?\169s en session, leur modification pouvaient modifier les cl?\195?\169s du cache... D?\195?\169sormais, ?\195?\160 l'insertion dans le cache, on clone la cl?\195?\169 pour ?\195?\170tre s?\195?\187r que le cache ne sera pas modifier
Added:
branches/wao-4.0.x/wao-services/src/main/java/fr/ifremer/wao/services/service/SynthesisCacheKey.java
branches/wao-4.0.x/wao-services/src/main/java/fr/ifremer/wao/services/service/WaoCacheKey.java
branches/wao-4.0.x/wao-services/src/test/java/fr/ifremer/wao/services/service/BoatsFilterValuesCacheKeyTest.java
Modified:
branches/wao-4.0.x/wao-persistence/src/main/java/fr/ifremer/wao/AbstractWaoFilter.java
branches/wao-4.0.x/wao-persistence/src/main/java/fr/ifremer/wao/BoatsFilter.java
branches/wao-4.0.x/wao-persistence/src/main/java/fr/ifremer/wao/ContactsFilter.java
branches/wao-4.0.x/wao-persistence/src/main/java/fr/ifremer/wao/SampleRowsFilter.java
branches/wao-4.0.x/wao-persistence/src/main/java/fr/ifremer/wao/entity/ContactTopiaDao.java
branches/wao-4.0.x/wao-services/src/main/java/fr/ifremer/wao/services/DefaultWaoServiceContext.java
branches/wao-4.0.x/wao-services/src/main/java/fr/ifremer/wao/services/WaoApplicationContext.java
branches/wao-4.0.x/wao-services/src/main/java/fr/ifremer/wao/services/WaoServiceContext.java
branches/wao-4.0.x/wao-services/src/main/java/fr/ifremer/wao/services/service/BoatsFilterValuesCacheKey.java
branches/wao-4.0.x/wao-services/src/main/java/fr/ifremer/wao/services/service/BoatsFilterValuesCacheLoader.java
branches/wao-4.0.x/wao-services/src/main/java/fr/ifremer/wao/services/service/BoatsService.java
branches/wao-4.0.x/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactsFilterValuesCacheKey.java
branches/wao-4.0.x/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactsFilterValuesCacheLoader.java
branches/wao-4.0.x/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactsService.java
branches/wao-4.0.x/wao-services/src/main/java/fr/ifremer/wao/services/service/InitWaoService.java
branches/wao-4.0.x/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerSamplingPlanService.java
branches/wao-4.0.x/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsVenteSamplingPlanService.java
branches/wao-4.0.x/wao-services/src/main/java/fr/ifremer/wao/services/service/SamplingPlanCacheKey.java
branches/wao-4.0.x/wao-services/src/main/java/fr/ifremer/wao/services/service/SynthesisService.java
branches/wao-4.0.x/wao-web/src/main/java/fr/ifremer/wao/web/CacheInvalidationTopiaEntityListener.java
branches/wao-4.0.x/wao-web/src/main/java/fr/ifremer/wao/web/DefaultWaoApplicationContext.java
Modified: branches/wao-4.0.x/wao-persistence/src/main/java/fr/ifremer/wao/AbstractWaoFilter.java
===================================================================
--- branches/wao-4.0.x/wao-persistence/src/main/java/fr/ifremer/wao/AbstractWaoFilter.java 2014-09-10 14:18:09 UTC (rev 2244)
+++ branches/wao-4.0.x/wao-persistence/src/main/java/fr/ifremer/wao/AbstractWaoFilter.java 2014-09-10 14:27:15 UTC (rev 2245)
@@ -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: branches/wao-4.0.x/wao-persistence/src/main/java/fr/ifremer/wao/BoatsFilter.java
===================================================================
--- branches/wao-4.0.x/wao-persistence/src/main/java/fr/ifremer/wao/BoatsFilter.java 2014-09-10 14:18:09 UTC (rev 2244)
+++ branches/wao-4.0.x/wao-persistence/src/main/java/fr/ifremer/wao/BoatsFilter.java 2014-09-10 14:27:15 UTC (rev 2245)
@@ -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: branches/wao-4.0.x/wao-persistence/src/main/java/fr/ifremer/wao/ContactsFilter.java
===================================================================
--- branches/wao-4.0.x/wao-persistence/src/main/java/fr/ifremer/wao/ContactsFilter.java 2014-09-10 14:18:09 UTC (rev 2244)
+++ branches/wao-4.0.x/wao-persistence/src/main/java/fr/ifremer/wao/ContactsFilter.java 2014-09-10 14:27:15 UTC (rev 2245)
@@ -28,8 +28,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;
@@ -125,7 +127,11 @@
}
public void setPeriodFrom(Date periodFrom) {
- this.periodFrom = periodFrom;
+ if (periodFrom == null) {
+ this.periodFrom = null;
+ } else {
+ this.periodFrom = DateUtil.setMinTimeOfDay(periodFrom);
+ }
}
public Date getPeriodTo() {
@@ -133,7 +139,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() {
@@ -409,4 +419,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: branches/wao-4.0.x/wao-persistence/src/main/java/fr/ifremer/wao/SampleRowsFilter.java
===================================================================
--- branches/wao-4.0.x/wao-persistence/src/main/java/fr/ifremer/wao/SampleRowsFilter.java 2014-09-10 14:18:09 UTC (rev 2244)
+++ branches/wao-4.0.x/wao-persistence/src/main/java/fr/ifremer/wao/SampleRowsFilter.java 2014-09-10 14:27:15 UTC (rev 2245)
@@ -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: branches/wao-4.0.x/wao-persistence/src/main/java/fr/ifremer/wao/entity/ContactTopiaDao.java
===================================================================
--- branches/wao-4.0.x/wao-persistence/src/main/java/fr/ifremer/wao/entity/ContactTopiaDao.java 2014-09-10 14:18:09 UTC (rev 2244)
+++ branches/wao-4.0.x/wao-persistence/src/main/java/fr/ifremer/wao/entity/ContactTopiaDao.java 2014-09-10 14:27:15 UTC (rev 2245)
@@ -39,7 +39,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;
@@ -126,8 +125,7 @@
}
if (filter.getPeriodTo() != null) {
- Date periodTo = DateUtil.setMaxTimeOfDay(filter.getPeriodTo());
- query.addWhereClause("c." + periodProperty + " <= :periodTo", ImmutableMap.of("periodTo", (Object) periodTo));
+ query.addWhereClause("c." + periodProperty + " <= :periodTo", ImmutableMap.of("periodTo", (Object) filter.getPeriodTo()));
}
if (CollectionUtils.isNotEmpty(filter.getContactIds())) {
Modified: branches/wao-4.0.x/wao-services/src/main/java/fr/ifremer/wao/services/DefaultWaoServiceContext.java
===================================================================
--- branches/wao-4.0.x/wao-services/src/main/java/fr/ifremer/wao/services/DefaultWaoServiceContext.java 2014-09-10 14:18:09 UTC (rev 2244)
+++ branches/wao-4.0.x/wao-services/src/main/java/fr/ifremer/wao/services/DefaultWaoServiceContext.java 2014-09-10 14:27:15 UTC (rev 2245)
@@ -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: branches/wao-4.0.x/wao-services/src/main/java/fr/ifremer/wao/services/WaoApplicationContext.java
===================================================================
--- branches/wao-4.0.x/wao-services/src/main/java/fr/ifremer/wao/services/WaoApplicationContext.java 2014-09-10 14:18:09 UTC (rev 2244)
+++ branches/wao-4.0.x/wao-services/src/main/java/fr/ifremer/wao/services/WaoApplicationContext.java 2014-09-10 14:27:15 UTC (rev 2245)
@@ -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: branches/wao-4.0.x/wao-services/src/main/java/fr/ifremer/wao/services/WaoServiceContext.java
===================================================================
--- branches/wao-4.0.x/wao-services/src/main/java/fr/ifremer/wao/services/WaoServiceContext.java 2014-09-10 14:18:09 UTC (rev 2244)
+++ branches/wao-4.0.x/wao-services/src/main/java/fr/ifremer/wao/services/WaoServiceContext.java 2014-09-10 14:27:15 UTC (rev 2245)
@@ -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: branches/wao-4.0.x/wao-services/src/main/java/fr/ifremer/wao/services/service/BoatsFilterValuesCacheKey.java
===================================================================
--- branches/wao-4.0.x/wao-services/src/main/java/fr/ifremer/wao/services/service/BoatsFilterValuesCacheKey.java 2014-09-10 14:18:09 UTC (rev 2244)
+++ branches/wao-4.0.x/wao-services/src/main/java/fr/ifremer/wao/services/service/BoatsFilterValuesCacheKey.java 2014-09-10 14:27:15 UTC (rev 2245)
@@ -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: branches/wao-4.0.x/wao-services/src/main/java/fr/ifremer/wao/services/service/BoatsFilterValuesCacheLoader.java
===================================================================
--- branches/wao-4.0.x/wao-services/src/main/java/fr/ifremer/wao/services/service/BoatsFilterValuesCacheLoader.java 2014-09-10 14:18:09 UTC (rev 2244)
+++ branches/wao-4.0.x/wao-services/src/main/java/fr/ifremer/wao/services/service/BoatsFilterValuesCacheLoader.java 2014-09-10 14:27:15 UTC (rev 2245)
@@ -38,7 +38,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: branches/wao-4.0.x/wao-services/src/main/java/fr/ifremer/wao/services/service/BoatsService.java
===================================================================
--- branches/wao-4.0.x/wao-services/src/main/java/fr/ifremer/wao/services/service/BoatsService.java 2014-09-10 14:18:09 UTC (rev 2244)
+++ branches/wao-4.0.x/wao-services/src/main/java/fr/ifremer/wao/services/service/BoatsService.java 2014-09-10 14:27:15 UTC (rev 2245)
@@ -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();
@@ -275,16 +286,6 @@
}
- public Collection<Boat> getBoats(BoatsFilter boatsFilter, int pageSize) {
-
- PaginationParameter pager = newBoatsPaginationParameter(0, pageSize);
-
- PaginationResult<Boat> boats = getBoatDao().find(boatsFilter, pager);
-
- return boats.getElements();
-
- }
-
public void changeBoatElligibility(AuthenticatedWaoUser authenticatedWaoUser, String boatId, String sampleRowId, boolean active) {
ElligibleBoatTopiaDao dao = getElligibleBoatDao();
Modified: branches/wao-4.0.x/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactsFilterValuesCacheKey.java
===================================================================
--- branches/wao-4.0.x/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactsFilterValuesCacheKey.java 2014-09-10 14:18:09 UTC (rev 2244)
+++ branches/wao-4.0.x/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactsFilterValuesCacheKey.java 2014-09-10 14:27:15 UTC (rev 2245)
@@ -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: branches/wao-4.0.x/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactsFilterValuesCacheLoader.java
===================================================================
--- branches/wao-4.0.x/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactsFilterValuesCacheLoader.java 2014-09-10 14:18:09 UTC (rev 2244)
+++ branches/wao-4.0.x/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactsFilterValuesCacheLoader.java 2014-09-10 14:27:15 UTC (rev 2245)
@@ -38,7 +38,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: branches/wao-4.0.x/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactsService.java
===================================================================
--- branches/wao-4.0.x/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactsService.java 2014-09-10 14:18:09 UTC (rev 2244)
+++ branches/wao-4.0.x/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactsService.java 2014-09-10 14:27:15 UTC (rev 2245)
@@ -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: branches/wao-4.0.x/wao-services/src/main/java/fr/ifremer/wao/services/service/InitWaoService.java
===================================================================
--- branches/wao-4.0.x/wao-services/src/main/java/fr/ifremer/wao/services/service/InitWaoService.java 2014-09-10 14:18:09 UTC (rev 2244)
+++ branches/wao-4.0.x/wao-services/src/main/java/fr/ifremer/wao/services/service/InitWaoService.java 2014-09-10 14:27:15 UTC (rev 2245)
@@ -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: branches/wao-4.0.x/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerSamplingPlanService.java
===================================================================
--- branches/wao-4.0.x/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerSamplingPlanService.java 2014-09-10 14:18:09 UTC (rev 2244)
+++ branches/wao-4.0.x/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsMerSamplingPlanService.java 2014-09-10 14:27:15 UTC (rev 2245)
@@ -127,7 +127,7 @@
}
result = builder.toPlan();
- samplingPlansCache.put(samplingPlanCacheKey, result);
+ samplingPlansCache.put(samplingPlanCacheKey.clone(), result);
}
Modified: branches/wao-4.0.x/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsVenteSamplingPlanService.java
===================================================================
--- branches/wao-4.0.x/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsVenteSamplingPlanService.java 2014-09-10 14:18:09 UTC (rev 2244)
+++ branches/wao-4.0.x/wao-services/src/main/java/fr/ifremer/wao/services/service/ObsVenteSamplingPlanService.java 2014-09-10 14:27:15 UTC (rev 2245)
@@ -77,7 +77,7 @@
}
result = builder.toPlan();
- samplingPlansCache.put(samplingPlanCacheKey, result);
+ samplingPlansCache.put(samplingPlanCacheKey.clone(), result);
}
Modified: branches/wao-4.0.x/wao-services/src/main/java/fr/ifremer/wao/services/service/SamplingPlanCacheKey.java
===================================================================
--- branches/wao-4.0.x/wao-services/src/main/java/fr/ifremer/wao/services/service/SamplingPlanCacheKey.java 2014-09-10 14:18:09 UTC (rev 2244)
+++ branches/wao-4.0.x/wao-services/src/main/java/fr/ifremer/wao/services/service/SamplingPlanCacheKey.java 2014-09-10 14:27:15 UTC (rev 2245)
@@ -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;
+ }
}
Added: branches/wao-4.0.x/wao-services/src/main/java/fr/ifremer/wao/services/service/SynthesisCacheKey.java
===================================================================
--- branches/wao-4.0.x/wao-services/src/main/java/fr/ifremer/wao/services/service/SynthesisCacheKey.java (rev 0)
+++ branches/wao-4.0.x/wao-services/src/main/java/fr/ifremer/wao/services/service/SynthesisCacheKey.java 2014-09-10 14:27:15 UTC (rev 2245)
@@ -0,0 +1,33 @@
+package fr.ifremer.wao.services.service;
+
+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: branches/wao-4.0.x/wao-services/src/main/java/fr/ifremer/wao/services/service/SynthesisService.java
===================================================================
--- branches/wao-4.0.x/wao-services/src/main/java/fr/ifremer/wao/services/service/SynthesisService.java 2014-09-10 14:18:09 UTC (rev 2244)
+++ branches/wao-4.0.x/wao-services/src/main/java/fr/ifremer/wao/services/service/SynthesisService.java 2014-09-10 14:27:15 UTC (rev 2245)
@@ -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);
}
Added: branches/wao-4.0.x/wao-services/src/main/java/fr/ifremer/wao/services/service/WaoCacheKey.java
===================================================================
--- branches/wao-4.0.x/wao-services/src/main/java/fr/ifremer/wao/services/service/WaoCacheKey.java (rev 0)
+++ branches/wao-4.0.x/wao-services/src/main/java/fr/ifremer/wao/services/service/WaoCacheKey.java 2014-09-10 14:27:15 UTC (rev 2245)
@@ -0,0 +1,16 @@
+package fr.ifremer.wao.services.service;
+
+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 {
+
+}
Added: branches/wao-4.0.x/wao-services/src/test/java/fr/ifremer/wao/services/service/BoatsFilterValuesCacheKeyTest.java
===================================================================
--- branches/wao-4.0.x/wao-services/src/test/java/fr/ifremer/wao/services/service/BoatsFilterValuesCacheKeyTest.java (rev 0)
+++ branches/wao-4.0.x/wao-services/src/test/java/fr/ifremer/wao/services/service/BoatsFilterValuesCacheKeyTest.java 2014-09-10 14:27:15 UTC (rev 2245)
@@ -0,0 +1,34 @@
+package fr.ifremer.wao.services.service;
+
+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: branches/wao-4.0.x/wao-web/src/main/java/fr/ifremer/wao/web/CacheInvalidationTopiaEntityListener.java
===================================================================
--- branches/wao-4.0.x/wao-web/src/main/java/fr/ifremer/wao/web/CacheInvalidationTopiaEntityListener.java 2014-09-10 14:18:09 UTC (rev 2244)
+++ branches/wao-4.0.x/wao-web/src/main/java/fr/ifremer/wao/web/CacheInvalidationTopiaEntityListener.java 2014-09-10 14:27:15 UTC (rev 2245)
@@ -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: branches/wao-4.0.x/wao-web/src/main/java/fr/ifremer/wao/web/DefaultWaoApplicationContext.java
===================================================================
--- branches/wao-4.0.x/wao-web/src/main/java/fr/ifremer/wao/web/DefaultWaoApplicationContext.java 2014-09-10 14:18:09 UTC (rev 2244)
+++ branches/wao-4.0.x/wao-web/src/main/java/fr/ifremer/wao/web/DefaultWaoApplicationContext.java 2014-09-10 14:27:15 UTC (rev 2245)
@@ -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();
}
1
0
r2244 - branches/wao-4.0.x/wao-web/src/main/java/fr/ifremer/wao/web
by bleny@users.forge.codelutin.com 10 Sep '14
by bleny@users.forge.codelutin.com 10 Sep '14
10 Sep '14
Author: bleny
Date: 2014-09-10 16:18:09 +0200 (Wed, 10 Sep 2014)
New Revision: 2244
Url: http://forge.codelutin.com/projects/wao/repository/revisions/2244
Log:
Retrait d'un log.debug sur la locale qui prodruit trop de sortie
Modified:
branches/wao-4.0.x/wao-web/src/main/java/fr/ifremer/wao/web/WaoActionSupport.java
Modified: branches/wao-4.0.x/wao-web/src/main/java/fr/ifremer/wao/web/WaoActionSupport.java
===================================================================
--- branches/wao-4.0.x/wao-web/src/main/java/fr/ifremer/wao/web/WaoActionSupport.java 2014-09-10 09:24:51 UTC (rev 2243)
+++ branches/wao-4.0.x/wao-web/src/main/java/fr/ifremer/wao/web/WaoActionSupport.java 2014-09-10 14:18:09 UTC (rev 2244)
@@ -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;
- }
}
1
0
r2243 - in trunk: . wao-services/src/main/java/fr/ifremer/wao/services/service wao-services/src/main/java/fr/ifremer/wao/services/service/mail wao-web/src/main/java/fr/ifremer/wao/web wao-web/src/main/java/fr/ifremer/wao/web/action
by bleny@users.forge.codelutin.com 10 Sep '14
by bleny@users.forge.codelutin.com 10 Sep '14
10 Sep '14
Author: bleny
Date: 2014-09-10 11:24:51 +0200 (Wed, 10 Sep 2014)
New Revision: 2243
Url: http://forge.codelutin.com/projects/wao/repository/revisions/2243
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/BoatsFilterValuesCacheLoader.java
trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactsFilterValuesCacheLoader.java
Modified:
trunk/
trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/BoatsFilterValuesCacheKey.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/ContactsService.java
trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/UpdateContactCommand.java
trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/mail/MammalsObservationEmail.java
trunk/wao-web/src/main/java/fr/ifremer/wao/web/DefaultWaoApplicationContext.java
trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/EditContactAction.java
Property changes on: trunk
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/wao-4.0-obsvente:2075-2085
/branches/wao-4.0.x:2169-2227
+ /branches/wao-4.0-obsvente:2075-2085
/branches/wao-4.0.x:2169-2242
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 09:21:00 UTC (rev 2242)
+++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/BoatsFilterValuesCacheKey.java 2014-09-10 09:24:51 UTC (rev 2243)
@@ -63,4 +63,19 @@
return Objects.hashCode(locale, optionalCompanyId, obsProgram, boatsFilter);
}
+ public Locale getLocale() {
+ return locale;
+ }
+
+ public ObsProgram getObsProgram() {
+ return obsProgram;
+ }
+
+ public Optional<String> getOptionalCompanyId() {
+ return optionalCompanyId;
+ }
+
+ public BoatsFilter getBoatsFilter() {
+ return boatsFilter;
+ }
}
Copied: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/BoatsFilterValuesCacheLoader.java (from rev 2242, branches/wao-4.0.x/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 (rev 0)
+++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/BoatsFilterValuesCacheLoader.java 2014-09-10 09:24:51 UTC (rev 2243)
@@ -0,0 +1,61 @@
+package fr.ifremer.wao.services.service;
+
+import com.google.common.cache.CacheLoader;
+import fr.ifremer.wao.WaoTopiaPersistenceContext;
+import fr.ifremer.wao.services.WaoApplicationContext;
+import fr.ifremer.wao.services.WaoServiceContext;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.util.Locale;
+
+public class BoatsFilterValuesCacheLoader extends CacheLoader<BoatsFilterValuesCacheKey, BoatsFilterValues> {
+
+ private static final Log log = LogFactory.getLog(BoatsFilterValuesCacheLoader.class);
+
+ protected WaoApplicationContext waoApplicationContext;
+
+ public BoatsFilterValuesCacheLoader(WaoApplicationContext waoApplicationContext) {
+ this.waoApplicationContext = waoApplicationContext;
+ }
+
+ @Override
+ public BoatsFilterValues load(BoatsFilterValuesCacheKey key) {
+
+ if (log.isTraceEnabled()) {
+ log.trace("start refreshing boatFilterValuesCache for key " + key);
+ }
+
+ Locale locale = key.getLocale();
+
+ WaoTopiaPersistenceContext persistenceContext = null;
+
+ try {
+
+ persistenceContext = waoApplicationContext.newPersistenceContext();
+
+ WaoServiceContext waoServiceContext = waoApplicationContext.newServiceContext(persistenceContext, locale);
+
+ BoatsService service = waoServiceContext.newService(BoatsService.class);
+
+ BoatsFilterValues boatsFilterValues = service.getBoatsFilterValues(key);
+
+ if (log.isTraceEnabled()) {
+ log.trace("will return from refreshing boatFilterValuesCache");
+ }
+
+ return boatsFilterValues;
+
+ } catch (Exception e) {
+ if (persistenceContext != null) {
+ persistenceContext.rollback();
+ }
+ throw e;
+ } finally {
+ if (persistenceContext != null) {
+ persistenceContext.close();
+ }
+ }
+
+ }
+}
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 09:21:00 UTC (rev 2242)
+++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/BoatsService.java 2014-09-10 09:24:51 UTC (rev 2243)
@@ -90,21 +90,37 @@
if (boatsFilterValues == null) {
- BoatTopiaDao dao = getBoatDao();
+ if (log.isTraceEnabled()) {
+ log.trace("cache fail, will compute filter values for key " + boatsFilterValuesCacheKey);
+ }
- List<Boat> boats = dao.findAll(filter);
+ boatsFilterValues = getBoatsFilterValues(boatsFilterValuesCacheKey);
- boatsFilterValues = new BoatsFilterValues(serviceContext.getLocale(), authenticatedWaoUser.getObsProgram(), optionalCompanyId);
+ cache.put(boatsFilterValuesCacheKey, boatsFilterValues);
- for (Boat boat : boats) {
- boatsFilterValues.addBoat(boat);
- }
+ }
- cache.put(boatsFilterValuesCacheKey, boatsFilterValues);
+ return boatsFilterValues;
+ }
+ public BoatsFilterValues getBoatsFilterValues(BoatsFilterValuesCacheKey boatsFilterValuesCacheKey) {
+
+ BoatTopiaDao dao = getBoatDao();
+
+ List<Boat> boats = dao.findAll(boatsFilterValuesCacheKey.getBoatsFilter());
+
+ BoatsFilterValues boatsFilterValues =
+ new BoatsFilterValues(
+ boatsFilterValuesCacheKey.getLocale(),
+ boatsFilterValuesCacheKey.getObsProgram(),
+ boatsFilterValuesCacheKey.getOptionalCompanyId());
+
+ for (Boat boat : boats) {
+ boatsFilterValues.addBoat(boat);
}
return boatsFilterValues;
+
}
public BoatsList getBoatsList(AuthenticatedWaoUser authenticatedWaoUser,
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 09:21:00 UTC (rev 2242)
+++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactsFilterValuesCacheKey.java 2014-09-10 09:24:51 UTC (rev 2243)
@@ -63,4 +63,19 @@
return Objects.hashCode(locale, optionalCompanyId, obsProgram, contactsFilter);
}
+ public Locale getLocale() {
+ return locale;
+ }
+
+ public ObsProgram getObsProgram() {
+ return obsProgram;
+ }
+
+ public Optional<String> getOptionalCompanyId() {
+ return optionalCompanyId;
+ }
+
+ public ContactsFilter getContactsFilter() {
+ return contactsFilter;
+ }
}
Copied: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactsFilterValuesCacheLoader.java (from rev 2242, branches/wao-4.0.x/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 (rev 0)
+++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactsFilterValuesCacheLoader.java 2014-09-10 09:24:51 UTC (rev 2243)
@@ -0,0 +1,61 @@
+package fr.ifremer.wao.services.service;
+
+import com.google.common.cache.CacheLoader;
+import fr.ifremer.wao.WaoTopiaPersistenceContext;
+import fr.ifremer.wao.services.WaoApplicationContext;
+import fr.ifremer.wao.services.WaoServiceContext;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.util.Locale;
+
+public class ContactsFilterValuesCacheLoader extends CacheLoader<ContactsFilterValuesCacheKey, ContactsFilterValues> {
+
+ private static final Log log = LogFactory.getLog(BoatsFilterValuesCacheLoader.class);
+
+ protected WaoApplicationContext waoApplicationContext;
+
+ public ContactsFilterValuesCacheLoader(WaoApplicationContext waoApplicationContext) {
+ this.waoApplicationContext = waoApplicationContext;
+ }
+
+ @Override
+ public ContactsFilterValues load(ContactsFilterValuesCacheKey key) {
+
+ if (log.isTraceEnabled()) {
+ log.trace("start refreshing boatFilterValuesCache for key " + key);
+ }
+
+ Locale locale = key.getLocale();
+
+ WaoTopiaPersistenceContext persistenceContext = null;
+
+ try {
+
+ persistenceContext = waoApplicationContext.newPersistenceContext();
+
+ WaoServiceContext waoServiceContext = waoApplicationContext.newServiceContext(persistenceContext, locale);
+
+ ContactsService service = waoServiceContext.newService(ContactsService.class);
+
+ ContactsFilterValues boatsFilterValues = service.getContactsFilterValues(key);
+
+ if (log.isTraceEnabled()) {
+ log.trace("will return from refreshing boatFilterValuesCache");
+ }
+
+ return boatsFilterValues;
+
+ } catch (Exception e) {
+ if (persistenceContext != null) {
+ persistenceContext.rollback();
+ }
+ throw e;
+ } finally {
+ if (persistenceContext != null) {
+ persistenceContext.close();
+ }
+ }
+
+ }
+}
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 09:21:00 UTC (rev 2242)
+++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactsService.java 2014-09-10 09:24:51 UTC (rev 2243)
@@ -153,19 +153,31 @@
ContactsFilterValues contactsFilterValues = cache.getIfPresent(cacheKey);
if (contactsFilterValues == null) {
+ contactsFilterValues = getContactsFilterValues(cacheKey);
+ cache.put(cacheKey, contactsFilterValues);
+ }
- ContactTopiaDao dao = getContactDao();
- List<Contact> contacts = dao.findAllForFilterValues(filter);
+ return contactsFilterValues;
+ }
- contactsFilterValues = new ContactsFilterValues(locale, obsProgram, optionalCompanyId);
- for (Contact contact : contacts) {
- contactsFilterValues.addContact(contact);
- }
+ public ContactsFilterValues getContactsFilterValues(ContactsFilterValuesCacheKey cacheKey) {
- cache.put(cacheKey, contactsFilterValues);
+ ContactTopiaDao dao = getContactDao();
+
+ List<Contact> contacts = dao.findAllForFilterValues(cacheKey.getContactsFilter());
+
+ ContactsFilterValues contactsFilterValues =
+ new ContactsFilterValues(
+ cacheKey.getLocale(),
+ cacheKey.getObsProgram(),
+ cacheKey.getOptionalCompanyId());
+
+ for (Contact contact : contacts) {
+ contactsFilterValues.addContact(contact);
}
return contactsFilterValues;
+
}
public ObsMerContactsList getContactsList(AuthenticatedWaoUser authenticatedWaoUser,
Modified: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/UpdateContactCommand.java
===================================================================
--- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/UpdateContactCommand.java 2014-09-10 09:21:00 UTC (rev 2242)
+++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/UpdateContactCommand.java 2014-09-10 09:24:51 UTC (rev 2243)
@@ -120,6 +120,10 @@
contact.setMammalsInfo(mammalsInfo);
}
+ public String getMammalsInfo() {
+ return contact.getMammalsInfo();
+ }
+
/**
* Check if mammals informations has changed.
*
Modified: trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/mail/MammalsObservationEmail.java
===================================================================
--- trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/mail/MammalsObservationEmail.java 2014-09-10 09:21:00 UTC (rev 2242)
+++ trunk/wao-services/src/main/java/fr/ifremer/wao/services/service/mail/MammalsObservationEmail.java 2014-09-10 09:24:51 UTC (rev 2243)
@@ -33,7 +33,8 @@
import java.util.Locale;
/**
- * Created on 4/5/14.
+ * Courriel de notification qui est envoyé lorsqu'un utilisateur rapporte, à la saisie d'un
+ * contact, qu'une capture accidentelle d'un mammifère est survenue pendant la marée.
*
* @author Tony Chemit <chemit(a)codelutin.com>
* @since 4.0
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 09:21:00 UTC (rev 2242)
+++ trunk/wao-web/src/main/java/fr/ifremer/wao/web/DefaultWaoApplicationContext.java 2014-09-10 09:24:51 UTC (rev 2243)
@@ -34,8 +34,10 @@
import fr.ifremer.wao.services.WaoWebApplicationContext;
import fr.ifremer.wao.services.service.BoatsFilterValues;
import fr.ifremer.wao.services.service.BoatsFilterValuesCacheKey;
+import fr.ifremer.wao.services.service.BoatsFilterValuesCacheLoader;
import fr.ifremer.wao.services.service.ContactsFilterValues;
import fr.ifremer.wao.services.service.ContactsFilterValuesCacheKey;
+import fr.ifremer.wao.services.service.ContactsFilterValuesCacheLoader;
import fr.ifremer.wao.services.service.InitWaoService;
import fr.ifremer.wao.services.service.SamplingPlan;
import fr.ifremer.wao.services.service.SamplingPlanCacheKey;
@@ -130,7 +132,11 @@
@Override
public Cache<BoatsFilterValuesCacheKey, BoatsFilterValues> getBoatsFilterValuesCache() {
if (boatsFilterValuesCache == null) {
- boatsFilterValuesCache = newCacheBuilder(100).expireAfterWrite(18, TimeUnit.HOURS).build();
+ BoatsFilterValuesCacheLoader loader = new BoatsFilterValuesCacheLoader(this);
+ boatsFilterValuesCache = newCacheBuilder(100)
+ . expireAfterAccess(20, TimeUnit.DAYS)
+ . refreshAfterWrite(20, TimeUnit.MINUTES)
+ . build(loader);
}
return boatsFilterValuesCache;
}
@@ -146,7 +152,11 @@
@Override
public Cache<ContactsFilterValuesCacheKey, ContactsFilterValues> getContactsFilterValuesCache() {
if (contactsFilterValuesCache == null) {
- contactsFilterValuesCache = newCacheBuilder(100).expireAfterWrite(18, TimeUnit.HOURS).build();
+ ContactsFilterValuesCacheLoader loader = new ContactsFilterValuesCacheLoader(this);
+ contactsFilterValuesCache = newCacheBuilder(100)
+ . expireAfterAccess(20, TimeUnit.DAYS)
+ . refreshAfterWrite(20, TimeUnit.MINUTES)
+ . build(loader);
}
return contactsFilterValuesCache;
}
@@ -178,6 +188,8 @@
}
+ logCacheStats();
+
return persistenceContext;
}
@@ -195,12 +207,7 @@
@Override
public void close() {
- if (log.isInfoEnabled()) {
- log.info("samplingPlansCache stats: " + getSamplingPlansCache().stats().toString());
- log.info("boatsFilterValuesCache stats: " + getBoatsFilterValuesCache().stats().toString());
- log.info("contactsFilterValuesCache stats: " + getContactsFilterValuesCache().stats().toString());
- log.info("synthesesCache stats: " + getSynthesesCache().stats().toString());
- }
+ logCacheStats();
if (topiaApplicationContext != null) {
@@ -210,6 +217,17 @@
}
+ protected void logCacheStats() {
+
+ if (log.isInfoEnabled()) {
+ log.info("samplingPlansCache stats: " + getSamplingPlansCache().stats().toString());
+ log.info("boatsFilterValuesCache stats: " + getBoatsFilterValuesCache().stats().toString());
+ log.info("contactsFilterValuesCache stats: " + getContactsFilterValuesCache().stats().toString());
+ log.info("synthesesCache stats: " + getSynthesesCache().stats().toString());
+ }
+
+ }
+
public void init() {
if (getApplicationConfig().isLogConfigurationProvided()) {
Modified: trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/EditContactAction.java
===================================================================
--- trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/EditContactAction.java 2014-09-10 09:21:00 UTC (rev 2242)
+++ trunk/wao-web/src/main/java/fr/ifremer/wao/web/action/EditContactAction.java 2014-09-10 09:24:51 UTC (rev 2243)
@@ -143,7 +143,8 @@
public UpdateContactCommand getUpdateContactCommand() {
if (updateContactCommand == null) {
- prepare();
+ // XXX brendan 02/09/14 avant le prepare, on ne sait pas si contactId a été injecté donc on ne l'utilise pas. Par ailleurs, même s'il avait été injecté, on se retrouverait avec une première instance de updateContactCommand qui sera perdue et l'entité sera décorée par une autre commande et on aura perdu des infos entre temps (notamment le flag qui vérifie si on a modifié les informations de capture accidentelle)
+ updateContactCommand = service.newUpdateContactCommandForCreation(getAuthenticatedWaoUser());
}
return updateContactCommand;
}
1
0
r2242 - branches/wao-4.0.x/wao-services/src/main/java/fr/ifremer/wao/services/service
by bleny@users.forge.codelutin.com 10 Sep '14
by bleny@users.forge.codelutin.com 10 Sep '14
10 Sep '14
Author: bleny
Date: 2014-09-10 11:21:00 +0200 (Wed, 10 Sep 2014)
New Revision: 2242
Url: http://forge.codelutin.com/projects/wao/repository/revisions/2242
Log:
La modification aurait d?\195?\187 ?\195?\170tre faite sur la branche et non le tronc (fixes #5756)
Modified:
branches/wao-4.0.x/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactsService.java
Modified: branches/wao-4.0.x/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactsService.java
===================================================================
--- branches/wao-4.0.x/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactsService.java 2014-09-09 16:15:13 UTC (rev 2241)
+++ branches/wao-4.0.x/wao-services/src/main/java/fr/ifremer/wao/services/service/ContactsService.java 2014-09-10 09:21:00 UTC (rev 2242)
@@ -843,13 +843,13 @@
throw new IllegalDeletionException(allUsages);
}
+ dao.delete(contact);
+
SamplingPlanService samplingPlanService = newService(SamplingPlanService.class);
-
samplingPlanService.recomputeSampleRowEstimatedAndRealTides(contact.getSampleRow());
- dao.delete(contact);
+ commit();
- commit();
}
protected void save0(UpdateContactCommand updateContactCommand) {
1
0