Commit cb65b561 authored by PECQUOT's avatar PECQUOT
Browse files

[fix] Better local dates handling, mainly fixed by using java.time.LocalDate,...

[fix] Better local dates handling, mainly fixed by using java.time.LocalDate, Date only data (like applied periods) are correctly get/set with database timezone (Mantis #44581)
[fix] On survey validation, the previous comment is retrieved from VALIDATION_HISTORY table (Mantis #44300)
[enh] Taxon groups are filtered by 'Identification' type only (Mantis #45149)
[fix] The cache 'taxon_name_by_taxon_group_id' now use a LocalDate and is refresh every day (Mantis #45383 and #45397)
[enh] Add the taxon citation on every taxon name (Mantis #45051)
[fix] Delete obsolete control rules (ex: a standard rule isEmpty is changed to a precondition rule, the first rule must be delete) (Mantis #45374)
[enh] on Rules UI, add a selection criteria on controlled program (Mantis #44572)
[fix] Fix Control rule bad behavior after deselection (Mantis #45309)
[fix] Fix Control rule duplication (Mantis #45306)

git-svn-id: https://scmforge.ifremer.fr/authscm/lp1ee9d/svn/reefdb/trunk@2363 cd918a83-917d-4a2a-92d7-bc1d03929fc5
parent 98ff7945
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -30,8 +30,8 @@ import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.cache.annotation.Caching;
import java.time.LocalDate;
import java.util.Collection;
import java.util.Date;
import java.util.List;
import java.util.Set;
......@@ -94,13 +94,13 @@ public interface ReefDbStrategyDao {
/**
* <p>getPmfmStrategiesByProgramCodeAndLocation.</p>
*
* @param programCode a {@link java.lang.String} object.
* @param monitoringLocationId a {@link java.lang.Integer} object.
* @param date a {@link java.util.Date} object.
* @param programCode a {@link String} object.
* @param monitoringLocationId a {@link Integer} object.
* @param date a {@link LocalDate} object.
* @return a {@link java.util.List} object.
*/
@Cacheable(value = PMFM_STRATEGIES_BY_PROG_LOC_DATE_CACHE)
Set<PmfmStrategyDTO> getPmfmStrategiesByProgramCodeAndLocation(String programCode, Integer monitoringLocationId, Date date);
Set<PmfmStrategyDTO> getPmfmStrategiesByProgramCodeAndLocation(String programCode, Integer monitoringLocationId, LocalDate date);
/**
* Retrieve all strategies that are applied on the given program and monitoring location
......
......@@ -123,7 +123,7 @@ public class ReefDbSurveyDaoImpl extends SurveyDaoImpl implements ReefDbSurveyDa
protected ObjectTypeDao objectTypeDao;
@Resource(name = "validationHistoryDao")
protected ValidationHistoryDao validationHistoryDao;
protected ValidationHistoryExtendDao validationHistoryDao;
@Resource(name = "qualificationHistoryDao")
protected QualificationHistoryDao qualificationHistoryDao;
......@@ -470,11 +470,10 @@ public class ReefDbSurveyDaoImpl extends SurveyDaoImpl implements ReefDbSurveyDa
// qualification comment
String oldSurveyValidCm = survey.getSurveyValidCm();
// TODO mantis #44300
// if (StringUtils.isBlank(oldSurveyValidCm)) {
// // try get old comment from history
// oldSurveyValidCm = validationHistoryDao.getLastValidationComment(surveyId);
// }
if (StringUtils.isBlank(oldSurveyValidCm)) {
// try get old comment from history (mantis #44300)
oldSurveyValidCm = validationHistoryDao.getLastValidationComment(surveyId, ObjectTypeCode.SURVEY.getValue());
}
survey.setSurveyValidCm(validationComment);
// synchronization status
......@@ -581,7 +580,7 @@ public class ReefDbSurveyDaoImpl extends SurveyDaoImpl implements ReefDbSurveyDa
result.setDepartment(departmentDao.getDepartmentById(departmentId));
// Apply DB timezone to survey date (Mantis #41597)
result.setDate(Daos.convertToDate(source.next(), config.getDbTimezone()));
result.setDate(Dates.convertToLocalDate(Daos.convertToDate(source.next()), config.getDbTimezone()));
result.setTime((Double) source.next());
result.setName((String) source.next());
......@@ -673,7 +672,7 @@ public class ReefDbSurveyDaoImpl extends SurveyDaoImpl implements ReefDbSurveyDa
}
// date
Date beanDate = Dates.resetTime(bean.getDate(), config.getDbTimezone());
Date beanDate = Dates.convertToDate(bean.getDate(), config.getDbTimezone());
if (entity.getSurveyDt() == null || !entity.getSurveyDt().equals(beanDate)) {
entity.setSurveyDt(beanDate);
}
......
......@@ -29,7 +29,8 @@ import fr.ifremer.reefdb.dto.referential.TaxonomicLevelDTO;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import java.util.Date;
import javax.annotation.Nonnull;
import java.time.LocalDate;
import java.util.List;
import java.util.Map;
......@@ -85,12 +86,13 @@ public interface ReefDbTaxonNameDao {
/**
* Get All Taxon Names of the Taxon Group
* Beware to reset time on date parameter before call this method
*
* @return a {@link com.google.common.collect.Multimap} object.
* @param date
*/
@Cacheable(value = TAXON_NAME_BY_TAXON_GROUP_ID_CACHE)
Multimap<Integer, TaxonDTO> getAllTaxonNamesMapByTaxonGroupId(Date date);
Multimap<Integer, TaxonDTO> getAllTaxonNamesMapByTaxonGroupId(@Nonnull LocalDate date);
/**
* <p>findTaxonNamesByCriteria.</p>
......
......@@ -27,6 +27,7 @@ import com.google.common.base.Preconditions;
import com.google.common.base.Predicate;
import com.google.common.collect.*;
import fr.ifremer.quadrige3.core.dao.referential.StatusCode;
import fr.ifremer.quadrige3.core.dao.referential.TaxonGroupTypeCode;
import fr.ifremer.quadrige3.core.dao.referential.taxon.*;
import fr.ifremer.quadrige3.core.dao.technical.Dates;
import fr.ifremer.quadrige3.core.dao.technical.hibernate.TemporaryDataHelper;
......@@ -56,7 +57,9 @@ import org.springframework.cache.Cache;
import org.springframework.dao.DataRetrievalFailureException;
import org.springframework.stereotype.Repository;
import javax.annotation.Nonnull;
import javax.annotation.Resource;
import java.time.LocalDate;
import java.util.*;
import java.util.stream.Collectors;
......@@ -173,12 +176,11 @@ public class ReefDbTaxonNameDaoImpl extends TaxonNameDaoImpl implements ReefDbTa
/** {@inheritDoc}
* @param date*/
@Override
public Multimap<Integer, TaxonDTO> getAllTaxonNamesMapByTaxonGroupId(Date date) {
Date referenceDate = date == null ? Dates.resetTime(new Date()) : date;
public Multimap<Integer, TaxonDTO> getAllTaxonNamesMapByTaxonGroupId(@Nonnull LocalDate date) {
Iterator<Object[]> it = queryIterator("taxonNameIdsWithTaxonGroupId",
"referenceDate", DateType.INSTANCE, referenceDate);
"referenceDate", DateType.INSTANCE, Dates.convertToDate(date, config.getDbTimezone()),
"taxonGroupTypeCode", StringType.INSTANCE, TaxonGroupTypeCode.IDENTIFICATION.getValue());
Multimap<Integer, TaxonDTO> result = ArrayListMultimap.create();
while (it.hasNext()) {
......@@ -547,6 +549,11 @@ public class ReefDbTaxonNameDaoImpl extends TaxonNameDaoImpl implements ReefDbTa
citation.setId(citationId);
citation.setName(citationName);
// Add citation in taxon name (Mantis #45051)
if (StringUtils.isNotBlank(citationName)) {
result.setName(String.format("%s [%s]", result.getName(), citationName));
}
result.setCitation(citation);
}
......
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