Commit 29922944 authored by LAVENIER's avatar LAVENIER
Browse files

[fix] Fix extraction caches

[fix] Aggregation: by default, put product as "manually" execution
parent aeeae2a2
......@@ -39,7 +39,7 @@ import org.springframework.context.annotation.Configuration;
public class ExtractionCacheConfiguration {
public interface Names {
String AGGREGATION_TYPE_BY_ID = "net.sumaris.core.extraction.service.aggregationTypeById";
String AGGREGATION_TYPE_BY_ID_AND_OPTIONS = "net.sumaris.core.extraction.service.aggregationTypeById";
String AGGREGATION_TYPE_BY_FORMAT = "net.sumaris.core.extraction.service.aggregationTypeByFormat";
}
......@@ -47,7 +47,7 @@ public class ExtractionCacheConfiguration {
public JCacheManagerCustomizer extractionCacheCustomizer() {
return cacheManager -> {
log.info("Adding {Extraction} caches...");
Caches.createHeapCache(cacheManager, Names.AGGREGATION_TYPE_BY_ID, Integer.class, AggregationTypeVO.class, CacheDurations.DEFAULT, 100);
Caches.createHeapCache(cacheManager, Names.AGGREGATION_TYPE_BY_ID_AND_OPTIONS, AggregationTypeVO.class, CacheDurations.DEFAULT, 100);
Caches.createHeapCache(cacheManager, Names.AGGREGATION_TYPE_BY_FORMAT, String.class, AggregationTypeVO.class, CacheDurations.DEFAULT, 100);
};
}
......
......@@ -115,7 +115,7 @@ public class AggregationServiceImpl implements AggregationService {
}
@Override
@Cacheable(cacheNames = ExtractionCacheConfiguration.Names.AGGREGATION_TYPE_BY_ID)
@Cacheable(cacheNames = ExtractionCacheConfiguration.Names.AGGREGATION_TYPE_BY_ID_AND_OPTIONS)
public AggregationTypeVO getTypeById(int id, ExtractionProductFetchOptions fetchOptions) {
ExtractionProductVO source = productService.get(id, fetchOptions);
return toAggregationType(source);
......@@ -297,7 +297,7 @@ public class AggregationServiceImpl implements AggregationService {
@Override
@Caching(
evict = {
@CacheEvict(cacheNames = ExtractionCacheConfiguration.Names.AGGREGATION_TYPE_BY_ID, allEntries = true),
@CacheEvict(cacheNames = ExtractionCacheConfiguration.Names.AGGREGATION_TYPE_BY_ID_AND_OPTIONS, allEntries = true),
@CacheEvict(cacheNames = ExtractionCacheConfiguration.Names.AGGREGATION_TYPE_BY_FORMAT, allEntries = true)
}
)
......@@ -348,7 +348,7 @@ public class AggregationServiceImpl implements AggregationService {
@Override
@Caching(
evict = {
@CacheEvict(cacheNames = ExtractionCacheConfiguration.Names.AGGREGATION_TYPE_BY_ID, allEntries = true),
@CacheEvict(cacheNames = ExtractionCacheConfiguration.Names.AGGREGATION_TYPE_BY_ID_AND_OPTIONS, allEntries = true),
@CacheEvict(cacheNames = ExtractionCacheConfiguration.Names.AGGREGATION_TYPE_BY_FORMAT, allEntries = true)
}
)
......@@ -383,7 +383,7 @@ public class AggregationServiceImpl implements AggregationService {
// Check if need aggregate (ig new or if filter changed)
ProcessingFrequencyEnum frequency = source.getProcessingFrequencyId() != null
? ProcessingFrequencyEnum.valueOf(source.getProcessingFrequencyId())
: ProcessingFrequencyEnum.NEVER;
: ProcessingFrequencyEnum.MANUALLY;
String filterAsString = writeFilterAsString(filter);
......@@ -430,6 +430,13 @@ public class AggregationServiceImpl implements AggregationService {
target.setStatusId(source.getStatusId());
target.setUpdateDate(source.getUpdateDate());
target.setIsSpatial(source.getIsSpatial());
if (target.getRecorderDepartment() == null) {
target.setRecorderDepartment(source.getRecorderDepartment());
}
if (target.getRecorderPerson() == null) {
target.setRecorderPerson(source.getRecorderPerson());
}
}
target.setStratum(source.getStratum());
target.setFilter(filterAsString);
......
......@@ -62,7 +62,7 @@ public interface ExtractionProductService {
@Transactional
@Caching(evict = {
@CacheEvict(cacheNames = ExtractionCacheConfiguration.Names.AGGREGATION_TYPE_BY_ID, allEntries = true),
@CacheEvict(cacheNames = ExtractionCacheConfiguration.Names.AGGREGATION_TYPE_BY_ID_AND_OPTIONS, allEntries = true),
@CacheEvict(cacheNames = ExtractionCacheConfiguration.Names.AGGREGATION_TYPE_BY_FORMAT, allEntries = true)
})
void delete(int id);
......
......@@ -206,7 +206,7 @@ public class ExtractionProductRepositoryImpl
@Override
@Caching(
evict = {
@CacheEvict(cacheNames = CacheConfiguration.Names.PRODUCT_BY_LABEL_AND_OPTIONS, key = "#vo.label", condition = "#vo.id != null"),
@CacheEvict(cacheNames = CacheConfiguration.Names.PRODUCT_BY_LABEL_AND_OPTIONS, allEntries = true),
@CacheEvict(cacheNames = CacheConfiguration.Names.PRODUCTS_BY_FILTER, allEntries = true),
}
)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment