...
 
Commits (25)
## Sprint 84 - v3.8.3
## Sprint 88 - v3.9.5
- Pas de mise à jour de modèle
## Sprint 87 - v3.9.4
- Pas de mise à jour de modèle
## Sprint 86 - v3.9.3
- Pas de mise à jour de modèle
## Sprint 85 - v3.8.3
- Pas de mise à jour de modèle
- Version corrective devant utiliser le server de synchronisation 3.6.3.2 uniquement
## Sprint 84 - v3.8.2
- Pas de mise à jour de modèle
- Version corrective devant utiliser le server de synchronisation 3.6.3.1 uniquement
## Sprint 83 - v3.9.2
- Pas de mise à jour de modèle
- Une nouvelle option a été ajoutée pour gérer les transcodages des référentiels suivant :
reefdb.transcribingItemType.label.pmfmExtraction
Sa valeur par défaut est `REEFDB-PMFM.PMFM_EXTRACTION`. Couplée avec l'option `reefdb.transcribingItemType.label.pmfmNm`, elle permet de transcoder les libellé des PSFMU lors des extractions avec la priorité suivante:
1- libellé transcodé pour extraction
2- libellé transcodé pour écran de saisie
3- libellé interne du psfmu (issu du transcodage pour écran de saisie)
4- libellé du paramètre
- Pour simplifier la configuration du serveur de synchronisation, l'option `quadrige3.synchro.import.referential.transcribingItemType.label.includes`
qui doit contenir tous les libellés des types de transcodage à importer, accepte désormais le caractère '%'.
quadrige3.synchro.import.referential.transcribingItemType.label.includes=REEFDB% (tous les types de transcodage commençant par REEFDB seront importés)
## Sprint 82 - v3.9.1
- Pas de mise à jour de modèle
## Sprint 81 - v3.9.0
- Pas de mise à jour de modèle
## Sprint 80 - v3.8.1
- Pas de mise à jour de modèle
......
......@@ -10,7 +10,7 @@
<groupId>fr.ifremer.reefdb</groupId>
<artifactId>reefdb</artifactId>
<version>3.8.3</version>
<version>3.9.5</version>
<packaging>pom</packaging>
<name>Reef DB</name>
......@@ -171,7 +171,7 @@
<maven.compiler.debug>true</maven.compiler.debug>
<!-- Quadrige3 Core version -->
<quadrige3-core.version>3.6.3.2</quadrige3-core.version>
<quadrige3-core.version>3.6.10</quadrige3-core.version>
<!-- Last ReefDb launcher version -->
<launcherVersion>3.0.3</launcherVersion>
......@@ -261,7 +261,7 @@
<repositories>
<repository>
<id>reefdb-public-group</id>
<url>http://server.e-is.pro/nexus/content/groups/reefdb</url>
<url>https://nexus.e-is.pro/nexus/content/groups/reefdb</url>
<snapshots>
<enabled>true</enabled>
<checksumPolicy>fail</checksumPolicy>
......@@ -276,7 +276,7 @@
<pluginRepositories>
<pluginRepository>
<id>reefdb-public-group</id>
<url>http://server.e-is.pro/nexus/content/groups/reefdb</url>
<url>https://nexus.e-is.pro/nexus/content/groups/reefdb</url>
<snapshots>
<enabled>true</enabled>
<checksumPolicy>fail</checksumPolicy>
......@@ -342,6 +342,18 @@
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit-addons</groupId>
<artifactId>junit-addons</artifactId>
<version>1.4</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>fr.ifremer.quadrige3</groupId>
<artifactId>quadrige3-test-shared</artifactId>
......@@ -1119,10 +1131,10 @@
<distribution.site.repository>scpexe://${distribution.site.host}${distribution.site.path}</distribution.site.repository>
<distribution.repository.id>eis-nexus-deploy</distribution.repository.id>
<distribution.repository.url>http://server.e-is.pro/nexus/content/repositories/reefdb-releases</distribution.repository.url>
<distribution.repository.url>https://nexus.e-is.pro/nexus/content/repositories/reefdb-releases</distribution.repository.url>
<distribution.snapshotRepository.id>eis-nexus-deploy</distribution.snapshotRepository.id>
<distribution.snapshotRepository.url>http://server.e-is.pro/nexus/content/repositories/reefdb-snapshots</distribution.snapshotRepository.url>
<distribution.snapshotRepository.url>https://nexus.e-is.pro/nexus/content/repositories/reefdb-snapshots</distribution.snapshotRepository.url>
<distribution.internet.url>${distribution.repository.url}</distribution.internet.url>
</properties>
......
......@@ -76,7 +76,7 @@
<repositories>
<repository>
<id>reefdb-public-group</id>
<url>http://server.e-is.pro/nexus/content/groups/reefdb</url>
<url>https://nexus.e-is.pro/nexus/content/groups/reefdb</url>
<snapshots>
<enabled>true</enabled>
<checksumPolicy>fail</checksumPolicy>
......@@ -91,7 +91,7 @@
<pluginRepositories>
<pluginRepository>
<id>reefdb-public-group</id>
<url>http://server.e-is.pro/nexus/content/groups/reefdb</url>
<url>https://nexus.e-is.pro/nexus/content/groups/reefdb</url>
<snapshots>
<enabled>true</enabled>
<checksumPolicy>fail</checksumPolicy>
......@@ -242,12 +242,12 @@
<properties>
<distribution.repository.id>eis-nexus-deploy</distribution.repository.id>
<distribution.repository.url>http://server.e-is.pro/nexus/content/repositories/reefdb-releases</distribution.repository.url>
<distribution.repository.url>https://nexus.e-is.pro/nexus/content/repositories/reefdb-releases</distribution.repository.url>
<distribution.snapshotRepository.id>eis-nexus-deploy</distribution.snapshotRepository.id>
<distribution.snapshotRepository.url>http://server.e-is.pro/nexus/content/repositories/reefdb-snapshots</distribution.snapshotRepository.url>
<distribution.snapshotRepository.url>https://nexus.e-is.pro/nexus/content/repositories/reefdb-snapshots</distribution.snapshotRepository.url>
<distribution.internet.url>http://server.e-is.pro/nexus/content/groups/public</distribution.internet.url>
<distribution.internet.url>https://nexus.e-is.pro/nexus/content/groups/public</distribution.internet.url>
</properties>
</profile>
......
......@@ -4,7 +4,7 @@
<parent>
<groupId>fr.ifremer.reefdb</groupId>
<artifactId>reefdb</artifactId>
<version>3.8.3</version>
<version>3.9.5</version>
</parent>
<artifactId>reefdb-core</artifactId>
......@@ -60,6 +60,16 @@
<artifactId>quadrige3-test-shared</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit-addons</groupId>
<artifactId>junit-addons</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
......
......@@ -35,8 +35,11 @@
# Please fill the missing licenses for dependencies :
#
#
#Fri Feb 09 17:30:26 CET 2018
#Fri Mar 06 09:36:42 CET 2020
com.oracle--ojdbc7--12.1.0.2.0=OTN license
commons-primitives--commons-primitives--1.0=The Apache Software License, Version 2.0
dom4j--dom4j--1.6.1=BSD License
junit-addons--junit-addons--1.4=
org.hibernate--hibernate-spatial--4.3-20140213=Lesser General Public License (LGPL)
xerces--xercesImpl--2.6.2=
xerces--xmlParserAPIs--2.6.2=
......@@ -967,6 +967,10 @@ public final class ReefDbConfiguration extends QuadrigeCoreConfiguration {
return applicationConfig.getOption(ReefDbConfigurationOption.TRANSCRIBING_ITEM_TYPE_LB_PMFM_NM.getKey());
}
public String getTranscribingItemTypeLbForPmfmExtraction() {
return applicationConfig.getOption(ReefDbConfigurationOption.TRANSCRIBING_ITEM_TYPE_LB_PMFM_EXTRACTION.getKey());
}
/**
* <p>getAlternativeTaxonOriginTaxRef.</p>
*
......
......@@ -24,7 +24,6 @@ package fr.ifremer.reefdb.config;
*/
import fr.ifremer.quadrige3.core.dao.referential.UnitId;
import fr.ifremer.quadrige3.core.dao.referential.transcribing.TranscribingItemTypeLb;
import fr.ifremer.quadrige3.core.dao.technical.QuadrigeEnumerationDef;
import org.nuiton.config.ConfigOptionDef;
import org.nuiton.version.Version;
......@@ -303,7 +302,13 @@ public enum ReefDbConfigurationOption implements ConfigOptionDef {
TRANSCRIBING_ITEM_TYPE_LB_PMFM_NM(
"reefdb.transcribingItemType.label.pmfmNm",
n("reefdb.config.option.transcribingItemType.label.pmfmNm.description"),
String.format("${%s}", TranscribingItemTypeLb.REEFDB_PMFM_NM.getKey()), // 1
String.format("${%s%s}", QuadrigeEnumerationDef.CONFIG_OPTION_PREFIX, "TranscribingItemTypeLb.REEFDB_PMFM_NM"),
String.class,
false),
TRANSCRIBING_ITEM_TYPE_LB_PMFM_EXTRACTION(
"reefdb.transcribingItemType.label.pmfmExtraction",
n("reefdb.config.option.transcribingItemType.label.pmfmExtraction.description"),
String.format("${%s%s}", QuadrigeEnumerationDef.CONFIG_OPTION_PREFIX, "TranscribingItemTypeLb.REEFDB_PMFM_EXTRACTION"),
String.class,
false),
/* constants used to calculate transition length */
......
......@@ -102,6 +102,16 @@ public interface ReefDbStrategyDao {
@Cacheable(value = PMFM_STRATEGIES_BY_PROG_LOC_DATE_CACHE)
Set<PmfmStrategyDTO> getPmfmStrategiesByProgramCodeAndLocation(String programCode, Integer monitoringLocationId, LocalDate date);
/**
* Retrieve all PMFM strategies that are applied on given programs and date range
*
* @param programCodes program codes
* @param startDate
* @param endDate
* @return set of pmfm strategies
*/
Set<PmfmStrategyDTO> getPmfmStrategiesByProgramCodesAndDates(Collection<String> programCodes, LocalDate startDate, LocalDate endDate);
/**
* Retrieve all strategies that are applied on the given program and monitoring location
*
......
......@@ -241,6 +241,39 @@ public class ReefDbStrategyDaoImpl extends StrategyDaoImpl implements ReefDbStra
return ImmutableSet.copyOf(pmfmStrategies);
}
@Override
public Set<PmfmStrategyDTO> getPmfmStrategiesByProgramCodesAndDates(Collection<String> programCodes, LocalDate startDate, LocalDate endDate) {
Set<PmfmStrategyDTO> pmfmStrategies = new HashSet<>();
List<ProgStratDTO> appliedStrategies = getAppliedStrategiesByProgramCodes(programCodes);
for (ProgStratDTO appliedStrategy: appliedStrategies) {
// filter on date range
if (appliedStrategy.getStartDate() != null && appliedStrategy.getEndDate() != null
&& !appliedStrategy.getStartDate().isAfter(endDate) && !appliedStrategy.getEndDate().isBefore(startDate)) {
// add all pmfm strategies in date range
pmfmStrategies.addAll(getPmfmsAppliedStrategy(appliedStrategy.getId()));
}
}
return ImmutableSet.copyOf(pmfmStrategies);
}
@SuppressWarnings("unchecked")
private List<ProgStratDTO> getAppliedStrategiesByProgramCodes(Collection<String> programCodes) {
Query query = createQuery("appliedStrategiesByProgramCodes").setParameterList("programCodes", programCodes);
Iterator<Object[]> rows = query.iterate();
List<ProgStratDTO> result = Lists.newArrayList();
TimeZone dbTimezone = config.getDbTimezone();
while (rows.hasNext()) {
result.add(toProgStratDTO(Arrays.asList(rows.next()).iterator(), dbTimezone));
}
return result;
}
/** {@inheritDoc} */
@Override
public List<ProgStratDTO> getStrategiesByProgramCodeAndMonitoringLocationId(String programCode, int monitoringLocationId) {
......@@ -915,7 +948,7 @@ public class ReefDbStrategyDaoImpl extends StrategyDaoImpl implements ReefDbStra
// code, name
program.setCode((String) source.next());
program.setName((String) source.next());
//TODO (report Q3): program.setStatus(Daos.getStatus((String) source.next()));
program.setStatus(Daos.getStatus((String) source.next()));
}
// strategy: id, name
......
......@@ -24,6 +24,7 @@ package fr.ifremer.reefdb.dao.system.extraction;
*/
import fr.ifremer.quadrige3.core.dao.technical.csv.CSVDao;
import fr.ifremer.reefdb.dto.referential.pmfm.PmfmDTO;
import org.springframework.jdbc.core.RowMapper;
import java.util.List;
......@@ -36,6 +37,14 @@ import java.util.Map;
*/
public interface ReefDbExtractionResultDao extends CSVDao {
/**
* <p>queryCount.</p>
*
* @param query a {@link String} object.
* @return a {@link java.lang.Long} object.
*/
long queryCount(String query);
/**
* <p>queryCount.</p>
*
......@@ -67,6 +76,14 @@ public interface ReefDbExtractionResultDao extends CSVDao {
List<String> queryStringList(String query, Map<String, Object> queryBindings);
/**
* <p>queryUpdate</p>
*
* @param query a {@link java.lang.String} object.
* @return a int.
*/
int queryUpdate(String query);
/**
* <p>queryUpdate.</p>
*
......@@ -75,4 +92,10 @@ public interface ReefDbExtractionResultDao extends CSVDao {
* @return a int.
*/
int queryUpdate(String query, Map<String, Object> queryBindings);
String getPmfmNameForExtraction(PmfmDTO pmfm);
String getPmfmUnitNameForExtraction(PmfmDTO pmfm);
}
......@@ -23,18 +23,24 @@ package fr.ifremer.reefdb.dao.system.extraction;
* #L%
*/
import fr.ifremer.quadrige3.core.dao.referential.transcribing.TranscribingItemExtendDao;
import fr.ifremer.quadrige3.core.dao.technical.Assert;
import fr.ifremer.quadrige3.core.dao.technical.csv.CSVDaoImpl;
import fr.ifremer.reefdb.config.ReefDbConfiguration;
import fr.ifremer.reefdb.dto.referential.pmfm.PmfmDTO;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.dao.DataRetrievalFailureException;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.stereotype.Repository;
import javax.annotation.Resource;
import javax.sql.DataSource;
import java.math.BigInteger;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Properties;
/**
......@@ -50,6 +56,12 @@ public class ReefDbExtractionResultDaoImpl extends CSVDaoImpl implements ReefDbE
protected final Properties connectionProperties;
@Resource
protected ReefDbConfiguration config;
@Resource(name = "transcribingItemDao")
private TranscribingItemExtendDao transcribingItemDao;
/**
* <p>Constructor for ReefDbExtractionResultDaoImpl.</p>
*
......@@ -78,24 +90,19 @@ public class ReefDbExtractionResultDaoImpl extends CSVDaoImpl implements ReefDbE
this.connectionProperties = connectionProperties;
}
@Override
public long queryCount(String query) {
return queryCount(query, null);
}
/**
* {@inheritDoc}
*/
@Override
public Long queryCount(String query, Map<String, Object> queryBindings) {
return query(connectionProperties, query, queryBindings, resultSet -> {
Object result = resultSet.getObject(1);
if (log.isDebugEnabled()) {
log.debug(String.format("queryCount result: %s", result));
}
if (result instanceof Integer) {
return ((Integer) result).longValue();
} else if (result instanceof BigInteger) {
return ((BigInteger) result).longValue();
}
return (Long) result;
});
Long count = queryCount(connectionProperties, query, queryBindings);
if (count == null) throw new DataRetrievalFailureException(String.format("query count result is null: %s ; bindings=%s", query, queryBindings));
return count;
}
/**
......@@ -106,6 +113,11 @@ public class ReefDbExtractionResultDaoImpl extends CSVDaoImpl implements ReefDbE
return query(connectionProperties, sql, queryBindings, rowMapper);
}
@Override
public int queryUpdate(String query) {
return queryUpdate(query, null);
}
/**
* {@inheritDoc}
*/
......@@ -114,6 +126,25 @@ public class ReefDbExtractionResultDaoImpl extends CSVDaoImpl implements ReefDbE
return queryUpdate(connectionProperties, query, paramMap);
}
@Override
public String getPmfmNameForExtraction(PmfmDTO pmfm) {
Assert.notNull(pmfm);
return Optional
.ofNullable(transcribingItemDao.getTranscribingItemById(config.getTranscribingItemTypeLbForPmfmExtraction(), pmfm.getId()))
.orElse(
Optional.ofNullable(transcribingItemDao.getTranscribingItemById(config.getTranscribingItemTypeLbForPmfmNm(), pmfm.getId()))
.orElse(
Optional.ofNullable(pmfm.getName())
.orElse(pmfm.getParameter().getName())
)
); }
@Override
public String getPmfmUnitNameForExtraction(PmfmDTO pmfm) {
Assert.notNull(pmfm);
return pmfm.getUnit() == null || config.getExtractionUnitIdsToIgnore().contains(pmfm.getUnit().getId()) ? "" : pmfm.getUnit().getName();
}
/**
* {@inheritDoc}
*/
......@@ -126,4 +157,5 @@ public class ReefDbExtractionResultDaoImpl extends CSVDaoImpl implements ReefDbE
public List<String> queryStringList(String query, Map<String, Object> queryBindings) {
return query(connectionProperties, query, queryBindings, (resultSet, i) -> resultSet.getString(1));
}
}
......@@ -287,6 +287,7 @@ public class DecoratorServiceImpl extends fr.ifremer.quadrige3.core.service.deco
}
}
@Deprecated
private class PMFMExtractionDecorator extends PMFMNameDecorator {
static final String SEPARATOR = "-";
......
......@@ -53,6 +53,7 @@ import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.nuiton.util.DateUtil;
import javax.annotation.Nonnull;
import java.sql.Array;
import java.sql.SQLException;
import java.time.format.DateTimeFormatter;
......@@ -119,6 +120,10 @@ public class ReefDbBeans extends QuadrigeBeans {
return addressBuilder.toString();
}
public static String toQuotedString(String string) {
return "'" + string.replaceAll("'", "''") + "'";
}
/**
* <p>toString.</p>
*
......@@ -177,8 +182,8 @@ public class ReefDbBeans extends QuadrigeBeans {
} else if (bean instanceof ExtractionPeriodDTO) {
ExtractionPeriodDTO period = (ExtractionPeriodDTO) bean;
return Dates.formatDate(period.getStartDate(), DEFAULT_DATE_FORMAT)
+ " => "
+ Dates.formatDate(period.getEndDate(), DEFAULT_DATE_FORMAT);
+ " => "
+ Dates.formatDate(period.getEndDate(), DEFAULT_DATE_FORMAT);
}
return bean.toString();
......@@ -496,16 +501,30 @@ public class ReefDbBeans extends QuadrigeBeans {
public static boolean haveSameMeasurements(Collection<MeasurementDTO> measurements, Collection<MeasurementDTO> otherMeasurements) {
List<Integer> pmfmIds = measurements.stream()
.filter(measurement -> !isMeasurementEmpty(measurement))
.map(measurement -> measurement.getPmfm().getId())
.collect(Collectors.toList());
.filter(measurement -> !isMeasurementEmpty(measurement))
.map(measurement -> measurement.getPmfm().getId())
.collect(Collectors.toList());
List<Integer> otherPmfmIds = otherMeasurements.stream()
.filter(measurement -> !isMeasurementEmpty(measurement))
.map(measurement -> measurement.getPmfm().getId())
.collect(Collectors.toList());
.filter(measurement -> !isMeasurementEmpty(measurement))
.map(measurement -> measurement.getPmfm().getId())
.collect(Collectors.toList());
return pmfmIds.containsAll(otherPmfmIds) && otherPmfmIds.containsAll(pmfmIds);
}
/**
* Compare measurement values only (not pmfm or other propoerty)
*
* @param measurement1 first measurement
* @param measurement2 second measurement
* @return true if their values are equals or null
*/
public static boolean measurementValuesEquals(@Nonnull MeasurementDTO measurement1, @Nonnull MeasurementDTO measurement2) {
return (measurement1.getNumericalValue() == null && measurement2.getNumericalValue() == null
&& measurement1.getQualitativeValue() == null && measurement2.getQualitativeValue() == null)
|| (measurement1.getNumericalValue() != null && measurement1.getNumericalValue().equals(measurement2.getNumericalValue()))
|| (measurement1.getQualitativeValue() != null && measurement1.getQualitativeValue().equals(measurement2.getQualitativeValue()));
}
/**
* Get the unified comments from all individual measurements
*
......@@ -520,6 +539,38 @@ public class ReefDbBeans extends QuadrigeBeans {
return getUnifiedString(comments, DEFAULT_STRING_SEPARATOR);
}
/**
* Method used as external function for HSQLDB
* see fr.ifremer.reefdb.service.extraction.ExtractionPerformServiceImpl#createDistinctFunction(java.lang.String, java.lang.String, java.lang.String)
*
* @param array the input array (any type)
* @param nonDistinctResult the result text if the array contains non distinct values
* @return the unified string
*/
@SuppressWarnings(value = "unused")
public static String getDistinctSQLString(Array array, String nonDistinctResult) {
try {
Set<String> strings = new HashSet<>();
for (Object object : (Object[]) array.getArray()) {
if (object != null) {
strings.add(object.toString());
}
}
return strings.isEmpty()
? ""
: strings.size() == 1
? strings.stream().findFirst().get()
: nonDistinctResult;
} catch (SQLException e) {
return "";
}
}
/**
* Method used as external function for HSQLDB
* see fr.ifremer.reefdb.service.extraction.ExtractionServiceImpl#createConcatDistinctFunction(java.lang.String, java.lang.String, java.lang.String)
......@@ -642,9 +693,9 @@ public class ReefDbBeans extends QuadrigeBeans {
return new ArrayList<>();
}
return filterCollection(bean.getErrors(), error -> error.isError()
&& (controlOnly == null || (controlOnly == error.isControl()))
&& error.containsPropertyName(propertyName)
&& (pmfmId == null || pmfmId.equals(error.getPmfmId())));
&& (controlOnly == null || (controlOnly == error.isControl()))
&& error.containsPropertyName(propertyName)
&& (pmfmId == null || pmfmId.equals(error.getPmfmId())));
}
/**
......@@ -694,14 +745,14 @@ public class ReefDbBeans extends QuadrigeBeans {
*/
public static List<ErrorDTO> getWarnings(ErrorAware bean, final String propertyName, final Integer pmfmId, final Boolean controlOnly) {
if (bean == null || CollectionUtils.isEmpty(bean.getErrors())
// if an error is found, return empty list because error is priority
|| !getErrors(bean, propertyName, pmfmId, controlOnly).isEmpty()) {
// if an error is found, return empty list because error is priority
|| !getErrors(bean, propertyName, pmfmId, controlOnly).isEmpty()) {
return new ArrayList<>();
}
return filterCollection(bean.getErrors(), error -> error.isWarning()
&& (controlOnly == null || (controlOnly == error.isControl()))
&& error.containsPropertyName(propertyName)
&& (pmfmId == null || pmfmId.equals(error.getPmfmId())));
&& (controlOnly == null || (controlOnly == error.isControl()))
&& error.containsPropertyName(propertyName)
&& (pmfmId == null || pmfmId.equals(error.getPmfmId())));
}
/**
......@@ -794,13 +845,13 @@ public class ReefDbBeans extends QuadrigeBeans {
private static Predicate<ErrorDTO> errorEqualPredicate(ErrorDTO thisError) {
return error -> error.isError() == thisError.isError()
&& error.isWarning() == thisError.isWarning()
&& error.isControl() == thisError.isControl()
&& Objects.equals(error.getControlElementCode(), thisError.getControlElementCode())
&& Objects.deepEquals(error.getPropertyName().toArray(), thisError.getPropertyName().toArray())
&& Objects.equals(error.getPmfmId(), thisError.getPmfmId())
&& Objects.equals(error.getIndividualId(), thisError.getIndividualId())
&& Objects.equals(error.getMessage(), thisError.getMessage());
&& error.isWarning() == thisError.isWarning()
&& error.isControl() == thisError.isControl()
&& Objects.equals(error.getControlElementCode(), thisError.getControlElementCode())
&& Objects.deepEquals(error.getPropertyName().toArray(), thisError.getPropertyName().toArray())
&& Objects.equals(error.getPmfmId(), thisError.getPmfmId())
&& Objects.equals(error.getIndividualId(), thisError.getIndividualId())
&& Objects.equals(error.getMessage(), thisError.getMessage());
}
/**
......@@ -811,9 +862,9 @@ public class ReefDbBeans extends QuadrigeBeans {
*/
public static boolean isPmfmMandatory(ControlRuleDTO controlRule) {
return ControlElementValues.MEASUREMENT.equals(controlRule.getControlElement()) &&
(ControlFeatureMeasurementValues.PMFM.equals(controlRule.getControlFeature())
|| ControlFeatureMeasurementValues.NUMERICAL_VALUE.equals(controlRule.getControlFeature())
|| ControlFeatureMeasurementValues.QUALITATIVE_VALUE.equals(controlRule.getControlFeature()));
(ControlFeatureMeasurementValues.PMFM.equals(controlRule.getControlFeature())
|| ControlFeatureMeasurementValues.NUMERICAL_VALUE.equals(controlRule.getControlFeature())
|| ControlFeatureMeasurementValues.QUALITATIVE_VALUE.equals(controlRule.getControlFeature()));
}
public static boolean isPreconditionRule(ControlRuleDTO controlRule) {
......@@ -826,14 +877,14 @@ public class ReefDbBeans extends QuadrigeBeans {
public static boolean isQualitativeControlRule(ControlRuleDTO controlRule) {
return ControlFunctionValues.IS_AMONG.equals(controlRule.getFunction())
&& ControlElementValues.MEASUREMENT.equals(controlRule.getControlElement())
&& ControlFeatureMeasurementValues.QUALITATIVE_VALUE.equals(controlRule.getControlFeature());
&& ControlElementValues.MEASUREMENT.equals(controlRule.getControlElement())
&& ControlFeatureMeasurementValues.QUALITATIVE_VALUE.equals(controlRule.getControlFeature());
}
public static boolean isNumericalControlRule(ControlRuleDTO controlRule) {
return ControlFunctionValues.MIN_MAX.equals(controlRule.getFunction())
&& ControlElementValues.MEASUREMENT.equals(controlRule.getControlElement())
&& ControlFeatureMeasurementValues.NUMERICAL_VALUE.equals(controlRule.getControlFeature());
&& ControlElementValues.MEASUREMENT.equals(controlRule.getControlElement())
&& ControlFeatureMeasurementValues.NUMERICAL_VALUE.equals(controlRule.getControlFeature());
}
/**
......@@ -844,8 +895,8 @@ public class ReefDbBeans extends QuadrigeBeans {
*/
public static boolean isSurveyValidated(SurveyDTO survey) {
return survey.getValidationDate() != null
|| SynchronizationStatusValues.SYNCHRONIZED.equals(survey.getSynchronizationStatus())
|| SynchronizationStatusValues.READY_TO_SYNCHRONIZE.equals(survey.getSynchronizationStatus());
|| SynchronizationStatusValues.SYNCHRONIZED.equals(survey.getSynchronizationStatus())
|| SynchronizationStatusValues.READY_TO_SYNCHRONIZE.equals(survey.getSynchronizationStatus());
}
/**
......@@ -858,8 +909,8 @@ public class ReefDbBeans extends QuadrigeBeans {
public static FilterDTO getFilterOfType(ExtractionDTO extraction, ExtractionFilterValues extractionFilter) {
return CollectionUtils.isNotEmpty(extraction.getFilters())
? findByProperty(extraction.getFilters(), FilterDTO.PROPERTY_FILTER_TYPE_ID, extractionFilter.getFilterTypeId())
: null;
? findByProperty(extraction.getFilters(), FilterDTO.PROPERTY_FILTER_TYPE_ID, extractionFilter.getFilterTypeId())
: null;
}
/**
......@@ -881,11 +932,28 @@ public class ReefDbBeans extends QuadrigeBeans {
return null;
}
public static void setFilterElements(ExtractionDTO extraction, ExtractionFilterValues extractionFilter, List<? extends QuadrigeBean> elements) {
FilterDTO filter = getFilterOfType(extraction, extractionFilter);
if (filter == null) {
filter = ReefDbBeanFactory.newFilterDTO();
filter.setFilterTypeId(extractionFilter.getFilterTypeId());
extraction.addFilters(filter);
}
filter.setElements(elements);
}
public static List<String> getIdsAsString(Collection<? extends QuadrigeBean> beans) {
if (beans == null)
return null;
return beans.stream().map(bean -> bean instanceof CodeOnly ? ((CodeOnly)bean).getCode() : bean.getId().toString()).collect(Collectors.toList());
return beans.stream().map(bean -> bean instanceof CodeOnly ? ((CodeOnly) bean).getCode() : bean.getId().toString()).collect(Collectors.toList());
}
public static List<ExtractionPeriodDTO> getExtractionPeriods(ExtractionDTO extraction) {
FilterDTO periodFilter = getFilterOfType(extraction, ExtractionFilterValues.PERIOD);
if (periodFilter == null || periodFilter.getElements() == null) return new ArrayList<>();
return periodFilter.getElements().stream().map((Function<QuadrigeBean, ExtractionPeriodDTO>) ExtractionPeriodDTO.class::cast).collect(Collectors.toList());
}
}
......@@ -36,7 +36,7 @@ public enum ExtractionFilterValues {
PERIOD(null, n("reefdb.core.enums.extractionFilter.period"), false),
PROGRAM(FilterTypeId.PROGRAM, n("reefdb.core.enums.extractionFilter.program"), false),
LOCATION(FilterTypeId.MONITORING_LOCATION, n("reefdb.core.enums.extractionFilter.location"), false),
// CAMPAIGN(FilterTypeId.CAMPAIGN, n("reefdb.core.enums.extractionFilter.campaign"), false),
CAMPAIGN(FilterTypeId.CAMPAIGN, n("reefdb.core.enums.extractionFilter.campaign"), false),
TAXON(FilterTypeId.TAXON_NAME, n("reefdb.core.enums.extractionFilter.taxon"), false),
TAXON_GROUP(FilterTypeId.TAXON_GROUP, n("reefdb.core.enums.extractionFilter.taxonGroup"), false),
DEPARTMENT(FilterTypeId.DEPARTMENT, n("reefdb.core.enums.extractionFilter.department"), false),
......
......@@ -29,7 +29,6 @@ import fr.ifremer.quadrige3.core.ProgressionCoreModel;
import fr.ifremer.quadrige3.core.dao.technical.Assert;
import fr.ifremer.quadrige3.core.dao.technical.Dates;
import fr.ifremer.quadrige3.core.dao.technical.Times;
import fr.ifremer.quadrige3.core.security.SecurityContextHelper;
import fr.ifremer.quadrige3.ui.core.dto.referential.BaseReferentialDTO;
import fr.ifremer.reefdb.config.ReefDbConfiguration;
import fr.ifremer.reefdb.dao.administration.user.ReefDbDepartmentDao;
......@@ -177,7 +176,8 @@ public class ObservationServiceImpl implements ObservationInternalService {
Collection<String> programCodes;
// if no filter on single program, force filter on writable programs
if (StringUtils.isBlank(programCode)) {
programCodes = programStrategyService.getWritableProgramCodesByQuserId(SecurityContextHelper.getQuadrigeUserId());
// get writable programs including locals (Mantis #49917)
programCodes = programStrategyService.getWritablePrograms().stream().map(ProgramDTO::getCode).collect(Collectors.toSet());
} else {
programCodes = Collections.singleton(programCode);
}
......@@ -438,6 +438,7 @@ public class ObservationServiceImpl implements ObservationInternalService {
Assert.notNull(duplicateSurvey);
// Remove ID
duplicateSurvey.setId(null);
duplicateSurvey.setDirty(true);
// duplicated data to keep:
if (survey.isObserversEmpty() && survey.getId() != null) {
......@@ -599,8 +600,10 @@ public class ObservationServiceImpl implements ObservationInternalService {
if (dataContext.isContextFiltered(FilterTypeValues.PROGRAM) && !forceNoContext) {
result = contextService.getFilteredPrograms(dataContext.getContextId());
// context filtered programs can eventually out of user rights, filter them
Set<String> writableProgramCodes = programStrategyService.getWritableProgramCodesByQuserId(dataContext.getPrincipalUserId());
result = result.stream().filter(programDTO -> writableProgramCodes.contains(programDTO.getCode())).collect(Collectors.toList());
// Set<String> writableProgramCodes = programStrategyService.getWritableProgramCodesByQuserId(dataContext.getPrincipalUserId());
// Get correct list of writable programs (Mantis #49913)
List<ProgramDTO> writablePrograms = programStrategyService.getWritableProgramsByUserAndStatus(dataContext.getPrincipalUserId(), StatusFilter.ACTIVE);
result = result.stream().filter(writablePrograms::contains).collect(Collectors.toList());
} else if (campaignId != null) {
result = programStrategyService.getWritableProgramsByCampaignId(campaignId);
} else {
......
......@@ -1215,4 +1215,9 @@ public interface ReferentialService {
*/
QualitativeValueDTO getQualitativeValue(int qualitativeValueId);
List<QualitativeValueDTO> getQualitativeValues(Collection<Integer> qualitativeValueIds);}
List<QualitativeValueDTO> getQualitativeValues(Collection<Integer> qualitativeValueIds);
List<QualitativeValueDTO> getQualitativeValues(String parameterCode);
}
......@@ -1464,6 +1464,14 @@ public class ReferentialServiceImpl implements ReferentialService {
return result;
}
@Override
public List<QualitativeValueDTO> getQualitativeValues(String parameterCode) {
if (StringUtils.isBlank(parameterCode))
return null;
return qualitativeValueDao.getQualitativeValuesByParameterCode(parameterCode);
}
/**
* {@inheritDoc}
*/
......
......@@ -152,6 +152,7 @@ reefdb.config.option.synchro.useServer.description=
reefdb.config.option.synchro.zipFile.prefix.description=
reefdb.config.option.timezone.description=
reefdb.config.option.tmp.directory.description=
reefdb.config.option.transcribingItemType.label.pmfmExtraction.description=
reefdb.config.option.transcribingItemType.label.pmfmNm.description=
reefdb.config.option.ui.autoPopupNumberEditor.description=
reefdb.config.option.ui.color.alternateRow.description=
......@@ -370,6 +371,8 @@ reefdb.service.extraction.fieldNamePrefix.SAMPLING_OPER=
reefdb.service.extraction.fieldNamePrefix.SURVEY=
reefdb.service.extraction.noData.error=
reefdb.service.extraction.noPmfm.error=
reefdb.service.extraction.notDistinct.MEAS_QUALIF_CM=
reefdb.service.extraction.notDistinct.MEAS_QUAL_FLAG_NM=
reefdb.service.observation.duplicate.measurementComment=
reefdb.service.observation.unvalidation.progression=
reefdb.service.observation.validation.progression=
......
......@@ -118,7 +118,7 @@ reefdb.config.option.synchro.useServer.description=
reefdb.config.option.synchro.zipFile.prefix.description=
reefdb.config.option.timezone.description=Fuseau horaire du poste client
reefdb.config.option.tmp.directory.description=Répertoire temporaire de l'application
reefdb.config.option.transcribingItemType.id.pmfmNm.description=
reefdb.config.option.transcribingItemType.label.pmfmExtraction.description=Libellé du type de transcodage pour les noms des PSFMU pour les extractions
reefdb.config.option.transcribingItemType.label.pmfmNm.description=Libellé du type de transcodage pour les noms des PSFMU
reefdb.config.option.ui.autoPopupNumberEditor.description=Ouvre automatiquement la calculette pour la saisie des nombres
reefdb.config.option.ui.color.alternateRow.description=Couleur de fond des lignes paires (non sélectionnée) dans un tableau
......@@ -291,12 +291,17 @@ reefdb.service.common.progression=%s \: traitement de %s/%s
reefdb.service.control=Contrôle
reefdb.service.controlRule.invalid.message=La règle de contrôle '%s' n'est pas respectée
reefdb.service.extraction.error=Une erreur s'est produite lors de l'extration.
reefdb.service.extraction.fieldName.INPUT_TAXON_NAME_ID=${reefdb.service.extraction.fieldNamePrefix.MEAS}_Identifiant_interne_TAXON_NAME_ID
reefdb.service.extraction.fieldName.INPUT_TAXON_NAME_NM=Taxon_saisi
reefdb.service.extraction.fieldName.CAMPAIGN_NM=${reefdb.service.extraction.fieldNamePrefix.SURVEY}_Campagne
reefdb.service.extraction.fieldName.INPUT_TAXON_NAME_ID=
reefdb.service.extraction.fieldName.INPUT_TAXON_NAME_NM=
reefdb.service.extraction.fieldName.MEAS_ANALYST_NM=${reefdb.service.extraction.fieldNamePrefix.MEAS}_Organisme_analyste
reefdb.service.extraction.fieldName.MEAS_CM=${reefdb.service.extraction.fieldNamePrefix.MEAS}_Commentaires
reefdb.service.extraction.fieldName.MEAS_DEP_NM=${reefdb.service.extraction.fieldNamePrefix.MEAS}_Organisme_analyste
reefdb.service.extraction.fieldName.MEAS_DEP_NM=
reefdb.service.extraction.fieldName.MEAS_IDS=${reefdb.service.extraction.fieldNamePrefix.MEAS}_Identifiants_interne_MEAS_ID
reefdb.service.extraction.fieldName.MEAS_INDIV_ID=${reefdb.service.extraction.fieldNamePrefix.MEAS}_Numero_individu
reefdb.service.extraction.fieldName.MEAS_QUALIF_CM=${reefdb.service.extraction.fieldNamePrefix.MEAS}_Commentaire_Qualif
reefdb.service.extraction.fieldName.MEAS_QUALIF_DT=${reefdb.service.extraction.fieldNamePrefix.MEAS}_Date_Qualif
reefdb.service.extraction.fieldName.MEAS_QUAL_FLAG_NM=${reefdb.service.extraction.fieldNamePrefix.MEAS}_Niveau_qualite
reefdb.service.extraction.fieldName.MON_LOC_ID=${reefdb.service.extraction.fieldNamePrefix.MON_LOC}_Identifiant
reefdb.service.extraction.fieldName.MON_LOC_LB=${reefdb.service.extraction.fieldNamePrefix.MON_LOC}_Mnemonique
reefdb.service.extraction.fieldName.MON_LOC_NM=Station
......@@ -304,6 +309,7 @@ reefdb.service.extraction.fieldName.MON_LOC_ORDER_ITEM_NUMBER=${reefdb.service.e
reefdb.service.extraction.fieldName.ORDER_ITEM_CD=${reefdb.service.extraction.fieldNamePrefix.MON_LOC}_Entite_classement_Identifiant
reefdb.service.extraction.fieldName.ORDER_ITEM_NM=${reefdb.service.extraction.fieldNamePrefix.MON_LOC}_Entite_classement
reefdb.service.extraction.fieldName.ORDER_ITEM_TYPE_NM=${reefdb.service.extraction.fieldNamePrefix.MON_LOC}_Entite_classement_Type
reefdb.service.extraction.fieldName.REF_TAXON_NM=Taxon
reefdb.service.extraction.fieldName.SAMPLING_EQUIPMENT_NM=${reefdb.service.extraction.fieldNamePrefix.SAMPLING_OPER}_Moyen_acquisition
reefdb.service.extraction.fieldName.SAMPLING_EQUIPMENT_SIZE=${reefdb.service.extraction.fieldNamePrefix.SAMPLING_OPER}_Moyen_acquisition_Taille
reefdb.service.extraction.fieldName.SAMPLING_EQUIPMENT_SIZE_UNIT_SYMBOL=${reefdb.service.extraction.fieldNamePrefix.SAMPLING_OPER}_Moyen_acquisition_Taille_Symbole_unite
......@@ -325,12 +331,14 @@ reefdb.service.extraction.fieldName.SAMPLING_OPER_POSITION_LONG_MAX=${reefdb.ser
reefdb.service.extraction.fieldName.SAMPLING_OPER_POSITION_LONG_MIN=${reefdb.service.extraction.fieldNamePrefix.SAMPLING_OPER}_Coordonnees_MINX
reefdb.service.extraction.fieldName.SAMPLING_OPER_QUALIF_CM=${reefdb.service.extraction.fieldNamePrefix.SAMPLING_OPER}_Commentaire_qualification
reefdb.service.extraction.fieldName.SAMPLING_OPER_QUALIF_DT=${reefdb.service.extraction.fieldNamePrefix.SAMPLING_OPER}_Date_qualification
reefdb.service.extraction.fieldName.SAMPLING_OPER_QUAL_FLAG=${reefdb.service.extraction.fieldNamePrefix.SAMPLING_OPER}_Niveau_qualite
reefdb.service.extraction.fieldName.SAMPLING_OPER_QUAL_FLAG=
reefdb.service.extraction.fieldName.SAMPLING_OPER_QUAL_FLAG_NM=${reefdb.service.extraction.fieldNamePrefix.SAMPLING_OPER}_Niveau_qualite
reefdb.service.extraction.fieldName.SAMPLING_OPER_SIZE=${reefdb.service.extraction.fieldNamePrefix.SAMPLING_OPER}_Taille
reefdb.service.extraction.fieldName.SAMPLING_OPER_SIZE_UNIT_SYMBOL=${reefdb.service.extraction.fieldNamePrefix.SAMPLING_OPER}_Unite
reefdb.service.extraction.fieldName.SAMPLING_OPER_TIME=${reefdb.service.extraction.fieldNamePrefix.SAMPLING_OPER}_Heure
reefdb.service.extraction.fieldName.SAMPLING_OPER_VALID_DT=${reefdb.service.extraction.fieldNamePrefix.SAMPLING_OPER}_Date_validation
reefdb.service.extraction.fieldName.SURVEY_BOTTOM_DEPTH=${reefdb.service.extraction.fieldNamePrefix.SURVEY}_Profondeur_precise
reefdb.service.extraction.fieldName.SURVEY_BOTTOM_DEPTH_UNIT_SYMBOL=${reefdb.service.extraction.fieldNamePrefix.SURVEY}_Profondeur_precise_Symbole_unite
reefdb.service.extraction.fieldName.SURVEY_CM=${reefdb.service.extraction.fieldNamePrefix.SURVEY}_Commentaire
reefdb.service.extraction.fieldName.SURVEY_CONTROL_DT=${reefdb.service.extraction.fieldNamePrefix.SURVEY}_Date_controle
reefdb.service.extraction.fieldName.SURVEY_DT=Date
......@@ -343,13 +351,15 @@ reefdb.service.extraction.fieldName.SURVEY_POSITION_LONG_MIN=${reefdb.service.ex
reefdb.service.extraction.fieldName.SURVEY_PROG_CD=Programme
reefdb.service.extraction.fieldName.SURVEY_QUALIF_CM=${reefdb.service.extraction.fieldNamePrefix.SURVEY}_Commentaire_qualification
reefdb.service.extraction.fieldName.SURVEY_QUALIF_DT=${reefdb.service.extraction.fieldNamePrefix.SURVEY}_Date_qualification
reefdb.service.extraction.fieldName.SURVEY_QUAL_FLAG=${reefdb.service.extraction.fieldNamePrefix.SURVEY}_Niveau_qualite
reefdb.service.extraction.fieldName.SURVEY_QUAL_FLAG=
reefdb.service.extraction.fieldName.SURVEY_QUAL_FLAG_NM=${reefdb.service.extraction.fieldNamePrefix.SURVEY}_Niveau_qualite
reefdb.service.extraction.fieldName.SURVEY_QUSERS=${reefdb.service.extraction.fieldNamePrefix.SURVEY}_Observateurs
reefdb.service.extraction.fieldName.SURVEY_TIME=${reefdb.service.extraction.fieldNamePrefix.SURVEY}_Heure
reefdb.service.extraction.fieldName.SURVEY_VALID_DT=${reefdb.service.extraction.fieldNamePrefix.SURVEY}_Date_validation
reefdb.service.extraction.fieldName.TAXON_GROUP_NM=Groupe_taxons
reefdb.service.extraction.fieldName.TAXON_MEAS_IDS=${reefdb.service.extraction.fieldNamePrefix.MEAS}_Identifiants_interne_TAXON_MEAS_ID
reefdb.service.extraction.fieldName.TAXON_NAME_NM=Taxon
reefdb.service.extraction.fieldName.TAXON_NAME_ID=${reefdb.service.extraction.fieldNamePrefix.MEAS}_Identifiant_interne_TAXON_NAME_ID
reefdb.service.extraction.fieldName.TAXON_NAME_NM=Taxon_saisi
reefdb.service.extraction.fieldName.TAXON_PAMPA=Taxon_pampa
reefdb.service.extraction.fieldNamePrefix.MEAS=MESURE
reefdb.service.extraction.fieldNamePrefix.MON_LOC=STATION
......@@ -357,6 +367,8 @@ reefdb.service.extraction.fieldNamePrefix.SAMPLING_OPER=REPLICAT
reefdb.service.extraction.fieldNamePrefix.SURVEY=OBSERVATION
reefdb.service.extraction.noData.error=Aucune observation ne correspond aux critères d'extraction.
reefdb.service.extraction.noPmfm.error=Aucune mesure ne correspond aux critères d'extraction.
reefdb.service.extraction.notDistinct.MEAS_QUALIF_CM=Qualifications différentes selon les résultats - non affichables dans ce format d'export
reefdb.service.extraction.notDistinct.MEAS_QUAL_FLAG_NM=Niveaux multiples
reefdb.service.observation.duplicate.measurementComment=Résultat dupliqué le %s depuis l'observation %s
reefdb.service.observation.save=Sauvegarde
reefdb.service.observation.unvalidation.progression=Dévalidation de %s observation(s) [%s-%s]
......
......@@ -43,6 +43,7 @@ pmfmId.PIT_ORIGIN=2326
UnitId.NO_UNIT=99
TranscribingItemTypeLb.REEFDB_PMFM_NM=REEFDB-PMFM.PMFM_NM
TranscribingItemTypeLb.REEFDB_PMFM_EXTRACTION=REEFDB-PMFM-EXTRACT.PMFM_NM
############################################
# Alternative Taxon Code #
......
......@@ -1754,6 +1754,32 @@
<query-param name="programCode" type="java.lang.String"/>
</query>
<query name="appliedStrategiesByProgramCodes">
<![CDATA[
SELECT DISTINCT
a.appliedStratId,
p.progCd,
p.progNm,
p.status.statusCd,
s.id,
s.stratNm,
ap.id.appliedPeriodStartDt as startDt,
ap.appliedPeriodEndDt as endDt,
dep.depId
FROM
AppliedStrategyImpl a
INNER JOIN a.strategy s
INNER JOIN s.program p
LEFT OUTER JOIN a.appliedPeriods ap
LEFT OUTER JOIN a.department dep
WHERE
p.progCd IN (:programCodes)
ORDER BY
a.strategy.stratNm, ap.id.appliedPeriodStartDt
]]>
<query-param name="programCodes" type="java.lang.String"/>
</query>
<query name="analysisDepartmentByAppliedStrategyId">
<![CDATA[
SELECT DISTINCT
......@@ -1830,6 +1856,7 @@
a.appliedStratId,
p.progCd,
p.progNm,
p.status.statusCd,
s.id,
s.stratNm,
ap.id.appliedPeriodStartDt as startDt,
......
<?xml version="1.0" encoding="UTF-8"?>
<!--
#%L
Dali :: Core
%%
Copyright (C) 2017 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%
-->
<queries name="extractionCleanHermeticData">
<query type="delete" table="&amp;tableName">
<where><![CDATA[SURVEY_PROG_CD = '&programCode']]></where>
<where operator="AND"><![CDATA[REC_DEP_ID != &recDepId]]></where>
</query>
</queries>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!--
#%L
Dali :: Core
%%
Copyright (C) 2017 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%
-->
<queries name="extractionCleanRawData">
<query type="delete" table="&amp;tableName">
<where>1=2</where>
<where operator="OR" group="taxonGroup">
<where>TAXON_GROUP_ID IS NULL</where>
<where operator="OR">
<notin field="TAXON_GROUP_ID"><![CDATA[&taxonGroupIds]]></notin>
</where>
</where>
<where operator="OR" group="taxonName">
<where>REF_TAXON_ID IS NULL</where>
<where operator="OR">
<where>
<notin field="REF_TAXON_ID"><![CDATA[&taxonNameIds]]></notin>
</where>
<where operator="OR" group="simple,complete,sinp">
<notin field="TAXON_NAME_ID"><![CDATA[&taxonNameIds]]></notin>
</where>
</where>
</where>
</query>
</queries>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!--
#%L
Dali :: Core
%%
Copyright (C) 2017 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%
-->
<queries name="extractionCountFrom">
<query type="select">
<select alias="COUNT_ALL" type="number">COUNT(*)</select>
<from><![CDATA[&tableName]]></from>
</query>
</queries>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!--
#%L
Dali :: Core
%%
Copyright (C) 2017 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%
-->
<queries name="extractionCreateBaseTable">
<query type="create" temp="true" table="&amp;baseTableName">
<with alias="MLOI">
<subquery>
<subselect alias="MON_LOC_ID" type="number">MLOI.MON_LOC_ID</subselect>
<subselect alias="ORDER_ITEM_NM" type="number">OI.ORDER_ITEM_NM</subselect>
<subselect alias="ORDER_ITEM_TYPE_NM" type="number">OIT.ORDER_ITEM_TYPE_NM</subselect>
<subselect alias="ORDER_ITEM_CD" type="number">OI.ORDER_ITEM_CD</subselect>
<subselect alias="MON_LOC_ORDER_ITEM_NUMBER" type="number">MLOI.MON_LOC_ORDER_ITEM_NUMBER</subselect>
<from alias="MLOI">MON_LOC_ORDER_ITEM</from>
<from join="true">LEFT OUTER JOIN ORDER_ITEM OI ON MLOI.ORDER_ITEM_ID = OI.ORDER_ITEM_ID</from>
<from join="true">LEFT OUTER JOIN ORDER_ITEM_TYPE OIT ON OI.ORDER_ITEM_TYPE_CD = OIT.ORDER_ITEM_TYPE_CD</from>
<where><![CDATA[OI.ORDER_ITEM_TYPE_CD = '&orderItemTypeCode']]></where>
</subquery>
</with>
<select alias="SURVEY_ID" type="number">S.SURVEY_ID</select>
<select alias="SURVEY_LB" type="text">S.SURVEY_LB</select>
<select alias="SURVEY_DT" type="date">S.SURVEY_DT</select>
<select alias="SURVEY_PROG_CD" type="text">PROG.PROG_CD</select>
<select alias="REC_DEP_ID" type="number">S.REC_DEP_ID</select>
<select alias="CAMPAIGN_NM" type="text">C.CAMPAIGN_NM</select>
<select alias="MON_LOC_ID" type="number">ML.MON_LOC_ID</select>
<select alias="MON_LOC_LB" type="text">ML.MON_LOC_LB</select>
<select alias="MON_LOC_NM" type="text">ML.MON_LOC_NM</select>
<select alias="ORDER_ITEM_NM" type="text">MLOI.ORDER_ITEM_NM</select>
<select alias="SAMPLING_OPER_ID" type="number">SO.SAMPLING_OPER_ID</select>
<select alias="SAMPLING_OPER_LB" type="text">SO.SAMPLING_OPER_LB</select>
<select alias="SURVEY_POSITION_LONG" type="text">TRIM(REGEXP_SUBSTRING(SP.SURVEY_POSITION, '[0-9.-]+'))</select>
<select alias="SURVEY_POSITION_LAT" type="text">TRIM(TRIM(TRAILING ')' FROM REGEXP_SUBSTRING(SP.SURVEY_POSITION, '[0-9.-]+\)$')))</select>
<select alias="SURVEY_QUSERS" type="text" group="simple,complete,sinp">GROUP_CONCAT(Q.QUSER_FIRST_NM || ' ' || Q.QUSER_LAST_NM || ' - ' || QD.DEP_NM SEPARATOR '|')</select>
<select alias="SURVEY_QUSERS" type="text" group="pampa">GROUP_CONCAT(Q.QUSER_FIRST_NM || ' ' || Q.QUSER_LAST_NM separator '|')</select>
<select alias="SAMPLING_OPER_SIZE" type="number">SO.SAMPLING_OPER_SIZE</select>
<select alias="SAMPLING_OPER_SIZE_UNIT_SYMBOL" type="text">SOSU.UNIT_SYMBOL</select>
<select alias="SAMPLING_EQUIPMENT_NM" type="text">SE.SAMPLING_EQUIPMENT_NM</select>
<select alias="SAMPLING_OPER_DEP_NM" type="text">SOD.DEP_NM</select>
<!-- Complete only part-->
<select alias="ORDER_ITEM_TYPE_NM" type="text" group="complete">MLOI.ORDER_ITEM_TYPE_NM</select>
<select alias="ORDER_ITEM_CD" type="text" group="complete">MLOI.ORDER_ITEM_CD</select>
<select alias="MON_LOC_ORDER_ITEM_NUMBER" type="number" group="complete">MLOI.MON_LOC_ORDER_ITEM_NUMBER</select>
<select alias="SURVEY_TIME" type="text" group="complete">S.SURVEY_TIME</select>
<select alias="SURVEY_CM" type="text" group="complete">S.SURVEY_CM</select>
<select alias="SURVEY_CONTROL_DT" type="date" group="complete">S.SURVEY_CONTROL_DT</select>
<select alias="SURVEY_VALID_DT" type="date" group="complete">S.SURVEY_VALID_DT</select>
<select alias="SURVEY_QUAL_FLAG_NM" type="text" group="complete">SQF.QUAL_FLAG_NM</select>
<select alias="SURVEY_QUALIF_DT" type="date" group="complete">S.SURVEY_QUALIF_DT</select>
<select alias="SURVEY_QUALIF_CM" type="text" group="complete">S.SURVEY_QUALIF_CM</select>
<select alias="SURVEY_INHERITED_POSITION" type="text" group="complete">CASEWHEN(IFNULL(S.SURVEY_ACTUAL_POSITION,'0')='0','1','0')</select>
<select alias="SURVEY_BOTTOM_DEPTH" type="number" group="complete">S.SURVEY_BOTTOM_DEPTH</select>
<select alias="SURVEY_BOTTOM_DEPTH_UNIT_SYMBOL" type="number" group="complete">SBDU.UNIT_SYMBOL</select>
<select alias="SAMPLING_OPER_TIME" type="number" group="complete,pampa">SO.SAMPLING_OPER_TIME</select>
<select alias="SURVEY_BOTTOM_DEPTH" type="number" group="pampa">S.SURVEY_BOTTOM_DEPTH</select>
<select alias="SAMPLING_OPER_DEPTH" type="number" group="complete">SO.SAMPLING_OPER_DEPTH</select>
<select alias="SAMPLING_OPER_MIN_DEPTH" type="number" group="complete">SO.SAMPLING_OPER_MIN_DEPTH</select>
<select alias="SAMPLING_OPER_MAX_DEPTH" type="number" group="complete">SO.SAMPLING_OPER_MAX_DEPTH</select>
<select alias="SAMPLING_OPER_INHERITED_POSITION" type="text" group="complete">CASEWHEN(IFNULL(SO.SAMPLING_OPER_ACTUAL_POSITION,'0')='0','1','0')</select>
<select alias="SAMPLING_OPER_DEPTH_UNIT_SYMBOL" type="text" group="complete">SODU.UNIT_SYMBOL</select>
<select alias="SAMPLING_OPER_DEPTH_UNIT" type="text" group="complete">SODU.UNIT_NM</select>
<select alias="SAMPLING_OPER_CM" type="text" group="complete">SO.SAMPLING_OPER_CM</select>
<select alias="SAMPLING_EQUIPMENT_SIZE" type="number" group="complete">SE.SAMPLING_EQUIPMENT_SIZE</select>
<select alias="SAMPLING_EQUIPMENT_SIZE_UNIT_SYMBOL" type="text" group="complete">SEU.UNIT_SYMBOL</select>
<select alias="SAMPLING_OPER_NUMBER_INDIV" type="number" group="complete">SO.SAMPLING_OPER_NUMBER_INDIV</select>
<select alias="SAMPLING_OPER_CONTROL_DT" type="date" group="complete">SO.SAMPLING_OPER_CONTROL_DT</select>
<select alias="SAMPLING_OPER_VALID_DT" type="date" group="complete">SO.SAMPLING_OPER_VALID_DT</select>
<select alias="SAMPLING_OPER_QUAL_FLAG_NM" type="text" group="complete">SOQF.QUAL_FLAG_NM</select>
<select alias="SAMPLING_OPER_QUALIF_DT" type="date" group="complete">SO.SAMPLING_OPER_QUALIF_DT</select>
<select alias="SAMPLING_OPER_QUALIF_CM" type="text" group="complete">SO.SAMPLING_OPER_QUALIF_CM</select>
<select alias="SAMPLING_OPER_POSITION_LONG" type="text" group="complete">TRIM(REGEXP_SUBSTRING(SOP.SAMPLING_OPER_POSITION, '[0-9.-]+'))</select>
<select alias="SAMPLING_OPER_POSITION_LAT" type="text" group="complete">TRIM(TRIM(TRAILING ')' FROM REGEXP_SUBSTRING(SOP.SAMPLING_OPER_POSITION, '[0-9.-]+\)$')))</select>
<from alias="S">SURVEY</from>
<from join="true">INNER JOIN SURVEY_PROG PROG ON PROG.SURVEY_ID = S.SURVEY_ID</from>
<from join="true">INNER JOIN MONITORING_LOCATION ML ON ML.MON_LOC_ID = S.MON_LOC_ID</from>
<from join="true">LEFT OUTER JOIN SAMPLING_OPERATION SO ON SO.SURVEY_ID = S.SURVEY_ID</from>
<from join="true">LEFT OUTER JOIN MLOI ON MLOI.MON_LOC_ID = S.MON_LOC_ID</from>
<from join="true">LEFT OUTER JOIN SURVEY_POINT SP ON S.SURVEY_ID = SP.SURVEY_ID</from>
<from join="true">LEFT OUTER JOIN CAMPAIGN C ON C.CAMPAIGN_ID = S.CAMPAIGN_ID</from>
<from join="true">LEFT OUTER JOIN SAMPLING_EQUIPMENT SE ON SE.SAMPLING_EQUIPMENT_ID = SO.SAMPLING_EQUIPMENT_ID</from>
<from join="true">LEFT OUTER JOIN DEPARTMENT SOD ON SOD.DEP_ID = SO.DEP_ID</from>
<from join="true">LEFT OUTER JOIN QUALITY_FLAG SQF ON SQF.QUAL_FLAG_CD = S.QUAL_FLAG_CD</from>
<from join="true">LEFT OUTER JOIN SURVEY_QUSER SQ ON SQ.SURVEY_ID = S.SURVEY_ID</from>
<from join="true">LEFT OUTER JOIN QUSER Q ON Q.QUSER_ID = SQ.QUSER_ID</from>
<from join="true">LEFT OUTER JOIN DEPARTMENT QD ON QD.DEP_ID = Q.DEP_ID</from>
<from join="true">LEFT OUTER JOIN UNIT SOSU ON SOSU.UNIT_ID = SO.SAMPLING_OPER_SIZE_UNIT_ID</from>
<from join="true" group="complete">LEFT OUTER JOIN QUALITY_FLAG SOQF ON SOQF.QUAL_FLAG_CD = SO.QUAL_FLAG_CD</from>
<from join="true" group="complete">LEFT OUTER JOIN UNIT SEU ON SE.UNIT_ID = SEU.UNIT_ID</from>
<from join="true" group="complete">LEFT OUTER JOIN UNIT SODU ON SODU.UNIT_ID = SO.SAMPLING_OPER_DEPTH_UNIT_ID</from>
<from join="true" group="complete">LEFT OUTER JOIN UNIT SBDU ON SBDU.UNIT_ID = S.SURVEY_BOTTOM_DEPTH_UNIT_ID</from>
<from join="true" group="complete">LEFT OUTER JOIN SAMPLING_OPER_POINT SOP ON SOP.SAMPLING_OPER_ID = SO.SAMPLING_OPER_ID</from>
<where group="periodFilter"/>
<where operator="AND" group="programFilter">
<in field="PROG.PROG_CD"><![CDATA[&progCodes]]></in>
</where>
<where operator="AND" group="locationFilter">
<in field="S.MON_LOC_ID"><![CDATA[&monLocIds]]></in>
</where>
<where operator="AND" group="campaignFilter">
<in field="S.CAMPAIGN_ID"><![CDATA[&campaignIds]]></in>
</where>
<where operator="AND" group="departmentFilter">
<in field="S.REC_DEP_ID"><![CDATA[&depIds]]></in>
</where>
<where operator="AND" group="pmfmFilter"><![CDATA[
(
EXISTS
(
SELECT *
FROM MEASUREMENT M
WHERE M.SURVEY_ID = S.SURVEY_ID
AND M.PMFM_ID IN (&pmfmIds)
)
OR EXISTS
(
SELECT *
FROM MEASUREMENT M
WHERE M.SAMPLING_OPER_ID = SO.SAMPLING_OPER_ID
AND M.PMFM_ID IN (&pmfmIds)
)
OR EXISTS
(
SELECT *
FROM TAXON_MEASUREMENT M
WHERE M.SAMPLING_OPER_ID = SO.SAMPLING_OPER_ID
AND M.PMFM_ID IN (&pmfmIds)
)
)]]>
</where>
<groupby>S.SURVEY_ID</groupby>
<groupby>S.SURVEY_LB</groupby>
<groupby>S.SURVEY_DT</groupby>
<groupby>PROG.PROG_CD</groupby>
<groupby>S.REC_DEP_ID</groupby>
<groupby>C.CAMPAIGN_NM</groupby>
<groupby>ML.MON_LOC_ID</groupby>
<groupby>ML.MON_LOC_LB</groupby>
<groupby>ML.MON_LOC_NM</groupby>
<groupby>MLOI.ORDER_ITEM_NM</groupby>
<groupby>SO.SAMPLING_OPER_ID</groupby>
<groupby>SO.SAMPLING_OPER_LB</groupby>
<groupby>SP.SURVEY_POSITION</groupby>
<groupby>SO.SAMPLING_OPER_SIZE</groupby>
<groupby>SOSU.UNIT_SYMBOL</groupby>
<groupby>SE.SAMPLING_EQUIPMENT_NM</groupby>
<groupby>SOD.DEP_NM</groupby>
<groupby group="complete">MLOI.ORDER_ITEM_TYPE_NM</groupby>
<groupby group="complete">MLOI.ORDER_ITEM_CD</groupby>
<groupby group="complete">MLOI.MON_LOC_ORDER_ITEM_NUMBER</groupby>
<groupby group="complete">S.SURVEY_TIME</groupby>
<groupby group="complete">S.SURVEY_CM</groupby>
<groupby group="complete">S.SURVEY_CONTROL_DT</groupby>
<groupby group="complete">S.SURVEY_VALID_DT</groupby>
<groupby group="complete">SQF.QUAL_FLAG_NM</groupby>
<groupby group="complete">S.SURVEY_QUALIF_DT</groupby>
<groupby group="complete">S.SURVEY_QUALIF_CM</groupby>
<groupby group="complete">S.SURVEY_ACTUAL_POSITION</groupby>
<groupby group="complete">S.SURVEY_BOTTOM_DEPTH</groupby>
<groupby group="complete">SBDU.UNIT_SYMBOL</groupby>
<groupby group="complete,pampa">SO.SAMPLING_OPER_TIME</groupby>
<groupby group="pampa">S.SURVEY_BOTTOM_DEPTH</groupby>
<groupby group="complete">SO.SAMPLING_OPER_DEPTH</groupby>
<groupby group="complete">SO.SAMPLING_OPER_MIN_DEPTH</groupby>
<groupby group="complete">SO.SAMPLING_OPER_MAX_DEPTH</groupby>
<groupby group="complete">SO.SAMPLING_OPER_ACTUAL_POSITION</groupby>
<groupby group="complete">SODU.UNIT_SYMBOL</groupby>
<groupby group="complete">SODU.UNIT_NM</groupby>
<groupby group="complete">SO.SAMPLING_OPER_CM</groupby>
<groupby group="complete">SE.SAMPLING_EQUIPMENT_SIZE</groupby>
<groupby group="complete">SEU.UNIT_SYMBOL</groupby>
<groupby group="complete">SO.SAMPLING_OPER_NUMBER_INDIV</groupby>